hedgewars/uGearsUtils.pas
changeset 7687 c73fd8cfa7c0
parent 7627 e1e112687fd6
child 7719 eeae1cb6b6bf
--- a/hedgewars/uGearsUtils.pas	Mon Aug 27 17:40:16 2012 +0200
+++ b/hedgewars/uGearsUtils.pas	Sun Sep 16 16:54:51 2012 +0200
@@ -108,7 +108,7 @@
 // Run the calcs only once we know we have a type that will need damage
                         tdX:= Gear^.X-fX;
                         tdY:= Gear^.Y-fY;
-                        if hwRound(hwAbs(tdX)+hwAbs(tdY)) < dmgBase then
+                        if (tdX.Round + tdY.Round + 2) < dmgBase then
                             dmg:= dmgBase - hwRound(Distance(tdX, tdY));
                         if dmg > 1 then
                             begin
@@ -142,7 +142,7 @@
 // Run the calcs only once we know we have a type that will need damage
                         tdX:= Gear^.X-fX;
                         tdY:= Gear^.Y-fY;
-                        if hwRound(hwAbs(tdX)+hwAbs(tdY)) < dmgBase then
+                        if (tdX.Round + tdY.Round + 2) < dmgBase then
                             dmg:= dmgBase - hwRound(Distance(tdX, tdY));
                         if dmg > 1 then
                             begin
@@ -241,9 +241,7 @@
         end;
     end
     else if Gear^.Kind <> gtStructure then // not gtHedgehog nor gtStructure
-        begin
         Gear^.Hedgehog:= AttackerHog;
-        end;
     inc(Gear^.Damage, Damage);
     
     ScriptCall('onGearDamage', Gear^.UID, Damage);
@@ -321,7 +319,8 @@
 var 
     dAngle: real;
 begin
-    dAngle := (Gear^.dX.QWordValue + Gear^.dY.QWordValue) / $80000000;
+// Frac/Round to be kind to JS as of 2012-08-27 where there is yet no int64/uint64
+    dAngle := (Gear^.dX.Round + Gear^.dY.Round) / 2 + (Gear^.dX.Frac+Gear^.dY.Frac) / $80000000;
     if not Gear^.dX.isNegative then
         Gear^.DirAngle := Gear^.DirAngle + dAngle
     else