From 730fb47e839dfc9a1368edfadb2801f9bdb3b7da Mon Sep 17 00:00:00 2001 From: Reki Date: Tue, 18 May 2021 22:07:55 -0400 Subject: [PATCH] Added 3 new entrypoints for VMs --- prvm_offsets.h | 6 ++++++ sv_ccmds.c | 8 ++++++++ sv_save.c | 8 ++++++++ vid_shared.c | 7 +++++++ 4 files changed, 29 insertions(+) diff --git a/prvm_offsets.h b/prvm_offsets.h index e89b058a..61210039 100644 --- a/prvm_offsets.h +++ b/prvm_offsets.h @@ -92,6 +92,7 @@ PRVM_DECLARE_clientfunction(CSQC_Parse_CenterPrint) PRVM_DECLARE_clientfunction(CSQC_Parse_Print) PRVM_DECLARE_clientfunction(CSQC_Parse_StuffCmd) PRVM_DECLARE_clientfunction(CSQC_Parse_TempEntity) +PRVM_DECLARE_clientfunction(CSQC_RendererRestarted) PRVM_DECLARE_clientfunction(CSQC_Shutdown) PRVM_DECLARE_clientfunction(CSQC_UpdateView) PRVM_DECLARE_clientfunction(GameCommand) @@ -417,6 +418,7 @@ PRVM_DECLARE_function(CSQC_Parse_CenterPrint) PRVM_DECLARE_function(CSQC_Parse_Print) PRVM_DECLARE_function(CSQC_Parse_StuffCmd) PRVM_DECLARE_function(CSQC_Parse_TempEntity) +PRVM_DECLARE_function(CSQC_RendererRestarted) PRVM_DECLARE_function(CSQC_Shutdown) PRVM_DECLARE_function(CSQC_UpdateView) PRVM_DECLARE_function(ClientConnect) @@ -429,6 +431,8 @@ PRVM_DECLARE_function(PlayerPostThink) PRVM_DECLARE_function(PlayerPreThink) PRVM_DECLARE_function(PutClientInServer) PRVM_DECLARE_function(RestoreGame) +PRVM_DECLARE_function(LoadTriggered) +PRVM_DECLARE_function(RestartTriggered) PRVM_DECLARE_function(SV_ChangeTeam) PRVM_DECLARE_function(SV_OnEntityNoSpawnFunction) PRVM_DECLARE_function(SV_OnEntityPostSpawnFunction) @@ -796,6 +800,8 @@ PRVM_DECLARE_serverfunction(PlayerPostThink) PRVM_DECLARE_serverfunction(PlayerPreThink) PRVM_DECLARE_serverfunction(PutClientInServer) PRVM_DECLARE_serverfunction(RestoreGame) +PRVM_DECLARE_serverfunction(LoadTriggered) +PRVM_DECLARE_serverfunction(RestartTriggered) PRVM_DECLARE_serverfunction(SV_ChangeTeam) PRVM_DECLARE_serverfunction(SV_OnEntityNoSpawnFunction) PRVM_DECLARE_serverfunction(SV_OnEntityPostSpawnFunction) diff --git a/sv_ccmds.c b/sv_ccmds.c index 31359d0f..ecc31438 100644 --- a/sv_ccmds.c +++ b/sv_ccmds.c @@ -140,6 +140,14 @@ static void SV_Restart_f(cmd_state_t *cmd) Con_Print("Only the server may restart\n"); return; } + + prvm_prog_t *prog = SVVM_prog; + if (PRVM_serverfunction(RestartTriggered)) + { + Con_DPrint("Calling RestartTriggered\n"); + PRVM_serverglobalfloat(time) = sv.time; + prog->ExecuteProgram(prog, PRVM_serverfunction(RestartTriggered), "QC function RestartTriggered is missing"); + } if(host.hook.ToggleMenu) host.hook.ToggleMenu(); diff --git a/sv_save.c b/sv_save.c index a08e33a5..4fc687a5 100644 --- a/sv_save.c +++ b/sv_save.c @@ -243,6 +243,14 @@ void SV_Loadgame_f(cmd_state_t *cmd) Con_Print("load : load a game\n"); return; } + + if (PRVM_serverfunction(LoadTriggered)) + { + Con_DPrint("Calling LoadTriggered\n"); + PRVM_serverglobalfloat(time) = sv.time; + PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(host_client->edict); + prog->ExecuteProgram(prog, PRVM_serverfunction(LoadTriggered), "QC function LoadTriggered is missing"); + } strlcpy (filename, Cmd_Argv(cmd, 1), sizeof(filename)); FS_DefaultExtension (filename, ".sav", sizeof (filename)); diff --git a/vid_shared.c b/vid_shared.c index bc4c9855..5f44880d 100644 --- a/vid_shared.c +++ b/vid_shared.c @@ -1488,6 +1488,13 @@ void VID_Restart_f(cmd_state_t *cmd) Sys_Error("Unable to restore to last working video mode"); } VID_OpenSystems(); + + prvm_prog_t *prog = CLVM_prog; + if (PRVM_clientfunction(CSQC_RendererRestarted)) + { + Con_DPrint("Calling CSQC_RendererRestarted\n"); + prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_RendererRestarted), "QC function CSQC_RendererRestarted is missing"); + } } const char *vidfallbacks[][2] = -- 2.39.2