allow for 0 values on AMShiftTarget, this allows for movement across one axis
authorXeli
Tue, 13 Mar 2012 21:09:46 +0100
changeset 6794 95ee7bde3514
parent 6793 d62f25f5d6ce
child 6795 e4831e13e04a
allow for 0 values on AMShiftTarget, this allows for movement across one axis
hedgewars/uWorld.pas
--- a/hedgewars/uWorld.pas	Sat Mar 17 17:24:38 2012 -0400
+++ b/hedgewars/uWorld.pas	Tue Mar 13 21:09:46 2012 +0100
@@ -503,17 +503,23 @@
     AMShiftTargetY:= cScreenHeight - AmmoRect.y;
     AMShiftX:= AMShiftTargetX;
     AMShiftY:= AMShiftTargetY;
-
-    if (AMShiftTargetX div MENUSPEED) <  (AMShiftTargetY div MENUSPEED) then
+    
+    if (AMShiftTargetX = 0) or (AMShiftTargetY = 0) then
         begin
         MenuSpeedX:= MENUSPEED;
-        MenuSpeedY:= AMShiftTargetY div (AMShiftTargetX div MENUSPEED);
+        MENUSpeedY:= MENUSPEED;
         end
     else
-        begin
-        MenuSpeedX:= AMShiftTargetX div (AMShiftTargetY div MENUSPEED);
-        MenuSpeedY:= MENUSPEED;
-        end;
+        if (AMShiftTargetX div MENUSPEED) <  (AMShiftTargetY div MENUSPEED) then
+            begin
+            MenuSpeedX:= MENUSPEED;
+            MenuSpeedY:= AMShiftTargetY div (AMShiftTargetX div MENUSPEED);
+            end
+        else
+            begin
+            MenuSpeedX:= AMShiftTargetX div (AMShiftTargetY div MENUSPEED);
+            MenuSpeedY:= MENUSPEED;
+            end;
 end;
 
 if bShowAmmoMenu then // show ammo menu