hedgewars/GSHandlers.inc
changeset 5839 7ea0745912f7
parent 5835 812be8a96927
child 5841 ef0a76e154cb
--- a/hedgewars/GSHandlers.inc	Sat Sep 10 10:13:19 2011 -0400
+++ b/hedgewars/GSHandlers.inc	Sat Sep 10 16:21:38 2011 +0200
@@ -1035,14 +1035,19 @@
                 // http://mantis.freepascal.org/view.php?id=17714 hits again
                 VGear^.dX := Gear^.X.QWordValue / SignAs(_1,_1).QWordValue;
                 VGear^.dY := Gear^.Y.QWordValue / SignAs(_1,_1).QWordValue;
+
+                if (Gear^.X.isNegative) then VGear^.dX:= -VGear^.dX;
+                if (Gear^.Y.isNegative) then VGear^.dY:= -VGear^.dY;
                 
                 // reached edge of land. assume infinite beam. Extend it way out past camera
                 if (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0) 
                     or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then
-                    begin
-                    VGear^.dX := VGear^.dX + (CurrentHedgehog^.Gear^.dX * LAND_WIDTH).QWordValue / SignAs(_1,_1).QWordValue;
-                    VGear^.dY := VGear^.dY + (CurrentHedgehog^.Gear^.dY * LAND_WIDTH).QWordValue / SignAs(_1,_1).QWordValue;
-                    end;
+                        // only extend if not under water
+                        if hwRound(Gear^.Y) < cWaterLine then
+                            begin
+                            VGear^.dX := VGear^.dX + LAND_WIDTH * (VGear^.dX - VGear^.X);
+                            VGear^.dY := VGear^.dY + LAND_WIDTH * (VGear^.dY - VGear^.Y);
+                            end;
                 
                 VGear^.Timer := 200;
                 end