merge
authorsheepluva
Sat, 29 Nov 2014 05:25:34 +0100
changeset 10568 5a867053add8
parent 10558 b574f04c9685 (current diff)
parent 10566 cc90ea6448c7 (diff)
child 10570 a781c9dc27ec
merge
--- a/hedgewars/pas2cRedo.pas	Fri Nov 28 21:30:36 2014 -0500
+++ b/hedgewars/pas2cRedo.pas	Sat Nov 29 05:25:34 2014 +0100
@@ -84,6 +84,7 @@
      min, max:function:integer;
     assign, rewrite, rewrite_2, reset, reset_2, flush, BlockWrite, BlockRead, close : procedure;
     FileExists, DirectoryExists, eof : function : boolean;
+    ExtractFileDir : function : string;
     ExtractFileName : function : string;
 
     ParamCount : function : integer;
--- a/hedgewars/uAmmos.pas	Fri Nov 28 21:30:36 2014 -0500
+++ b/hedgewars/uAmmos.pas	Sat Nov 29 05:25:34 2014 +0100
@@ -43,11 +43,11 @@
 procedure SetWeapon(weap: TAmmoType);
 procedure DisableSomeWeapons;
 procedure ResetWeapons;
-function  GetAmmoByNum(num: Longword): PHHAmmo;
+function  GetAmmoByNum(num: LongInt): PHHAmmo;
 function  GetCurAmmoEntry(var Hedgehog: THedgehog): PAmmo;
 function  GetAmmoEntry(var Hedgehog: THedgehog; am: TAmmoType): PAmmo;
 
-var StoreCnt: Longword;
+var StoreCnt: LongInt;
 
 implementation
 uses uVariables, uCommands, uUtils, uCaptions, uDebug;
@@ -151,7 +151,7 @@
 FillAmmoStore(StoresList[Pred(StoreCnt)], newAmmos)
 end;
 
-function GetAmmoByNum(num: Longword): PHHAmmo;
+function GetAmmoByNum(num: LongInt): PHHAmmo;
 begin
     TryDo(num < StoreCnt, 'Invalid store number', true);
     GetAmmoByNum:= StoresList[num]
--- a/hedgewars/uFloat.pas	Fri Nov 28 21:30:36 2014 -0500
+++ b/hedgewars/uFloat.pas	Sat Nov 29 05:25:34 2014 +0100
@@ -370,8 +370,8 @@
 
 function hwSqrt1(const t: hwFloat): hwFloat;
 const pwr = 8; // even value, feel free to adjust
-      rThreshold = 1 shl (pwr + 32);
-      lThreshold = 1 shl (pwr div 2 + 32);
+      rThreshold: QWord = 1 shl (pwr + 32);
+      lThreshold: QWord = 1 shl (pwr div 2 + 32);
 var l, r: QWord;
     c: hwFloat;
 begin
--- a/hedgewars/uGearsRender.pas	Fri Nov 28 21:30:36 2014 -0500
+++ b/hedgewars/uGearsRender.pas	Sat Nov 29 05:25:34 2014 +0100
@@ -166,8 +166,7 @@
 end;
 
 procedure DrawRope(Gear: PGear);
-var roplen: LongInt;
-    i: Longword;
+var roplen, i: LongInt;
 begin
     if (cReducedQuality and rqSimpleRope) <> 0 then
         DrawRopeLinesRQ(Gear)
@@ -624,7 +623,7 @@
 
         if ((Gear^.State and gstAnimation) <> 0) then
             begin
-            if (TWave(Gear^.Tag) < Low(TWave)) or (TWave(Gear^.Tag) > High(TWave)) then
+            if (Gear^.Tag < LongInt(ord(Low(TWave)))) or (Gear^.Tag > LongInt(ord(High(TWave)))) then
                 begin
                 Gear^.State:= Gear^.State and (not gstAnimation);
                 end
@@ -711,7 +710,7 @@
                                             LongInt(rightX)+WorldDx,
                                             cWaterLine+WorldDy,
                                             LongInt(leftX)+WorldDx);
-                        if hwRound(Gear^.X) > rightX-256 then
+                        if hwRound(Gear^.X) > LongInt(rightX) - 256 then
                             DrawSpriteClipped(sprGirder,
                                             leftX-(rightX-ox)-256,
                                             oy-256,
@@ -1167,7 +1166,7 @@
                         end;
                     if Gear^.Timer < 1833 then
                         begin
-                        DrawTextureRotatedF(SpritesData[sprPortal].texture, min(abs(1.25 - (Gear^.Timer mod 1333) / 400), 1.25), 0, 0,
+                        DrawTextureRotatedF(SpritesData[sprPortal].texture, MinD(abs(1.25 - (Gear^.Timer mod 1333) / 400), 1.25), 0, 0,
                                             x, LongInt(Gear^.Angle) + WorldDy - 16, 4 + Gear^.Tag, 1, 32, 32, 270);
                         end
                     end;
--- a/hedgewars/uIO.pas	Fri Nov 28 21:30:36 2014 -0500
+++ b/hedgewars/uIO.pas	Sat Nov 29 05:25:34 2014 +0100
@@ -350,7 +350,7 @@
 
 while (headcmd <> nil)
     and (tmpflag or (headcmd^.cmd = '#')) // '#' is the only cmd which can be sent within same tick after 'N'
-    and ((GameTicks = hiTicks shl 16 + headcmd^.loTime)
+    and ((GameTicks = LongWord(hiTicks shl 16 + headcmd^.loTime))
         or (headcmd^.cmd = 's') // for these commands time is not specified
         or (headcmd^.cmd = 'h') // seems the hedgewars protocol does not allow remote synced commands
         or (headcmd^.cmd = '#') // must be synced for saves to work
@@ -426,7 +426,7 @@
     end;
 
 if (headcmd <> nil) and tmpflag and (not CurrentTeam^.hasGone) then
-    TryDo(GameTicks < hiTicks shl 16 + headcmd^.loTime,
+    TryDo(GameTicks < LongWord(hiTicks shl 16) + headcmd^.loTime,
             'oops, queue error. in buffer: ' + headcmd^.cmd +
             ' (' + IntToStr(GameTicks) + ' > ' +
             IntToStr(hiTicks shl 16 + headcmd^.loTime) + ')',
--- a/hedgewars/uLandGenTemplateBased.pas	Fri Nov 28 21:30:36 2014 -0500
+++ b/hedgewars/uLandGenTemplateBased.pas	Sat Nov 29 05:25:34 2014 +0100
@@ -18,7 +18,7 @@
     with Template do
         begin
         pa.Count:= BasePointsCount;
-        for i:= 0 to pred(pa.Count) do
+        for i:= 0 to pred(LongInt(pa.Count)) do
             begin
             pa.ar[i].x:= BasePoints^[i].x + LongInt(GetRandom(BasePoints^[i].w));
             if pa.ar[i].x <> NTPX then
@@ -174,7 +174,7 @@
 
     // now go through all other segments
     fp:= pa.ar[0];
-    for i:= 0 to pa.Count - 2 do
+    for i:= 0 to LongInt(pa.Count) - 2 do
         if pa.ar[i].x = NTPX then
             fp:= pa.ar[i + 1]
         else if (i <> si) then
@@ -210,7 +210,7 @@
         end;
 
     // go through all points, including fill points
-    for i:= 0 to Pred(pa.Count + fillPointsCount) do
+    for i:= 0 to Pred(LongInt(pa.Count + fillPointsCount)) do
         // if this point isn't on current segment
         if (si <> i) and (i <> si + 1) and (pa.ar[i].x <> NTPX) then
         begin
@@ -294,7 +294,7 @@
     newPoint.y:= 0;
     i:= 0;
 
-    while i < pa.Count - 1 do
+    while i < LongInt(pa.Count) - 1 do
     begin
         FindPoint(i, fillPointsCount, newPoint, pa);
 
--- a/hedgewars/uLandObjects.pas	Fri Nov 28 21:30:36 2014 -0500
+++ b/hedgewars/uLandObjects.pas	Sat Nov 29 05:25:34 2014 +0100
@@ -253,15 +253,15 @@
     inc(x1, 2);
     if k = 16 then
         begin
-        while (x2 < (rightX-150)) and (CountNonZeroz(x2, y) = 0) do
+        while (x2 < (LongInt(rightX)-150)) and (CountNonZeroz(x2, y) = 0) do
             inc(x2, 2);
         i:= x2 + 12;
         repeat
         inc(x2, 2);
         k:= CountNonZeroz(x2, y)
-        until (x2 >= (rightX-150)) or (k = 0) or (k = 16) or (x2 > i) or (x2 - x1 >= 768);
+        until (x2 >= (LongInt(rightX)-150)) or (k = 0) or (k = 16) or (x2 > i) or (x2 - x1 >= 768);
 
-        if (x2 < (rightX - 150)) and (k = 16) and (x2 - x1 > 250) and (x2 - x1 < 768)
+        if (x2 < (LongInt(rightX) - 150)) and (k = 16) and (x2 - x1 > 250) and (x2 - x1 < 768)
         and (not CheckIntersect(x1 - 32, y - 64, x2 - x1 + 64, 144)) then
                 break;
         end;
--- a/hedgewars/uLandOutline.pas	Fri Nov 28 21:30:36 2014 -0500
+++ b/hedgewars/uLandOutline.pas	Sat Nov 29 05:25:34 2014 +0100
@@ -253,7 +253,7 @@
 var i: Longword;
 begin
     CheckSelfIntersect:= false;
-    if (ind <= 0) or (ind >= Pred(pa.Count)) then
+    if (ind <= 0) or (LongInt(ind) >= Pred(pa.Count)) then
         exit;
 
     CheckSelfIntersect:= true;
--- a/hedgewars/uPhysFSLayer.pas	Fri Nov 28 21:30:36 2014 -0500
+++ b/hedgewars/uPhysFSLayer.pas	Sat Nov 29 05:25:34 2014 +0100
@@ -179,13 +179,11 @@
     // need access to teams and frontend configs (for bindings)
     pfsMountAtRoot(UserPathPrefix);
 
-    {$IFNDEF PAS2C}
     if cTestLua then
         begin
-            pfsMountAtRoot(ExtractFileDir(cScriptName));
+            pfsMountAtRoot(ansistring(ExtractFileDir(cScriptName)));
             cScriptName := ExtractFileName(cScriptName);
         end;
-    {$ENDIF}
 end;
 
 procedure freeModule;
--- a/hedgewars/uScript.pas	Fri Nov 28 21:30:36 2014 -0500
+++ b/hedgewars/uScript.pas	Sat Nov 29 05:25:34 2014 +0100
@@ -2534,7 +2534,7 @@
 function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt;
 begin
 if (not ScriptLoaded) or (not ScriptExists(fname)) then
-    exit;
+    exit(0);
 SetGlobals;
 lua_getglobal(luaState, Str2PChar(fname));
 lua_pushinteger(luaState, par1);
--- a/hedgewars/uUtils.pas	Fri Nov 28 21:30:36 2014 -0500
+++ b/hedgewars/uUtils.pas	Sat Nov 29 05:25:34 2014 +0100
@@ -37,6 +37,7 @@
 function  EnumToStr(const en : TSprite) : shortstring; overload;
 
 function  Min(a, b: LongInt): LongInt; inline;
+function  MinD(a, b: double) : double; inline;
 function  Max(a, b: LongInt): LongInt; inline;
 
 function  IntToStr(n: LongInt): shortstring;
@@ -194,6 +195,14 @@
     Min:= b
 end;
 
+function MinD(a, b: double): double;
+begin
+if a < b then
+    MinD:= a
+else
+    MinD:= b
+end;
+
 function Max(a, b: LongInt): LongInt;
 begin
 if a > b then
@@ -280,7 +289,7 @@
 
 function DecodeBase64(s: shortstring): shortstring;
 const table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
-var i, t, c: Longword;
+var i, t, c: LongInt;
 begin
 c:= 0;
 for i:= 1 to Length(s) do
--- a/hedgewars/uWorld.pas	Fri Nov 28 21:30:36 2014 -0500
+++ b/hedgewars/uWorld.pas	Sat Nov 29 05:25:34 2014 +0100
@@ -1872,12 +1872,12 @@
         end
     else
         begin
-        if abs(prevPoint.X - WorldDx - hwRound(FollowGear^.X)) > rightX - leftX - 100 then
+        if abs(prevPoint.X - WorldDx - hwRound(FollowGear^.X)) > LongInt(rightX) - leftX - 100 then
             begin
-            if (prevPoint.X - WorldDx) * 2 < LongInt(rightX + leftX) then
-                cameraJump:= rightX - leftX
+            if (prevPoint.X - WorldDx) * 2 < LongInt((rightX + leftX)) then
+                cameraJump:= LongInt(rightX) - leftX
                 else
-                cameraJump:= leftX - rightX;
+                cameraJump:= LongInt(leftX) - rightX;
             WorldDx:= WorldDx - cameraJump;
             end;
 
--- a/project_files/hwc/rtl/SysUtils.h	Fri Nov 28 21:30:36 2014 -0500
+++ b/project_files/hwc/rtl/SysUtils.h	Sat Nov 29 05:25:34 2014 +0100
@@ -31,6 +31,9 @@
 #define     StrToInt                fpcrtl_strToInt
 #define     strToInt                fpcrtl_strToInt
 
+string255   fpcrtl_extractFileDir(string255 f);
+#define     fpcrtl_ExtractFileDir  fpcrtl_extractFileDir
+
 string255   fpcrtl_extractFileName(string255 f);
 #define     fpcrtl_ExtractFileName  fpcrtl_extractFileName
 
--- a/project_files/hwc/rtl/system.h	Fri Nov 28 21:30:36 2014 -0500
+++ b/project_files/hwc/rtl/system.h	Sat Nov 29 05:25:34 2014 +0100
@@ -1,6 +1,7 @@
 #ifndef SYSTEM_H_
 #define SYSTEM_H_
 
+#include <stdlib.h>
 #include <time.h>
 #include "Types.h"
 #include "misc.h"
@@ -134,7 +135,8 @@
 
 int         fpcrtl_UTF8ToUnicode(PWideChar dest, PChar src, SizeInt maxLen);
 
-#define     fpcrtl_halt(t)                                  assert(0)
+// #define     fpcrtl_halt(t)                                  assert(0)
+#define     fpcrtl_halt(t)                                  exit(t)
 
 #define     fpcrtl_Load_GL_VERSION_2_0()                    1
 
--- a/project_files/hwc/rtl/sysutils.c	Fri Nov 28 21:30:36 2014 -0500
+++ b/project_files/hwc/rtl/sysutils.c	Sat Nov 29 05:25:34 2014 +0100
@@ -131,6 +131,24 @@
     return atoi(s.str);
 }
 
+string255 fpcrtl_extractFileDir(string255 f)
+{
+    const char sep[] = {'\\', '/', ':'};
+    LongInt i,j;
+
+    i = f.len - 1;
+    while(i >= 0){
+        for(j = 0; j < sizeof(sep); j++){
+            if(f.str[i] == sep[j]){
+                goto FPCRTL_EXTRACTFILEDIR_END;
+            }
+        }
+        i--;
+    }
+FPCRTL_EXTRACTFILEDIR_END:
+    return fpcrtl_copy(f, 1, i);
+}
+
 //function ExtractFileName(const FileName: string): string;
 //var
 //  i : longint;