--- a/hedgewars/uCommands.pas Thu Jul 26 11:01:32 2012 +0200
+++ b/hedgewars/uCommands.pas Thu Jul 26 11:10:56 2012 +0200
@@ -27,26 +27,31 @@
procedure initModule;
procedure freeModule;
+procedure RegisterVariable(Name: shortstring; p: TCommandHandler; Trusted: boolean; Rand: boolean);
procedure RegisterVariable(Name: shortstring; p: TCommandHandler; Trusted: boolean);
procedure ParseCommand(CmdStr: shortstring; TrustedSource: boolean);
procedure ParseTeamCommand(s: shortstring);
procedure StopMessages(Message: Longword);
implementation
-uses uConsts, uVariables, uConsole, uUtils, uDebug;
+uses uConsts, uVariables, uConsole, uUtils, uDebug, SDLh;
type PVariable = ^TVariable;
TVariable = record
Next: PVariable;
Name: string[15];
Handler: TCommandHandler;
- Trusted: boolean;
+ Trusted, Rand: boolean;
end;
var
Variables: PVariable;
procedure RegisterVariable(Name: shortstring; p: TCommandHandler; Trusted: boolean);
+begin
+RegisterVariable(Name, p, Trusted, false);
+end;
+procedure RegisterVariable(Name: shortstring; p: TCommandHandler; Trusted: boolean; Rand: boolean);
var
value: PVariable;
begin
@@ -56,6 +61,7 @@
value^.Name:= Name;
value^.Handler:= p;
value^.Trusted:= Trusted;
+value^.Rand:= Rand;
if Variables = nil then
Variables:= value
@@ -81,13 +87,18 @@
s:= '';
SplitBySpace(CmdStr, 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
+ begin
+ if t^.Rand and (not CheckNoTeamOrHH) then
+ CheckSum:= CheckSum xor LongWord(SDLNet_Read32(@CmdStr)) xor LongWord(s[0]) xor GameTicks;
t^.Handler(s);
+ end;
exit
end
else