hedgewars/uCommands.pas
changeset 9301 c5d1c8259ef4
parent 9080 9b42757d7e71
child 9998 736015b847e3
equal deleted inserted replaced
9300:e5dafb5843c6 9301:c5d1c8259ef4
    34 procedure ParseCommand(CmdStr: shortstring; TrustedSource, ExternalSource: boolean);
    34 procedure ParseCommand(CmdStr: shortstring; TrustedSource, ExternalSource: boolean);
    35 procedure ParseTeamCommand(s: shortstring);
    35 procedure ParseTeamCommand(s: shortstring);
    36 procedure StopMessages(Message: Longword);
    36 procedure StopMessages(Message: Longword);
    37 
    37 
    38 implementation
    38 implementation
    39 uses uConsts, uVariables, uConsole, uUtils, uDebug, SDLh;
    39 uses uConsts, uVariables, uConsole, uUtils, SDLh;
    40 
    40 
    41 type  PVariable = ^TVariable;
    41 type  PVariable = ^TVariable;
    42     TVariable = record
    42     TVariable = record
    43         Next: PVariable;
    43         Next: PVariable;
    44         Name: string[15];
    44         Name: string[15];
    50 
    50 
    51 procedure RegisterVariable(Name: shortstring; p: TCommandHandler; Trusted: boolean);
    51 procedure RegisterVariable(Name: shortstring; p: TCommandHandler; Trusted: boolean);
    52 begin
    52 begin
    53 RegisterVariable(Name, p, Trusted, false);
    53 RegisterVariable(Name, p, Trusted, false);
    54 end;
    54 end;
       
    55 
    55 procedure RegisterVariable(Name: shortstring; p: TCommandHandler; Trusted: boolean; Rand: boolean);
    56 procedure RegisterVariable(Name: shortstring; p: TCommandHandler; Trusted: boolean; Rand: boolean);
    56 var
    57 var value: PVariable;
    57     value: PVariable;
       
    58 begin
    58 begin
    59 New(value);
    59 New(value);
    60 TryDo(value <> nil, 'RegisterVariable: value = nil', true);
    60 if value = nil then
       
    61     ParseCommand('fatal RegisterVariable: value = nil', true);
       
    62 
    61 FillChar(value^, sizeof(TVariable), 0);
    63 FillChar(value^, sizeof(TVariable), 0);
    62 value^.Name:= Name;
    64 value^.Name:= Name;
    63 value^.Handler:= p;
    65 value^.Handler:= p;
    64 value^.Trusted:= Trusted;
    66 value^.Trusted:= Trusted;
    65 value^.Rand:= Rand;
    67 value^.Rand:= Rand;