From c3ea7019c9ce6dd91e6f40a027a45cd27da17385 Mon Sep 17 00:00:00 2001 From: havoc Date: Wed, 25 Feb 2009 10:28:47 +0000 Subject: [PATCH] ZQ_PAUSE extension patch from GreEn`mArine git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8757 d7cf8633-e32d-0410-b094-e92efae38249 --- clvm_cmds.c | 11 +++++++++++ host.c | 5 +++++ progsvm.h | 1 + prvm_edict.c | 1 + server.h | 1 + svvm_cmds.c | 32 ++++++++++++++++++++++++++++++++ 6 files changed, 51 insertions(+) diff --git a/clvm_cmds.c b/clvm_cmds.c index f0faa31f..7849ffe2 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -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 f00b8e6d..dbad918f 100644 --- 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(); diff --git a/progsvm.h b/progsvm.h index 1f459d43..d53c6f42 100644 --- 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 diff --git a/prvm_edict.c b/prvm_edict.c index 72b9c3e2..a751a15e 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -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"); diff --git a/server.h b/server.h index 7095d436..99c5296d 100644 --- 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; diff --git a/svvm_cmds.c b/svvm_cmds.c index 9ce38d3b..0bd684c9 100644 --- a/svvm_cmds.c +++ b/svvm_cmds.c @@ -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); -- 2.39.2