gfAISurvival: fix issue when cpu cannot find new place to spawn
authorburp
Sun, 05 Sep 2010 00:48:07 +0200
changeset 3831 3410db7ac43e
parent 3830 5c7af1bf692a
child 3832 f949798219bf
gfAISurvival: fix issue when cpu cannot find new place to spawn
hedgewars/uGears.pas
--- a/hedgewars/uGears.pas	Sat Sep 04 16:24:11 2010 +0200
+++ b/hedgewars/uGears.pas	Sun Sep 05 00:48:07 2010 +0200
@@ -1552,6 +1552,7 @@
 end;
 
 procedure ResurrectHedgehog(gear: PGear);
+var tempTeam : PTeam;
 begin
     gear^.dX := _0;
     gear^.dY := _0;
@@ -1564,10 +1565,13 @@
         if Team^.AIKillsTex <> nil then FreeTexture(Team^.AIKillsTex);
         Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16);
     end;
+    tempTeam := PHedgehog(gear^.Hedgehog)^.Team;
     FindPlace(gear, false, 0, LAND_WIDTH); 
-    RenderHealth(PHedgehog(gear^.Hedgehog)^);
-    RecountTeamHealth(PHedgehog(gear^.Hedgehog)^.Team);
-    ScriptCall('onResurrect', gear^.uid);
+    if gear <> nil then begin
+        RenderHealth(PHedgehog(gear^.Hedgehog)^);
+        ScriptCall('onResurrect', gear^.uid);
+    end;
+    RecountTeamHealth(tempTeam);
 end;
 
 function SpawnCustomCrateAt(x, y: LongInt; crate: TCrateType; content: Longword): PGear;