ZQ_PAUSE extension patch from GreEn`mArine
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 25 Feb 2009 10:28:47 +0000 (10:28 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 25 Feb 2009 10:28:47 +0000 (10:28 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8757 d7cf8633-e32d-0410-b094-e92efae38249

clvm_cmds.c
host.c
progsvm.h
prvm_edict.c
server.h
svvm_cmds.c

index f0faa31..7849ffe 100644 (file)
@@ -3606,6 +3606,17 @@ VM_cvar_description,                                     // #518 float(string name) cvar_description = #518; (DP
 NULL,                                                  // #519
 VM_keynumtostring,                             // #520 string keynumtostring(float keynum)
 VM_findkeysforcommand,         // #521 string findkeysforcommand(string command)
+NULL,                                                  // #522
+NULL,                                                  // #523
+NULL,                                                  // #524
+NULL,                                                  // #525
+NULL,                                                  // #526
+NULL,                                                  // #527
+NULL,                                                  // #528
+NULL,                                                  // #529
+NULL,                                                  // #530
+NULL,                                  // #531
+NULL,                                                  // #532
 };
 
 const int vm_cl_numbuiltins = sizeof(vm_cl_builtins) / sizeof(prvm_builtin_t);
diff --git a/host.c b/host.c
index f00b8e6..dbad918 100644 (file)
--- a/host.c
+++ b/host.c
@@ -801,6 +801,11 @@ void Host_Main(void)
 
                        // send all messages to the clients
                        SV_SendClientMessages();
+                       
+                       if (sv.paused == 1 && realtime > sv.pausedstart && sv.pausedstart > 0) {
+                               prog->globals.generic[OFS_PARM0] = realtime - sv.pausedstart;
+                               PRVM_ExecuteProgram(prog->funcoffsets.SV_PausedTic, "QC function SV_PausedTic is missing");
+                       }
 
                        // end the server VM frame
                        SV_VM_End();
index 1f459d4..d53c6f4 100644 (file)
--- a/progsvm.h
+++ b/progsvm.h
@@ -300,6 +300,7 @@ typedef struct prvm_prog_funcoffsets_s
        func_t GameCommand; // any
        func_t SV_Shutdown; // ssqc
        func_t URI_Get_Callback; // any
+       func_t SV_PausedTic; //ssqc
 
        // menu qc only uses some functions, nothing else
        func_t m_draw; // mqc
index 72b9c3e..a751a15 100644 (file)
@@ -1523,6 +1523,7 @@ void PRVM_FindOffsets(void)
        prog->funcoffsets.GameCommand                     = PRVM_ED_FindFunctionOffset("GameCommand");
        prog->funcoffsets.SV_Shutdown                     = PRVM_ED_FindFunctionOffset("SV_Shutdown");
        prog->funcoffsets.URI_Get_Callback                = PRVM_ED_FindFunctionOffset("URI_Get_Callback");
+       prog->funcoffsets.SV_PausedTic                    = PRVM_ED_FindFunctionOffset("SV_PausedTic");
        prog->globaloffsets.SV_InitCmd                    = PRVM_ED_FindGlobalOffset("SV_InitCmd");
        prog->globaloffsets.self                          = PRVM_ED_FindGlobalOffset("self");
        prog->globaloffsets.time                          = PRVM_ED_FindGlobalOffset("time");
index 7095d43..99c5296 100644 (file)
--- a/server.h
+++ b/server.h
@@ -68,6 +68,7 @@ typedef struct server_s
        qboolean active;
 
        qboolean paused;
+       double pausedstart;
        // handle connections specially
        qboolean loadgame;
 
index 9ce38d3..0bd684c 100644 (file)
@@ -170,6 +170,7 @@ char *vm_sv_extensions =
 "PRYDON_CLIENTCURSOR "
 "TENEBRAE_GFX_DLIGHTS "
 "TW_SV_STEPCONTROL "
+"ZQ_PAUSE "
 //"EXT_CSQC " // not ready yet
 ;
 
@@ -2954,6 +2955,24 @@ static void VM_SV_pointparticles (void)
        SV_FlushBroadcastMessages();
 }
 
+//PF_setpause,    // void(float pause) setpause        = #531;
+static void VM_SV_setpause(void) {
+       int pauseValue;
+       pauseValue = (int)PRVM_G_FLOAT(OFS_PARM0);
+       if (pauseValue != 0) { //pause the game
+               sv.paused = 1;
+               sv.pausedstart = Sys_DoubleTime();
+       } else { //disable pause, in case it was enabled
+               if (sv.paused != 0) {
+                       sv.paused = 0;
+                       sv.pausedstart = 0;
+               }
+       }
+       // send notification to all clients
+       MSG_WriteByte(&sv.reliable_datagram, svc_setpause);
+       MSG_WriteByte(&sv.reliable_datagram, sv.paused);
+}
+
 prvm_builtin_t vm_sv_builtins[] = {
 NULL,                                                  // #0 NULL function (not callable) (QUAKE)
 VM_makevectors,                                        // #1 void(vector ang) makevectors (QUAKE)
@@ -3479,6 +3498,19 @@ VM_argv_end_index,                                               // #516 float(float idx) argv_end_index = #516; (DP_QC_T
 VM_buf_cvarlist,                                               // #517 void(float buf, string prefix, string antiprefix) buf_cvarlist = #517; (DP_QC_STRINGBUFFERS_CVARLIST)
 VM_cvar_description,                                   // #518 float(string name) cvar_description = #518; (DP_QC_CVAR_DESCRIPTION)
 NULL,                                                  // #519
+NULL,                                                  // #520
+NULL,                                                  // #521
+NULL,                                                  // #522
+NULL,                                                  // #523
+NULL,                                                  // #524
+NULL,                                                  // #525
+NULL,                                                  // #526
+NULL,                                                  // #527
+NULL,                                                  // #528
+NULL,                                                  // #529
+NULL,                                                  // #530
+VM_SV_setpause,                                        // #531 void(float pause) setpause = #531;
+NULL,                                                  // #532
 };
 
 const int vm_sv_numbuiltins = sizeof(vm_sv_builtins) / sizeof(prvm_builtin_t);