Delete CI in ResurrectHedgehog prior to FindPlace. Restrict FindPlace to the waterline, a bit more efficient.
authornemo
Sun, 05 Sep 2010 11:26:17 -0400
changeset 3832 f949798219bf
parent 3831 3410db7ac43e
child 3833 58afaa38781b
Delete CI in ResurrectHedgehog prior to FindPlace. Restrict FindPlace to the waterline, a bit more efficient.
hedgewars/uGears.pas
--- a/hedgewars/uGears.pas	Sun Sep 05 00:48:07 2010 +0200
+++ b/hedgewars/uGears.pas	Sun Sep 05 11:26:17 2010 -0400
@@ -1566,6 +1566,7 @@
         Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16);
     end;
     tempTeam := PHedgehog(gear^.Hedgehog)^.Team;
+    DeleteCI(gear);
     FindPlace(gear, false, 0, LAND_WIDTH); 
     if gear <> nil then begin
         RenderHealth(PHedgehog(gear^.Hedgehog)^);
@@ -1732,26 +1733,26 @@
         inc(x, Delta);
         cnt:= 0;
         y:= min(1024, topY) - 2 * Gear^.Radius;
-        while y < LAND_HEIGHT do
+        while y < cWaterLine do
             begin
             repeat
                 inc(y, 2);
-            until (y >= LAND_HEIGHT) or (CountNonZeroz(x, y, Gear^.Radius - 1, 1) = 0);
+            until (y >= cWaterLine) or (CountNonZeroz(x, y, Gear^.Radius - 1, 1) = 0);
 
             sy:= y;
 
             repeat
                 inc(y);
-            until (y >= LAND_HEIGHT) or (CountNonZeroz(x, y, Gear^.Radius - 1, 1) <> 0);
+            until (y >= cWaterLine) or (CountNonZeroz(x, y, Gear^.Radius - 1, 1) <> 0);
 
             if (y - sy > Gear^.Radius * 2) and
                (((Gear^.Kind = gtExplosives)
-                   and (y < LAND_HEIGHT-1)
+                   and (y < cWaterLine)
                    and (CheckGearsNear(x, y - Gear^.Radius, [gtFlame, gtHedgehog, gtMine, gtCase, gtExplosives], 60, 60) = nil)
                    and (CountNonZeroz(x, y+1, Gear^.Radius - 1, Gear^.Radius+1) > Gear^.Radius))
                or
                  ((Gear^.Kind <> gtExplosives)
-                   and (y < LAND_HEIGHT)
+                   and (y < cWaterLine)
                    and (CheckGearsNear(x, y - Gear^.Radius, [gtFlame, gtHedgehog, gtMine, gtCase, gtExplosives], 110, 110) = nil))) then
                 begin
                 ar[cnt].X:= x;
@@ -1787,6 +1788,7 @@
     else
     begin
     OutError('Can''t find place for Gear', false);
+    if Gear^.Kind = gtHedgehog then PHedgehog(Gear^.Hedgehog)^.Effects[heResurrectable] := false;
     DeleteGear(Gear);
     Gear:= nil
     end