本文整理汇总了C++中PR_ExecuteProgram函数的典型用法代码示例。如果您正苦于以下问题:C++ PR_ExecuteProgram函数的具体用法?C++ PR_ExecuteProgram怎么用?C++ PR_ExecuteProgram使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PR_ExecuteProgram函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PR1_GamePutClientInServer
void PR1_GamePutClientInServer(int spec)
{
if (spec)
{
// none...
}
else
{
PR_ExecuteProgram(PR_GLOBAL(PutClientInServer));
}
}
示例2: SV_Kill_f
/*
==================
SV_Kill_f
==================
*/
static void SV_Kill_f (void)
{
if (sv_player->v.health <= 0 && sv_player->v.deadflag != DEAD_NO)
{
SV_ClientPrintf (host_client, PRINT_HIGH, "Can't suicide -- already dead!\n");
return;
}
pr_global_struct->time = sv.time;
pr_global_struct->self = EDICT_TO_PROG(sv_player);
PR_ExecuteProgram (pr_global_struct->ClientKill);
}
示例3: SV_DropClient
/*
=====================
SV_DropClient
Called when the player is getting totally kicked off the host
if (crash = true), don't bother sending signofs
=====================
*/
void
SV_DropClient(qboolean crash)
{
int saveSelf;
int i;
client_t *client;
if (!crash) {
// send any final messages (don't check for errors)
if (NET_CanSendMessage(host_client->netconnection)) {
MSG_WriteByte(&host_client->message, svc_disconnect);
NET_SendMessage(host_client->netconnection,
&host_client->message);
}
if (host_client->edict && host_client->spawned) {
// call the prog function for removing a client
// this will set the body to a dead frame, among other things
saveSelf = pr_global_struct->self;
pr_global_struct->self = EDICT_TO_PROG(host_client->edict);
PR_ExecuteProgram(pr_global_struct->ClientDisconnect);
pr_global_struct->self = saveSelf;
}
Sys_Printf("Client %s removed\n", host_client->name);
}
// break the net connection
NET_Close(host_client->netconnection);
host_client->netconnection = NULL;
// free the client (the body stays around)
host_client->active = false;
host_client->name[0] = 0;
host_client->old_frags = -999999;
net_activeconnections--;
// send notification to all clients
for (i = 0, client = svs.clients; i < svs.maxclients; i++, client++) {
if (!client->active)
continue;
MSG_WriteByte(&client->message, svc_updatename);
MSG_WriteByte(&client->message, host_client - svs.clients);
MSG_WriteString(&client->message, "");
MSG_WriteByte(&client->message, svc_updatefrags);
MSG_WriteByte(&client->message, host_client - svs.clients);
MSG_WriteShort(&client->message, 0);
MSG_WriteByte(&client->message, svc_updatecolors);
MSG_WriteByte(&client->message, host_client - svs.clients);
MSG_WriteByte(&client->message, 0);
}
}
示例4: SV_ConnectClient
/*
================
SV_ConnectClient
Initializes a client_t for a new net connection. This will only be called
once for a player each game, not once for each level change.
================
*/
void SV_ConnectClient (int clientnum)
{
edict_t *ent;
client_t *client;
int edictnum;
struct qsocket_s *netconnection;
int i;
float spawn_parms[NUM_SPAWN_PARMS];
client = svs.clients + clientnum;
Con_DPrintf ("Client %s connected\n", client->netconnection->address);
edictnum = clientnum+1;
ent = EDICT_NUM(edictnum);
// set up the client_t
netconnection = client->netconnection;
if (sv.loadgame)
memcpy (spawn_parms, client->spawn_parms, sizeof(spawn_parms));
memset (client, 0, sizeof(*client));
client->netconnection = netconnection;
strcpy (client->name, "unconnected");
client->active = true;
client->spawned = false;
client->edict = ent;
client->message.data = client->msgbuf;
client->message.maxsize = sizeof(client->msgbuf);
client->message.allowoverflow = true; // we can catch it
#ifdef IDGODS
client->privileged = IsID(&client->netconnection->addr);
#else
client->privileged = false;
#endif
if (sv.loadgame)
memcpy (client->spawn_parms, spawn_parms, sizeof(spawn_parms));
else
{
// call the progs to get default spawn parms for the new client
PR_ExecuteProgram (pr_global_struct->SetNewParms);
for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
client->spawn_parms[i] = (&pr_global_struct->parm1)[i];
}
SV_SendServerinfo (client);
}
示例5: SV_Physics
/*
================
SV_Physics
================
*/
void SV_Physics (void)
{
int i;
edict_t *ent;
// let the progs know that a new frame has started
pr_global_struct->self = EDICT_TO_PROG(sv.edicts);
pr_global_struct->other = EDICT_TO_PROG(sv.edicts);
pr_global_struct->time = sv.time;
PR_ExecuteProgram (pr_global_struct->StartFrame);
//SV_CheckAllEnts ();
//
// treat each object in turn
//
ent = sv.edicts;
for (i=0 ; i<sv.num_edicts ; i++, ent = NEXT_EDICT(ent))
{
if (ent->free)
continue;
if (pr_global_struct->force_retouch)
{
SV_LinkEdict (ent, true); // force retouch even for stationary
}
if (i > 0 && i <= svs.maxclients)
SV_Physics_Client (ent, i);
else if (ent->v.movetype == MOVETYPE_PUSH)
SV_Physics_Pusher (ent);
else if (ent->v.movetype == MOVETYPE_NONE)
SV_Physics_None (ent);
else if (ent->v.movetype == MOVETYPE_NOCLIP)
SV_Physics_Noclip (ent);
else if (ent->v.movetype == MOVETYPE_STEP)
SV_Physics_Step (ent);
else if (ent->v.movetype == MOVETYPE_TOSS
|| ent->v.movetype == MOVETYPE_BOUNCE
|| ent->v.movetype == MOVETYPE_FLY
|| ent->v.movetype == MOVETYPE_FLYMISSILE)
SV_Physics_Toss (ent);
else
Sys_Error ("SV_Physics: bad movetype %i", (int)ent->v.movetype);
}
if (pr_global_struct->force_retouch)
pr_global_struct->force_retouch--;
sv.time += host_frametime;
}
示例6: SV_Impact
/*
==================
SV_Impact
Two entities have touched, so run their touch functions
==================
*/
void SV_Impact(edict_t * e1, edict_t * e2)
{
int old_self, old_other;
old_self = pr_global_struct->self;
old_other = pr_global_struct->other;
pr_global_struct->time = sv.time;
if (e1->v.touch && e1->v.solid != SOLID_NOT) {
pr_global_struct->self = EDICT_TO_PROG(e1);
pr_global_struct->other = EDICT_TO_PROG(e2);
PR_ExecuteProgram(e1->v.touch);
}
if (e2->v.touch && e2->v.solid != SOLID_NOT) {
pr_global_struct->self = EDICT_TO_PROG(e2);
pr_global_struct->other = EDICT_TO_PROG(e1);
PR_ExecuteProgram(e2->v.touch);
}
pr_global_struct->self = old_self;
pr_global_struct->other = old_other;
}
示例7: SV_RunThink
/*
=============
SV_RunThink
Runs thinking code if time. There is some play in the exact time the think
function will be called, because it is called before any movement is done
in a frame. Not used for pushmove objects, because they must be exact.
Returns false if the entity removed itself.
=============
*/
qboolean SV_RunThink (edict_t *ent)
{
float thinktime;
int oldcount;
thinktime = ent->v.nextthink;
if (thinktime <= 0 || thinktime > sv.time + host_frametime)
return true;
if (thinktime < sv.time)
thinktime = sv.time; // don't let things stay in the past.
// it is possible to start that way
// by a trigger with a local time.
ent->v.nextthink = 0;
PR_GLOBAL(time) = thinktime;
PR_GLOBAL(self) = EDICT_TO_PROG(ent);
PR_GLOBAL(other) = EDICT_TO_PROG(sv.edicts);
// JDH: the extra 1 added to total_monsters by monster_fish happens
// in swimmonster_start_go, during the first frame (sv.time = 1).
// But fix it only if total_monsters was increased when fish were
// spawned (ie. if sv.fish_counted is true)
if ((sv.time == 1.0) && sv_fishfix.value && sv.fish_counted &&
!strcmp(pr_strings + ent->v.classname, "monster_fish") &&
!strcmp(pr_functions[ent->v.think].s_name, "swimmonster_start_go"))
{
oldcount = PR_GLOBAL(total_monsters);
}
else oldcount = -1;
PR_ExecuteProgram (ent->v.think);
if (oldcount != -1)
{
if ((int)PR_GLOBAL(total_monsters) - oldcount == 1)
{
PR_GLOBAL(total_monsters) -= 1;
if (sv.fish_counted == 1)
{
Con_Print ("Detected fish-count bug in progs.dat; monster count has been adjusted\n");
sv.fish_counted++;
}
}
}
return !ent->free;
}
示例8: PR_ConsoleCmd
qbool PR_ConsoleCmd(void)
{
if (mod_ConsoleCmd)
{
if (sv_redirected != RD_MOD)
{
pr_global_struct->time = sv.time;
pr_global_struct->self = 0;
}
PR_ExecuteProgram (mod_ConsoleCmd);
return (int) G_FLOAT(OFS_RETURN);
}
return false;
}
示例9: Menu_Enter
void
Menu_Enter ()
{
if (!top_menu) {
Key_SetKeyDest (key_console);
return;
}
Key_SetKeyDest (key_menu);
menu = Hash_Find (menu_hash, top_menu);
if (menu && menu->enter_hook) {
run_menu_pre ();
PR_ExecuteProgram (&menu_pr_state, menu->enter_hook);
run_menu_post ();
}
}
示例10: quit_f
static void
quit_f (void)
{
int ret;
if (confirm_quit->int_val && menu_quit) {
run_menu_pre ();
PR_ExecuteProgram (&menu_pr_state, menu_quit);
ret = R_INT (&menu_pr_state);
run_menu_post ();
if (!ret)
return;
}
bi_Menu_Quit (&menu_pr_state);
}
示例11: SV_Physics_Pusher
/*
================
SV_Physics_Pusher
================
*/
void SV_Physics_Pusher (edict_t *ent)
{
float thinktime;
float oldltime;
float movetime;
oldltime = ent->v.ltime;
#ifdef _DEBUG
if (!ent->v.classname && ent->v.think)
movetime = 0;
#endif
thinktime = ent->v.nextthink;
if (thinktime < ent->v.ltime + host_frametime)
{
movetime = thinktime - ent->v.ltime;
if (movetime < 0)
movetime = 0;
}
else
movetime = host_frametime;
if (movetime)
{
#ifdef HEXEN2_SUPPORT
if (hexen2 && (ent->v.avelocity[0] || ent->v.avelocity[1] || ent->v.avelocity[2]))
{
SV_PushRotate (ent, movetime);
}
else
#endif
SV_PushMove (ent, movetime); // advances ent->v.ltime if not blocked
}
if (thinktime > oldltime && thinktime <= ent->v.ltime)
{
ent->v.nextthink = 0;
PR_GLOBAL(time) = sv.time;
PR_GLOBAL(self) = EDICT_TO_PROG(ent);
PR_GLOBAL(other) = EDICT_TO_PROG(sv.edicts);
PR_ExecuteProgram (ent->v.think);
if (ent->free)
return;
}
}
示例12: Host_Kill_f
static void
Host_Kill_f (void)
{
if (cmd_source == src_command) {
CL_Cmd_ForwardToServer ();
return;
}
if (SVfloat (sv_player, health) <= 0) {
SV_ClientPrintf ("Can't suicide -- already dead!\n");
return;
}
*sv_globals.time = sv.time;
*sv_globals.self = EDICT_TO_PROG (&sv_pr_state, sv_player);
PR_ExecuteProgram (&sv_pr_state, sv_funcs.ClientKill);
}
示例13: main
int
main (int argc, char **argv)
{
dfunction_t *dfunc;
func_t main_func = 0;
const char *name = "progs.dat";
string_t *pr_argv;
int pr_argc = 1, i;
i = parse_options (argc, argv);
argc -= i;
argv += i;
init_qf ();
if (argc > 0)
name = argv[0];
if (!load_progs (name))
Sys_Error ("couldn't load %s", name);
PR_PushFrame (&pr);
if (argc > 2)
pr_argc = argc - 1;
pr_argv = PR_Zone_Malloc (&pr, (pr_argc + 1) * 4);
pr_argv[0] = PR_SetTempString (&pr, name);
for (i = 1; i < pr_argc; i++)
pr_argv[i] = PR_SetTempString (&pr, argv[1 + i]);
pr_argv[i] = 0;
if ((dfunc = PR_FindFunction (&pr, ".main"))
|| (dfunc = PR_FindFunction (&pr, "main")))
main_func = dfunc - pr.pr_functions;
else
PR_Undefined (&pr, "function", "main");
PR_RESET_PARAMS (&pr);
P_INT (&pr, 0) = pr_argc;
P_POINTER (&pr, 1) = PR_SetPointer (&pr, pr_argv);
PR_ExecuteProgram (&pr, main_func);
PR_PopFrame (&pr);
if (options.flote)
return R_FLOAT (&pr);
return R_INT (&pr);
}
示例14: bi_Menu_Leave
static void
bi_Menu_Leave (progs_t *pr)
{
if (menu) {
if (menu->leave_hook) {
run_menu_pre ();
PR_ExecuteProgram (&menu_pr_state, menu->leave_hook);
run_menu_post ();
}
menu = menu->parent;
if (!menu) {
if (con_data.force_commandline) {
Key_SetKeyDest (key_console);
} else {
Key_SetKeyDest (key_game);
}
}
}
}
示例15: Host_QC_Exec
/*
==================
Host_QC_Exec
Execute QC commands from the console
==================
*/
void Host_QC_Exec (void)
{
dfunction_t *f;
if (cmd_source == src_command)
{
Cmd_ForwardToServer ();
return;
}
if (!developer.value)
return;
f = 0;
if ((f = ED_FindFunction(Cmd_Argv(1))) != NULL)
{
pr_global_struct->self = EDICT_TO_PROG(sv_player);
PR_ExecuteProgram ((func_t)(f - pr_functions));
}
else
Con_Printf("bad function\n");
}