Fix engine crash when using lasersight outside the world bounds
authoralfadur
Wed, 12 Sep 2018 19:51:45 +0300
changeset 13781 720dc03600c9
parent 13780 8a7699ccb608
child 13782 3fa9e30927f1
Fix engine crash when using lasersight outside the world bounds
hedgewars/uGearsRender.pas
--- a/hedgewars/uGearsRender.pas	Tue Sep 11 22:49:27 2018 +0200
+++ b/hedgewars/uGearsRender.pas	Wed Sep 12 19:51:45 2018 +0300
@@ -301,7 +301,7 @@
     sign, hx, hy, tx, ty, sx, sy, m: LongInt;  // hedgehog, crosshair, temp, sprite, direction
     dx, dy, ax, ay, aAngle, dAngle, hAngle, lx, ly: real;  // laser, change
     wraps: LongWord; // numbe of wraps for laser in world wrap
-    defaultPos, HatVisible: boolean;
+    defaultPos, HatVisible, inWorldBounds: boolean;
     HH: PHedgehog;
     CurWeapon: PAmmo;
     iceOffset:Longint;
@@ -444,7 +444,8 @@
                 hx:= tx;
                 hy:= ty;
                 wraps:= 0;
-                while ((Land[ty, tx] and lfAll) = 0) do
+                inWorldBounds := ((ty and LAND_HEIGHT_MASK) or (tx and LAND_WIDTH_MASK)) = 0;
+                while inWorldBounds and ((Land[ty, tx] and lfAll) = 0) do
                     begin
                     if wraps > cMaxLaserSightWraps then
                         break;