engine to c now compiles with some manual intervention (as of bug 596) webgl
authorkoda
Thu, 04 Apr 2013 01:38:30 +0200
branchwebgl
changeset 8850 ae8a957c69fd
parent 8847 ff7fbab7cd56
child 8853 ef59a44a9f08
engine to c now compiles with some manual intervention (as of bug #596)
hedgewars/ArgParsers.inc
hedgewars/GSHandlers.inc
hedgewars/uChat.pas
hedgewars/uLandOutline.pas
hedgewars/uLocale.pas
hedgewars/uUtils.pas
project_files/hwc/rtl/system.c
project_files/hwc/rtl/system.h
--- a/hedgewars/ArgParsers.inc	Thu Apr 04 00:32:57 2013 +0200
+++ b/hedgewars/ArgParsers.inc	Thu Apr 04 01:38:30 2013 +0200
@@ -93,7 +93,7 @@
         end
 end;
 
-function parseNick(nick: String): String;
+function parseNick(nick: shortstring): shortstring;
 begin
     if isInternal then
         parseNick:= DecodeBase64(nick)
@@ -140,18 +140,22 @@
 {$ENDIF}
 end;
 
-function getLongIntParameter(str:String; var paramIndex:LongInt; var wrongParameter:Boolean): LongInt;
+function getLongIntParameter(str:shortstring; var paramIndex:LongInt; var wrongParameter:Boolean): LongInt;
 var tmpInt, c: LongInt;
 begin
     inc(paramIndex);
+{$IFDEF PAS2C}
+    val(str, tmpInt);
+{$ELSE}
     val(str, tmpInt, c);
     wrongParameter:= c <> 0;
     if wrongParameter then
         WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a number, you passed "'+str+'"');
+{$ENDIF}
     getLongIntParameter:= tmpInt;
 end;
 
-function getStringParameter(str:String; var paramIndex:LongInt; var wrongParameter:Boolean): String;
+function getStringParameter(str:shortstring; var paramIndex:LongInt; var wrongParameter:Boolean): shortstring;
 begin
     inc(paramIndex);
     wrongParameter:= (str='') or (Copy(str,1,2) = '--');
@@ -160,14 +164,14 @@
     getStringParameter:= str;
 end;
 
-procedure parseClassicParameter(cmdarray: array of String; size:LongInt; var paramIndex:LongInt); forward;
+procedure parseClassicParameter(cmdarray: array of shortstring; size:LongInt; var paramIndex:LongInt); forward;
 
-function parseParameter(cmd:String; arg:String; var paramIndex:LongInt): Boolean;
-const videoarray: array [0..4] of String = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth');
-      audioarray: array [0..2] of String = ('--volume','--nomusic','--nosound');
-      otherarray: array [0..2] of String = ('--locale','--fullscreen','--showfps');
-      mediaarray: array [0..9] of String = ('--fullscreen-width', '--fullscreen-height', '--width', '--height', '--depth', '--volume','--nomusic','--nosound','--locale','--fullscreen');
-      allarray: array [0..13] of String = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth','--volume','--nomusic','--nosound','--locale','--fullscreen','--showfps','--altdmg','--frame-interval','--low-quality');
+function parseParameter(cmd:shortstring; arg:shortstring; var paramIndex:LongInt): Boolean;
+const videoarray: array [0..4] of shortstring = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth');
+      audioarray: array [0..2] of shortstring = ('--volume','--nomusic','--nosound');
+      otherarray: array [0..2] of shortstring = ('--locale','--fullscreen','--showfps');
+      mediaarray: array [0..9] of shortstring = ('--fullscreen-width', '--fullscreen-height', '--width', '--height', '--depth', '--volume','--nomusic','--nosound','--locale','--fullscreen');
+      allarray: array [0..13] of shortstring = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth','--volume','--nomusic','--nosound','--locale','--fullscreen','--showfps','--altdmg','--frame-interval','--low-quality');
       reallyAll: array[0..30] of shortstring = (
                 '--prefix', '--user-prefix', '--locale', '--fullscreen-width', '--fullscreen-height', '--width', 
                 '--height', '--frame-interval', '--volume','--nomusic', '--nosound',
@@ -233,10 +237,10 @@
     end;
 end;
 
-procedure parseClassicParameter(cmdarray: array of String; size:LongInt; var paramIndex:LongInt);
+procedure parseClassicParameter(cmdarray: array of shortstring; size:LongInt; var paramIndex:LongInt);
 var index, tmpInt: LongInt;
     isBool, isValid: Boolean;
-    cmd, arg, newSyntax: String;
+    cmd, arg, newSyntax: shortstring;
 begin
     WriteLn(stdout, 'WARNING: you are using a deprecated command, which could be removed in a future version!');
     WriteLn(stdout, '         Consider updating to the latest syntax, which is much more flexible!');
--- a/hedgewars/GSHandlers.inc	Thu Apr 04 00:32:57 2013 +0200
+++ b/hedgewars/GSHandlers.inc	Thu Apr 04 01:38:30 2013 +0200
@@ -1233,7 +1233,7 @@
             Gear^.X := Gear^.X + Gear^.dX;
             Gear^.Y := Gear^.Y + _1_9;
             end;
-        SetAllHHToActive;
+        SetAllHHToActive(true);
         end;
     if TestCollisionYwithGear(Gear, 1) <> 0 then
         begin
@@ -2338,7 +2338,7 @@
     else
         begin
         DeleteCI(HHGear);
-        SetAllHHToActive;
+        SetAllHHToActive(true);
         Gear^.doStep := @doStepTeleportAnim;
 
   // copy old HH position and direction to Gear (because we need them for drawing the vanishing hog)
@@ -5207,14 +5207,14 @@
                     UpdateLandTexture(landRect.x, landRect.w, landRect.y, landRect.h, true);
 
                     // FillRoundInLandWithIce(Target.X, Target.Y, iceRadius);
-                    SetAllHHToActive;
+                    SetAllHHToActive(true);
                     Timer := iceWaitCollision;
                     end;
 
                 if (Timer = iceCollideWithWater) and ((GameTicks - Power) > groundFreezingTime) then
                     begin
                     DrawIceBreak(Target.X, cWaterLine - iceHeight, iceRadius, iceHeight);
-                    SetAllHHToActive;
+                    SetAllHHToActive(true);
                     Timer := iceWaitCollision;
                     end;
 
--- a/hedgewars/uChat.pas	Thu Apr 04 00:32:57 2013 +0200
+++ b/hedgewars/uChat.pas	Thu Apr 04 01:38:30 2013 +0200
@@ -41,7 +41,7 @@
     Width: LongInt;
     s: shortstring;
     end;
-    TChatCmd = (quit, pause, finish, fullscreen);
+    TChatCmd = (quitCmd, pauseCmd, finishCmd, fullscreenCmd);
 
 var Strs: array[0 .. MaxStrIndex] of TChatLine;
     MStrs: array[0 .. MaxStrIndex] of shortstring;
--- a/hedgewars/uLandOutline.pas	Thu Apr 04 00:32:57 2013 +0200
+++ b/hedgewars/uLandOutline.pas	Thu Apr 04 01:38:30 2013 +0200
@@ -27,8 +27,6 @@
                                      end
            end;
 
-const
-    cMaxEdgePoints = 16384;
 
 procedure Push(_xl, _xr, _y, _dir: LongInt);
 begin
--- a/hedgewars/uLocale.pas	Thu Apr 04 00:32:57 2013 +0200
+++ b/hedgewars/uLocale.pas	Thu Apr 04 01:38:30 2013 +0200
@@ -62,10 +62,10 @@
         if (s[1] < '0') or (s[1] > '9') then
             continue;
         TryDo(Length(s) > 6, 'Load locale: empty string', true);
-        val(s[1]+s[2], a, c);
+        val(s[1]+s[2], a{$IFNDEF PAS2C}, c{$ENDIF});
         TryDo(c = 0, 'Load locale: numbers should be two-digit: ' + s, true);
         TryDo(s[3] = ':', 'Load locale: ":" expected', true);
-        val(s[4]+s[5], b, c);
+        val(s[4]+s[5], b{$IFNDEF PAS2C}, c{$ENDIF});
         TryDo(c = 0, 'Load locale: numbers should be two-digit' + s, true);
         TryDo(s[6] = '=', 'Load locale: "=" expected', true);
         Delete(s, 1, 6);
--- a/hedgewars/uUtils.pas	Thu Apr 04 00:32:57 2013 +0200
+++ b/hedgewars/uUtils.pas	Thu Apr 04 01:38:30 2013 +0200
@@ -194,14 +194,18 @@
 str(n, IntToStr)
 end;
 
-function  StrToInt(s: shortstring): LongInt;
+function StrToInt(s: shortstring): LongInt;
 var c: LongInt;
 begin
+{$IFDEF PAS2C}
+val(s, StrToInt);
+{$ELSE}
 val(s, StrToInt, c);
 {$IFDEF DEBUGFILE}
 if c <> 0 then
     writeln(f, 'Error at position ' + IntToStr(c) + ' : ' + s[c])
 {$ENDIF}
+{$ENDIF}
 end;
 
 function FloatToStr(n: hwFloat): shortstring;
--- a/project_files/hwc/rtl/system.c	Thu Apr 04 00:32:57 2013 +0200
+++ b/project_files/hwc/rtl/system.c	Thu Apr 04 01:38:30 2013 +0200
@@ -169,23 +169,21 @@
     // decimal
     return atoi(src);
 }
-void __attribute__((overloadable)) fpcrtl_val__vars(string255 s, LongInt *a,
-        LongInt *c) {
-    *c = 0; // no error
+
+void __attribute__((overloadable)) fpcrtl_val__vars(string255 s, LongInt *a)
+{
     FIX_STRING(s);
     *a = str_to_int(s.str);
 }
 
-void __attribute__((overloadable)) fpcrtl_val__vars(string255 s, Byte *a,
-        LongInt *c) {
-    *c = 0; // no error
+void __attribute__((overloadable)) fpcrtl_val__vars(string255 s, Byte *a)
+{
     FIX_STRING(s);
     *a = str_to_int(s.str);
 }
 
-void __attribute__((overloadable)) fpcrtl_val__vars(string255 s, LongWord *a,
-        LongInt *c) {
-    *c = 0; // no error
+void __attribute__((overloadable)) fpcrtl_val__vars(string255 s, LongWord *a)
+{
     FIX_STRING(s);
     *a = str_to_int(s.str);
 }
--- a/project_files/hwc/rtl/system.h	Thu Apr 04 00:32:57 2013 +0200
+++ b/project_files/hwc/rtl/system.h	Thu Apr 04 01:38:30 2013 +0200
@@ -77,10 +77,10 @@
 
 Integer     fpcrtl_trunc(extended n);
 
-#define     fpcrtl_val(s, a, c)                             fpcrtl_val__vars(s, &(a), &(c))
-void        __attribute__((overloadable))                   fpcrtl_val__vars(string255 s, LongInt *a, LongInt *c);
-void        __attribute__((overloadable))                   fpcrtl_val__vars(string255 s, Byte *a, LongInt *c);
-void        __attribute__((overloadable))                   fpcrtl_val__vars(string255 s, LongWord *a, LongInt *c);
+#define     fpcrtl_val(s, a)                                fpcrtl_val__vars(s, &(a))
+void        __attribute__((overloadable))                   fpcrtl_val__vars(string255 s, LongInt *a);
+void        __attribute__((overloadable))                   fpcrtl_val__vars(string255 s, Byte *a);
+void        __attribute__((overloadable))                   fpcrtl_val__vars(string255 s, LongWord *a);
 
 #define     fpcrtl_randomize()                              srand(time(NULL))