hedgewars/uCommands.pas
changeset 5352 7f57d0c7816a
parent 4976 088d40d8aba2
child 5554 b27ed6c6f538
--- a/hedgewars/uCommands.pas	Tue Jun 28 19:16:42 2011 -0400
+++ b/hedgewars/uCommands.pas	Tue Jun 28 21:48:28 2011 -0400
@@ -33,7 +33,7 @@
 procedure StopMessages(Message: Longword);
 
 implementation
-uses Types, uConsts, uVariables, uConsole, uUtils, uDebug;
+uses Types, uConsts, uVariables, uConsole, uUtils, uDebug, uScript;
 
 type  PVariable = ^TVariable;
       TVariable = record
@@ -68,7 +68,7 @@
 
 procedure ParseCommand(CmdStr: shortstring; TrustedSource: boolean);
 var ii: LongInt;
-    s: shortstring;
+    s, i, o: shortstring;
     t: PVariable;
     c: char;
 begin
@@ -85,6 +85,8 @@
       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
@@ -94,8 +96,12 @@
                          if s[0]=#0 then
                             begin
                             str(PLongInt(t^.Handler)^, s);
-                            WriteLnToConsole('$' + CmdStr + ' is "' + s + '"');
-                            end else val(s, PLongInt(t^.Handler)^);
+                            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)^);
               vthwFloat: if c='$' then
                          if s[0]=#0 then
                             begin
@@ -106,13 +112,23 @@
                          if s[0]=#0 then
                             begin
                             str(ord(boolean(t^.Handler^)), s);
-                            WriteLnToConsole('$' + CmdStr + ' is "' + s + '"');
-                            end else
+                            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
                             begin
                             val(s, ii);
                             boolean(t^.Handler^):= not (ii = 0)
                             end;
               end;
+              end;
          exit
          end else t:= t^.Next
       end;