It compiles \o/
authorunc0rr
Mon, 10 Feb 2014 00:43:03 +0400
changeset 10127 7f29a65aa1e4
parent 10126 2fa3bb7785ee
child 10128 0f6878b5395a
It compiles \o/ Doesn't link yet though, need to implement new rtl functions
hedgewars/LuaPas.pas
hedgewars/config.inc.in
hedgewars/hwengine.pas
hedgewars/uChat.pas
hedgewars/uCommandHandlers.pas
hedgewars/uGame.pas
hedgewars/uGearsList.pas
hedgewars/uLocale.pas
hedgewars/uMisc.pas
hedgewars/uPhysFSLayer.pas
hedgewars/uRenderUtils.pas
hedgewars/uScript.pas
hedgewars/uStats.pas
hedgewars/uStore.pas
hedgewars/uUtils.pas
hedgewars/uVariables.pas
misc/libphyslayer/hwpacksmounter.h
project_files/hwc/CMakeLists.txt
project_files/hwc/rtl/fpcrtl.h
project_files/hwc/rtl/misc.h
project_files/hwc/rtl/pas2c.h
project_files/hwc/rtl/system.h
tools/pas2c/Pas2C.hs
--- a/hedgewars/LuaPas.pas	Sun Feb 09 19:00:13 2014 +0100
+++ b/hedgewars/LuaPas.pas	Mon Feb 10 00:43:03 2014 +0400
@@ -928,8 +928,10 @@
 end;
 
 function lua_tostringA(L : Plua_State; idx : LongInt) : ansistring;
+var p: PChar;
 begin
-    lua_tostringA := ansistring(lua_tolstring(L, idx, nil));
+    p:= lua_tolstring(L, idx, nil);
+    lua_tostringA := ansistring(p);
 end;
 
 function lua_open : Plua_State;
--- a/hedgewars/config.inc.in	Sun Feb 09 19:00:13 2014 +0100
+++ b/hedgewars/config.inc.in	Mon Feb 10 00:43:03 2014 +0400
@@ -27,7 +27,7 @@
       cHashString = '${HEDGEWARS_HASH}';
       cDefaultPathPrefix = '${HEDGEWARS_FULL_DATADIR}/Data';
 {$IFDEF PAS2C}
-      cFontsPaths: array[0..0] of PChar = (nil);
+      cFontsPaths: array[0..1] of PChar = (nil, nil);
 {$ELSE}
       cFontsPaths: ${FONTS_DIRS_ARRAY}
 {$ENDIF}
--- a/hedgewars/hwengine.pas	Sun Feb 09 19:00:13 2014 +0100
+++ b/hedgewars/hwengine.pas	Mon Feb 10 00:43:03 2014 +0400
@@ -336,8 +336,8 @@
     initEverything(true);
     WriteLnToConsole('Hedgewars engine ' + cVersionString + '-r' + cRevisionString +
                      ' (' + cHashString + ') with protocol #' + inttostr(cNetProtoVersion));
-    AddFileLog('Prefix: "' + PathPrefix +'"');
-    AddFileLog('UserPrefix: "' + UserPathPrefix +'"');
+    AddFileLog('Prefix: "' + shortstring(PathPrefix) +'"');
+    AddFileLog('UserPrefix: "' + shortstring(UserPathPrefix) +'"');
 
     for i:= 0 to ParamCount do
         AddFileLog(inttostr(i) + ': ' + ParamStr(i));
--- a/hedgewars/uChat.pas	Sun Feb 09 19:00:13 2014 +0100
+++ b/hedgewars/uChat.pas	Mon Feb 10 00:43:03 2014 +0400
@@ -100,7 +100,7 @@
     delete(str, 1, 1)
     end;
 
-font:= CheckCJKFont(str, fnt16);
+font:= CheckCJKFont(ansistring(str), fnt16);
 w:= 0; h:= 0; // avoid compiler hints
 TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(str), @w, @h);
 
--- a/hedgewars/uCommandHandlers.pas	Sun Feb 09 19:00:13 2014 +0100
+++ b/hedgewars/uCommandHandlers.pas	Mon Feb 10 00:43:03 2014 +0400
@@ -582,12 +582,12 @@
 if autoCameraOn then
     begin
     FollowGear:= nil;
-    AddCaption('Auto Camera Off', $CCCCCC, capgrpVolume);
+    AddCaption(ansistring('Auto Camera Off'), $CCCCCC, capgrpVolume);
     autoCameraOn:= false
     end
 else
     begin
-    AddCaption('Auto Camera On', $CCCCCC, capgrpVolume);
+    AddCaption(ansistring('Auto Camera On'), $CCCCCC, capgrpVolume);
     bShowFinger:= true;
     if not CurrentHedgehog^.Unplaced then
         FollowGear:= CurrentHedgehog^.Gear;
--- a/hedgewars/uGame.pas	Sun Feb 09 19:00:13 2014 +0100
+++ b/hedgewars/uGame.pas	Mon Feb 10 00:43:03 2014 +0400
@@ -32,7 +32,7 @@
 
 procedure DoGameTick(Lag: LongInt);
 var i,j : LongInt;
-    s: shortstring;
+    s: ansistring;
 begin
 if isPaused then
     exit;
@@ -76,8 +76,8 @@
             AddCaption(trmsg[sidMute], cWhiteColor, capgrpVolume)
         else if not isAudioMuted then
             begin
-            str(i, s);
-            AddCaption(Format(trmsg[sidVolume], s), cWhiteColor, capgrpVolume)
+            s:= ansistring(inttostr(i));
+            AddCaption(FormatA(trmsg[sidVolume], s), cWhiteColor, capgrpVolume)
             end
         end;
     end;
--- a/hedgewars/uGearsList.pas	Sun Feb 09 19:00:13 2014 +0100
+++ b/hedgewars/uGearsList.pas	Mon Feb 10 00:43:03 2014 +0400
@@ -700,7 +700,7 @@
                 begin
                 inc(Team^.stats.AIKills);
                 FreeTexture(Team^.AIKillsTex);
-                Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16);
+                Team^.AIKillsTex := RenderStringTex(ansistring(inttostr(Team^.stats.AIKills)), Team^.Clan^.Color, fnt16);
                 end
         end;
 with Gear^ do
--- a/hedgewars/uLocale.pas	Sun Feb 09 19:00:13 2014 +0100
+++ b/hedgewars/uLocale.pas	Mon Feb 10 00:43:03 2014 +0400
@@ -40,7 +40,7 @@
     trevt_n: array[TEventId] of integer;
 
 procedure LoadLocale(FileName: shortstring);
-var s: ansistring = '';
+var s: ansistring;
     f: pfsFile;
     a, b, c: LongInt;
     first: array[TEventId] of boolean;
@@ -62,11 +62,16 @@
         if (s[1] < '0') or (s[1] > '9') then
             continue;
         TryDo(Length(s) > 6, 'Load locale: empty string', true);
+        {$IFNDEF PAS2C}
         val(s[1]+s[2], a, c);
         TryDo(c = 0, ansistring('Load locale: numbers should be two-digit: ') + s, true);
-        TryDo(s[3] = ':', 'Load locale: ":" expected', true);
         val(s[4]+s[5], b, c);
         TryDo(c = 0, ansistring('Load locale: numbers should be two-digit: ') + s, true);
+        {$ELSE}
+        val(s[1]+s[2], a);
+        val(s[4]+s[5], b);
+        {$ENDIF}
+        TryDo(s[3] = ':', 'Load locale: ":" expected', true);
         TryDo(s[6] = '=', 'Load locale: "=" expected', true);
         Delete(s, 1, 6);
         case a of
--- a/hedgewars/uMisc.pas	Sun Feb 09 19:00:13 2014 +0100
+++ b/hedgewars/uMisc.pas	Mon Feb 10 00:43:03 2014 +0400
@@ -256,7 +256,7 @@
 
 // allocate and fill structure that will be passed to new thread
 New(image); // will be disposed in SaveScreenshot()
-image^.filename:= UserPathPrefix + filename + ext;
+image^.filename:= shortstring(UserPathPrefix) + filename + ext;
 image^.width:= cScreenWidth div k;
 image^.height:= cScreenHeight div k;
 image^.size:= size;
--- a/hedgewars/uPhysFSLayer.pas	Sun Feb 09 19:00:13 2014 +0100
+++ b/hedgewars/uPhysFSLayer.pas	Mon Feb 10 00:43:03 2014 +0400
@@ -36,7 +36,7 @@
 {$ENDIF}
 
 implementation
-uses uConsts, uUtils, uVariables, sysutils;
+uses uConsts, uUtils, uVariables{$IFNDEF PAS2C}, sysutils{$ENDIF};
 
 {$IFNDEF PAS2C}
 function PHYSFS_init(argv0: PChar) : LongInt; cdecl; external PhysfsLibName;
@@ -132,17 +132,17 @@
         pfsBlockRead:= r
 end;
 
-procedure pfsMount(path: AnsiString; mountpoint: PChar);
+procedure pfsMount(path: ansistring; mountpoint: PChar);
 begin
-    if PHYSFS_mount(Str2PChar(path), mountpoint, false) then
-        AddFileLog('[PhysFS] mount ' + path + ' at ' + mountpoint + ' : ok')
+    if PHYSFS_mount(PChar(path), mountpoint, false) then
+        AddFileLog('[PhysFS] mount ' + shortstring(path) + ' at ' + shortstring(mountpoint) + ' : ok')
     else
-        AddFileLog('[PhysFS] mount ' + path + ' at ' + mountpoint + ' : FAILED ("' + PHYSFS_getLastError() + '")');
+        AddFileLog('[PhysFS] mount ' + shortstring(path) + ' at ' + shortstring(mountpoint) + ' : FAILED ("' + shortstring(PHYSFS_getLastError()) + '")');
 end;
 
-procedure pfsMountAtRoot(path: AnsiString);
+procedure pfsMountAtRoot(path: ansistring);
 begin
-    pfsMount(path, '/');
+    pfsMount(path, PChar('/'));
 end;
 
 procedure initModule;
@@ -165,11 +165,11 @@
         begin
             fp := cFontsPaths[i];
             if fp <> nil then
-                pfsMount(fp, '/Fonts');
+                pfsMount(ansistring(fp), PChar('/Fonts'));
         end;
 
     pfsMountAtRoot(PathPrefix);
-    pfsMountAtRoot(UserPathPrefix + '/Data');
+    pfsMountAtRoot(UserPathPrefix + ansistring('/Data'));
 
     hedgewarsMountPackages;
 
--- a/hedgewars/uRenderUtils.pas	Sun Feb 09 19:00:13 2014 +0100
+++ b/hedgewars/uRenderUtils.pas	Mon Feb 10 00:43:03 2014 +0400
@@ -82,7 +82,7 @@
     clr: TSDL_Color;
     finalRect, textRect: TSDL_Rect;
 begin
-    TTF_SizeUTF8(Fontz[Font].Handle, Str2PChar(s), @w, @h);
+    TTF_SizeUTF8(Fontz[Font].Handle, PChar(s), @w, @h);
     if (maxLength <> 0) and (w > maxLength) then w := maxLength;
     finalRect.x:= X;
     finalRect.y:= Y;
@@ -96,7 +96,7 @@
     clr.r:= (Color shr 16) and $FF;
     clr.g:= (Color shr 8) and $FF;
     clr.b:= Color and $FF;
-    tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, Str2PChar(s), clr);
+    tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, PChar(s), clr);
     finalRect.x:= X + cFontBorder + 2;
     finalRect.y:= Y + cFontBorder;
     SDLTry(tmpsurf <> nil, true);
@@ -280,7 +280,7 @@
     if length(s) = 0 then s:= _S' ';
     font:= CheckCJKFont(s, font);
     w:= 0; h:= 0; // avoid compiler hints
-    TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(s), @w, @h);
+    TTF_SizeUTF8(Fontz[font].Handle, PChar(s), @w, @h);
     if (maxLength <> 0) and (w > maxLength) then w := maxLength;
 
     finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, w + cFontBorder * 2 + 4, h + cFontBorder * 2,
@@ -302,7 +302,9 @@
 var textWidth, textHeight, x, y, w, h, i, j, pos, prevpos, line, numLines, edgeWidth, edgeHeight, cornerWidth, cornerHeight: LongInt;
     finalSurface, tmpsurf, rotatedEdge: PSDL_Surface;
     rect: TSDL_Rect;
+    {$IFNDEF PAS2C}
     chars: set of char = [#9,' ',';',':','?','!',','];
+    {$ENDIF}
     substr: shortstring;
     edge, corner, tail: TSPrite;
 begin
@@ -338,7 +340,7 @@
         s:= '...';
     font:= CheckCJKFont(s, font);
     w:= 0; h:= 0; // avoid compiler hints
-    TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(s), @w, @h);
+    TTF_SizeUTF8(Fontz[font].Handle, PChar(s), @w, @h);
     if w<8 then
         w:= 8;
     j:= 0;
@@ -346,7 +348,9 @@
         begin
         w:= 0;
         i:= round(Sqrt(length(s)) * 2);
+        {$IFNDEF PAS2C}
         s:= WrapText(s, #1, chars, i);
+        {$ENDIF}
         pos:= 1; prevpos:= 0; line:= 0;
     // Find the longest line for the purposes of centring the text.  Font dependant.
         while pos <= length(s) do
--- a/hedgewars/uScript.pas	Sun Feb 09 19:00:13 2014 +0100
+++ b/hedgewars/uScript.pas	Mon Feb 10 00:43:03 2014 +0400
@@ -228,7 +228,7 @@
 begin
     if lua_gettop(L) = 5 then
         begin
-        ShowMission(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), lua_tointeger(L, 4), lua_tointeger(L, 5));
+        ShowMission(lua_tostringA(L, 1), lua_tostringA(L, 2), lua_tostringA(L, 3), lua_tointeger(L, 4), lua_tointeger(L, 5));
         end
     else
         LuaParameterCountError('ShowMission', 'caption, subcaption, text, icon, time', lua_gettop(L));
@@ -308,10 +308,10 @@
 function lc_addcaption(L : Plua_State) : LongInt; Cdecl;
 begin
     if lua_gettop(L) = 1 then
-        AddCaption(lua_tostring(L, 1), cWhiteColor, capgrpMessage)
+        AddCaption(lua_tostringA(L, 1), cWhiteColor, capgrpMessage)
     else if lua_gettop(L) = 3 then
         begin
-        AddCaption(lua_tostring(L, 1), lua_tointeger(L, 2) shr 8, TCapGroup(lua_tointeger(L, 3)));
+        AddCaption(lua_tostringA(L, 1), lua_tointeger(L, 2) shr 8, TCapGroup(lua_tointeger(L, 3)));
         end
     else
         LuaParameterCountError('AddCaption', 'text[, color, captiongroup]', lua_gettop(L));
@@ -847,12 +847,12 @@
                 if (hh.Gear <> nil) or (hh.GearHidden <> nil) then
                     begin
                     FreeTexture(hh.NameTagTex);
-                    hh.NameTagTex:= RenderStringTex(hh.Name, clan^.Color, fnt16);
+                    hh.NameTagTex:= RenderStringTex(ansistring(hh.Name), clan^.Color, fnt16);
                     RenderHealth(hh);
                     end;
                 end;
             FreeTexture(team^.NameTagTex);
-            team^.NameTagTex:= RenderStringTex(clan^.Teams[i]^.TeamName, clan^.Color, fnt16);
+            team^.NameTagTex:= RenderStringTex(ansistring(clan^.Teams[i]^.TeamName), clan^.Color, fnt16);
             end;
 
         clan^.HealthTex:= makeHealthBarTexture(cTeamHealthWidth + 5, clan^.Teams[0]^.NameTagTex^.h, clan^.Color);
@@ -898,7 +898,7 @@
             gear^.Hedgehog^.Team^.TeamName := lua_tostring(L, 2);
 
             FreeTexture(gear^.Hedgehog^.Team^.NameTagTex);
-            gear^.Hedgehog^.Team^.NameTagTex:= RenderStringTex(gear^.Hedgehog^.Team^.TeamName, gear^.Hedgehog^.Team^.Clan^.Color, fnt16);
+            gear^.Hedgehog^.Team^.NameTagTex:= RenderStringTex(ansistring(gear^.Hedgehog^.Team^.TeamName), gear^.Hedgehog^.Team^.Clan^.Color, fnt16);
             end
         else
             lua_pushnil(L);
@@ -943,7 +943,7 @@
             gear^.Hedgehog^.Name:= lua_tostring(L, 2);
 
             FreeTexture(gear^.Hedgehog^.NameTagTex);
-            gear^.Hedgehog^.NameTagTex:= RenderStringTex(gear^.Hedgehog^.Name, gear^.Hedgehog^.Team^.Clan^.Color, fnt16)
+            gear^.Hedgehog^.NameTagTex:= RenderStringTex(ansistring(gear^.Hedgehog^.Name), gear^.Hedgehog^.Team^.Clan^.Color, fnt16)
             end
         end;
     lc_sethogname:= 0;
--- a/hedgewars/uStats.pas	Sun Feb 09 19:00:13 2014 +0100
+++ b/hedgewars/uStats.pas	Mon Feb 10 00:43:03 2014 +0400
@@ -97,12 +97,14 @@
 
 procedure TurnReaction;
 var i, t: LongInt;
+    s: ansistring;
 begin
 TryDo(not bBetweenTurns, 'Engine bug: TurnReaction between turns', true);
 
 inc(FinishedTurnsTotal);
 if FinishedTurnsTotal <> 0 then
     begin
+    s:= ansistring(CurrentHedgehog^.Name);
     inc(CurrentHedgehog^.stats.FinishedTurns);
 
     if (CurrentHedgehog^.stats.DamageGiven = DamageTotal) and (DamageTotal > 0) then
@@ -112,7 +114,7 @@
         begin
         AddVoice(sndStupid, PreviousTeam^.voicepack);
         if CurrentHedgehog^.stats.DamageGiven = CurrentHedgehog^.stats.StepDamageRecv then
-            AddCaption(Format(GetEventString(eidHurtSelf), CurrentHedgehog^.Name), cWhiteColor, capgrpMessage);
+            AddCaption(FormatA(GetEventString(eidHurtSelf), s), cWhiteColor, capgrpMessage);
         end
 
     else if DamageClan <> 0 then
@@ -140,7 +142,7 @@
     else if isTurnSkipped then
         begin
         AddVoice(sndBoring, PreviousTeam^.voicepack);
-        AddCaption(Format(GetEventString(eidTurnSkipped), CurrentHedgehog^.Name), cWhiteColor, capgrpMessage);
+        AddCaption(FormatA(GetEventString(eidTurnSkipped), s), cWhiteColor, capgrpMessage);
         end
     else if not PlacingHogs then
         AddVoice(sndCoward, PreviousTeam^.voicepack);
--- a/hedgewars/uStore.pas	Sun Feb 09 19:00:13 2014 +0100
+++ b/hedgewars/uStore.pas	Mon Feb 10 00:43:03 2014 +0400
@@ -185,9 +185,9 @@
 for t:= 0 to Pred(TeamsCount) do
     with TeamsArray[t]^ do
         begin
-        NameTagTex:= RenderStringTexLim(TeamName, Clan^.Color, Font, cTeamHealthWidth);
+        NameTagTex:= RenderStringTexLim(ansistring(TeamName), Clan^.Color, Font, cTeamHealthWidth);
         if length(Owner) > 0 then
-            OwnerTex:= RenderStringTexLim(Owner, Clan^.Color, Font, cTeamHealthWidth);
+            OwnerTex:= RenderStringTexLim(ansistring(Owner), Clan^.Color, Font, cTeamHealthWidth);
 
         r.x:= 0;
         r.y:= 0;
@@ -253,7 +253,7 @@
         SDL_FreeSurface(texsurf);
         texsurf:= nil;
 
-        AIKillsTex := RenderStringTex(inttostr(stats.AIKills), Clan^.Color, fnt16);
+        AIKillsTex := RenderStringTex(ansistring(inttostr(stats.AIKills)), Clan^.Color, fnt16);
 
         dec(drY, r.h + 2);
         DrawHealthY:= drY;
@@ -261,7 +261,7 @@
             with Hedgehogs[i] do
                 if Gear <> nil then
                     begin
-                    NameTagTex:= RenderStringTexLim(Name, Clan^.Color, fnt16, cTeamHealthWidth);
+                    NameTagTex:= RenderStringTexLim(ansistring(Name), Clan^.Color, fnt16, cTeamHealthWidth);
                     if Hat = 'NoHat' then
                         begin
                         if (month = 4) and (md = 20) then
@@ -451,7 +451,7 @@
     with Ammoz[ai] do
         begin
         TryDo(length(trAmmo[NameId]) > 0,'No default text/translation found for ammo type #' + intToStr(ord(ai)) + '!',true);
-        tmpsurf:= TTF_RenderUTF8_Blended(Fontz[CheckCJKFont(trAmmo[NameId],fnt16)].Handle, Str2PChar(trAmmo[NameId]), cWhiteColorChannels);
+        tmpsurf:= TTF_RenderUTF8_Blended(Fontz[CheckCJKFont(trAmmo[NameId],fnt16)].Handle, PChar(trAmmo[NameId]), cWhiteColorChannels);
         TryDo(tmpsurf <> nil,'Name-texture creation for ammo type #' + intToStr(ord(ai)) + ' failed!',true);
         tmpsurf:= doSurfaceConversion(tmpsurf);
         FreeTexture(NameTex);
@@ -585,7 +585,7 @@
 begin
 str(Hedgehog.Gear^.Health, s);
 FreeTexture(Hedgehog.HealthTagTex);
-Hedgehog.HealthTagTex:= RenderStringTex(s, Hedgehog.Team^.Clan^.Color, fnt16)
+Hedgehog.HealthTagTex:= RenderStringTex(ansistring(s), Hedgehog.Team^.Clan^.Color, fnt16)
 end;
 
 function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface;
@@ -840,7 +840,7 @@
 procedure SetupOpenGL;
 var buf: array[byte] of char;
     AuxBufNum: LongInt = 0;
-    tmpstr: AnsiString;
+    tmpstr: ansistring;
     tmpint: LongInt;
     tmpn: LongInt;
 begin
--- a/hedgewars/uUtils.pas	Sun Feb 09 19:00:13 2014 +0100
+++ b/hedgewars/uUtils.pas	Mon Feb 10 00:43:03 2014 +0400
@@ -516,7 +516,7 @@
 {$IFNDEF PAS2C}
     f:= stderr; // if everything fails, write to stderr
 {$ENDIF}
-    if (UserPathPrefix <> '') then
+    if (length(UserPathPrefix) > 0) then
         begin
         {$IFNDEF PAS2C}
         // create directory if it doesn't exist
@@ -527,7 +527,7 @@
         i:= 0;
         while(i < 7) do
             begin
-            assign(f, UserPathPrefix + '/Logs/' + logfileBase + inttostr(i) + '.log');
+            assign(f, shortstring(UserPathPrefix) + '/Logs/' + logfileBase + inttostr(i) + '.log');
             if IOResult = 0 then
                 break;
             inc(i)
--- a/hedgewars/uVariables.pas	Sun Feb 09 19:00:13 2014 +0100
+++ b/hedgewars/uVariables.pas	Mon Feb 10 00:43:03 2014 +0400
@@ -41,8 +41,8 @@
     cLocaleFName       : shortstring;
     cLocale            : shortstring;
     cTimerInterval     : LongInt;
-    PathPrefix         : shortstring;
-    UserPathPrefix     : shortstring;
+    PathPrefix         : ansistring;
+    UserPathPrefix     : ansistring;
     cShowFPS           : boolean;
     cFlattenFlakes     : boolean;
     cFlattenClouds     : boolean;
--- a/misc/libphyslayer/hwpacksmounter.h	Sun Feb 09 19:00:13 2014 +0100
+++ b/misc/libphyslayer/hwpacksmounter.h	Mon Feb 10 00:43:03 2014 +0400
@@ -3,7 +3,10 @@
 
 #include "physfs.h"
 #include "physfscompat.h"
+
+#ifndef PAS2C
 #include "lua.h"
+#endif
 
 #ifdef __cplusplus
 extern "C" {
--- a/project_files/hwc/CMakeLists.txt	Sun Feb 09 19:00:13 2014 +0100
+++ b/project_files/hwc/CMakeLists.txt	Mon Feb 10 00:43:03 2014 +0400
@@ -12,6 +12,7 @@
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/rtl)
 include_directories(${PHYSFS_INCLUDE_DIR})
 include_directories(${PHYSLAYER_INCLUDE_DIR})
+include_directories(${LUA_INCLUDE_DIR})
 add_subdirectory(rtl)
 
 configure_file(${CMAKE_SOURCE_DIR}/hedgewars/config.inc.in ${CMAKE_CURRENT_BINARY_DIR}/config.inc)
@@ -60,6 +61,8 @@
 
 
 #compile the c files
+add_definitions(-DPAS2C)
+
 add_executable(hwengine WIN32 ${engine_sources})
 
 target_link_libraries(hwengine  fpcrtl
--- a/project_files/hwc/rtl/fpcrtl.h	Sun Feb 09 19:00:13 2014 +0100
+++ b/project_files/hwc/rtl/fpcrtl.h	Mon Feb 10 00:43:03 2014 +0400
@@ -190,6 +190,7 @@
 #define _chrconcat                          fpcrtl_chrconcat
 #define _pchar                              fpcrtl_pchar
 #define _strconcatA                         fpcrtl_strconcatA
+#define _strncompareA                       fpcrtl_strncompareA
 
 // hooks are implemented in javascript
 void start_hook(void);
--- a/project_files/hwc/rtl/misc.h	Sun Feb 09 19:00:13 2014 +0100
+++ b/project_files/hwc/rtl/misc.h	Mon Feb 10 00:43:03 2014 +0400
@@ -46,12 +46,13 @@
 bool        fpcrtl_strcompare(string255 str1, string255 str2);
 bool        fpcrtl_strcomparec(string255 a, char b);
 bool        fpcrtl_strncompare(string255 a, string255 b);
+bool        fpcrtl_strncompareA(astring a, astring b);
 
 char*       fpcrtl__pchar(string255 s);
 string255   fpcrtl_pchar2str(char *s);
+astring     fpcrtl_pchar2astr(char *s);
 astring     fpcrtl_str2astr(string255 s);
 string255   fpcrtl_astr2str(astring s);
-string255   fpcrtl_astr2str(astring a);
 #define     fpcrtl_TypeInfo                         sizeof // dummy
 
 #ifdef EMSCRIPTEN
--- a/project_files/hwc/rtl/pas2c.h	Sun Feb 09 19:00:13 2014 +0100
+++ b/project_files/hwc/rtl/pas2c.h	Mon Feb 10 00:43:03 2014 +0400
@@ -28,7 +28,7 @@
         };
         struct {
             unsigned char _dummy2;
-            unsigned char str[MAX_ANSISTRING_LENGTH];
+            unsigned char s[MAX_ANSISTRING_LENGTH];
         };
         struct {
             uint16_t len;
@@ -76,6 +76,7 @@
 bool _strcompare(string255 a, string255 b);
 bool _strcomparec(string255 a, unsigned char b);
 bool _strncompare(string255 a, string255 b);
+bool _strncompareA(astring a, astring b);
 
 
 #define STRINIT(a) {.len = sizeof(a) - 1, .str = a}
--- a/project_files/hwc/rtl/system.h	Sun Feb 09 19:00:13 2014 +0100
+++ b/project_files/hwc/rtl/system.h	Mon Feb 10 00:43:03 2014 +0400
@@ -22,6 +22,7 @@
  * Index is 1-based.
  */
 string255   fpcrtl_copy(string255 s, Integer Index, Integer Count);
+astring     fpcrtl_copyA(astring s, Integer Index, Integer Count);
 
 /*
  * Delete removes Count characters from string S, starting at position Index.
@@ -42,6 +43,7 @@
 
 Integer     __attribute__((overloadable))                   fpcrtl_pos(Char c, string255 str);
 Integer     __attribute__((overloadable))                   fpcrtl_pos(string255 substr, string255 str);
+Integer     __attribute__((overloadable))                   fpcrtl_pos(string255 substr, astring str);
 
 Integer     fpcrtl_length(string255 s);
 #define     fpcrtl_Length                                   fpcrtl_length
--- a/tools/pas2c/Pas2C.hs	Sun Feb 09 19:00:13 2014 +0100
+++ b/tools/pas2c/Pas2C.hs	Mon Feb 10 00:43:03 2014 +0400
@@ -1140,6 +1140,7 @@
          a -> error $ "Getting element of " ++ show a ++ "\nReference: " ++ show ae
     case t of
          BTString ->  return $ r <> text ".s" <> brackets e
+         BTAString ->  return $ r <> text ".s" <> brackets e
          _ -> return $ r <> brackets e
 ref2C (SimpleReference name) = id2C IOLookup name
 ref2C rf@(RecordField (Dereference ref1) ref2) = do
@@ -1202,6 +1203,7 @@
         ("pchar", BTAString) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "_pcharA" $ BTPointerTo BTChar))
         ("shortstring", BTAString) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "astr2str" $ BTString))
         ("shortstring", BTPointerTo _) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "pchar2str" $ BTString))
+        ("ansistring", BTPointerTo _) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "pchar2astr" $ BTAString))
         ("ansistring", BTString) -> ref2C $ FunCall [expr] (SimpleReference (Identifier "str2astr" $ BTAString))
         (a, _) -> do
             e <- expr2C expr