From 468f2af6459a6222dc8bbfb4470250f7ffd00edc Mon Sep 17 00:00:00 2001 From: cloudwalk Date: Fri, 14 May 2021 16:22:19 +0000 Subject: [PATCH] sv_save: Remove SV_CanSave hook and just call it directly. Move it to sv_save.c git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@13136 d7cf8633-e32d-0410-b094-e92efae38249 --- host.h | 1 - sv_main.c | 25 ------------------------- sv_save.c | 31 ++++++++++++++++++++++++++----- 3 files changed, 26 insertions(+), 31 deletions(-) diff --git a/host.h b/host.h index 80b5aa74..c87c3649 100644 --- a/host.h +++ b/host.h @@ -34,7 +34,6 @@ typedef struct host_s void (*Disconnect)(void); void (*ToggleMenu)(void); qbool (*CL_Intermission)(void); // Quake compatibility - qbool (*SV_CanSave)(void); // Quake compatibility void (*CL_SendCvar)(struct cmd_state_s *); void (*SV_SendCvar)(struct cmd_state_s *); } hook; diff --git a/sv_main.c b/sv_main.c index 090e1f48..5a469a5f 100644 --- a/sv_main.c +++ b/sv_main.c @@ -434,30 +434,6 @@ static void SV_AreaStats_f(cmd_state_t *cmd) World_PrintAreaStats(&sv.world, "server"); } -static qbool SV_CanSave(void) -{ - prvm_prog_t *prog = SVVM_prog; - if(SV_IsLocalServer() == 1) - { - // singleplayer checks - if ((svs.clients[0].active && PRVM_serveredictfloat(svs.clients[0].edict, deadflag))) - { - Con_Print("Can't savegame with a dead player\n"); - return false; - } - - if(host.hook.CL_Intermission && host.hook.CL_Intermission()) - { - Con_Print("Can't save in intermission.\n"); - return false; - } - } - else - Con_Print(CON_WARN "Warning: saving a multiplayer game may have strange results when restored (to properly resume, all players must join in the same player slots and then the game can be reloaded).\n"); - return true; - -} - static void SV_ServerOptions (void) { int i; @@ -710,7 +686,6 @@ void SV_Init (void) Cvar_RegisterVariable (&sv_writepicture_quality); SV_InitOperatorCommands(); - host.hook.SV_CanSave = SV_CanSave; sv_mempool = Mem_AllocPool("server", 0, NULL); diff --git a/sv_save.c b/sv_save.c index a08e33a5..799a0d8a 100644 --- a/sv_save.c +++ b/sv_save.c @@ -176,6 +176,30 @@ void SV_Savegame_to(prvm_prog_t *prog, const char *name) Con_Print("done.\n"); } +static qbool SV_CanSave(void) +{ + prvm_prog_t *prog = SVVM_prog; + if(SV_IsLocalServer() == 1) + { + // singleplayer checks + // FIXME: This only checks if the first player is dead? + if ((svs.clients[0].active && PRVM_serveredictfloat(svs.clients[0].edict, deadflag))) + { + Con_Print("Can't savegame with a dead player\n"); + return false; + } + + if(host.hook.CL_Intermission && host.hook.CL_Intermission()) + { + Con_Print("Can't save in intermission.\n"); + return false; + } + } + else + Con_Print(CON_WARN "Warning: saving a multiplayer game may have strange results when restored (to properly resume, all players must join in the same player slots and then the game can be reloaded).\n"); + return true; +} + /* =============== SV_Savegame_f @@ -192,11 +216,8 @@ void SV_Savegame_f(cmd_state_t *cmd) return; } - if(host.hook.SV_CanSave) - { - if(!host.hook.SV_CanSave()) - return; - } + if(!SV_CanSave()) + return; if (Cmd_Argc(cmd) != 2) { -- 2.39.2