extra nil check for lua hog switch
authornemo
Tue, 21 Aug 2012 21:46:05 -0400
changeset 7573 364cd923db43
parent 7571 22a7bfa3e6bb
child 7575 f415b3e0f3b9
extra nil check for lua hog switch
hedgewars/uScript.pas
--- a/hedgewars/uScript.pas	Wed Aug 22 10:27:26 2012 +0400
+++ b/hedgewars/uScript.pas	Tue Aug 21 21:46:05 2012 -0400
@@ -980,10 +980,13 @@
         if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) and (CurrentHedgehog <> nil) then
             begin
             prevgear := CurrentHedgehog^.Gear;
-            prevgear^.Active := false;
-            prevgear^.State:= prevgear^.State and (not gstHHDriven);
-            prevgear^.Z := cHHZ;
-            prevgear^.Message:= prevgear^.Message or gmRemoveFromList or gmAddToList;
+            if prevgear <> nil then
+                begin
+                prevgear^.Active := false;
+                prevgear^.State:= prevgear^.State and (not gstHHDriven);
+                prevgear^.Z := cHHZ;
+                prevgear^.Message:= prevgear^.Message or gmRemoveFromList or gmAddToList;
+                end;
             
             SwitchCurrentHedgehog(gear^.Hedgehog);
             CurrentTeam:= CurrentHedgehog^.Team;