From: divverent Date: Sat, 19 Jan 2008 11:16:12 +0000 (+0000) Subject: new SV progs function SV_Shutdown, gets called just before progs get unloaded/renewed... X-Git-Tag: xonotic-v0.1.0preview~2526 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=1d8da07221092afe494af77d6cd5e47fa9d8bf5d;p=xonotic%2Fdarkplaces.git new SV progs function SV_Shutdown, gets called just before progs get unloaded/renewed. Useful to save data at the end of a level. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7982 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/host.c b/host.c index f395b478..7862e440 100644 --- a/host.c +++ b/host.c @@ -516,6 +516,13 @@ void Host_ShutdownServer(void) for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++) if (host_client->active) SV_DropClient(false); // server shutdown + if(prog->loaded) + if(prog->funcoffsets.SV_Shutdown) + { + func_t s = prog->funcoffsets.SV_Shutdown; + prog->funcoffsets.SV_Shutdown = 0; // prevent it from getting called again + PRVM_ExecuteProgram(s,"SV_Shutdown() required"); + } SV_VM_End(); NetConn_CloseServerPorts(); diff --git a/progsvm.h b/progsvm.h index 8b412bca..4d8afd01 100644 --- a/progsvm.h +++ b/progsvm.h @@ -276,6 +276,7 @@ typedef struct prvm_prog_funcoffsets_s func_t SV_PlayerPhysics; // ssqc func_t SV_OnEntityNoSpawnFunction; // ssqc func_t GameCommand; // any + func_t SV_Shutdown; // ssqc // menu qc only uses some functions, nothing else func_t m_draw; // mqc diff --git a/prvm_edict.c b/prvm_edict.c index 8d982791..5f16668c 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -1442,6 +1442,7 @@ void PRVM_FindOffsets(void) prog->funcoffsets.SV_PlayerPhysics = PRVM_ED_FindFunctionOffset("SV_PlayerPhysics"); prog->funcoffsets.SV_OnEntityNoSpawnFunction = PRVM_ED_FindFunctionOffset("SV_OnEntityNoSpawnFunction"); prog->funcoffsets.GameCommand = PRVM_ED_FindFunctionOffset("GameCommand"); + prog->funcoffsets.SV_Shutdown = PRVM_ED_FindFunctionOffset("SV_Shutdown"); prog->globaloffsets.SV_InitCmd = PRVM_ED_FindGlobalOffset("SV_InitCmd"); prog->globaloffsets.self = PRVM_ED_FindGlobalOffset("self"); prog->globaloffsets.time = PRVM_ED_FindGlobalOffset("time"); diff --git a/svvm_cmds.c b/svvm_cmds.c index 65953bda..4f43379e 100644 --- a/svvm_cmds.c +++ b/svvm_cmds.c @@ -3321,6 +3321,13 @@ void VM_SV_Cmd_Init(void) void VM_SV_Cmd_Reset(void) { + if(prog->funcoffsets.SV_Shutdown) + { + func_t s = prog->funcoffsets.SV_Shutdown; + prog->funcoffsets.SV_Shutdown = 0; // prevent it from getting called again + PRVM_ExecuteProgram(s,"SV_Shutdown() required"); + } + VM_Cmd_Reset(); }