--- a/hedgewars/uCommandHandlers.pas Fri Jul 20 14:16:05 2012 -0400
+++ b/hedgewars/uCommandHandlers.pas Fri Jul 20 15:12:47 2012 -0400
@@ -786,23 +786,23 @@
procedure initModule;
begin
//////// Begin top sorted by freq analysis not including chatmsg
- 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);
+ RegisterVariable('+right' , @chRight_p , false, true);
+ RegisterVariable('-right' , @chRight_m , false, true);
+ RegisterVariable('+up' , @chUp_p , false, true);
+ RegisterVariable('-up' , @chUp_m , false, true);
+ RegisterVariable('+left' , @chLeft_p , false, true);
+ RegisterVariable('-left' , @chLeft_m , false, true);
+ RegisterVariable('+attack' , @chAttack_p , false, true);
+ RegisterVariable('+down' , @chDown_p , false, true);
+ RegisterVariable('-down' , @chDown_m , false, true);
+ RegisterVariable('hjump' , @chHJump , false, true);
+ RegisterVariable('ljump' , @chLJump , false, true);
+ RegisterVariable('nextturn', @chNextTurn , false, true);
+ RegisterVariable('-attack' , @chAttack_m , false, true);
+ RegisterVariable('slot' , @chSlot , false, true);
+ RegisterVariable('setweap' , @chSetWeapon , false, true);
//////// End top by freq analysis
- RegisterVariable('gencmd' , @chGenCmd , false);
+ RegisterVariable('gencmd' , @chGenCmd , false, true);
RegisterVariable('flag' , @chFlag , false);
RegisterVariable('script' , @chScript , false);
RegisterVariable('proto' , @chCheckProto , true );
--- a/hedgewars/uCommands.pas Fri Jul 20 14:16:05 2012 -0400
+++ b/hedgewars/uCommands.pas Fri Jul 20 15:12:47 2012 -0400
@@ -27,26 +27,31 @@
procedure initModule;
procedure freeModule;
+procedure RegisterVariable(Name: shortstring; p: TCommandHandler; Trusted: boolean; Synced: 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, Synced: 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; Synced: boolean);
var
value: PVariable;
begin
@@ -56,6 +61,7 @@
value^.Name:= Name;
value^.Handler:= p;
value^.Trusted:= Trusted;
+value^.Synced:= Synced;
if Variables = nil then
Variables:= value
@@ -81,11 +87,13 @@
s:= '';
SplitBySpace(CmdStr, s);
AddFileLog('[Cmd] ' + CmdStr + ' (' + inttostr(length(s)) + ')');
+
t:= Variables;
while t <> nil do
begin
if t^.Name = CmdStr then
begin
+ if t^.Synced then CheckSum:= CheckSum xor LongWord(SDLNet_Read32(@CmdStr)) xor LongWord(s[0]) xor GameTicks;
if TrustedSource or t^.Trusted then
t^.Handler(s);
exit