hedgewars/uGears.pas
changeset 3831 3410db7ac43e
parent 3799 5341dc5a8919
child 3832 f949798219bf
--- 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;