- Remove support for variables in command handlers
authorunc0rr
Sat, 21 Apr 2012 19:51:13 +0400
changeset 6898 344b0dbd9690
parent 6897 a9126661f613
child 6899 c3d44a836086
- Remove support for variables in command handlers - Make parameter to RegisterVariable typed instead of just pointer - Catch a bug due to wrong type passed to RegisterVariable
hedgewars/pas2c.h
hedgewars/pas2cSystem.pas
hedgewars/uAmmos.pas
hedgewars/uChat.pas
hedgewars/uCommandHandlers.pas
hedgewars/uCommands.pas
hedgewars/uGears.pas
hedgewars/uIO.pas
hedgewars/uLand.pas
hedgewars/uLandPainted.pas
hedgewars/uSound.pas
hedgewars/uStore.pas
hedgewars/uTeams.pas
--- a/hedgewars/pas2c.h	Fri Apr 20 23:03:20 2012 +0400
+++ b/hedgewars/pas2c.h	Sat Apr 21 19:51:13 2012 +0400
@@ -54,9 +54,22 @@
 
 void __FillChar(pointer p, int size, char fill);
 string255 _strconcat(string255 a, string255 b);
+string255 _strappend(string255 s, char c);
+string255 _strprepend(char c, string255 s);
+char * _pchar(string255 s);
 
 int Length(string255 a);
 string255 copy(string255 a, int s, int l);
 string255 delete(string255 a, int s, int l);
 
 #define STRCONSTDECL(a, b) const string255 a = {.len = sizeof(b), .str = b}
+
+typedef int file;
+extern int FileMode;
+extern int IOResult;
+
+void assign(int f, string255 fileName);
+void reset(int f, int size);
+#define BlockRead(a, b, c, d) BlockRead_(a, &(b), c, &(d))
+void BlockRead_(int f, void * p, int size, int * sizeRead);
+void close(int f);
--- a/hedgewars/pas2cSystem.pas	Fri Apr 20 23:03:20 2012 +0400
+++ b/hedgewars/pas2cSystem.pas	Sat Apr 21 19:51:13 2012 +0400
@@ -67,6 +67,7 @@
     StrPas, FormatDateTime, copy, delete, str, pos, trim : function : shortstring;
     Length, StrToInt : function : integer;
     SetLength, val : procedure;
+    _pchar : function : PChar;
 
     assign, rewrite, reset, flush, BlockWrite, BlockRead, close : procedure;
     IOResult : function : integer;
@@ -131,7 +132,7 @@
     
     Assigned : function : boolean;
     
-    _strconcat : function : string;
+    _strconcat, _strappend, _strprepend : function : string;
     _strcompare, _strncompare : function : boolean;
 
     png_structp, png_set_write_fn, png_get_io_ptr,
--- a/hedgewars/uAmmos.pas	Fri Apr 20 23:03:20 2012 +0400
+++ b/hedgewars/uAmmos.pas	Sat Apr 21 19:51:13 2012 +0400
@@ -26,10 +26,10 @@
 procedure freeModule;
 
 procedure AddAmmoStore;
-procedure SetAmmoLoadout(s: shortstring);
-procedure SetAmmoProbability(s: shortstring);
-procedure SetAmmoDelay(s: shortstring);
-procedure SetAmmoReinforcement(s: shortstring);
+procedure SetAmmoLoadout(var s: shortstring);
+procedure SetAmmoProbability(var s: shortstring);
+procedure SetAmmoDelay(var s: shortstring);
+procedure SetAmmoReinforcement(var s: shortstring);
 procedure AssignStores;
 procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType);
 procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType; cnt: LongWord);
@@ -421,22 +421,22 @@
         Ammoz[t].Probability:= 0
 end;
 
-procedure SetAmmoLoadout(s: shortstring);
+procedure SetAmmoLoadout(var s: shortstring);
 begin
     ammoLoadout:= s;
 end;
 
-procedure SetAmmoProbability(s: shortstring);
+procedure SetAmmoProbability(var s: shortstring);
 begin
     ammoProbability:= s;
 end;
 
-procedure SetAmmoDelay(s: shortstring);
+procedure SetAmmoDelay(var s: shortstring);
 begin
     ammoDelay:= s;
 end;
 
-procedure SetAmmoReinforcement(s: shortstring);
+procedure SetAmmoReinforcement(var s: shortstring);
 begin
     ammoReinforcement:= s;
 end;
@@ -470,11 +470,11 @@
 procedure initModule;
 var i: Longword;
 begin
-    RegisterVariable('ammloadt', vtCommand, @SetAmmoLoadout, false);
-    RegisterVariable('ammdelay', vtCommand, @SetAmmoDelay, false);
-    RegisterVariable('ammprob',  vtCommand, @SetAmmoProbability, false);
-    RegisterVariable('ammreinf', vtCommand, @SetAmmoReinforcement, false);
-    RegisterVariable('ammstore', vtCommand, @chAddAmmoStore , false);
+    RegisterVariable('ammloadt', @SetAmmoLoadout, false);
+    RegisterVariable('ammdelay', @SetAmmoDelay, false);
+    RegisterVariable('ammprob',  @SetAmmoProbability, false);
+    RegisterVariable('ammreinf', @SetAmmoReinforcement, false);
+    RegisterVariable('ammstore', @chAddAmmoStore , false);
 
     StoreCnt:= 0;
     ammoLoadout:= '';
--- a/hedgewars/uChat.pas	Fri Apr 20 23:03:20 2012 +0400
+++ b/hedgewars/uChat.pas	Sat Apr 21 19:51:13 2012 +0400
@@ -388,11 +388,11 @@
 procedure initModule;
 var i: ShortInt;
 begin
-    RegisterVariable('chatmsg', vtCommand, @chChatMessage, true);
-    RegisterVariable('say', vtCommand, @chSay, true);
-    RegisterVariable('team', vtCommand, @chTeamSay, true);
-    RegisterVariable('history', vtCommand, @chHistory, true );
-    RegisterVariable('chat', vtCommand, @chChat, true );
+    RegisterVariable('chatmsg', @chChatMessage, true);
+    RegisterVariable('say', @chSay, true);
+    RegisterVariable('team', @chTeamSay, true);
+    RegisterVariable('history', @chHistory, true );
+    RegisterVariable('chat', @chChat, true );
 
     lastStr:= 0;
     visibleCount:= 0;
--- a/hedgewars/uCommandHandlers.pas	Fri Apr 20 23:03:20 2012 +0400
+++ b/hedgewars/uCommandHandlers.pas	Sat Apr 21 19:51:13 2012 +0400
@@ -659,90 +659,191 @@
     ZoomValue:= cDefaultZoomLevel;
 end;
 
+procedure chMapGen(var s: shortstring);
+begin
+val(s, cMapGen)
+end;
+
+procedure chTemplateFilter(var s: shortstring);
+begin
+val(s, cTemplateFilter)
+end;
+
+procedure chInactDelay(var s: shortstring);
+begin
+val(s, cInactDelay)
+end;
+
+procedure chReadyDelay(var s: shortstring);
+begin
+val(s, cReadyDelay)
+end;
+
+procedure chCaseFactor(var s: shortstring);
+begin
+val(s, cCaseFactor)
+end;
+
+procedure chHealthCaseProb(var s: shortstring);
+begin
+val(s, cHealthCaseProb)
+end;
+
+procedure chHealthCaseAmount(var s: shortstring);
+begin
+val(s, cHealthCaseAmount)
+end;
+
+procedure chSuddenDTurns(var s: shortstring);
+begin
+val(s, cSuddenDTurns)
+end;
+
+procedure chWaterRise(var s: shortstring);
+begin
+val(s, cWaterRise)
+end;
+
+procedure chHealthDecrease(var s: shortstring);
+begin
+val(s, cHealthDecrease)
+end;
+
+procedure chDamagePercent(var s: shortstring);
+begin
+val(s, cDamagePercent)
+end;
+
+procedure chRopePercent(var s: shortstring);
+begin
+val(s, cRopePercent)
+end;
+
+procedure chGetAwayTime(var s: shortstring);
+begin
+val(s, cGetAwayTime)
+end;
+
+procedure chMineDudPercent(var s: shortstring);
+begin
+val(s, cMineDudPercent)
+end;
+
+procedure chLandMines(var s: shortstring);
+begin
+val(s, cLandMines)
+end;
+
+procedure chExplosives(var s: shortstring);
+begin
+val(s, cExplosives)
+end;
+
+procedure chGameFlags(var s: shortstring);
+begin
+val(s, GameFlags)
+end;
+
+procedure chHedgehogTurnTime(var s: shortstring);
+begin
+val(s, cHedgehogTurnTime)
+end;
+
+procedure chMinesTime(var s: shortstring);
+begin
+val(s, cMinesTime)
+end;
+
+procedure chFastUntilLag(var s: shortstring);
+var i: LongInt;
+begin
+val(s, i);
+fastUntilLag:= i <> 0
+end;
 
 procedure initModule;
 begin
 //////// Begin top sorted by freq analysis not including chatmsg
-    RegisterVariable('+right'  , vtCommand, @chRight_p      , false);
-    RegisterVariable('-right'  , vtCommand, @chRight_m      , false);
-    RegisterVariable('+up'     , vtCommand, @chUp_p         , false);
-    RegisterVariable('-up'     , vtCommand, @chUp_m         , false);
-    RegisterVariable('+left'   , vtCommand, @chLeft_p       , false);
-    RegisterVariable('-left'   , vtCommand, @chLeft_m       , false);
-    RegisterVariable('+attack' , vtCommand, @chAttack_p     , false);
-    RegisterVariable('+down'   , vtCommand, @chDown_p       , false);
-    RegisterVariable('-down'   , vtCommand, @chDown_m       , false);
-    RegisterVariable('hjump'   , vtCommand, @chHJump        , false);
-    RegisterVariable('ljump'   , vtCommand, @chLJump        , false);
-    RegisterVariable('nextturn', vtCommand, @chNextTurn     , false);
-    RegisterVariable('-attack' , vtCommand, @chAttack_m     , false);
-    RegisterVariable('slot'    , vtCommand, @chSlot         , false);
-    RegisterVariable('setweap' , vtCommand, @chSetWeapon    , false);
+    RegisterVariable('+right'  , @chRight_p      , false);
+    RegisterVariable('-right'  , @chRight_m      , false);
+    RegisterVariable('+up'     , @chUp_p         , false);
+    RegisterVariable('-up'     , @chUp_m         , false);
+    RegisterVariable('+left'   , @chLeft_p       , false);
+    RegisterVariable('-left'   , @chLeft_m       , false);
+    RegisterVariable('+attack' , @chAttack_p     , false);
+    RegisterVariable('+down'   , @chDown_p       , false);
+    RegisterVariable('-down'   , @chDown_m       , false);
+    RegisterVariable('hjump'   , @chHJump        , false);
+    RegisterVariable('ljump'   , @chLJump        , false);
+    RegisterVariable('nextturn', @chNextTurn     , false);
+    RegisterVariable('-attack' , @chAttack_m     , false);
+    RegisterVariable('slot'    , @chSlot         , false);
+    RegisterVariable('setweap' , @chSetWeapon    , false);
 //////// End top by freq analysis
-    RegisterVariable('gencmd'  , vtCommand, @chGenCmd       , false);
-    RegisterVariable('flag'    , vtCommand, @chFlag         , false);
-    RegisterVariable('script'  , vtCommand, @chScript       , false);
-    RegisterVariable('proto'   , vtCommand, @chCheckProto   , true );
-    RegisterVariable('spectate', vtBoolean, @fastUntilLag   , false);
-    RegisterVariable('capture' , vtCommand, @chCapture      , true );
-    RegisterVariable('rotmask' , vtCommand, @chRotateMask   , true );
-    RegisterVariable('rdriven' , vtCommand, @chTeamLocal    , false);
-    RegisterVariable('map'     , vtCommand, @chSetMap       , false);
-    RegisterVariable('theme'   , vtCommand, @chSetTheme     , false);
-    RegisterVariable('seed'    , vtCommand, @chSetSeed      , false);
-    RegisterVariable('template_filter', vtLongInt, @cTemplateFilter, false);
-    RegisterVariable('mapgen'  , vtLongInt, @cMapGen        , false);
-    RegisterVariable('maze_size',vtLongInt, @cTemplateFilter, false);
-    RegisterVariable('delay'   , vtLongInt, @cInactDelay    , false);
-    RegisterVariable('ready'   , vtLongInt, @cReadyDelay    , false);
-    RegisterVariable('casefreq', vtLongInt, @cCaseFactor    , false);
-    RegisterVariable('healthprob', vtLongInt, @cHealthCaseProb, false);
-    RegisterVariable('hcaseamount', vtLongInt, @cHealthCaseAmount, false);
-    RegisterVariable('sd_turns', vtLongInt, @cSuddenDTurns  , false);
-    RegisterVariable('waterrise', vtLongInt, @cWaterRise    , false);
-    RegisterVariable('healthdec', vtLongInt, @cHealthDecrease, false);
-    RegisterVariable('damagepct',vtLongInt, @cDamagePercent , false);
-    RegisterVariable('ropepct' , vtLongInt, @cRopePercent   , false);
-    RegisterVariable('getawaytime' , vtLongInt, @cGetAwayTime , false);
-    RegisterVariable('minedudpct',vtLongInt,@cMineDudPercent, false);
-    RegisterVariable('minesnum', vtLongInt, @cLandMines     , false);
-    RegisterVariable('explosives',vtLongInt,@cExplosives    , false);
-    RegisterVariable('gmflags' , vtLongInt, @GameFlags      , false);
-    RegisterVariable('turntime', vtLongInt, @cHedgehogTurnTime, false);
-    RegisterVariable('minestime',vtLongInt, @cMinesTime     , false);
-    RegisterVariable('fort'    , vtCommand, @chFort         , false);
-    RegisterVariable('grave'   , vtCommand, @chGrave        , false);
-    RegisterVariable('hat'     , vtCommand, @chSetHat       , false);
-    RegisterVariable('quit'    , vtCommand, @chQuit         , true );
-    RegisterVariable('forcequit', vtCommand, @chForceQuit   , true );
-    RegisterVariable('confirm' , vtCommand, @chConfirm      , true );
-    RegisterVariable('halt',     vtCommand, @chHalt         , true );
-    RegisterVariable('+speedup', vtCommand, @chSpeedup_p    , true );
-    RegisterVariable('-speedup', vtCommand, @chSpeedup_m    , true );
-    RegisterVariable('zoomin'  , vtCommand, @chZoomIn       , true );
-    RegisterVariable('zoomout' , vtCommand, @chZoomOut      , true );
-    RegisterVariable('zoomreset',vtCommand, @chZoomReset    , true );
-    RegisterVariable('ammomenu', vtCommand, @chAmmoMenu     , true);
-    RegisterVariable('+precise', vtCommand, @chPrecise_p    , false);
-    RegisterVariable('-precise', vtCommand, @chPrecise_m    , false);
-    RegisterVariable('switch'  , vtCommand, @chSwitch       , false);
-    RegisterVariable('timer'   , vtCommand, @chTimer        , false);
-    RegisterVariable('taunt'   , vtCommand, @chTaunt        , false);
-    RegisterVariable('put'     , vtCommand, @chPut          , false);
-    RegisterVariable('+volup'  , vtCommand, @chVol_p        , true );
-    RegisterVariable('-volup'  , vtCommand, @chVol_m        , true );
-    RegisterVariable('+voldown', vtCommand, @chVol_m        , true );
-    RegisterVariable('-voldown', vtCommand, @chVol_p        , true );
-    RegisterVariable('findhh'  , vtCommand, @chFindhh       , true );
-    RegisterVariable('pause'   , vtCommand, @chPause        , true );
-    RegisterVariable('+cur_u'  , vtCommand, @chCurU_p       , true );
-    RegisterVariable('-cur_u'  , vtCommand, @chCurU_m       , true );
-    RegisterVariable('+cur_d'  , vtCommand, @chCurD_p       , true );
-    RegisterVariable('-cur_d'  , vtCommand, @chCurD_m       , true );
-    RegisterVariable('+cur_l'  , vtCommand, @chCurL_p       , true );
-    RegisterVariable('-cur_l'  , vtCommand, @chCurL_m       , true );
-    RegisterVariable('+cur_r'  , vtCommand, @chCurR_p       , true );
-    RegisterVariable('-cur_r'  , vtCommand, @chCurR_m       , true );
+    RegisterVariable('gencmd'  , @chGenCmd       , false);
+    RegisterVariable('flag'    , @chFlag         , false);
+    RegisterVariable('script'  , @chScript       , false);
+    RegisterVariable('proto'   , @chCheckProto   , true );
+    RegisterVariable('spectate', @chFastUntilLag   , false);
+    RegisterVariable('capture' , @chCapture      , true );
+    RegisterVariable('rotmask' , @chRotateMask   , true );
+    RegisterVariable('rdriven' , @chTeamLocal    , false);
+    RegisterVariable('map'     , @chSetMap       , false);
+    RegisterVariable('theme'   , @chSetTheme     , false);
+    RegisterVariable('seed'    , @chSetSeed      , false);
+    RegisterVariable('template_filter', @chTemplateFilter, false);
+    RegisterVariable('mapgen'  , @chMapGen        , false);
+    RegisterVariable('maze_size',@chTemplateFilter, false);
+    RegisterVariable('delay'   , @chInactDelay    , false);
+    RegisterVariable('ready'   , @chReadyDelay    , false);
+    RegisterVariable('casefreq', @chCaseFactor    , false);
+    RegisterVariable('healthprob', @chHealthCaseProb, false);
+    RegisterVariable('hcaseamount', @chHealthCaseAmount, false);
+    RegisterVariable('sd_turns', @chSuddenDTurns  , false);
+    RegisterVariable('waterrise', @chWaterRise    , false);
+    RegisterVariable('healthdec', @chHealthDecrease, false);
+    RegisterVariable('damagepct',@chDamagePercent , false);
+    RegisterVariable('ropepct' , @chRopePercent   , false);
+    RegisterVariable('getawaytime' , @chGetAwayTime , false);
+    RegisterVariable('minedudpct',@chMineDudPercent, false);
+    RegisterVariable('minesnum', @chLandMines     , false);
+    RegisterVariable('explosives',@chExplosives    , false);
+    RegisterVariable('gmflags' , @chGameFlags      , false);
+    RegisterVariable('turntime', @chHedgehogTurnTime, false);
+    RegisterVariable('minestime',@chMinesTime     , false);
+    RegisterVariable('fort'    , @chFort         , false);
+    RegisterVariable('grave'   , @chGrave        , false);
+    RegisterVariable('hat'     , @chSetHat       , false);
+    RegisterVariable('quit'    , @chQuit         , true );
+    RegisterVariable('forcequit', @chForceQuit   , true );
+    RegisterVariable('confirm' , @chConfirm      , true );
+    RegisterVariable('halt',     @chHalt         , true );
+    RegisterVariable('+speedup', @chSpeedup_p    , true );
+    RegisterVariable('-speedup', @chSpeedup_m    , true );
+    RegisterVariable('zoomin'  , @chZoomIn       , true );
+    RegisterVariable('zoomout' , @chZoomOut      , true );
+    RegisterVariable('zoomreset',@chZoomReset    , true );
+    RegisterVariable('ammomenu', @chAmmoMenu     , true);
+    RegisterVariable('+precise', @chPrecise_p    , false);
+    RegisterVariable('-precise', @chPrecise_m    , false);
+    RegisterVariable('switch'  , @chSwitch       , false);
+    RegisterVariable('timer'   , @chTimer        , false);
+    RegisterVariable('taunt'   , @chTaunt        , false);
+    RegisterVariable('put'     , @chPut          , false);
+    RegisterVariable('+volup'  , @chVol_p        , true );
+    RegisterVariable('-volup'  , @chVol_m        , true );
+    RegisterVariable('+voldown', @chVol_m        , true );
+    RegisterVariable('-voldown', @chVol_p        , true );
+    RegisterVariable('findhh'  , @chFindhh       , true );
+    RegisterVariable('pause'   , @chPause        , true );
+    RegisterVariable('+cur_u'  , @chCurU_p       , true );
+    RegisterVariable('-cur_u'  , @chCurU_m       , true );
+    RegisterVariable('+cur_d'  , @chCurD_p       , true );
+    RegisterVariable('-cur_d'  , @chCurD_m       , true );
+    RegisterVariable('+cur_l'  , @chCurL_p       , true );
+    RegisterVariable('-cur_l'  , @chCurL_m       , true );
+    RegisterVariable('+cur_r'  , @chCurR_p       , true );
+    RegisterVariable('-cur_r'  , @chCurR_m       , true );
 end;
 
 procedure freeModule;
--- a/hedgewars/uCommands.pas	Fri Apr 20 23:03:20 2012 +0400
+++ b/hedgewars/uCommands.pas	Sat Apr 21 19:51:13 2012 +0400
@@ -23,12 +23,11 @@
 interface
 
 var isDeveloperMode: boolean;
-type TVariableType = (vtCommand, vtLongInt, vtBoolean);
-    TCommandHandler = procedure (var params: shortstring);
+type TCommandHandler = procedure (var params: shortstring);
 
 procedure initModule;
 procedure freeModule;
-procedure RegisterVariable(Name: shortstring; VType: TVariableType; p: pointer; Trusted: boolean);
+procedure RegisterVariable(Name: shortstring; p: TCommandHandler; Trusted: boolean);
 procedure ParseCommand(CmdStr: shortstring; TrustedSource: boolean);
 procedure StopMessages(Message: Longword);
 
@@ -39,15 +38,14 @@
     TVariable = record
         Next: PVariable;
         Name: string[15];
-        VType: TVariableType;
-        Handler: pointer;
+        Handler: TCommandHandler;
         Trusted: boolean;
         end;
 
 var
     Variables: PVariable;
 
-procedure RegisterVariable(Name: shortstring; VType: TVariableType; p: pointer; Trusted: boolean);
+procedure RegisterVariable(Name: shortstring; p: TCommandHandler; Trusted: boolean);
 var
     value: PVariable;
 begin
@@ -55,7 +53,6 @@
 TryDo(value <> nil, 'RegisterVariable: value = nil', true);
 FillChar(value^, sizeof(TVariable), 0);
 value^.Name:= Name;
-value^.VType:= VType;
 value^.Handler:= p;
 value^.Trusted:= Trusted;
 
@@ -80,48 +77,22 @@
     exit;
 c:= CmdStr[1];
 if (c = '/') or (c = '$') then
-    Delete(CmdStr, 1, 1)
-else
-    c:= '/';
+    Delete(CmdStr, 1, 1);
 s:= '';
 SplitBySpace(CmdStr, s);
-AddFileLog('[Cmd] ' + c + CmdStr + ' (' + inttostr(length(s)) + ')');
+AddFileLog('[Cmd] ' + CmdStr + ' (' + inttostr(length(s)) + ')');
 t:= Variables;
 while t <> nil do
     begin
     if t^.Name = CmdStr then
         begin
         if TrustedSource or t^.Trusted then
-            case t^.VType of
-                vtCommand: if c='/' then
-                    begin
-                    TCommandHandler(t^.Handler)(s);
-                    end;
-                vtLongInt: if c='$' then
-                    if s[0]=#0 then
-                        begin
-                        str(PLongInt(t^.Handler)^, s);
-                        WriteLnToConsole('$' + CmdStr + ' is "' + s + '"');
-                        end
-                    else
-                        val(s, PLongInt(t^.Handler)^);
-                vtBoolean: if c='$' then
-                    if s[0]=#0 then
-                        begin
-                        str(ord(boolean(t^.Handler^)), s);
-                        WriteLnToConsole('$' + CmdStr + ' is "' + s + '"');
-                        end
-                    else
-                        begin
-                        val(s, ii);
-                        boolean(t^.Handler^):= not (ii = 0)
-                        end;
-                end;
-            exit
-            end
-        else
-            t:= t^.Next
-        end;
+            t^.Handler(s);
+        exit
+        end
+    else
+        t:= t^.Next
+    end;
 case c of
     '$': WriteLnToConsole(errmsgUnknownVariable + ': "$' + CmdStr + '"')
     else
--- a/hedgewars/uGears.pas	Fri Apr 20 23:03:20 2012 +0400
+++ b/hedgewars/uGears.pas	Sat Apr 21 19:51:13 2012 +0400
@@ -1302,8 +1302,8 @@
 begin
     doStepHandlers:= handlers;
 
-    RegisterVariable('skip', vtCommand, @chSkip, false);
-    RegisterVariable('hogsay', vtCommand, @chHogSay, true );
+    RegisterVariable('skip', @chSkip, false);
+    RegisterVariable('hogsay', @chHogSay, true );
 
     CurAmmoGear:= nil;
     GearsList:= nil;
--- a/hedgewars/uIO.pas	Fri Apr 20 23:03:20 2012 +0400
+++ b/hedgewars/uIO.pas	Sat Apr 21 19:51:13 2012 +0400
@@ -104,7 +104,7 @@
     WriteLnToConsole(msgOK);
     WriteToConsole('Establishing IPC connection to tcp 127.0.0.1:' + IntToStr(ipcPort) + ' ');
     {$HINTS OFF}
-    SDLTry(SDLNet_ResolveHost(ipaddr, '127.0.0.1', ipcPort) = 0, true);
+    SDLTry(SDLNet_ResolveHost(ipaddr, PChar('127.0.0.1'), ipcPort) = 0, true);
     {$HINTS ON}
     IPCSock:= SDLNet_TCP_Open(ipaddr);
     SDLTry(IPCSock <> nil, true);
@@ -206,7 +206,7 @@
 end;
 
 procedure SendStat(sit: TStatInfoType; s: shortstring);
-const stc: array [TStatInfoType] of char = 'rDkKHTPsSB';
+const stc: array [TStatInfoType] of char = ('r', 'D', 'k', 'K', 'H', 'T', 'P', 's', 'S', 'B');
 var buf: shortstring;
 begin
 buf:= 'i' + stc[sit] + s;
@@ -420,7 +420,7 @@
 
 procedure initModule;
 begin
-    RegisterVariable('fatal', vtCommand, @chFatalError, true );
+    RegisterVariable('fatal', @chFatalError, true );
 
     IPCSock:= nil;
 
--- a/hedgewars/uLand.pas	Fri Apr 20 23:03:20 2012 +0400
+++ b/hedgewars/uLand.pas	Sat Apr 21 19:51:13 2012 +0400
@@ -737,8 +737,8 @@
 
 procedure initModule;
 begin
-    RegisterVariable('landcheck', vtCommand, @chLandCheck, false);
-    RegisterVariable('sendlanddigest', vtCommand, @chSendLandDigest, false);
+    RegisterVariable('landcheck', @chLandCheck, false);
+    RegisterVariable('sendlanddigest', @chSendLandDigest, false);
 
     LandBackSurface:= nil;
     digest:= '';
--- a/hedgewars/uLandPainted.pas	Fri Apr 20 23:03:20 2012 +0400
+++ b/hedgewars/uLandPainted.pas	Sat Apr 21 19:51:13 2012 +0400
@@ -186,7 +186,7 @@
     pointsListHead:= nil;
     pointsListLast:= nil;
 
-    RegisterVariable('draw', vtCommand, @chDraw, false);
+    RegisterVariable('draw', @chDraw, false);
 end;
 
 procedure freeModule;
--- a/hedgewars/uSound.pas	Fri Apr 20 23:03:20 2012 +0400
+++ b/hedgewars/uSound.pas	Sat Apr 21 19:51:13 2012 +0400
@@ -543,7 +543,7 @@
 
 procedure initModule;
 begin
-    RegisterVariable('voicepack', vtCommand, @chVoicepack, false);
+    RegisterVariable('voicepack', @chVoicepack, false);
     MusicFN:='';
 end;
 
--- a/hedgewars/uStore.pas	Fri Apr 20 23:03:20 2012 +0400
+++ b/hedgewars/uStore.pas	Sat Apr 21 19:51:13 2012 +0400
@@ -1117,7 +1117,7 @@
 var ai: TAmmoType;
     i: LongInt;
 begin
-    RegisterVariable('fullscr', vtCommand, @chFullScr, true);
+    RegisterVariable('fullscr', @chFullScr, true);
 
     SDLPrimSurface:= nil;
 
--- a/hedgewars/uTeams.pas	Fri Apr 20 23:03:20 2012 +0400
+++ b/hedgewars/uTeams.pas	Sat Apr 21 19:51:13 2012 +0400
@@ -605,12 +605,12 @@
 
 procedure initModule;
 begin
-RegisterVariable('addhh', vtCommand, @chAddHH, false);
-RegisterVariable('addteam', vtCommand, @chAddTeam, false);
-RegisterVariable('hhcoords', vtCommand, @chSetHHCoords, false);
-RegisterVariable('bind', vtCommand, @chBind, true );
-RegisterVariable('teamgone', vtCommand, @chTeamGone, true );
-RegisterVariable('finish', vtCommand, @chFinish, true ); // all teams gone
+RegisterVariable('addhh', @chAddHH, false);
+RegisterVariable('addteam', @chAddTeam, false);
+RegisterVariable('hhcoords', @chSetHHCoords, false);
+RegisterVariable('bind', @chBind, true );
+RegisterVariable('teamgone', @chTeamGone, true );
+RegisterVariable('finish', @chFinish, true ); // all teams gone
 
 CurrentTeam:= nil;
 PreviousTeam:= nil;