From: divverent Date: Tue, 6 Aug 2013 13:40:35 +0000 (+0000) Subject: In prog reset functions, do not call functions unless prog->loaded. X-Git-Tag: xonotic-v0.8.0~96^2~45 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=97703839c970c295ba6173da463906bdec6d55cd;p=xonotic%2Fdarkplaces.git In prog reset functions, do not call functions unless prog->loaded. This fixes segfaults in case progs loading itself may have caused Host_Error. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11995 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/csprogs.c b/csprogs.c index 36cecf83..fa5e690b 100644 --- a/csprogs.c +++ b/csprogs.c @@ -1160,10 +1160,13 @@ void CL_VM_ShutDown (void) if(!cl.csqc_loaded) return; CSQC_BEGIN - PRVM_clientglobalfloat(time) = cl.time; - PRVM_clientglobaledict(self) = 0; - if (PRVM_clientfunction(CSQC_Shutdown)) - prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_Shutdown), "QC function CSQC_Shutdown is missing"); + if (prog->loaded) + { + PRVM_clientglobalfloat(time) = cl.time; + PRVM_clientglobaledict(self) = 0; + if (PRVM_clientfunction(CSQC_Shutdown)) + prog->ExecuteProgram(prog, PRVM_clientfunction(CSQC_Shutdown), "QC function CSQC_Shutdown is missing"); + } PRVM_Prog_Reset(prog); CSQC_END Con_DPrint("CSQC ^1unloaded\n"); diff --git a/menu.c b/menu.c index 34a8de7f..d1311ca3 100644 --- a/menu.c +++ b/menu.c @@ -5333,8 +5333,8 @@ static void MP_NewMap(void) static void MP_Shutdown (void) { prvm_prog_t *prog = MVM_prog; - - prog->ExecuteProgram(prog, PRVM_menufunction(m_shutdown),"m_shutdown() required"); + if (prog->loaded) + prog->ExecuteProgram(prog, PRVM_menufunction(m_shutdown),"m_shutdown() required"); // reset key_dest key_dest = key_game; diff --git a/svvm_cmds.c b/svvm_cmds.c index e9d51fdf..c75dd077 100644 --- a/svvm_cmds.c +++ b/svvm_cmds.c @@ -3835,7 +3835,8 @@ void SVVM_init_cmd(prvm_prog_t *prog) void SVVM_reset_cmd(prvm_prog_t *prog) { World_End(&sv.world); - if(PRVM_serverfunction(SV_Shutdown)) + + if(prog->loaded && PRVM_serverfunction(SV_Shutdown)) { func_t s = PRVM_serverfunction(SV_Shutdown); PRVM_serverglobalfloat(time) = sv.time;