Engine:
authorsmxx
Sat, 05 Jun 2010 20:49:51 +0000
changeset 3499 66eba4e41b91
parent 3498 1c74e277069c
child 3500 af8390d807d6
Engine: * Avoid any offset applied if weapon's origin is set to (0, 0)
hedgewars/uGears.pas
--- 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"}