fix: let's use less random code for drawing the bullet trajectory
authorsheepluva
Sat, 10 Sep 2011 16:21:38 +0200
changeset 5839 7ea0745912f7
parent 5838 180ffae2c039
child 5840 00a3e2452e79
fix: let's use less random code for drawing the bullet trajectory
hedgewars/GSHandlers.inc
--- 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