# HG changeset patch
# User nemo
# Date 1313177587 14400
# Node ID b27ed6c6f53843a5f75312bc5dbc17a669e01c29
# Parent  4bb542350a180de2983cbda911e7cc647fd8fce8
Revert ParseCommandOverride change since it appears to be badly screwing up scripting.  Need to find out why.  This backs out 7f57d0c7816a and the recent workaround.

diff -r 4bb542350a18 -r b27ed6c6f538 hedgewars/uCommands.pas
--- a/hedgewars/uCommands.pas	Fri Aug 12 14:09:08 2011 -0400
+++ b/hedgewars/uCommands.pas	Fri Aug 12 15:33:07 2011 -0400
@@ -33,7 +33,7 @@
 procedure StopMessages(Message: Longword);
 
 implementation
-uses Types, uConsts, uVariables, uConsole, uUtils, uDebug, uScript;
+uses Types, uConsts, uVariables, uConsole, uUtils, uDebug;
 
 type  PVariable = ^TVariable;
       TVariable = record
@@ -68,7 +68,7 @@
 
 procedure ParseCommand(CmdStr: shortstring; TrustedSource: boolean);
 var ii: LongInt;
-    s, i, o: shortstring;
+    s: shortstring;
     t: PVariable;
     c: char;
 begin
@@ -85,8 +85,6 @@
       if t^.Name = CmdStr then
          begin
          if TrustedSource or t^.Trusted then
-            begin
-            if (c <> '$') or (s[0] <> #0) then s:= ParseCommandOverride(CmdStr, s);
             case t^.VType of
               vtCommand: if c='/' then
                          begin
@@ -96,12 +94,8 @@
                          if s[0]=#0 then
                             begin
                             str(PLongInt(t^.Handler)^, s);
-                            i:= inttostr(PLongInt(t^.Handler)^);
-                            o:= ParseCommandOverride(CmdStr, i);
-                            if i <> o then val(o, PLongInt(t^.Handler)^) 
-                            else WriteLnToConsole('$' + CmdStr + ' is "' + s + '"');
-                            end 
-                         else val(s, PLongInt(t^.Handler)^);
+                            WriteLnToConsole('$' + CmdStr + ' is "' + s + '"');
+                            end else val(s, PLongInt(t^.Handler)^);
               vthwFloat: if c='$' then
                          if s[0]=#0 then
                             begin
@@ -112,23 +106,13 @@
                          if s[0]=#0 then
                             begin
                             str(ord(boolean(t^.Handler^)), s);
-                            if boolean(t^.Handler^) then i:= '1'
-                            else i:= '0';
-                            o:= ParseCommandOverride(CmdStr, i);
-                            if i <> o then 
-                                begin
-                                val(o, ii);
-                                boolean(t^.Handler^):= not (ii = 0)
-                                end
-                            else WriteLnToConsole('$' + CmdStr + ' is "' + s + '"');
-                            end 
-                         else
+                            WriteLnToConsole('$' + CmdStr + ' is "' + s + '"');
+                            end else
                             begin
                             val(s, ii);
                             boolean(t^.Handler^):= not (ii = 0)
                             end;
               end;
-              end;
          exit
          end else t:= t^.Next
       end;
diff -r 4bb542350a18 -r b27ed6c6f538 hedgewars/uScript.pas
--- a/hedgewars/uScript.pas	Fri Aug 12 14:09:08 2011 -0400
+++ b/hedgewars/uScript.pas	Fri Aug 12 15:33:07 2011 -0400
@@ -43,7 +43,6 @@
 function ScriptCall(fname : shortstring; par1, par2, par3: LongInt) : LongInt;
 function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt;
 function ScriptExists(fname : shortstring) : boolean;
-function ParseCommandOverride(key, value : shortstring) : shortstring;
 
 procedure initModule;
 procedure freeModule;
@@ -1115,7 +1114,6 @@
 
 function lc_addteam(L : Plua_State) : LongInt; Cdecl;
 var np: LongInt;
-    color, name, grave, fort, voice, flag: shortstring;
 begin
     np:= lua_gettop(L);
     if (np < 5) or (np > 6) then
@@ -1125,22 +1123,11 @@
         end
     else
         begin
-(*
- FIXME FIXME FIXME FIXME
- Something is very wrong here.
- For some reason, the lua_tostring after the first ParseCommand, are empty.  Is ParseCommand scribbling on stuff?
-*)
-        color:= lua_tostring(L, 1);
-        name := lua_tostring(L, 2);
-        grave:= lua_tostring(L, 3);
-        fort := lua_tostring(L, 4);
-        voice:= lua_tostring(L, 5);
-        if (np = 6) flag:= lua_tostring(L, 6);
-        ParseCommand('addteam x ' + name + ' ' + color, true);
-        ParseCommand('grave ' + grave, true);
-        ParseCommand('fort ' + fort, true);
-        ParseCommand('voicepack ' + voice, true);
-        if (np = 6) then ParseCommand('flag ' + flag, true);
+        ParseCommand('addteam x ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 1), true);
+        ParseCommand('grave ' + lua_tostring(L, 3), true);
+        ParseCommand('fort ' + lua_tostring(L, 4), true);
+        ParseCommand('voicepack ' + lua_tostring(L, 5), true);
+        if (np = 6) then ParseCommand('flag ' + lua_tostring(L, 6), true);
         CurrentTeam^.Binds:= DefaultBinds
         // fails on x64
         //lua_pushinteger(L, LongInt(CurrentTeam));
@@ -1658,25 +1645,6 @@
 GetGlobals;
 end;
 
-function ParseCommandOverride(key, value : shortstring) : shortstring;
-begin
-ParseCommandOverride:= value;
-if not ScriptExists('ParseCommandOverride') then exit;
-lua_getglobal(luaState, Str2PChar('ParseCommandOverride'));
-lua_pushstring(luaState, Str2PChar(key));
-lua_pushstring(luaState, Str2PChar(value));
-if lua_pcall(luaState, 2, 1, 0) <> 0 then
-    begin
-    LuaError('Lua: Error while calling ParseCommandOverride: ' + lua_tostring(luaState, -1));
-    lua_pop(luaState, 1)
-    end
-else
-    begin
-    ParseCommandOverride:= lua_tostring(luaState, -1);
-    lua_pop(luaState, 1)
-    end;
-end;
-
 function ScriptCall(fname : shortstring; par1: LongInt) : LongInt;
 begin
 ScriptCall:= ScriptCall(fname, par1, 0, 0, 0)