hedgewars/uGears.pas
changeset 3499 66eba4e41b91
parent 3496 8fb007d36c09
child 3508 a7ca07614a2d
--- a/hedgewars/uGears.pas	Sat Jun 05 19:50:02 2010 +0000
+++ b/hedgewars/uGears.pas	Sat Jun 05 20:49:51 2010 +0000
@@ -130,12 +130,18 @@
 
 function GetLaunchX(at: TAmmoType; dir: LongInt; angle: LongInt): LongInt;
 begin
-    GetLaunchX:= sign(dir) * (8 + hwRound(AngleSin(angle) * Ammoz[at].ejectX) + hwRound(AngleCos(angle) * Ammoz[at].ejectY))
+    if (Ammoz[at].ejectX <> 0) or (Ammoz[at].ejectY <> 0) then
+        GetLaunchX:= sign(dir) * (8 + hwRound(AngleSin(angle) * Ammoz[at].ejectX) + hwRound(AngleCos(angle) * Ammoz[at].ejectY))
+    else
+        GetLaunchX:= 0
 end;
 
 function GetLaunchY(at: TAmmoType; angle: LongInt): LongInt;
 begin
-    GetLaunchY:= hwRound(AngleSin(angle) * Ammoz[at].ejectY) - hwRound(AngleCos(angle) * Ammoz[at].ejectX) - 2;
+    if (Ammoz[at].ejectX <> 0) or (Ammoz[at].ejectY <> 0) then
+        GetLaunchY:= hwRound(AngleSin(angle) * Ammoz[at].ejectY) - hwRound(AngleCos(angle) * Ammoz[at].ejectX) - 2
+    else
+        GetLaunchY:= 0
 end;
 
 {$INCLUDE "GSHandlers.inc"}