]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
sv_main: Fix segfault and logic bugs when saving.
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 2 Oct 2020 02:26:44 +0000 (02:26 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 2 Oct 2020 02:26:44 +0000 (02:26 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12989 d7cf8633-e32d-0410-b094-e92efae38249

sv_main.c

index 1da0531e9af7c9c75aa3a34d5f8ef9033a7aaaf3..463806d77bcee20fec8028051135f9dcfe34c24d 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -438,13 +438,13 @@ static qbool SV_CanSave(void)
        if(SV_IsLocalGame() == 1)
        {
                // singleplayer checks
-               if (!(svs.clients[0].active && PRVM_serveredictfloat(svs.clients[0].edict, deadflag)))
+               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())
+               if(host.hook.CL_Intermission && host.hook.CL_Intermission())
                {
                        Con_Print("Can't save in intermission.\n");
                        return false;
@@ -2020,7 +2020,7 @@ void SV_SpawnServer (const char *map)
  */
 int SV_IsLocalGame(void)
 {
-       if (sv.active && LHNETADDRESS_GetAddressType(&host_client->netconnection->peeraddress) == LHNETADDRESSTYPE_LOOP)
+       if (sv.active && &svs.clients[0] && LHNETADDRESS_GetAddressType(&svs.clients[0].netconnection->peeraddress) == LHNETADDRESSTYPE_LOOP)
                return svs.maxclients;
        return 0;
 }