Fix reading out of bounds of the collisions array. This fixes flying hedgehogs and not moving after explosion
authorunc0rr
Tue, 06 Sep 2005 19:09:39 +0000
changeset 12 366adfa1a727
parent 11 b64d67d222b9
child 13 7a5db822fd3f
Fix reading out of bounds of the collisions array. This fixes flying hedgehogs and not moving after explosion
hedgewars/uCollisions.pas
--- a/hedgewars/uCollisions.pas	Sun Sep 04 21:19:19 2005 +0000
+++ b/hedgewars/uCollisions.pas	Tue Sep 06 19:09:39 2005 +0000
@@ -100,6 +100,8 @@
 var x1, x2, y1, y2: integer;
     i: Longword;
 begin
+Result:= false;
+if Count = 0 then exit;
 x1:= round(Gear.X);
 y1:= round(Gear.Y);
 {if (Gear.State and gstOutOfHH) = 0 then
@@ -111,7 +113,6 @@
       or (y1 - Gear.HalfHeight > round(p.Y) + p.HalfHeight)
       or (y1 + Gear.HalfHeight < round(p.Y) - p.HalfHeight)) then Gear.State:= Gear.State or gstOutOfHH;
    end; }
-Result:= false;
 if forX then
    begin
    x1:= x1 + Dir*Gear.HalfWidth;