Small fixes for better FPC compatibility
authorunc0rr
Fri, 11 Aug 2006 20:00:29 +0000
changeset 108 08f1fe6f21f8
parent 107 b08ce0293a51
child 109 ab0340f580c2
Small fixes for better FPC compatibility
hedgewars/GSHandlers.inc
hedgewars/HHHandlers.inc
hedgewars/uAIAmmoTests.pas
hedgewars/uAIMisc.pas
hedgewars/uConsole.pas
hedgewars/uGame.pas
hedgewars/uGears.pas
hedgewars/uLocale.pas
hedgewars/uMisc.pas
hedgewars/uStore.pas
hedgewars/uWorld.pas
--- a/hedgewars/GSHandlers.inc	Fri Aug 11 16:17:50 2006 +0000
+++ b/hedgewars/GSHandlers.inc	Fri Aug 11 20:00:29 2006 +0000
@@ -46,7 +46,7 @@
 
 procedure CheckCollision(Gear: PGear);
 begin
-if TestCollisionXwithGear(Gear, Sign(Gear.X)) or TestCollisionYwithGear(Gear, Sign(Gear.Y))
+if TestCollisionXwithGear(Gear, hwSign(Gear.X)) or TestCollisionYwithGear(Gear, hwSign(Gear.Y))
    then Gear.State:= Gear.State or      gstCollision
    else Gear.State:= Gear.State and not gstCollision
 end;
@@ -80,13 +80,13 @@
 procedure doStepFallingGear(Gear: PGear);
 var b: boolean;
 begin
-if TestCollisionYwithGear(Gear, Sign(Gear.dY)) then
+if TestCollisionYwithGear(Gear, hwSign(Gear.dY)) then
    begin
    Gear.dX:=   Gear.dX * Gear.Friction;
    Gear.dY:= - Gear.dY * Gear.Elasticity;
    b:= false
    end else b:= true;
-if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then
+if TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then
    begin
    Gear.dX:= - Gear.dX * Gear.Elasticity;
 //   Gear.dY:=   Gear.dY;
@@ -384,7 +384,7 @@
 if TestCollisionYwithGear(Gear, 1) then
    begin
    Gear.dY:= 0;
-   HHGear.dX:= 0.0000001 * Sign(PGear(Gear.Hedgehog).dX);
+   HHGear.dX:= 0.0000001 * hwSign(PGear(Gear.Hedgehog).dX);
    HHGear.dY:= 0;
    end else
    begin
@@ -429,7 +429,7 @@
 const flCheck: boolean = false;
 var HHGear: PGear;
     len, cs, cc, tx, ty: Double;
-    lx, ly: integer;
+    lx, ly: LongInt;
 
     procedure DeleteMe;
     begin
@@ -445,6 +445,7 @@
 
 begin
 HHGear:= PHedgehog(Gear.Hedgehog).Gear;
+
 if ((HHGear.State and gstHHDriven) = 0)
    or (CheckGearDrowning(HHGear)) then
    begin
@@ -459,9 +460,11 @@
 
 if not TestCollisionYwithGear(HHGear, 1) then HHGear.dY:= HHGear.dY + cGravity;
 
-HHGear.DirAngle:= arctan2(Gear.dY + HHGear.dY, Gear.dX + HHGear.dX);
-cs:= sin(HHGear.DirAngle);
-cc:= cos(HHGear.DirAngle);
+cs:= Gear.dY + HHGear.dY;
+cc:= Gear.dX + HHGear.dX;
+len:= 1 / sqrt(sqr(cc)+sqr(cs));
+cc:= cc * len;
+cs:= cs * len;
 
 flCheck:= not flCheck;
 if flCheck then  // check whether rope needs dividing
@@ -471,8 +474,8 @@
          begin
          tx:= cc*len;
          ty:= cs*len;
-         lx:= round(Gear.X + tx) + Sign(HHGear.dX);
-         ly:= round(Gear.Y + ty) + Sign(HHGear.dY);
+         lx:= round(Gear.X + tx) + hwSign(HHGear.dX);
+         ly:= round(Gear.Y + ty) + hwSign(HHGear.dY);
          if ((ly and $FFFFFC00) = 0) and ((lx and $FFFFF800) = 0)and (Land[ly, lx] <> 0) then
            begin
            with RopePoints.ar[RopePoints.Count] do
@@ -509,30 +512,40 @@
 
 Gear.dX:= HHGear.X - Gear.X;
 Gear.dY:= HHGear.Y - Gear.Y;
-HHGear.DirAngle:= arctan2(Gear.dY + HHGear.dY, Gear.dX + HHGear.dX);
-cs:= sin(HHGear.DirAngle);
-cc:= cos(HHGear.DirAngle);
+
+cs:= Gear.dY + HHGear.dY;
+cc:= Gear.dX + HHGear.dX;
+len:= 1 / sqrt(sqr(cc)+sqr(cs));
+cc:= cc * len;
+cs:= cs * len;
 
 HHGear.dX:= HHGear.X;
 HHGear.dY:= HHGear.Y;
 
 if ((Gear.Message and gm_Down) <> 0) and (Gear.Elasticity < Gear.Friction) then
-   if not (TestCollisionXwithGear(HHGear, Sign(Gear.dX))
-        or TestCollisionYwithGear(HHGear, Sign(Gear.dY))) then Gear.Elasticity:= Gear.Elasticity + 0.3;
+   if not (TestCollisionXwithGear(HHGear, hwSign(Gear.dX))
+        or TestCollisionYwithGear(HHGear, hwSign(Gear.dY))) then Gear.Elasticity:= Gear.Elasticity + 0.3;
 
 if ((Gear.Message and gm_Up) <> 0) and (Gear.Elasticity > 30) then
-   if not (TestCollisionXwithGear(HHGear, -Sign(Gear.dX))
-        or TestCollisionYwithGear(HHGear, -Sign(Gear.dY))) then Gear.Elasticity:= Gear.Elasticity - 0.3;
+   if not (TestCollisionXwithGear(HHGear, -hwSign(Gear.dX))
+        or TestCollisionYwithGear(HHGear, -hwSign(Gear.dY))) then Gear.Elasticity:= Gear.Elasticity - 0.3;
 
 HHGear.X:= Gear.X + cc*Gear.Elasticity;
 HHGear.Y:= Gear.Y + cs*Gear.Elasticity;
 
+if (GameTicks >= 165118) and (GameTicks <= 165121) then
+   begin
+   AddFileLog('==9==> ('+floattostr(cc)+','+floattostr(cs)+')');
+   AddFileLog('==a==>  '+floattostr(Gear.Elasticity));
+   AddFileLog('==b==> ('+floattostr(HHGear.X)+','+floattostr(HHGear.Y)+')');
+   end;
+
 HHGear.dX:= HHGear.X - HHGear.dX;
 HHGear.dY:= HHGear.Y - HHGear.dY;
 
-if TestCollisionXwithGear(HHGear, Sign(HHGear.dX)) then
+if TestCollisionXwithGear(HHGear, hwSign(HHGear.dX)) then
    HHGear.dX:= -0.6 * HHGear.dX;
-if TestCollisionYwithGear(HHGear, Sign(HHGear.dY)) then
+if TestCollisionYwithGear(HHGear, hwSign(HHGear.dY)) then
    HHGear.dY:= -0.6 * HHGear.dY;
 
 if (Gear.Message and gm_Attack) <> 0 then
@@ -557,7 +570,7 @@
       HHGear.State:= HHGear.State and not (gstFalling or gstHHJumping);
       end else
       begin
-      if TestCollisionXwithGear(HHGear, Sign(HHGear.dX)) then HHGear.dX:= 0.0000001 * Sign(HHGear.dX);
+      if TestCollisionXwithGear(HHGear, hwSign(HHGear.dX)) then HHGear.dX:= 0.0000001 * hwSign(HHGear.dX);
       HHGear.X:= HHGear.X + HHGear.dX;
       HHGear.Y:= HHGear.Y + HHGear.dY;
       Gear.X:= Gear.X + HHGear.dX;
@@ -568,8 +581,8 @@
       ty:= 0;
       while tt > 20 do
             begin
-            if  TestCollisionXwithXYShift(Gear, round(tx), round(ty), Sign(Gear.dX))
-             or TestCollisionYwithXYShift(Gear, round(tx), round(ty), Sign(Gear.dY)) then
+            if  TestCollisionXwithXYShift(Gear, round(tx), round(ty), hwSign(Gear.dX))
+             or TestCollisionYwithXYShift(Gear, round(tx), round(ty), hwSign(Gear.dY)) then
                 begin
                 Gear.X:= Gear.X + tx;
                 Gear.Y:= Gear.Y + ty;
@@ -865,11 +878,11 @@
 AllInactive:= false;
 HHGear:= PHedgehog(Gear.Hedgehog).Gear;
 HHGear.X:= round(HHGear.X) - 0.5;
-HHGear.dX:= 0.0000001 * Sign(HHGear.dX);
+HHGear.dX:= 0.0000001 * hwSign(HHGear.dX);
 HHGear.dY:= -0.30;
 
 Gear.X:= HHGear.X;
-Gear.dX:= Sign(HHGear.dX)* 0.45;
+Gear.dX:= hwSign(HHGear.dX)* 0.45;
 Gear.dY:= -0.9;
 Gear.doStep:= doStepFirePunchWork;
 DrawTunnel(HHGear.X - cHHRadius, HHGear.Y + 1, 0.5, 0.0, cHHRadius * 4, 5);
--- a/hedgewars/HHHandlers.inc	Fri Aug 11 16:17:50 2006 +0000
+++ b/hedgewars/HHHandlers.inc	Fri Aug 11 20:00:29 2006 +0000
@@ -63,7 +63,7 @@
            StopTPUSound;
            PlaySound(sndThrowRelease);
            end;
-        xx:= Sign(dX)*Sin(Angle*pi/cMaxAngle);
+        xx:= hwSign(dX)*Sin(Angle*pi/cMaxAngle);
         yy:= -Cos(Angle*pi/cMaxAngle);
              case Ammo[CurSlot, CurAmmo].AmmoType of
                       amGrenade: FollowGear:= AddGear(round(X), round(Y), gtAmmo_Bomb,    0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, Ammo[CurSlot, CurAmmo].Timer);
@@ -77,11 +77,11 @@
                    amPickHammer: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y) + cHHRadius, gtPickHammer, 0);
                          amSkip: TurnTimeLeft:= 0;
                          amRope: CurAmmoGear:= AddGear(round(Gear.X), round(Gear.Y), gtRope, 0, xx, yy);
-                         amMine: AddGear(round(X) + Sign(dX) * 7, round(Y), gtMine, 0, Sign(dX) * 0.02, 0, 3000);
+                         amMine: AddGear(round(X) + hwSign(dX) * 7, round(Y), gtMine, 0, hwSign(dX) * 0.02, 0, 3000);
                        amDEagle: AddGear(round(X), round(Y), gtDEagleShot, 0, xx * 0.5, yy * 0.5);
-                     amDynamite: AddGear(round(X) + Sign(dX) * 7, round(Y), gtDynamite, 0, Sign(dX) * 0.035, 0, 5000);
-                  amBaseballBat: AddGear(round(X) + Sign(dX) * 10, round(Y), gtShover, 0, xx * 0.5, yy * 0.5).Radius:= 20;
-                    amFirePunch: CurAmmoGear:= AddGear(round(X) + Sign(dX) * 10, round(Y), gtFirePunch, 0);
+                     amDynamite: AddGear(round(X) + hwSign(dX) * 7, round(Y), gtDynamite, 0, hwSign(dX) * 0.035, 0, 5000);
+                  amBaseballBat: AddGear(round(X) + hwSign(dX) * 10, round(Y), gtShover, 0, xx * 0.5, yy * 0.5).Radius:= 20;
+                    amFirePunch: CurAmmoGear:= AddGear(round(X) + hwSign(dX) * 10, round(Y), gtFirePunch, 0);
                   end;
         Power:= 0;
         if CurAmmoGear <> nil then
@@ -144,7 +144,7 @@
    begin
    TurnTimeLeft:= 0;
    if ((Gear.State and (gstMoving or gstFalling)) = 0)
-      and (CurAmmoGear = nil) then Gear.dX:= 0.0000001 * Sign(Gear.dX);
+      and (CurAmmoGear = nil) then Gear.dX:= 0.0000001 * hwSign(Gear.dX);
    Gear.State:= Gear.State and not gstHHDriven;
    if Gear.Damage > 0 then
       Gear.State:= Gear.State and not gstHHJumping;
@@ -176,10 +176,10 @@
       if (abs(Gear.dX) < 0.0000002) and (Gear.dY < -0.02) then
          begin
          Gear.dY:= -0.25;
-         Gear.dX:= Sign(Gear.dX) * 0.02
+         Gear.dX:= hwSign(Gear.dX) * 0.02
          end;
    Gear.Message:= Gear.Message and not (gm_LJump or gm_HJump);     
-   if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then Gear.dX:= 0.0000001 * Sign(Gear.dX);
+   if TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then Gear.dX:= 0.0000001 * hwSign(Gear.dX);
    Gear.X:= Gear.X + Gear.dX;
    Gear.dY:= Gear.dY + cGravity;
    if (Gear.dY < 0)and TestCollisionYwithGear(Gear, -1) then Gear.dY:= 0;
@@ -188,7 +188,7 @@
       begin
       CheckHHDamage(Gear);
       if ((abs(Gear.dX) + abs(Gear.dY)) < 0.55)
-         and ((Gear.State and gstHHJumping) <> 0) then Gear.dX:= 0.0000001 * Sign(Gear.dX);
+         and ((Gear.State and gstHHJumping) <> 0) then Gear.dX:= 0.0000001 * hwSign(Gear.dX);
       Gear.State:= Gear.State and not (gstFalling or gstHHJumping);
       StepTicks:= 300; 
       Gear.dY:= 0
@@ -210,13 +210,13 @@
       begin
       Gear.Message:= 0;
       if not TestCollisionYwithGear(Gear, -1) then
-         if not TestCollisionXwithXYShift(Gear, 0, -2, Sign(Gear.dX)) then Gear.Y:= Gear.Y - 2 else
-         if not TestCollisionXwithXYShift(Gear, 0, -1, Sign(Gear.dX)) then Gear.Y:= Gear.Y - 1;
-      if not (TestCollisionXwithGear(Gear, Sign(Gear.dX))
+         if not TestCollisionXwithXYShift(Gear, 0, -2, hwSign(Gear.dX)) then Gear.Y:= Gear.Y - 2 else
+         if not TestCollisionXwithXYShift(Gear, 0, -1, hwSign(Gear.dX)) then Gear.Y:= Gear.Y - 1;
+      if not (TestCollisionXwithGear(Gear, hwSign(Gear.dX))
          or   TestCollisionYwithGear(Gear, -1)) then
          begin
          Gear.dY:= -0.15;
-         Gear.dX:= Sign(Gear.dX) * 0.15;
+         Gear.dX:= hwSign(Gear.dX) * 0.15;
          Gear.State:= Gear.State or gstFalling or gstHHJumping;
          exit
          end;
@@ -227,35 +227,35 @@
       if not TestCollisionYwithGear(Gear, -1) then
          begin
          Gear.dY:= -0.20;
-         Gear.dX:= 0.0000001 * Sign(Gear.dX);
-         Gear.X:= Gear.X - Sign(Gear.dX)*0.00008; // shift compensation
+         Gear.dX:= 0.0000001 * hwSign(Gear.dX);
+         Gear.X:= Gear.X - hwSign(Gear.dX)*0.00008; // shift compensation
          Gear.State:= Gear.State or gstFalling or gstHHJumping;
          exit
          end;
       end;
-   PrevdX:= Sign(Gear.dX);
+   PrevdX:= hwSign(Gear.dX);
    if (Gear.Message and gm_Left  )<>0 then Gear.dX:= -1.0 else
    if (Gear.Message and gm_Right )<>0 then Gear.dX:=  1.0 else exit;
    StepTicks:= cHHStepTicks;
-   if PrevdX <> Sign(Gear.dX) then exit;
+   if PrevdX <> hwSign(Gear.dX) then exit;
    PHedgehog(Gear.Hedgehog).visStepPos:= (PHedgehog(Gear.Hedgehog).visStepPos + 1) and 7;
-   if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then
+   if TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then
       begin
-      if not (TestCollisionXwithXYShift(Gear, 0, -6, Sign(Gear.dX))
+      if not (TestCollisionXwithXYShift(Gear, 0, -6, hwSign(Gear.dX))
          or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1;
-      if not (TestCollisionXwithXYShift(Gear, 0, -5, Sign(Gear.dX))
+      if not (TestCollisionXwithXYShift(Gear, 0, -5, hwSign(Gear.dX))
          or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1;
-      if not (TestCollisionXwithXYShift(Gear, 0, -4, Sign(Gear.dX))
+      if not (TestCollisionXwithXYShift(Gear, 0, -4, hwSign(Gear.dX))
          or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1;
-      if not (TestCollisionXwithXYShift(Gear, 0, -3, Sign(Gear.dX))
+      if not (TestCollisionXwithXYShift(Gear, 0, -3, hwSign(Gear.dX))
          or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1;
-      if not (TestCollisionXwithXYShift(Gear, 0, -2, Sign(Gear.dX))
+      if not (TestCollisionXwithXYShift(Gear, 0, -2, hwSign(Gear.dX))
          or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1;
-      if not (TestCollisionXwithXYShift(Gear, 0, -1, Sign(Gear.dX))
+      if not (TestCollisionXwithXYShift(Gear, 0, -1, hwSign(Gear.dX))
          or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1;
       end;
-   if not TestCollisionXwithGear(Gear, Sign(Gear.dX)) then Gear.X:= Gear.X + Gear.dX;
-   Gear.dX:= 0.0000001 * Sign(Gear.dX);
+   if not TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then Gear.X:= Gear.X + Gear.dX;
+   Gear.dX:= 0.0000001 * hwSign(Gear.dX);
    SetAllHHToActive;
 
    if not TestCollisionYwithGear(Gear, 1) then
@@ -280,7 +280,7 @@
       begin
       Gear.Y:= Gear.Y - 6;
       Gear.dY:= 0;
-      Gear.dX:= 0.0000001 * Sign(Gear.dX);
+      Gear.dX:= 0.0000001 * hwSign(Gear.dX);
       Gear.State:= Gear.State or gstFalling
       end;
    end
@@ -304,7 +304,7 @@
    end else begin
    CheckHHDamage(Gear);
    if ((abs(Gear.dX) + abs(Gear.dY)) < 0.55)
-      and ((Gear.State and gstHHJumping) <> 0) then Gear.dX:= 0.0000001 * Sign(Gear.dX);
+      and ((Gear.State and gstHHJumping) <> 0) then Gear.dX:= 0.0000001 * hwSign(Gear.dX);
    Gear.State:= Gear.State and not (gstFalling or gstHHJumping);
    if Gear.dY > 0 then Gear.dY:= 0;
    if ((Gear.State and gstMoving) <> 0) then Gear.dX:= Gear.dX * Gear.Friction
@@ -313,22 +313,22 @@
 if (Gear.State <> 0) then DeleteCI(Gear);
 
 if (Gear.State and gstMoving) <> 0 then
-   if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then
+   if TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then
       if ((Gear.State and gstFalling) = 0) then
          if abs(Gear.dX) > 0.01 then
-            if not TestCollisionXwithXYShift(Gear, Sign(Gear.dX) - Gear.dX, -1, Sign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.96; Gear.Y:= Gear.Y - 1 end else
-            if not TestCollisionXwithXYShift(Gear, Sign(Gear.dX) - Gear.dX, -2, Sign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.93; Gear.Y:= Gear.Y - 2 end else
-            if not TestCollisionXwithXYShift(Gear, Sign(Gear.dX) - Gear.dX, -3, Sign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.90; Gear.Y:= Gear.Y - 3 end else
-            if not TestCollisionXwithXYShift(Gear, Sign(Gear.dX) - Gear.dX, -4, Sign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.87; Gear.Y:= Gear.Y - 4 end else
-            if not TestCollisionXwithXYShift(Gear, Sign(Gear.dX) - Gear.dX, -5, Sign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.84; Gear.Y:= Gear.Y - 5 end else
+            if not TestCollisionXwithXYShift(Gear, hwSign(Gear.dX) - Gear.dX, -1, hwSign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.96; Gear.Y:= Gear.Y - 1 end else
+            if not TestCollisionXwithXYShift(Gear, hwSign(Gear.dX) - Gear.dX, -2, hwSign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.93; Gear.Y:= Gear.Y - 2 end else
+            if not TestCollisionXwithXYShift(Gear, hwSign(Gear.dX) - Gear.dX, -3, hwSign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.90; Gear.Y:= Gear.Y - 3 end else
+            if not TestCollisionXwithXYShift(Gear, hwSign(Gear.dX) - Gear.dX, -4, hwSign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.87; Gear.Y:= Gear.Y - 4 end else
+            if not TestCollisionXwithXYShift(Gear, hwSign(Gear.dX) - Gear.dX, -5, hwSign(Gear.dX)) then begin Gear.X:= Gear.X + Gear.dX; Gear.dX:= Gear.dX * 0.84; Gear.Y:= Gear.Y - 5 end else
             if abs(Gear.dX) > 0.02 then Gear.dX:= -0.5 * Gear.dX
                                    else begin
                                         Gear.State:= Gear.State and not gstMoving;
-                                        Gear.dX:= 0.0000001 * Sign(Gear.dX)
+                                        Gear.dX:= 0.0000001 * hwSign(Gear.dX)
                                         end
                                    else begin
                                         Gear.State:= Gear.State and not gstMoving;
-                                        Gear.dX:= 0.0000001 * Sign(Gear.dX)
+                                        Gear.dX:= 0.0000001 * hwSign(Gear.dX)
                                         end
          else Gear.dX:= -Gear.dX;
 
@@ -336,7 +336,7 @@
    (sqr(Gear.dX) + sqr(Gear.dY) < 0.0008) then
    begin
    Gear.State:= Gear.State and not gstMoving;
-   Gear.dX:= 0.0000001 * Sign(Gear.dX);
+   Gear.dX:= 0.0000001 * hwSign(Gear.dX);
    Gear.dY:= 0
    end else Gear.State:= Gear.State or gstMoving;
 
--- a/hedgewars/uAIAmmoTests.pas	Fri Aug 11 16:17:50 2006 +0000
+++ b/hedgewars/uAIAmmoTests.pas	Fri Aug 11 20:00:29 2006 +0000
@@ -244,8 +244,8 @@
    end;
 Time:= 0;
 Power:= 1;
-Angle:= DxDy2AttackAngle(Sign(Targ.X - Me.X), 1);
-Result:= RateShove(Me, round(Me.X) + 10 * Sign(Targ.X - Me.X), round(Me.Y), 15, 30)
+Angle:= DxDy2AttackAngle(hwSign(Targ.X - Me.X), 1);
+Result:= RateShove(Me, round(Me.X) + 10 * hwSign(Targ.X - Me.X), round(Me.Y), 15, 30)
 end;
 
 function TestFirePunch(Me: PGear; Targ: TPoint; out Time: Longword; out Angle, Power: integer; out ExplX, ExplY, ExplR: integer): integer;
@@ -259,10 +259,10 @@
    end;
 Time:= 0;
 Power:= 1;
-Angle:= DxDy2AttackAngle(Sign(Targ.X - Me.X), 1);
+Angle:= DxDy2AttackAngle(hwSign(Targ.X - Me.X), 1);
 Result:= 0;
 for i:= 0 to 4 do
-    Result:= Result + RateShove(Me, round(Me.X) + 10 * Sign(Targ.X - Me.X), round(Me.Y) - 20 * i - 5, 10, 30)
+    Result:= Result + RateShove(Me, round(Me.X) + 10 * hwSign(Targ.X - Me.X), round(Me.Y) - 20 * i - 5, 10, 30)
 end;
 
 end.
--- a/hedgewars/uAIMisc.pas	Fri Aug 11 16:17:50 2006 +0000
+++ b/hedgewars/uAIMisc.pas	Fri Aug 11 20:00:29 2006 +0000
@@ -243,19 +243,19 @@
     jmpHJump: if not TestCollisionYwithGear(Gear, -1) then
                  begin
                  Gear.dY:= -0.20;
-                 Gear.dX:= 0.0000001 * Sign(Gear.dX);
-                 Gear.X:= Gear.X - Sign(Gear.dX)*0.00008; // shift compensation
+                 Gear.dX:= 0.0000001 * hwSign(Gear.dX);
+                 Gear.X:= Gear.X - hwSign(Gear.dX)*0.00008; // shift compensation
                  Gear.State:= Gear.State or gstFalling or gstHHJumping;
                  end else exit;
     jmpLJump: begin
               if not TestCollisionYwithGear(Gear, -1) then
-                 if not TestCollisionXwithXYShift(Gear, 0, -2, Sign(Gear.dX)) then Gear.Y:= Gear.Y - 2 else
-                 if not TestCollisionXwithXYShift(Gear, 0, -1, Sign(Gear.dX)) then Gear.Y:= Gear.Y - 1;
-              if not (TestCollisionXwithGear(Gear, Sign(Gear.dX))
+                 if not TestCollisionXwithXYShift(Gear, 0, -2, hwSign(Gear.dX)) then Gear.Y:= Gear.Y - 2 else
+                 if not TestCollisionXwithXYShift(Gear, 0, -1, hwSign(Gear.dX)) then Gear.Y:= Gear.Y - 1;
+              if not (TestCollisionXwithGear(Gear, hwSign(Gear.dX))
                  or   TestCollisionYwithGear(Gear, -1)) then
                  begin
                  Gear.dY:= -0.15;
-                 Gear.dX:= Sign(Gear.dX) * 0.15;
+                 Gear.dX:= hwSign(Gear.dX) * 0.15;
                  Gear.State:= Gear.State or gstFalling or gstHHJumping
                  end else exit
               end
@@ -269,9 +269,9 @@
       if (abs(Gear.dX) < 0.0000002) and (Gear.dY < -0.02) then
          begin
          Gear.dY:= -0.25;
-         Gear.dX:= Sign(Gear.dX) * 0.02
+         Gear.dX:= hwSign(Gear.dX) * 0.02
          end;
-   if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then Gear.dX:= 0.0000001 * Sign(Gear.dX);
+   if TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then Gear.dX:= 0.0000001 * hwSign(Gear.dX);
    Gear.X:= Gear.X + Gear.dX;
    inc(GoInfo.Ticks);
    Gear.dY:= Gear.dY + cGravity;
@@ -340,23 +340,23 @@
    end;
    if (Gear.Message and gm_Left  )<>0 then Gear.dX:= -1.0 else
    if (Gear.Message and gm_Right )<>0 then Gear.dX:=  1.0 else exit;
-   if TestCollisionXwithGear(Gear, Sign(Gear.dX)) then
+   if TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then
       begin
-      if not (TestCollisionXwithXYShift(Gear, 0, -6, Sign(Gear.dX))
+      if not (TestCollisionXwithXYShift(Gear, 0, -6, hwSign(Gear.dX))
          or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1;
-      if not (TestCollisionXwithXYShift(Gear, 0, -5, Sign(Gear.dX))
+      if not (TestCollisionXwithXYShift(Gear, 0, -5, hwSign(Gear.dX))
          or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1;
-      if not (TestCollisionXwithXYShift(Gear, 0, -4, Sign(Gear.dX))
+      if not (TestCollisionXwithXYShift(Gear, 0, -4, hwSign(Gear.dX))
          or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1;
-      if not (TestCollisionXwithXYShift(Gear, 0, -3, Sign(Gear.dX))
+      if not (TestCollisionXwithXYShift(Gear, 0, -3, hwSign(Gear.dX))
          or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1;
-      if not (TestCollisionXwithXYShift(Gear, 0, -2, Sign(Gear.dX))
+      if not (TestCollisionXwithXYShift(Gear, 0, -2, hwSign(Gear.dX))
          or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1;
-      if not (TestCollisionXwithXYShift(Gear, 0, -1, Sign(Gear.dX))
+      if not (TestCollisionXwithXYShift(Gear, 0, -1, hwSign(Gear.dX))
          or TestCollisionYwithGear(Gear, -1)) then Gear.Y:= Gear.Y - 1;
       end;
 
-   if not TestCollisionXwithGear(Gear, Sign(Gear.dX)) then
+   if not TestCollisionXwithGear(Gear, hwSign(Gear.dX)) then
       begin
       Gear.X:= Gear.X + Gear.dX;
       inc(GoInfo.Ticks, cHHStepTicks)
@@ -383,7 +383,7 @@
       begin
       Gear.Y:= Gear.Y - 6;
       Gear.dY:= 0;
-      Gear.dX:= 0.0000001 * Sign(Gear.dX);
+      Gear.dX:= 0.0000001 * hwSign(Gear.dX);
       Gear.State:= Gear.State or gstFalling
       end
    end
--- a/hedgewars/uConsole.pas	Fri Aug 11 16:17:50 2006 +0000
+++ b/hedgewars/uConsole.pas	Fri Aug 11 20:00:29 2006 +0000
@@ -36,7 +36,7 @@
 uses SDLh;
 {$INCLUDE options.inc}
 const isDeveloperMode: boolean = true;
-type TVariableType = (vtCommand, vtInteger, vtReal, vtBoolean);
+type TVariableType = (vtCommand, vtInteger, vtDouble, vtBoolean);
      TCommandHandler = procedure (var params: shortstring);
 
 procedure DrawConsole(Surface: PSDL_Surface);
@@ -163,7 +163,7 @@
 end;
 
 procedure ParseCommand(CmdStr: shortstring);
-type PReal = ^Double;
+type PDouble = ^Double;
 var i, ii: integer;
     s: shortstring;
     t: PVariable;
@@ -191,12 +191,12 @@
                             str(PInteger(t.Handler)^, s);
                             WriteLnToConsole('$' + CmdStr + ' is "' + s + '"');
                             end else val(s, PInteger(t.Handler)^, i);
-                 vtReal: if c='$' then
+                 vtDouble: if c='$' then
                          if s[0]=#0 then
                             begin
-                            str(PReal(t.Handler)^:4:6, s);
+                            str(PDouble(t.Handler)^:4:6, s);
                             WriteLnToConsole('$' + CmdStr + ' is "' + s + '"');
-                            end else val(s, PReal(t.Handler)^   , i);
+                            end else val(s, PDouble(t.Handler)^   , i);
              vtBoolean: if c='$' then
                          if s[0]=#0 then
                             begin
--- a/hedgewars/uGame.pas	Fri Aug 11 16:17:50 2006 +0000
+++ b/hedgewars/uGame.pas	Fri Aug 11 20:00:29 2006 +0000
@@ -64,7 +64,7 @@
    end;
 
 if Lag > 100 then Lag:= 100
-else if GameType = gmtSave then Lag:= 2500;
+else if GameType = gmtSave then if GameTicks < 164550 then Lag:= 2500;
 
 i:= 1;
 while (GameState <> gsExit) and (i <= Lag) do
--- a/hedgewars/uGears.pas	Fri Aug 11 16:17:50 2006 +0000
+++ b/hedgewars/uGears.pas	Fri Aug 11 20:00:29 2006 +0000
@@ -43,10 +43,10 @@
              NextGear, PrevGear: PGear;
              Active: Boolean;
              State : Cardinal;
-             X : Real;
-             Y : Real;
-             dX: Real;
-             dY: Real;
+             X : Double;
+             Y : Double;
+             dX: Double;
+             dY: Double;
              Kind: TGearType;
              Pos: Longword;
              doStep: TGearStepProcedure;
@@ -54,8 +54,8 @@
              Angle, Power : Cardinal;
              DirAngle: Double;
              Timer : LongWord;
-             Elasticity: Real;
-             Friction  : Real;
+             Elasticity: Double;
+             Friction  : Double;
              Message : Longword;
              Hedgehog: pointer;
              Health, Damage: integer;
@@ -79,7 +79,7 @@
 
 implementation
 uses uWorld, uMisc, uStore, uConsole, uSound, uTeams, uRandom, uCollisions,
-     uLand, uIO, uLandGraphics, uAIMisc, uLocale{$IFDEF FPC}, Math{$ENDIF};
+     uLand, uIO, uLandGraphics, uAIMisc, uLocale;
 var RopePoints: record
                 Count: Longword;
                 HookAngle: integer;
@@ -134,7 +134,7 @@
 const Counter: Longword = 0;
 begin
 inc(Counter);
-{$IFDEF DEBUGFILE}AddFileLog('AddGear: ('+inttostr(x)+','+inttostr(y)+')');{$ENDIF}
+{$IFDEF DEBUGFILE}AddFileLog('AddGear: ('+inttostr(x)+','+inttostr(y)+'), d('+floattostr(dX)+','+floattostr(dY)+')');{$ENDIF}
 New(Result);
 {$IFDEF DEBUGFILE}AddFileLog('AddGear: handle = '+inttostr(integer(Result)));{$ENDIF}
 FillChar(Result^, sizeof(TGear), 0);
@@ -491,7 +491,7 @@
       case Gear.Kind of
            gtCloud: DrawSprite(sprCloud   , Round(Gear.X) + WorldDx, Round(Gear.Y) + WorldDy, Gear.State, Surface);
        gtAmmo_Bomb: DrawSprite(sprBomb , Round(Gear.X) - 8 + WorldDx, Round(Gear.Y) - 8 + WorldDy, trunc(Gear.DirAngle), Surface);
-        gtHedgehog: DrawHedgehog(Round(Gear.X) - 14 + WorldDx, Round(Gear.Y) - 18 + WorldDy, Sign(Gear.dX),
+        gtHedgehog: DrawHedgehog(Round(Gear.X) - 14 + WorldDx, Round(Gear.Y) - 18 + WorldDy, hwSign(Gear.dX),
                                  0, PHedgehog(Gear.Hedgehog).visStepPos div 2,
                                  Surface);
     gtAmmo_Grenade: DrawSprite(sprGrenade , Round(Gear.X) - 16 + WorldDx, Round(Gear.Y) - 16 + WorldDy, DxDy2Angle32(Gear.dY, Gear.dX), Surface);
@@ -589,8 +589,8 @@
                           if (Mask and EXPLNoDamage) = 0 then inc(Gear.Damage, dmg);
                           if ((Mask and EXPLDoNotTouchHH) = 0) or (Gear.Kind <> gtHedgehog) then
                              begin
-                             Gear.dX:= Gear.dX + dmg / 200 * Sign(Gear.X - X);
-                             Gear.dY:= Gear.dY + dmg / 200 * Sign(Gear.Y - Y);
+                             Gear.dX:= Gear.dX + dmg / 200 * hwSign(Gear.X - X);
+                             Gear.dY:= Gear.dY + dmg / 200 * hwSign(Gear.Y - Y);
                              Gear.Active:= true;
                              FollowGear:= Gear
                              end;
--- a/hedgewars/uLocale.pas	Fri Aug 11 16:17:50 2006 +0000
+++ b/hedgewars/uLocale.pas	Fri Aug 11 20:00:29 2006 +0000
@@ -37,8 +37,8 @@
                    sidPickHammer, sidSkip, sidRope, sidMine, sidDEagle,
                    sidDynamite, sidBaseballBat, sidFirePunch, sidSeconds);
      TMsgStrId = (sidStartFight, sidDraw, sidWinner);
-var trammo: array[TAmmoStrId] of shortstring;
-    trmsg: array[TMsgStrId] of shortstring;
+var trammo: array[TAmmoStrId] of string;
+    trmsg: array[TMsgStrId] of string;
 
 procedure LoadLocale(FileName: string);
 function Format(fmt: shortstring; var arg: shortstring): shortstring;
@@ -52,7 +52,7 @@
     a, b, c: integer;
 begin
 {$I-}
-assignfile(f, FileName);
+AssignFile(f, FileName);
 reset(f);
 TryDo(IOResult = 0, 'Cannot load locale "' + FileName + '"', true);
 while not eof(f) do
--- a/hedgewars/uMisc.pas	Fri Aug 11 16:17:50 2006 +0000
+++ b/hedgewars/uMisc.pas	Fri Aug 11 20:00:29 2006 +0000
@@ -71,10 +71,10 @@
     cColorNearBlack       : Cardinal = 16;
     cExplosionBorderColor : LongWord = $808080;
 
-    cDrownSpeed   : Real = 0.06;
-    cMaxWindSpeed : Real = 0.0005;
-    cWindSpeed    : Real = 0.0001;
-    cGravity      : Real = 0.0005;
+    cDrownSpeed   : Double = 0.06;
+    cMaxWindSpeed : Double = 0.0005;
+    cWindSpeed    : Double = 0.0001;
+    cGravity      : Double = 0.0005;
 
     cShowFPS      : boolean = true;
     cFullScreen   : boolean = true;
@@ -97,7 +97,7 @@
 
     AttackBar: integer = 0; // 0 - none, 1 - just bar at the right-down corner, 2 - like in WWP
 
-function Sign(r: Double): integer;
+function hwSign(r: Double): integer;
 function Min(a, b: integer): integer;
 function Max(a, b: integer): integer;
 procedure OutError(Msg: String; const isFatalError: boolean=false);
@@ -112,9 +112,6 @@
 procedure AddFileLog(s: shortstring);
 function RectToStr(Rect: TSDL_Rect): shortstring;
 {$ENDIF}
-{$IFNDEF FPC}
-function arctan2(const Y, X: Double): Double;
-{$ENDIF}
 
 var CursorPoint: TPoint;
     TargetPoint: TPoint = (X: NoPointX; Y: 0);
@@ -126,7 +123,7 @@
 {$ENDIF}
 
 
-function Sign(r: Double): integer;
+function hwSign(r: Double): integer;
 begin
 if r < 0 then Result:= -1 else Result:= 1
 end;
@@ -213,7 +210,7 @@
 end;
 
 initialization
-assignfile(f, 'debug.txt');
+AssignFile(f, 'debug.txt');
 rewrite(f);
 
 finalization
--- a/hedgewars/uStore.pas	Fri Aug 11 16:17:50 2006 +0000
+++ b/hedgewars/uStore.pas	Fri Aug 11 20:00:29 2006 +0000
@@ -49,7 +49,7 @@
 procedure DrawCentered(X, Top: integer; Source, Surface: PSDL_Surface);
 procedure DrawFromStoreRect(X, Y: integer; Rect: PSDL_Rect; Surface: PSDL_Surface);
 procedure DrawHedgehog(X, Y: integer; Dir: integer; Pos, Step: LongWord; Surface: PSDL_Surface);
-function  RenderString(var s: shortstring; Color: integer; font: THWFont): PSDL_Surface;
+function  RenderString(s: string; Color: integer; font: THWFont): PSDL_Surface;
 procedure RenderHealth(var Hedgehog: THedgehog);
 procedure AddProgress;
 function  LoadImage(filename: string; hasAlpha: boolean; const critical: boolean = true): PSDL_Surface;
@@ -444,10 +444,10 @@
 SDL_FreeSurface(StoreSurface )
 end;
 
-function RenderString(var s: shortstring; Color: integer; font: THWFont): PSDL_Surface;
+function  RenderString(s: string; Color: integer; font: THWFont): PSDL_Surface;
 var w, h: integer;
 begin
-TTF_SizeUTF8(Fontz[font].Handle, PChar(String(s)), w, h);
+TTF_SizeUTF8(Fontz[font].Handle, PChar(s), w, h);
 Result:= SDL_CreateRGBSurface(SDL_HWSURFACE, w + 6, h + 2, cBits, PixelFormat.RMask, PixelFormat.GMask, PixelFormat.BMask, 0);
 TryDo(Result <> nil, 'RenderString: fail to create surface', true);
 WriteInRoundRect(Result, 0, 0, Color, font, s);
--- a/hedgewars/uWorld.pas	Fri Aug 11 16:17:50 2006 +0000
+++ b/hedgewars/uWorld.pas	Fri Aug 11 20:00:29 2006 +0000
@@ -40,7 +40,7 @@
 
 procedure InitWorld;
 procedure DrawWorld(Lag: integer; Surface: PSDL_Surface);
-procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup);
+procedure AddCaption(s: string; Color: Longword; Group: TCapGroup);
 procedure MoveCamera;
 
 {$IFDEF COUNTTICKS}
@@ -156,7 +156,7 @@
                            DrawGear(sQuestion, Round(Gear.X)  - 10 + WorldDx, Round(Gear.Y) - cHHRadius - 34 + WorldDy, Surface)
                         else
                         if ShowCrosshair and ((Gear.State and gstAttacked) = 0) then
-                           DrawCaption(Round(Gear.X + Sign(Gear.dX) * Sin(Gear.Angle*pi/cMaxAngle)*60) + WorldDx,
+                           DrawCaption(Round(Gear.X + hwSign(Gear.dX) * Sin(Gear.Angle*pi/cMaxAngle)*60) + WorldDx,
                                        Round(Gear.Y - Cos(Gear.Angle*pi/cMaxAngle)*60) + WorldDy - 4,
                                        Team.CrossHairRect, Surface)
                      end;
@@ -201,7 +201,7 @@
            end;
         2: with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
                 begin
-                tdx:= Sign(Gear.dX) * Sin(Gear.Angle*pi/cMaxAngle);
+                tdx:= hwSign(Gear.dX) * Sin(Gear.Angle*pi/cMaxAngle);
                 tdy:= - Cos(Gear.Angle*pi/cMaxAngle);
                 for i:= (Gear.Power * 24) div cPowerDivisor downto 0 do
                     DrawSprite(sprPower, round(Gear.X + WorldDx + tdx * (24 + i * 2)) - 16,
@@ -303,7 +303,7 @@
 if cShowFPS then DXOutText(cScreenWidth - 50, 10, fnt16, inttostr(FPS) + ' fps', Surface)
 end;
 
-procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup);
+procedure AddCaption(s: string; Color: Longword; Group: TCapGroup);
 var i, t, m, k: LongWord;
 begin
 if Group in [capgrpGameState, capgrpNetSay] then WriteLnToConsole(s);
@@ -356,7 +356,7 @@
       exit
       end
       else begin
-      CursorPoint.x:= (CursorPoint.x * 7 + (round(FollowGear.X + Sign(FollowGear.dX) * 100) + WorldDx)) div 8;
+      CursorPoint.x:= (CursorPoint.x * 7 + (round(FollowGear.X + hwSign(FollowGear.dX) * 100) + WorldDx)) div 8;
       CursorPoint.y:= (CursorPoint.y * 7 + (round(FollowGear.Y) + WorldDy)) div 8
       end;