Even more love to pas2c
authorunc0rr
Mon, 27 Jan 2014 22:34:06 +0400
changeset 10080 ac51bcb534ef
parent 10079 c88e38a0f478
child 10081 0af84e5cbd4d
Even more love to pas2c
hedgewars/config.inc.in
hedgewars/pas2cRedo.pas
hedgewars/pas2cSystem.pas
hedgewars/uGearsRender.pas
hedgewars/uInputHandler.pas
hedgewars/uLocale.pas
hedgewars/uPhysFSLayer.pas
hedgewars/uUtils.pas
hedgewars/uWorld.pas
--- a/hedgewars/config.inc.in	Mon Jan 27 01:07:12 2014 +0400
+++ b/hedgewars/config.inc.in	Mon Jan 27 22:34:06 2014 +0400
@@ -27,7 +27,7 @@
       cHashString = '${HEDGEWARS_HASH}';
       cDefaultPathPrefix = '${HEDGEWARS_FULL_DATADIR}/Data';
 {$IFDEF PAS2C}
-      cFontsPaths = '';
+      cFontsPaths: array[0..0] of PChar = (nil);
 {$ELSE}
       cFontsPaths: ${FONTS_DIRS_ARRAY}
 {$ENDIF}
--- a/hedgewars/pas2cRedo.pas	Mon Jan 27 01:07:12 2014 +0400
+++ b/hedgewars/pas2cRedo.pas	Mon Jan 27 22:34:06 2014 +0400
@@ -74,10 +74,11 @@
     StrPas, FormatDateTime, copy, delete, str, PosS, trim, LowerCase : function : shortstring;
     pos : function : integer;
     StrToInt : function : integer;
-    SetLength, val : procedure;
-    _pchar : function : PChar;
+    SetLength, val, StrDispose, StrCopy : procedure;
+    _pchar, StrAlloc : function : PChar;
     pchar2str : function : string;
     memcpy : procedure;
+    StrLength : function : integer;
 
      min, max:function:integer;
     assign, rewrite, rewrite_2, reset, reset_2, flush, BlockWrite, BlockRead, close : procedure;
--- a/hedgewars/pas2cSystem.pas	Mon Jan 27 01:07:12 2014 +0400
+++ b/hedgewars/pas2cSystem.pas	Mon Jan 27 22:34:06 2014 +0400
@@ -129,6 +129,7 @@
     PHYSFS_init, PHYSFS_deinit, PHYSFS_mount, PHYSFS_readBytes : function : LongInt;
     PHYSFSRWOPS_openRead, PHYSFSRWOPS_openWrite, PHYSFS_openRead : function : pointer;
     PHYSFS_eof, PHYSFS_close, PHYSFS_exists : function : boolean;
+    PHYSFS_getLastError : function : PChar;
 
     hedgewarsMountPackages, physfsReaderSetBuffer, hedgewarsMountPackage : procedure;
     physfsReader : function : pointer;
--- a/hedgewars/uGearsRender.pas	Mon Jan 27 01:07:12 2014 +0400
+++ b/hedgewars/uGearsRender.pas	Mon Jan 27 22:34:06 2014 +0400
@@ -965,13 +965,9 @@
                 tx := ox;
                 tx := round(max(((-cScreenWidth + 16) / zoom) + SpritesData[sprFinger].Width div 2, min(((cScreenWidth - 16) / zoom) - SpritesData[sprFinger].Width div 2, tx)));
                 ty := round(max(cScreenHeight div 2 - ((cScreenHeight - 16) / (zoom)) + SpritesData[sprFinger].Height div 2, min(cScreenHeight div 2 - ((-cScreenHeight + SpritesData[sprFinger].Height) / (zoom)) - SpritesData[sprFinger].Width div 2 - 96, ty)));
-                t := tx-ox;
-                if t <> 0 then
-                    dAngle := radtodeg(-arctan2(-(ty-oy),t)) + 90
-                else if ty > oy then
-                    dAngle := 180
-                else
-                    dAngle := 0;
+
+                dAngle := DxDy2Angle(ty - oy, tx - ox) + 90;
+
                 DrawSpriteRotatedF(sprFinger, tx, ty, GameTicks div 32 mod 16, 1, dAngle);
                 end;
 
--- a/hedgewars/uInputHandler.pas	Mon Jan 27 01:07:12 2014 +0400
+++ b/hedgewars/uInputHandler.pas	Mon Jan 27 22:34:06 2014 +0400
@@ -506,7 +506,7 @@
                 if l <> 'default' then
                     begin
                     if (length(l) = 2) and (l[1] = '\') then
-                        l:= l[1]
+                        l:= l[1] + ''
                     else if (l[1] = '"') and (l[length(l)] = '"') then
                         l:= copy(l, 2, length(l) - 2);
 
--- a/hedgewars/uLocale.pas	Mon Jan 27 01:07:12 2014 +0400
+++ b/hedgewars/uLocale.pas	Mon Jan 27 22:34:06 2014 +0400
@@ -60,16 +60,16 @@
     while not pfsEof(f) do
         begin
         pfsReadLnA(f, s);
-        if (Length(s) > 0) and (s[0] >= '0') and (s[0] <= '9') then
+        if (StrLength(s) > 0) and (s[0] >= '0') and (s[0] <= '9') then
             begin
-            TryDo(Length(s) > 6, 'Load locale: empty string', true);
+            TryDo(StrLength(s) > 6, 'Load locale: empty string', true);
             val(s[0]+s[1], a, c);
             TryDo(c = 0, 'Load locale: numbers should be two-digit: ' + s, true);
             TryDo(s[2] = ':', 'Load locale: ":" expected', true);
             val(s[3]+s[4], b, c);
             TryDo(c = 0, 'Load locale: numbers should be two-digit' + s, true);
             TryDo(s[5] = '=', 'Load locale: "=" expected', true);
-            sc:= StrAlloc(length(s) - 5);
+            sc:= StrAlloc(StrLength(s) - 5);
             StrCopy(sc, @s[6]);
             case a of
                 0: if (b >=0) and (b <= ord(High(TAmmoStrId))) then
--- a/hedgewars/uPhysFSLayer.pas	Mon Jan 27 01:07:12 2014 +0400
+++ b/hedgewars/uPhysFSLayer.pas	Mon Jan 27 22:34:06 2014 +0400
@@ -186,11 +186,13 @@
     // need access to teams and frontend configs (for bindings)
     pfsMountAtRoot(UserPathPrefix);
 
+    {$IFNDEF PAS2C}
     if cTestLua then
         begin
             pfsMountAtRoot(ExtractFileDir(cScriptName));
             cScriptName := ExtractFileName(cScriptName);
         end;
+    {$ENDIF}
 end;
 
 procedure freeModule;
--- a/hedgewars/uUtils.pas	Mon Jan 27 01:07:12 2014 +0400
+++ b/hedgewars/uUtils.pas	Mon Jan 27 22:34:06 2014 +0400
@@ -73,6 +73,7 @@
 {$IFNDEF PAS2C}
 procedure Write(var f: textfile; s: shortstring);
 procedure WriteLn(var f: textfile; s: shortstring);
+function StrLength(s: PChar): Longword;
 {$ENDIF}
 
 function  isPhone: Boolean; inline;
@@ -441,6 +442,11 @@
 begin
 system.writeln(f, s)
 end;
+
+function StrLength(s: PChar): Longword;
+begin
+    StrLength:= length(s)
+end;
 {$ENDIF}
 
 // this function is just to determine whether we are running on a limited screen device
--- a/hedgewars/uWorld.pas	Mon Jan 27 01:07:12 2014 +0400
+++ b/hedgewars/uWorld.pas	Mon Jan 27 22:34:06 2014 +0400
@@ -124,18 +124,22 @@
 function AddGoal(s: ansistring; gf: longword; si: TGoalStrId; i: LongInt): ansistring;
 var t: ansistring;
 begin
+{$IFNDEF PAS2C}
     if (GameFlags and gf) <> 0 then
         begin
         t:= inttostr(i);
         s:= s + FormatA(trgoal[si], t) + '|'
         end;
+{$ENDIF}
     AddGoal:= s;
 end;
 
 function AddGoal(s: ansistring; gf: longword; si: TGoalStrId): ansistring;
 begin
+{$IFNDEF PAS2C}
     if (GameFlags and gf) <> 0 then
         s:= s + trgoal[si] + '|';
+{$ENDIF}
     AddGoal:= s;
 end;