nil out CurrentHedgehog in FreeModule, add a test for nil'd CurrentHedgehog in DelCI since I'd still like to use DeleteGear for the other stuff it does. Move some variable initialiasations in AI Misc to hopefully avoid some uninit val errors.
authornemo
Mon, 08 Dec 2014 10:14:47 -0500
changeset 10635 8e8b320eefad
parent 10634 35d059bd0932
child 10636 aba9ae27ead0
nil out CurrentHedgehog in FreeModule, add a test for nil'd CurrentHedgehog in DelCI since I'd still like to use DeleteGear for the other stuff it does. Move some variable initialiasations in AI Misc to hopefully avoid some uninit val errors.
hedgewars/uAIMisc.pas
hedgewars/uCollisions.pas
hedgewars/uTeams.pas
--- a/hedgewars/uAIMisc.pas	Mon Dec 08 09:35:14 2014 -0500
+++ b/hedgewars/uAIMisc.pas	Mon Dec 08 10:14:47 2014 -0500
@@ -556,6 +556,7 @@
                 pX:= Point.x;
                 pY:= Point.y;
                 fallDmg:= 0;
+                dX:= 0;
                 if (Flags and afTrackFall <> 0) and (Score > 0) and (dmg < Score) then
                     begin
                     dX:= (0.005 * dmg + 0.01) / Density;
@@ -741,10 +742,11 @@
                 end;
             if dmg > 0 then
                 begin
+                fallDmg:= 0;
+                pX:= Point.x;
+                pY:= Point.y;
                 if (not dead) and (Score > 0) and (dmg < Score) then
                     begin
-                    pX:= Point.x;
-                    pY:= Point.y;
                     dX:= gdX * dmg / Density;
                     dY:= gdY * dmg / Density;
                     if dX < 0 then dX:= dX - 0.01
--- a/hedgewars/uCollisions.pas	Mon Dec 08 09:35:14 2014 -0500
+++ b/hedgewars/uCollisions.pas	Mon Dec 08 10:14:47 2014 -0500
@@ -97,7 +97,7 @@
 if Gear^.CollisionIndex >= 0 then
     begin
     with cinfos[Gear^.CollisionIndex] do
-        ChangeRoundInLand(X, Y, Radius - 1, false, (Gear = CurrentHedgehog^.Gear) or ((Gear^.Kind = gtCase) and (Gear^.State and gstFrozen = 0)));
+        ChangeRoundInLand(X, Y, Radius - 1, false, ((CurrentHedgehog <> nil) and (Gear = CurrentHedgehog^.Gear)) or ((Gear^.Kind = gtCase) and (Gear^.State and gstFrozen = 0)));
     cinfos[Gear^.CollisionIndex]:= cinfos[Pred(Count)];
     cinfos[Gear^.CollisionIndex].cGear^.CollisionIndex:= Gear^.CollisionIndex;
     Gear^.CollisionIndex:= -1;
--- a/hedgewars/uTeams.pas	Mon Dec 08 09:35:14 2014 -0500
+++ b/hedgewars/uTeams.pas	Mon Dec 08 10:14:47 2014 -0500
@@ -845,6 +845,7 @@
 procedure freeModule;
 var i, h: LongWord;
 begin
+CurrentHedgehog:= nil;
 if TeamsCount > 0 then
     begin
     for i:= 0 to Pred(TeamsCount) do