|
|
|
@ -50,6 +50,17 @@ var private /*config*/ Text chatCommandPrefix;
|
|
|
|
|
// Temporary measure until a better solution is finished. |
|
|
|
|
var private /*config*/ array<string> allowedPlayers; |
|
|
|
|
|
|
|
|
|
// Contains name of the command to call plus, optionally, |
|
|
|
|
// additional sub-command name. |
|
|
|
|
// Normally sub-command name is parsed by the command itself, however |
|
|
|
|
// command aliases can try to enforce one. |
|
|
|
|
struct CommandCallPair |
|
|
|
|
{ |
|
|
|
|
var MutableText commandName; |
|
|
|
|
// In case it is enforced by an alias |
|
|
|
|
var MutableText subCommandName; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var LoggerAPI.Definition errCommandDuplicate; |
|
|
|
|
|
|
|
|
|
protected function OnEnabled() |
|
|
|
@ -452,7 +463,7 @@ public final function HandleInputWith(Parser parser, EPlayer callerPlayer)
|
|
|
|
|
local PlayerController controller; |
|
|
|
|
local Command commandInstance; |
|
|
|
|
local Command.CallData callData; |
|
|
|
|
local MutableText commandName; |
|
|
|
|
local CommandCallPair callPair; |
|
|
|
|
|
|
|
|
|
if (parser == none) return; |
|
|
|
|
if (callerPlayer == none) return; |
|
|
|
@ -472,8 +483,8 @@ public final function HandleInputWith(Parser parser, EPlayer callerPlayer)
|
|
|
|
|
if (!foundID) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
parser.MUntilMany(commandName, commandDelimiters, true, true); |
|
|
|
|
commandInstance = GetCommand(commandName); |
|
|
|
|
callPair = ParseCommandCallPairWith(parser); |
|
|
|
|
commandInstance = GetCommand(callPair.commandName); |
|
|
|
|
if ( commandInstance == none |
|
|
|
|
&& callerPlayer != none && callerPlayer.IsExistent()) |
|
|
|
|
{ |
|
|
|
@ -482,15 +493,64 @@ public final function HandleInputWith(Parser parser, EPlayer callerPlayer)
|
|
|
|
|
.Flush() |
|
|
|
|
.Say(F("{$TextFailure Command not found!}")); |
|
|
|
|
} |
|
|
|
|
commandName.FreeSelf(); |
|
|
|
|
if (parser.Ok() && commandInstance != none) |
|
|
|
|
{ |
|
|
|
|
callData = commandInstance.ParseInputWith(parser, callerPlayer); |
|
|
|
|
callData = commandInstance |
|
|
|
|
.ParseInputWith(parser, callerPlayer, callPair.subCommandName); |
|
|
|
|
commandInstance.Execute(callData, callerPlayer); |
|
|
|
|
commandInstance.DeallocateCallData(callData); |
|
|
|
|
} |
|
|
|
|
_.memory.Free(callPair.commandName); |
|
|
|
|
_.memory.Free(callPair.subCommandName); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Parses command's name into `CommandCallPair` - sub-command is filled in case |
|
|
|
|
// specified name is an alias with specified sub-command name. |
|
|
|
|
private final function CommandCallPair ParseCommandCallPairWith(Parser parser) |
|
|
|
|
{ |
|
|
|
|
local Text resolvedValue; |
|
|
|
|
local MutableText userSpecifiedName; |
|
|
|
|
local CommandCallPair result; |
|
|
|
|
local Text.Character dotCharacter; |
|
|
|
|
|
|
|
|
|
if (parser == none) return result; |
|
|
|
|
if (!parser.Ok()) return result; |
|
|
|
|
|
|
|
|
|
parser.MUntilMany(userSpecifiedName, commandDelimiters, true, true); |
|
|
|
|
resolvedValue = _.alias.ResolveCommand(userSpecifiedName); |
|
|
|
|
// This isn't an alias |
|
|
|
|
if (resolvedValue == none) |
|
|
|
|
{ |
|
|
|
|
result.commandName = userSpecifiedName; |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
// It is an alias - parse it |
|
|
|
|
dotCharacter = _.text.GetCharacter("."); |
|
|
|
|
resolvedValue.Parse() |
|
|
|
|
.MUntil(result.commandName, dotCharacter) |
|
|
|
|
.MatchS(".") |
|
|
|
|
.MUntil(result.subCommandName, dotCharacter) |
|
|
|
|
.FreeSelf(); |
|
|
|
|
if (result.subCommandName.IsEmpty()) |
|
|
|
|
{ |
|
|
|
|
result.subCommandName.FreeSelf(); |
|
|
|
|
result.subCommandName = none; |
|
|
|
|
} |
|
|
|
|
resolvedValue.FreeSelf(); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*// Contains name of the command to call plus, optionally, |
|
|
|
|
// additional sub-command name. |
|
|
|
|
// Normally sub-command name is parsed by the command itself, however |
|
|
|
|
// command aliases can try to enforce one. |
|
|
|
|
struct CommandCallPair |
|
|
|
|
{ |
|
|
|
|
var MutableText commandName; |
|
|
|
|
// In case it is enforced by an alias |
|
|
|
|
var MutableText subCommandName; |
|
|
|
|
}; */ |
|
|
|
|
|
|
|
|
|
private function bool HandleCommands( |
|
|
|
|
EPlayer sender, |
|
|
|
|
MutableText message, |
|
|
|
|