]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
new SV progs function SV_Shutdown, gets called just before progs get unloaded/renewed...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 19 Jan 2008 11:16:12 +0000 (11:16 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 19 Jan 2008 11:16:12 +0000 (11:16 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7982 d7cf8633-e32d-0410-b094-e92efae38249

host.c
progsvm.h
prvm_edict.c
svvm_cmds.c

diff --git a/host.c b/host.c
index f395b478f8b454df1f27f197777d42732dc62a6a..7862e440f2b95a519a8378518b5c40c069de8421 100644 (file)
--- 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();
index 8b412bca46dce777fd92476068d0fdaac2bd7e60..4d8afd0195050187d09b446a95c3dd390e0075c8 100644 (file)
--- 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
index 8d98279115833fccb9e8eacb64cc52c2d5921ef2..5f16668ceda1d2452541bfc4aada66d7304e9b50 100644 (file)
@@ -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");
index 65953bda51cdecb8bcec0332f2b67c817a3fa182..4f43379eaffc1e1d659233194cd49ba4f4eeb140 100644 (file)
@@ -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();
 }