Fix possible crashes/hangs due to recent changes
authorunC0Rr
Tue, 09 Feb 2016 14:40:06 +0300
changeset 11539 c22d292e7266
parent 11538 00860966354d
child 11540 1ae92bbb5a6d
child 11544 b69f5f22a3ba
Fix possible crashes/hangs due to recent changes
hedgewars/uGame.pas
hedgewars/uGearsList.pas
hedgewars/uIO.pas
hedgewars/uLand.pas
hedgewars/uLandObjects.pas
hedgewars/uStore.pas
hedgewars/uTeams.pas
--- a/hedgewars/uGame.pas	Mon Feb 08 14:58:36 2016 +0300
+++ b/hedgewars/uGame.pas	Tue Feb 09 14:40:06 2016 +0300
@@ -88,7 +88,7 @@
     end;
 PlayNextVoice;
 i:= 1;
-while (GameState <> gsExit) and (i <= Lag) do
+while (GameState <> gsExit) and (i <= Lag) and allOK do
     begin
     if not CurrentTeam^.ExtDriven then
         begin
--- a/hedgewars/uGearsList.pas	Mon Feb 08 14:58:36 2016 +0300
+++ b/hedgewars/uGearsList.pas	Tue Feb 09 14:40:06 2016 +0300
@@ -150,7 +150,8 @@
     AddFileLog('Attempted to remove Gear #'+inttostr(Gear^.uid)+' from the list twice.');
     exit
     end;
-if checkFails((Gear = nil) or (curHandledGear = nil) or (Gear = curHandledGear), 'You''re doing it wrong', true) then exit;
+    
+checkFails((Gear = nil) or (curHandledGear = nil) or (Gear = curHandledGear), 'You''re doing it wrong', true);
 
 if Gear^.NextGear <> nil then
     Gear^.NextGear^.PrevGear:= Gear^.PrevGear;
--- a/hedgewars/uIO.pas	Mon Feb 08 14:58:36 2016 +0300
+++ b/hedgewars/uIO.pas	Tue Feb 09 14:40:06 2016 +0300
@@ -234,13 +234,13 @@
         begin
         s[0]:= char(i);
         ss:= ss + s;
-        while (Length(ss) > 1)and(Length(ss) > byte(ss[1])) do
+        while (Length(ss) > 1)and(Length(ss) > byte(ss[1])) and allOK do
             begin
             ParseIPCCommand(copy(ss, 2, byte(ss[1])));
             Delete(ss, 1, Succ(byte(ss[1])));
             end
         end
-until i = 0;
+until (i = 0) or (not allOK);
 
 close(f)
 {$I+}
@@ -328,7 +328,7 @@
 repeat
     IPCCheckSock;
     SDL_Delay(1)
-until isPonged
+until isPonged or (not allOK)
 end;
 
 procedure SendIPCAndWaitReply(s: shortstring);
--- a/hedgewars/uLand.pas	Mon Feb 08 14:58:36 2016 +0300
+++ b/hedgewars/uLand.pas	Tue Feb 09 14:40:06 2016 +0300
@@ -668,6 +668,8 @@
 
 FreeLandObjects;
 
+if not allOK then exit;
+
 if GrayScale then
     begin
     if (cReducedQuality and rqBlurryLand) = 0 then
--- a/hedgewars/uLandObjects.pas	Mon Feb 08 14:58:36 2016 +0300
+++ b/hedgewars/uLandObjects.pas	Tue Feb 09 14:40:06 2016 +0300
@@ -525,7 +525,7 @@
 ThemeObjects.Count:= 0;
 SprayObjects.Count:= 0;
 
-while not pfsEOF(f) do
+while (not pfsEOF(f)) and allOK do
     begin
     pfsReadLn(f, s);
     if Length(s) = 0 then
--- a/hedgewars/uStore.pas	Mon Feb 08 14:58:36 2016 +0300
+++ b/hedgewars/uStore.pas	Tue Feb 09 14:40:06 2016 +0300
@@ -396,6 +396,7 @@
            and ((cCloudsNumber > 0) or (ii <> sprCloud))
            and ((vobCount > 0) or (ii <> sprFlake))
            and (savesurf or (not cOnlyStats)) // in stats-only only load those which are needed later
+           and allOK
             then
             begin
             if reload then
@@ -454,7 +455,7 @@
                 Surface:= nil
         end;
 
-if not cOnlyStats then
+if (not cOnlyStats) and allOK then
     begin
     WriteNames(fnt16);
 
--- a/hedgewars/uTeams.pas	Mon Feb 08 14:58:36 2016 +0300
+++ b/hedgewars/uTeams.pas	Tue Feb 09 14:40:06 2016 +0300
@@ -608,14 +608,18 @@
     // color is always little endian so the mask must be constant also in big endian archs
     Color:= Color or $FF000000;
     AddTeam(Color);
-    CurrentTeam^.TeamName:= ts;
-    CurrentTeam^.PlayerHash:= s;
-    loadTeamBinds(ts);
+    
+    if CurrentTeam <> nil then
+        begin
+        CurrentTeam^.TeamName:= ts;
+        CurrentTeam^.PlayerHash:= s;
+        loadTeamBinds(ts);
 
-    if GameType in [gmtDemo, gmtSave, gmtRecord] then
-        CurrentTeam^.ExtDriven:= true;
+        if GameType in [gmtDemo, gmtSave, gmtRecord] then
+            CurrentTeam^.ExtDriven:= true;
 
-    CurrentTeam^.voicepack:= AskForVoicepack('Default')
+        CurrentTeam^.voicepack:= AskForVoicepack('Default')
+        end
     end
 end;