- pas2c recognizes typecasts in initialization expressions
authorunc0rr
Wed, 12 Feb 2014 00:50:15 +0400
changeset 10131 4b4a043111f4
parent 10130 a9d509848390
child 10132 701844ed50d3
- pas2c recognizes typecasts in initialization expressions - Forbid incompatible pointer types - Fixes and new functions to fpcrtl
hedgewars/pas2cRedo.pas
hedgewars/pas2cSystem.pas
hedgewars/uGearsHandlersMess.pas
hedgewars/uLand.pas
hedgewars/uLandGraphics.pas
hedgewars/uLandObjects.pas
hedgewars/uLandPainted.pas
hedgewars/uLandTemplates.pas
hedgewars/uScript.pas
hedgewars/uStore.pas
hedgewars/uTextures.pas
hedgewars/uUtils.pas
project_files/hwc/CMakeLists.txt
project_files/hwc/rtl/misc.c
project_files/hwc/rtl/misc.h
project_files/hwc/rtl/pas2c.h
project_files/hwc/rtl/system.c
project_files/hwc/rtl/system.h
tools/pas2c/Pas2C.hs
tools/pas2c/PascalParser.hs
--- a/hedgewars/pas2cRedo.pas	Tue Feb 11 22:05:03 2014 +0400
+++ b/hedgewars/pas2cRedo.pas	Wed Feb 12 00:50:15 2014 +0400
@@ -74,7 +74,7 @@
     StrPas, FormatDateTime, copy, delete, str, PosS, trim, LowerCase : function : shortstring;
     pos : function : integer;
     StrToInt : function : integer;
-    SetLength, val, StrDispose, StrCopy : procedure;
+    SetLength, SetLengthA, val, StrDispose, StrCopy : procedure;
     _pchar, _pcharA, StrAlloc : function : PChar;
     pchar2str, astr2str : function : string;
     pchar2astr, str2astr : function : ansistring;
--- a/hedgewars/pas2cSystem.pas	Tue Feb 11 22:05:03 2014 +0400
+++ b/hedgewars/pas2cSystem.pas	Wed Feb 12 00:50:15 2014 +0400
@@ -40,6 +40,7 @@
     char = char;
     PChar = ^char;
     PPChar = ^Pchar;
+    PWideChar = ^WideChar;
 
     PByte = ^Byte;
     PWord = ^Word;
--- a/hedgewars/uGearsHandlersMess.pas	Tue Feb 11 22:05:03 2014 +0400
+++ b/hedgewars/uGearsHandlersMess.pas	Wed Feb 12 00:50:15 2014 +0400
@@ -882,7 +882,7 @@
                         end
                     else allpx:= false
                     end;
-                p:= @(p^[s^.pitch shr 2])
+                p:= PLongWordArray(@(p^[s^.pitch shr 2]))
                 end;
 
             // Why is this here.  For one thing, there's no test on +1 being safe.
--- a/hedgewars/uLand.pas	Tue Feb 11 22:05:03 2014 +0400
+++ b/hedgewars/uLand.pas	Wed Feb 12 00:50:15 2014 +0400
@@ -420,7 +420,7 @@
         else
             LandPixels[y div 2, x div 2]:= p^[x] or AMask;
 
-    p:= @(p^[Surface^.pitch div 4]);
+    p:= PLongwordArray(@(p^[Surface^.pitch div 4]));
     end;
 
 if SDL_MustLock(Surface) then
@@ -595,7 +595,7 @@
             begin
             for x:= 0 to Pred(tmpsurf^.w) do
                 SetLand(Land[cpY + y, cpX + x], p^[x]);
-            p:= @(p^[tmpsurf^.pitch div 4]);
+            p:= PLongwordArray(@(p^[tmpsurf^.pitch div 4]));
             end;
 
     if SDL_MustLock(tmpsurf) then
--- a/hedgewars/uLandGraphics.pas	Tue Feb 11 22:05:03 2014 +0400
+++ b/hedgewars/uLandGraphics.pas	Wed Feb 12 00:50:15 2014 +0400
@@ -615,7 +615,7 @@
 bpp:= Image^.format^.BytesPerPixel;
 TryDo(bpp = 4, 'It should be 32 bpp sprite', true);
 // Check that sprite fits free space
-p:= @(PByteArray(Image^.pixels)^[ Image^.pitch * row * h + col * w * 4 ]);
+p:= PByteArray(@(PByteArray(Image^.pixels)^[ Image^.pitch * row * h + col * w * 4 ]));
 case bpp of
     4: for y:= 0 to Pred(h) do
         begin
@@ -628,7 +628,7 @@
                             SDL_UnlockSurface(Image);
                         exit;
                     end;
-        p:= @(p^[Image^.pitch]);
+        p:= PByteArray(@(p^[Image^.pitch]));
         end;
     end;
 
@@ -641,7 +641,7 @@
     end;
 
 // Checked, now place
-p:= @(PByteArray(Image^.pixels)^[ Image^.pitch * row * h + col * w * 4 ]);
+p:= PByteArray(@(PByteArray(Image^.pixels)^[ Image^.pitch * row * h + col * w * 4 ]));
 case bpp of
     4: for y:= 0 to Pred(h) do
         begin
@@ -666,7 +666,7 @@
                     Land[cpY + y, cpX + x]:= lfObject or LandFlags;
                 LandPixels[gY, gX]:= PLongword(@(p^[x * 4]))^
                 end;
-        p:= @(p^[Image^.pitch]);
+        p:= PByteArray(@(p^[Image^.pitch]));
         end;
     end;
 if SDL_MustLock(Image) then
--- a/hedgewars/uLandObjects.pas	Tue Feb 11 22:05:03 2014 +0400
+++ b/hedgewars/uLandObjects.pas	Wed Feb 12 00:50:15 2014 +0400
@@ -130,7 +130,7 @@
             if (Land[cpY + y, cpX + x] <= lfAllObjMask) and ((p^[x] and AMask) <> 0) then
                 Land[cpY + y, cpX + x]:= lfObject or LandFlags
             end;
-    p:= @(p^[Image^.pitch shr 2])
+    p:= PLongwordArray(@(p^[Image^.pitch shr 2]))
     end;
 
 if SDL_MustLock(Image) then
@@ -170,8 +170,8 @@
         if (Land[cpY + y, cpX + x] <= lfAllObjMask) or (Land[cpY + y, cpX + x] and lfObject <> 0)  then
             SetLand(Land[cpY + y, cpX + x], mp^[x]);
         end;
-    p:= @(p^[Image^.pitch shr 2]);
-    mp:= @(mp^[Mask^.pitch shr 2])
+    p:= PLongwordArray(@(p^[Image^.pitch shr 2]));
+    mp:= PLongwordArray(@(mp^[Mask^.pitch shr 2]))
     end;
 
 if SDL_MustLock(Image) then
--- a/hedgewars/uLandPainted.pas	Tue Feb 11 22:05:03 2014 +0400
+++ b/hedgewars/uLandPainted.pas	Wed Feb 12 00:50:15 2014 +0400
@@ -33,6 +33,7 @@
     X, Y: SmallInt;
     flags: byte;
     end;
+    PPointRec = ^PointRec;
 
 type
     PPointEntry = ^PointEntry;
@@ -45,7 +46,7 @@
 
 procedure chDraw(var s: shortstring);
 var rec: PointRec;
-    prec: ^PointRec;
+    prec: PPointRec;
     pe: PPointEntry;
     i, l: byte;
 begin
@@ -53,7 +54,7 @@
     l:= length(s);
     while i < l do
         begin
-        prec:= @s[i];
+        prec:= PPointRec(@s[i]);
         rec:= prec^;
         rec.X:= SDLNet_Read16(@rec.X);
         rec.Y:= SDLNet_Read16(@rec.Y);
--- a/hedgewars/uLandTemplates.pas	Tue Feb 11 22:05:03 2014 +0400
+++ b/hedgewars/uLandTemplates.pas	Wed Feb 12 00:50:15 2014 +0400
@@ -1809,9 +1809,9 @@
 ////////////////////////////////////////////////////////////////////////
 var EdgeTemplates: array[0..45] of TEdgeTemplate =
       (
-       (BasePoints: @Template0Points;
+       (BasePoints: PPointArray(@Template0Points);
         BasePointsCount: Succ(High(Template0Points));
-        FillPoints: @Template0FPoints;
+        FillPoints: PPointArray(@Template0FPoints);
         FillPointsCount: Succ(High(Template0FPoints));
         BezierizeCount: 3;
         RandPassesCount: 8;
@@ -1820,9 +1820,9 @@
         hasGirders: true;
         MaxHedgeHogs: 18;
        ),
-       (BasePoints: @Template1Points;
+       (BasePoints: PPointArray(@Template1Points);
         BasePointsCount: Succ(High(Template1Points));
-        FillPoints: @Template1FPoints;
+        FillPoints: PPointArray(@Template1FPoints);
         FillPointsCount: Succ(High(Template1FPoints));
         BezierizeCount: 3;
         RandPassesCount: 7;
@@ -1831,9 +1831,9 @@
         hasGirders: true;
         MaxHedgeHogs: 18;
        ),
-       (BasePoints: @Template2Points;
+       (BasePoints: PPointArray(@Template2Points);
         BasePointsCount: Succ(High(Template2Points));
-        FillPoints: @Template2FPoints;
+        FillPoints: PPointArray(@Template2FPoints);
         FillPointsCount: Succ(High(Template2FPoints));
         BezierizeCount: 2;
         RandPassesCount: 6;
@@ -1842,9 +1842,9 @@
         hasGirders: true;
         MaxHedgeHogs: 18;
        ),
-       (BasePoints: @Template3Points;
+       (BasePoints: PPointArray(@Template3Points);
         BasePointsCount: Succ(High(Template3Points));
-        FillPoints: @Template3FPoints;
+        FillPoints: PPointArray(@Template3FPoints);
         FillPointsCount: Succ(High(Template3FPoints));
         BezierizeCount: 3;
         RandPassesCount: 4;
@@ -1853,9 +1853,9 @@
         hasGirders: true;
         MaxHedgeHogs: 18;
        ),
-       (BasePoints: @Template4Points;
+       (BasePoints: PPointArray(@Template4Points);
         BasePointsCount: Succ(High(Template4Points));
-        FillPoints: @Template4FPoints;
+        FillPoints: PPointArray(@Template4FPoints);
         FillPointsCount: Succ(High(Template4FPoints));
         BezierizeCount: 3;
         RandPassesCount: 4;
@@ -1864,9 +1864,9 @@
         hasGirders: true;
         MaxHedgeHogs: 18;
        ),
-       (BasePoints: @Template5Points;
+       (BasePoints: PPointArray(@Template5Points);
         BasePointsCount: Succ(High(Template5Points));
-        FillPoints: @Template5FPoints;
+        FillPoints: PPointArray(@Template5FPoints);
         FillPointsCount: Succ(High(Template5FPoints));
         BezierizeCount: 2;
         RandPassesCount: 8;
@@ -1875,9 +1875,9 @@
         hasGirders: true;
         MaxHedgeHogs: 18;
        ),
-       (BasePoints: @Template6Points;
+       (BasePoints: PPointArray(@Template6Points);
         BasePointsCount: Succ(High(Template6Points));
-        FillPoints: @Template6FPoints;
+        FillPoints: PPointArray(@Template6FPoints);
         FillPointsCount: Succ(High(Template6FPoints));
         BezierizeCount: 2;
         RandPassesCount: 5;
@@ -1886,9 +1886,9 @@
         hasGirders: true;
         MaxHedgeHogs: 18;
        ),
-       (BasePoints: @Template7Points;
+       (BasePoints: PPointArray(@Template7Points);
         BasePointsCount: Succ(High(Template7Points));
-        FillPoints: @Template7FPoints;
+        FillPoints: PPointArray(@Template7FPoints);
         FillPointsCount: Succ(High(Template7FPoints));
         BezierizeCount: 4;
         RandPassesCount: 4;
@@ -1897,9 +1897,9 @@
         hasGirders: true;
         MaxHedgeHogs: 18;
        ),
-       (BasePoints: @Template8Points;
+       (BasePoints: PPointArray(@Template8Points);
         BasePointsCount: Succ(High(Template8Points));
-        FillPoints: @Template8FPoints;
+        FillPoints: PPointArray(@Template8FPoints);
         FillPointsCount: Succ(High(Template8FPoints));
         BezierizeCount: 2;
         RandPassesCount: 7;
@@ -1908,9 +1908,9 @@
         hasGirders: true;
         MaxHedgeHogs: 18;
        ),
-       (BasePoints: @Template9Points;
+       (BasePoints: PPointArray(@Template9Points);
         BasePointsCount: Succ(High(Template9Points));
-        FillPoints: @Template9FPoints;
+        FillPoints: PPointArray(@Template9FPoints);
         FillPointsCount: Succ(High(Template9FPoints));
         BezierizeCount: 1;
         RandPassesCount: 5;
@@ -1919,9 +1919,9 @@
         hasGirders: true;
         MaxHedgeHogs: 18;
        ),
-       (BasePoints: @Template10Points;
+       (BasePoints: PPointArray(@Template10Points);
         BasePointsCount: Succ(High(Template10Points));
-        FillPoints: @Template10FPoints;
+        FillPoints: PPointArray(@Template10FPoints);
         FillPointsCount: Succ(High(Template10FPoints));
         BezierizeCount: 2;
         RandPassesCount: 6;
@@ -1930,9 +1930,9 @@
         hasGirders: true;
         MaxHedgeHogs: 18;
        ),
-       (BasePoints: @Template11Points;
+       (BasePoints: PPointArray(@Template11Points);
         BasePointsCount: Succ(High(Template11Points));
-        FillPoints: @Template11FPoints;
+        FillPoints: PPointArray(@Template11FPoints);
         FillPointsCount: Succ(High(Template11FPoints));
         BezierizeCount: 1;
         RandPassesCount: 8;
@@ -1941,9 +1941,9 @@
         hasGirders: true;
         MaxHedgeHogs: 18;
        ),
-       (BasePoints: @Template12Points;
+       (BasePoints: PPointArray(@Template12Points);
         BasePointsCount: Succ(High(Template12Points));
-        FillPoints: @Template12FPoints;
+        FillPoints: PPointArray(@Template12FPoints);
         FillPointsCount: Succ(High(Template12FPoints));
         BezierizeCount: 3;
         RandPassesCount: 8;
@@ -1952,9 +1952,9 @@
         hasGirders: true;
         MaxHedgeHogs: 18;
        ),
-       (BasePoints: @Template13Points;
+       (BasePoints: PPointArray(@Template13Points);
         BasePointsCount: Succ(High(Template13Points));
-        FillPoints: @Template13FPoints;
+        FillPoints: PPointArray(@Template13FPoints);
         FillPointsCount: Succ(High(Template13FPoints));
         BezierizeCount: 3;
         RandPassesCount: 5;
@@ -1963,9 +1963,9 @@
         hasGirders: true;
         MaxHedgeHogs: 18;
        ),
-       (BasePoints: @Template14Points;
+       (BasePoints: PPointArray(@Template14Points);
         BasePointsCount: Succ(High(Template14Points));
-        FillPoints: @Template14FPoints;
+        FillPoints: PPointArray(@Template14FPoints);
         FillPointsCount: Succ(High(Template14FPoints));
         BezierizeCount: 3;
         RandPassesCount: 7;
@@ -1974,9 +1974,9 @@
         hasGirders: true;
         MaxHedgeHogs: 18;
        ),
-       (BasePoints: @Template15Points;
+       (BasePoints: PPointArray(@Template15Points);
         BasePointsCount: Succ(High(Template15Points));
-        FillPoints: @Template15FPoints;
+        FillPoints: PPointArray(@Template15FPoints);
         FillPointsCount: Succ(High(Template15FPoints));
         BezierizeCount: 2;
         RandPassesCount: 6;
@@ -1985,9 +1985,9 @@
         hasGirders: true;
         MaxHedgeHogs: 18;
        ),
-       (BasePoints: @Template16Points;
+       (BasePoints: PPointArray(@Template16Points);
         BasePointsCount: Succ(High(Template16Points));
-        FillPoints: @Template16FPoints;
+        FillPoints: PPointArray(@Template16FPoints);
         FillPointsCount: Succ(High(Template16FPoints));
         BezierizeCount: 2;
         RandPassesCount: 6;
@@ -1996,9 +1996,9 @@
         hasGirders: true;
         MaxHedgeHogs: 18;
        ),
-       (BasePoints: @Template17Points;
+       (BasePoints: PPointArray(@Template17Points);
         BasePointsCount: Succ(High(Template17Points));
-        FillPoints: @Template17FPoints;
+        FillPoints: PPointArray(@Template17FPoints);
         FillPointsCount: Succ(High(Template17FPoints));
         BezierizeCount: 3;
         RandPassesCount: 7;
@@ -2007,9 +2007,9 @@
         hasGirders: true;
         MaxHedgeHogs: 18;
        ),
-       (BasePoints: @Template18Points;
+       (BasePoints: PPointArray(@Template18Points);
         BasePointsCount: Succ(High(Template18Points));
-        FillPoints: @Template18FPoints;
+        FillPoints: PPointArray(@Template18FPoints);
         FillPointsCount: Succ(High(Template18FPoints));
         BezierizeCount: 3;
         RandPassesCount: 8;
@@ -2018,9 +2018,9 @@
         hasGirders: true;
         MaxHedgeHogs: 36;
        ),
-       (BasePoints: @Template19Points;
+       (BasePoints: PPointArray(@Template19Points);
         BasePointsCount: Succ(High(Template19Points));
-        FillPoints: @Template19FPoints;
+        FillPoints: PPointArray(@Template19FPoints);
         FillPointsCount: Succ(High(Template19FPoints));
         BezierizeCount: 3;
         RandPassesCount: 7;
@@ -2029,9 +2029,9 @@
         hasGirders: true;
         MaxHedgeHogs: 36;
        ),
-       (BasePoints: @Template20Points;
+       (BasePoints: PPointArray(@Template20Points);
         BasePointsCount: Succ(High(Template20Points));
-        FillPoints: @Template20FPoints;
+        FillPoints: PPointArray(@Template20FPoints);
         FillPointsCount: Succ(High(Template20FPoints));
         BezierizeCount: 2;
         RandPassesCount: 6;
@@ -2040,9 +2040,9 @@
         hasGirders: true;
         MaxHedgeHogs: 36;
        ),
-       (BasePoints: @Template21Points;
+       (BasePoints: PPointArray(@Template21Points);
         BasePointsCount: Succ(High(Template21Points));
-        FillPoints: @Template21FPoints;
+        FillPoints: PPointArray(@Template21FPoints);
         FillPointsCount: Succ(High(Template21FPoints));
         BezierizeCount: 3;
         RandPassesCount: 4;
@@ -2051,9 +2051,9 @@
         hasGirders: true;
         MaxHedgeHogs: 36;
        ),
-       (BasePoints: @Template22Points;
+       (BasePoints: PPointArray(@Template22Points);
         BasePointsCount: Succ(High(Template22Points));
-        FillPoints: @Template22FPoints;
+        FillPoints: PPointArray(@Template22FPoints);
         FillPointsCount: Succ(High(Template22FPoints));
         BezierizeCount: 3;
         RandPassesCount: 4;
@@ -2062,9 +2062,9 @@
         hasGirders: true;
         MaxHedgeHogs: 36;
        ),
-       (BasePoints: @Template23Points;
+       (BasePoints: PPointArray(@Template23Points);
         BasePointsCount: Succ(High(Template23Points));
-        FillPoints: @Template23FPoints;
+        FillPoints: PPointArray(@Template23FPoints);
         FillPointsCount: Succ(High(Template23FPoints));
         BezierizeCount: 2;
         RandPassesCount: 8;
@@ -2073,9 +2073,9 @@
         hasGirders: true;
         MaxHedgeHogs: 36;
        ),
-       (BasePoints: @Template24Points;
+       (BasePoints: PPointArray(@Template24Points);
         BasePointsCount: Succ(High(Template24Points));
-        FillPoints: @Template24FPoints;
+        FillPoints: PPointArray(@Template24FPoints);
         FillPointsCount: Succ(High(Template24FPoints));
         BezierizeCount: 2;
         RandPassesCount: 5;
@@ -2084,9 +2084,9 @@
         hasGirders: true;
         MaxHedgeHogs: 36;
        ),
-       (BasePoints: @Template25Points;
+       (BasePoints: PPointArray(@Template25Points);
         BasePointsCount: Succ(High(Template25Points));
-        FillPoints: @Template25FPoints;
+        FillPoints: PPointArray(@Template25FPoints);
         FillPointsCount: Succ(High(Template25FPoints));
         BezierizeCount: 4;
         RandPassesCount: 4;
@@ -2095,9 +2095,9 @@
         hasGirders: true;
         MaxHedgeHogs: 36;
        ),
-       (BasePoints: @Template26Points;
+       (BasePoints: PPointArray(@Template26Points);
         BasePointsCount: Succ(High(Template26Points));
-        FillPoints: @Template26FPoints;
+        FillPoints: PPointArray(@Template26FPoints);
         FillPointsCount: Succ(High(Template26FPoints));
         BezierizeCount: 2;
         RandPassesCount: 7;
@@ -2106,9 +2106,9 @@
         hasGirders: true;
         MaxHedgeHogs: 36;
        ),
-       (BasePoints: @Template27Points;
+       (BasePoints: PPointArray(@Template27Points);
         BasePointsCount: Succ(High(Template27Points));
-        FillPoints: @Template27FPoints;
+        FillPoints: PPointArray(@Template27FPoints);
         FillPointsCount: Succ(High(Template27FPoints));
         BezierizeCount: 1;
         RandPassesCount: 5;
@@ -2117,9 +2117,9 @@
         hasGirders: true;
         MaxHedgeHogs: 36;
        ),
-       (BasePoints: @Template28Points;
+       (BasePoints: PPointArray(@Template28Points);
         BasePointsCount: Succ(High(Template28Points));
-        FillPoints: @Template28FPoints;
+        FillPoints: PPointArray(@Template28FPoints);
         FillPointsCount: Succ(High(Template28FPoints));
         BezierizeCount: 2;
         RandPassesCount: 6;
@@ -2128,9 +2128,9 @@
         hasGirders: true;
         MaxHedgeHogs: 36;
        ),
-       (BasePoints: @Template29Points;
+       (BasePoints: PPointArray(@Template29Points);
         BasePointsCount: Succ(High(Template29Points));
-        FillPoints: @Template29FPoints;
+        FillPoints: PPointArray(@Template29FPoints);
         FillPointsCount: Succ(High(Template29FPoints));
         BezierizeCount: 1;
         RandPassesCount: 8;
@@ -2139,9 +2139,9 @@
         hasGirders: true;
         MaxHedgeHogs: 36;
        ),
-       (BasePoints: @Template30Points;
+       (BasePoints: PPointArray(@Template30Points);
         BasePointsCount: Succ(High(Template30Points));
-        FillPoints: @Template30FPoints;
+        FillPoints: PPointArray(@Template30FPoints);
         FillPointsCount: Succ(High(Template30FPoints));
         BezierizeCount: 3;
         RandPassesCount: 8;
@@ -2150,9 +2150,9 @@
         hasGirders: true;
         MaxHedgeHogs: 36;
        ),
-       (BasePoints: @Template31Points;
+       (BasePoints: PPointArray(@Template31Points);
         BasePointsCount: Succ(High(Template31Points));
-        FillPoints: @Template31FPoints;
+        FillPoints: PPointArray(@Template31FPoints);
         FillPointsCount: Succ(High(Template31FPoints));
         BezierizeCount: 3;
         RandPassesCount: 5;
@@ -2161,9 +2161,9 @@
         hasGirders: true;
         MaxHedgeHogs: 36;
        ),
-       (BasePoints: @Template32Points;
+       (BasePoints: PPointArray(@Template32Points);
         BasePointsCount: Succ(High(Template32Points));
-        FillPoints: @Template32FPoints;
+        FillPoints: PPointArray(@Template32FPoints);
         FillPointsCount: Succ(High(Template32FPoints));
         BezierizeCount: 3;
         RandPassesCount: 7;
@@ -2172,9 +2172,9 @@
         hasGirders: true;
         MaxHedgeHogs: 36;
        ),
-       (BasePoints: @Template33Points;
+       (BasePoints: PPointArray(@Template33Points);
         BasePointsCount: Succ(High(Template33Points));
-        FillPoints: @Template33FPoints;
+        FillPoints: PPointArray(@Template33FPoints);
         FillPointsCount: Succ(High(Template33FPoints));
         BezierizeCount: 2;
         RandPassesCount: 6;
@@ -2183,9 +2183,9 @@
         hasGirders: true;
         MaxHedgeHogs: 36;
        ),
-       (BasePoints: @Template34Points;
+       (BasePoints: PPointArray(@Template34Points);
         BasePointsCount: Succ(High(Template34Points));
-        FillPoints: @Template34FPoints;
+        FillPoints: PPointArray(@Template34FPoints);
         FillPointsCount: Succ(High(Template34FPoints));
         BezierizeCount: 2;
         RandPassesCount: 6;
@@ -2194,9 +2194,9 @@
         hasGirders: true;
         MaxHedgeHogs: 36;
        ),
-       (BasePoints: @Template35Points;
+       (BasePoints: PPointArray(@Template35Points);
         BasePointsCount: Succ(High(Template35Points));
-        FillPoints: @Template35FPoints;
+        FillPoints: PPointArray(@Template35FPoints);
         FillPointsCount: Succ(High(Template35FPoints));
         BezierizeCount: 3;
         RandPassesCount: 7;
@@ -2205,9 +2205,9 @@
         hasGirders: true;
         MaxHedgeHogs: 36;
        ),
-       (BasePoints: @Template36Points;
+       (BasePoints: PPointArray(@Template36Points);
         BasePointsCount: Succ(High(Template36Points));
-        FillPoints: @Template36FPoints;
+        FillPoints: PPointArray(@Template36FPoints);
         FillPointsCount: Succ(High(Template36FPoints));
         BezierizeCount: 4;
         RandPassesCount: 12;
@@ -2216,9 +2216,9 @@
         hasGirders: false;
         MaxHedgeHogs: 32;
        ),
-       (BasePoints: @Template37Points;
+       (BasePoints: PPointArray(@Template37Points);
         BasePointsCount: Succ(High(Template37Points));
-        FillPoints: @Template37FPoints;
+        FillPoints: PPointArray(@Template37FPoints);
         FillPointsCount: Succ(High(Template37FPoints));
         BezierizeCount: 3;
         RandPassesCount: 3;
@@ -2227,9 +2227,9 @@
         hasGirders: true;
         MaxHedgeHogs: 48;
        ),
-       (BasePoints: @Template38Points;
+       (BasePoints: PPointArray(@Template38Points);
         BasePointsCount: Succ(High(Template38Points));
-        FillPoints: @Template38FPoints;
+        FillPoints: PPointArray(@Template38FPoints);
         FillPointsCount: Succ(High(Template38FPoints));
         BezierizeCount: 4;
         RandPassesCount: 4;
@@ -2238,9 +2238,9 @@
         hasGirders: true;
         MaxHedgeHogs: 48;
        ),
-       (BasePoints: @Template39Points;
+       (BasePoints: PPointArray(@Template39Points);
         BasePointsCount: Succ(High(Template39Points));
-        FillPoints: @Template39FPoints;
+        FillPoints: PPointArray(@Template39FPoints);
         FillPointsCount: Succ(High(Template39FPoints));
         BezierizeCount: 3;
         RandPassesCount: 3;
@@ -2249,9 +2249,9 @@
         hasGirders: false;
         MaxHedgeHogs: 8;
        ),
-       (BasePoints: @Template40Points;
+       (BasePoints: PPointArray(@Template40Points);
         BasePointsCount: Succ(High(Template40Points));
-        FillPoints: @Template40FPoints;
+        FillPoints: PPointArray(@Template40FPoints);
         FillPointsCount: Succ(High(Template40FPoints));
         BezierizeCount: 3;
         RandPassesCount: 3;
@@ -2260,9 +2260,9 @@
         hasGirders: false;
         MaxHedgeHogs: 8;
        ),
-       (BasePoints: @Template41Points;
+       (BasePoints: PPointArray(@Template41Points);
         BasePointsCount: Succ(High(Template41Points));
-        FillPoints: @Template41FPoints;
+        FillPoints: PPointArray(@Template41FPoints);
         FillPointsCount: Succ(High(Template41FPoints));
         BezierizeCount: 2;
         RandPassesCount: 9;
@@ -2271,9 +2271,9 @@
         hasGirders: true;
         MaxHedgeHogs: 48;
        ),
-       (BasePoints: @Template42Points;
+       (BasePoints: PPointArray(@Template42Points);
         BasePointsCount: Succ(High(Template42Points));
-        FillPoints: @Template42FPoints;
+        FillPoints: PPointArray(@Template42FPoints);
         FillPointsCount: Succ(High(Template42FPoints));
         BezierizeCount: 3;
         RandPassesCount: 3;
@@ -2282,9 +2282,9 @@
         hasGirders: false;
         MaxHedgeHogs: 8;
        ),
-       (BasePoints: @Template43Points;
+       (BasePoints: PPointArray(@Template43Points);
         BasePointsCount: Succ(High(Template43Points));
-        FillPoints: @Template43FPoints;
+        FillPoints: PPointArray(@Template43FPoints);
         FillPointsCount: Succ(High(Template43FPoints));
         BezierizeCount: 2;
         RandPassesCount: 9;
@@ -2293,9 +2293,9 @@
         hasGirders: true;
         MaxHedgeHogs: 48;
        ),
-       (BasePoints: @Template44Points;
+       (BasePoints: PPointArray(@Template44Points);
         BasePointsCount: Succ(High(Template44Points));
-        FillPoints: @Template44FPoints;
+        FillPoints: PPointArray(@Template44FPoints);
         FillPointsCount: Succ(High(Template44FPoints));
         BezierizeCount: 5;
         RandPassesCount: 3;
@@ -2304,9 +2304,9 @@
         hasGirders: false;
         MaxHedgeHogs: 48;
        ),
-       (BasePoints: @Template45Points;
+       (BasePoints: PPointArray(@Template45Points);
         BasePointsCount: Succ(High(Template45Points));
-        FillPoints: @Template45FPoints;
+        FillPoints: PPointArray(@Template45FPoints);
         FillPointsCount: Succ(High(Template45FPoints));
         BezierizeCount: 5;
         RandPassesCount: 7;
--- a/hedgewars/uScript.pas	Tue Feb 11 22:05:03 2014 +0400
+++ b/hedgewars/uScript.pas	Wed Feb 12 00:50:15 2014 +0400
@@ -209,7 +209,7 @@
 begin
     if lua_gettop(L) = 1 then
         begin
-        t:= lua_tolstring(L,1,@c);
+        t:= lua_tolstring(L, 1, Psize_t(@c));
 
         for i:= 1 to c do s[i]:= t[i-1];
         s[0]:= char(c);
--- a/hedgewars/uStore.pas	Tue Feb 11 22:05:03 2014 +0400
+++ b/hedgewars/uStore.pas	Wed Feb 12 00:50:15 2014 +0400
@@ -1279,7 +1279,7 @@
 while length(tmpdesc) > 0 do
     begin
     tmpline:= tmpdesc;
-    SplitByChar(tmpline, tmpdesc, '|');
+    SplitByCharA(tmpline, tmpdesc, '|');
     if length(tmpline) > 0 then
         begin
         TTF_SizeUTF8(Fontz[font].Handle, PChar(tmpline), @i, @j);
@@ -1322,7 +1322,7 @@
 while length(tmpdesc) > 0 do
     begin
     tmpline:= tmpdesc;
-    SplitByChar(tmpline, tmpdesc, '|');
+    SplitByCharA(tmpline, tmpdesc, '|');
     r2:= r;
     if length(tmpline) > 0 then
         begin
@@ -1330,7 +1330,7 @@
 
         // render highlighted caption (if there is a ':')
         tmpline2:= _S'';
-        SplitByChar(tmpline, tmpline2, ':');
+        SplitByCharA(tmpline, tmpline2, ':');
         if length(tmpline2) > 0 then
             begin
             tmpline:= tmpline + ':';
--- a/hedgewars/uTextures.pas	Tue Feb 11 22:05:03 2014 +0400
+++ b/hedgewars/uTextures.pas	Wed Feb 12 00:50:15 2014 +0400
@@ -119,7 +119,7 @@
         tw:= (tw and $FF shl RShift) or (tw and $FF shl BShift) or (tw and $FF shl GShift) or (fromP4^[x] and AMask);
         fromP4^[x]:= tw;
         end;
-    fromP4:= @(fromP4^[Surf^.pitch div 4])
+    fromP4:= PLongWordArray(@(fromP4^[Surf^.pitch div 4]))
     end;
 end;
 
@@ -265,15 +265,15 @@
             toP4^[x]:= fromP4^[x];
         for x:= Surf^.w to Pred(tw) do
             toP4^[x]:= 0;
-        toP4:= @(toP4^[tw]);
-        fromP4:= @(fromP4^[Surf^.pitch div 4])
+        toP4:= PLongWordArray(@(toP4^[tw]));
+        fromP4:= PLongWordArray(@(fromP4^[Surf^.pitch div 4]))
         end;
 
     for y:= Surf^.h to Pred(th) do
         begin
         for x:= 0 to Pred(tw) do
             toP4^[x]:= 0;
-        toP4:= @(toP4^[tw])
+        toP4:= PLongWordArray(@(toP4^[tw]))
         end;
 
     glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tw, th, 0, GL_RGBA, GL_UNSIGNED_BYTE, tmpp);
--- a/hedgewars/uUtils.pas	Tue Feb 11 22:05:03 2014 +0400
+++ b/hedgewars/uUtils.pas	Wed Feb 12 00:50:15 2014 +0400
@@ -25,10 +25,7 @@
 
 procedure SplitBySpace(var a, b: shortstring);
 procedure SplitByChar(var a, b: shortstring; c: char);
-
-{$IFNDEF PAS2C}
-procedure SplitByChar(var a, b: ansistring; c: char);
-{$ENDIF}
+procedure SplitByCharA(var a, b: ansistring; c: char);
 
 function  EnumToStr(const en : TGearType) : shortstring; overload;
 function  EnumToStr(const en : TVisualGearType) : shortstring; overload;
@@ -130,17 +127,22 @@
 end;
 
 {$IFNDEF PAS2C}
-procedure SplitByChar(var a, b: ansistring; c: char);
+procedure SetLengthA(var s: ansistring; len: Longword);
+begin
+    SetLength(s, len)
+end;
+{$ENDIF}
+
+procedure SplitByCharA(var a, b: ansistring; c: char);
 var i: LongInt;
 begin
 i:= Pos(c, a);
 if i > 0 then
     begin
     b:= copy(a, i + 1, Length(a) - i);
-    setlength(a, Pred(i));
+    SetLengthA(a, Pred(i));
     end else b:= '';
-end; { SplitByChar }
-{$ENDIF}
+end; { SplitByCharA }
 
 function EnumToStr(const en : TGearType) : shortstring; overload;
 begin
@@ -311,7 +313,7 @@
       begin
       CharArray[i - 1] := s[i];
       end;
-CharArray[Length(s)]:= #0;
+   CharArray[Length(s)]:= #0;
    Str2PChar:= @(CharArray[0]);
 end;
 
@@ -377,7 +379,7 @@
 {$ENDIF}
     exit;
 
-l:= Utf8ToUnicode(@tmpstr, PChar(s), min(length(tmpstr), length(s)))-1;
+l:= Utf8ToUnicode(PWideChar(@tmpstr), PChar(s), min(length(tmpstr), length(s)))-1;
 i:= 0;
 
 while i < l do
--- a/project_files/hwc/CMakeLists.txt	Tue Feb 11 22:05:03 2014 +0400
+++ b/project_files/hwc/CMakeLists.txt	Wed Feb 12 00:50:15 2014 +0400
@@ -63,6 +63,7 @@
 
 #compile the c files
 add_definitions(-DPAS2C)
+add_definitions(-Werror=incompatible-pointer-types)
 
 add_executable(hwengine WIN32 ${engine_sources})
 
--- a/project_files/hwc/rtl/misc.c	Tue Feb 11 22:05:03 2014 +0400
+++ b/project_files/hwc/rtl/misc.c	Wed Feb 12 00:50:15 2014 +0400
@@ -171,7 +171,7 @@
     return result;
 }
 
-astring fpcrtl_str2astr(string255 s)
+astring fpcrtl_str2astr(const string255 s)
 {
     astring result;
 
@@ -181,7 +181,7 @@
     return result;
 }
 
-string255 fpcrtl_astr2str(astring s)
+string255 fpcrtl_astr2str(const astring s)
 {
     string255 result;
 
@@ -193,7 +193,7 @@
 
 char __pcharBuf[256];
 
-char* fpcrtl__pchar__vars(string255 * s)
+char* fpcrtl__pchar__vars(const string255 * s)
 {
     memcpy(__pcharBuf, &s->s[1], s->len);
     __pcharBuf[s->len] = 0;
--- a/project_files/hwc/rtl/misc.h	Tue Feb 11 22:05:03 2014 +0400
+++ b/project_files/hwc/rtl/misc.h	Wed Feb 12 00:50:15 2014 +0400
@@ -50,12 +50,12 @@
 
 #define     fpcrtl__pchar(s)                    fpcrtl__pchar__vars(&(s))
 #define     fpcrtl__pcharA(s)                   fpcrtl__pcharA__vars(&(s))
-char*       fpcrtl__pchar__vars(string255 * s);
+char*       fpcrtl__pchar__vars(const string255 * s);
 char*       fpcrtl__pcharA__vars(astring * s);
 string255   fpcrtl_pchar2str(const char *s);
 astring     fpcrtl_pchar2astr(const char *s);
-astring     fpcrtl_str2astr(string255 s);
-string255   fpcrtl_astr2str(astring s);
+astring     fpcrtl_str2astr(const string255 s);
+string255   fpcrtl_astr2str(const astring s);
 #define     fpcrtl_TypeInfo                         sizeof // dummy
 
 #ifdef EMSCRIPTEN
--- a/project_files/hwc/rtl/pas2c.h	Tue Feb 11 22:05:03 2014 +0400
+++ b/project_files/hwc/rtl/pas2c.h	Wed Feb 12 00:50:15 2014 +0400
@@ -23,15 +23,15 @@
 typedef union astring_
     {
         struct {
-            unsigned char _dummy1;
-            string255 str255;
+            uint16_t len;
         };
         struct {
             unsigned char _dummy2;
             unsigned char s[MAX_ANSISTRING_LENGTH + 1];
         };
         struct {
-            uint16_t len;
+            unsigned char _dummy1;
+            string255 str255;
         };
     } astring;
 
--- a/project_files/hwc/rtl/system.c	Tue Feb 11 22:05:03 2014 +0400
+++ b/project_files/hwc/rtl/system.c	Wed Feb 12 00:50:15 2014 +0400
@@ -66,20 +66,18 @@
         count = s.len + 1 - index;
     }
 
-    memcpy(result.s + 1, s.s + index - 1, count);
+    memcpy(result.s + 1, s.s + index, count);
 
     result.len = count;
 
     return result;
 }
 
-void fpcrtl_delete__vars(string255 *s, SizeInt index, SizeInt count) {
+void __attribute__((overloadable)) fpcrtl_delete__vars(string255 *s, SizeInt index, SizeInt count) {
     // number of chars to be move
     int num_move;
     int new_length;
 
-    string255 temp = *s;
-
     if (index < 1) {
         // in fpc, if index < 1, the string won't be modified
         return;
@@ -90,7 +88,6 @@
     }
 
     if (count > s->len - index + 1) {
-        s->str[index - 1] = 0;
         s->len = index - 1;
         return;
     }
@@ -98,13 +95,41 @@
     num_move = s->len - index + 1 - count;
     new_length = s->len - count;
 
-    memmove(s->str + index - 1, temp.str + index - 1 + count, num_move);
+    memmove(s->str + index - 1, s->str + index - 1 + count, num_move);
     s->str[new_length] = 0;
 
     s->len = new_length;
 
 }
 
+void __attribute__((overloadable)) fpcrtl_delete__vars(astring *s, SizeInt index, SizeInt count) {
+    // number of chars to be move
+    int num_move;
+    int new_length;
+
+    if (index < 1) {
+        // in fpc, if index < 1, the string won't be modified
+        return;
+    }
+
+    if(index > s->len){
+        return;
+    }
+
+    if (count > s->len - index + 1) {
+        s->len = index - 1;
+        return;
+    }
+
+    num_move = s->len - index + 1 - count;
+    new_length = s->len - count;
+
+    memmove(s->s + index, s->s + index + count, num_move);
+
+    s->len = new_length;
+
+}
+
 string255 fpcrtl_floatToStr(double n) {
     string255 t;
     sprintf(t.str, "%f", n);
@@ -127,7 +152,7 @@
 
 Integer __attribute__((overloadable)) fpcrtl_pos(string255 substr, string255 str) {
 
-    char* p;
+    unsigned char* p;
 
     if (str.len == 0) {
         return 0;
@@ -146,12 +171,20 @@
         return 0;
     }
 
-    return strlen(str.str) - strlen(p) + 1;
+    return p - (unsigned char*)&str.s;
+}
+
+Integer __attribute__((overloadable)) fpcrtl_pos(Char c, astring str) {
+    string255 t;
+    t.len = 1;
+    t.str[0] = c;
+    t.str[1] = 0;
+    return fpcrtl_pos(t, str);
 }
 
 Integer __attribute__((overloadable)) fpcrtl_pos(string255 substr, astring str) {
 
-    char* p;
+    unsigned char* p;
 
     if (str.len == 0) {
         return 0;
@@ -170,7 +203,7 @@
         return 0;
     }
 
-    return str.len - strlen(p) + 1;
+    return p - (unsigned char *)&str.s;
 }
 
 Integer fpcrtl_length(string255 s) {
--- a/project_files/hwc/rtl/system.h	Tue Feb 11 22:05:03 2014 +0400
+++ b/project_files/hwc/rtl/system.h	Wed Feb 12 00:50:15 2014 +0400
@@ -30,7 +30,8 @@
  * and the length of the string is adjusted.
  */
 #define     fpcrtl_delete(s, index, count)                  fpcrtl_delete__vars(&(s), index, count)
-void        fpcrtl_delete__vars(string255 *s, SizeInt index, SizeInt count);
+void        __attribute__((overloadable))                   fpcrtl_delete__vars(string255 *s, SizeInt index, SizeInt count);
+void        __attribute__((overloadable))                   fpcrtl_delete__vars(astring *s, SizeInt index, SizeInt count);
 
 string255   fpcrtl_floatToStr(double n);
 
@@ -44,12 +45,15 @@
 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     __attribute__((overloadable))                   fpcrtl_pos(Char c, astring str);
 
 Integer     fpcrtl_length(string255 s);
 #define     fpcrtl_Length                                   fpcrtl_length
 Integer     fpcrtl_lengthA(astring s);
 #define     fpcrtl_LengthA                                  fpcrtl_lengthA
 
+#define     fpcrtl_SetLengthA(s, l)                         do{(s).len = (l);}while(0)
+
 #define     fpcrtl_sqr(x)                                   ((x) * (x))
 
 #define     fpcrtl_odd(x)                                   ((x) % 2 != 0 ? true : false)
--- a/tools/pas2c/Pas2C.hs	Tue Feb 11 22:05:03 2014 +0400
+++ b/tools/pas2c/Pas2C.hs	Wed Feb 12 00:50:15 2014 +0400
@@ -699,6 +699,10 @@
 initExpr2C' (BuiltInFunction "succ" [e]) = liftM (<> text " + 1") $ initExpr2C' e
 initExpr2C' (BuiltInFunction "pred" [e]) = liftM (<> text " - 1") $ initExpr2C' e
 initExpr2C' b@(BuiltInFunction _ _) = error $ show b
+initExpr2C' (InitTypeCast t' i) = do
+    e <- initExpr2C i
+    t <- id2C IOLookup t'
+    return . parens $ parens t <> e
 initExpr2C' a = error $ "initExpr2C: don't know how to render " ++ show a
 
 
--- a/tools/pas2c/PascalParser.hs	Tue Feb 11 22:05:03 2014 +0400
+++ b/tools/pas2c/PascalParser.hs	Wed Feb 12 00:50:15 2014 +0400
@@ -629,7 +629,7 @@
         , char' '$' >> many hexDigit >>= \h -> comments >> return (InitHexNumber h)
         , char' '@' >> initExpression >>= \c -> comments >> return (InitAddress c)
         , try $ string' "nil" >> return InitNull
-        , itypeCast
+        , try itypeCast
         , iD >>= return . InitReference
         ]
 
@@ -681,10 +681,11 @@
         ]
 
     itypeCast = do
-        t <- choice $ map (\s -> try $ caseInsensitiveString s >>= \i -> notFollowedBy alphaNum >> return i) knownTypes
+        --t <- choice $ map (\s -> try $ caseInsensitiveString s >>= \i -> notFollowedBy alphaNum >> return i) knownTypes
+        t <- iD
         i <- parens pas initExpression
         comments
-        return $ InitTypeCast (Identifier t BTUnknown) i
+        return $ InitTypeCast t i
 
 builtInFunction :: Parsec String u a -> Parsec String u (String, [a])
 builtInFunction e = do