Browse Source

Change Command_Feature's interface for accepting command input

pull/8/head
Anton Tarasenko 2 years ago
parent
commit
7fdd51d5b7
  1. 32
      sources/Commands/Commands_Feature.uc

32
sources/Commands/Commands_Feature.uc

@ -417,6 +417,25 @@ public final function array<Text> GetGroupsNames()
return emptyResult; return emptyResult;
} }
/**
* Handles user input: finds appropriate command and passes the rest of
* the arguments to it for further processing.
*
* @param input Test that contains user's command input.
* @param callerPlayer Player that caused this command call.
*/
public final function HandleInput(BaseText input, EPlayer callerPlayer)
{
local Parser wrapper;
if (input == none) {
return;
}
wrapper = input.Parse();
HandleInputWith(wrapper, callerPlayer);
wrapper.FreeSelf();
}
/** /**
* Handles user input: finds appropriate command and passes the rest of * Handles user input: finds appropriate command and passes the rest of
* the arguments to it for further processing. * the arguments to it for further processing.
@ -425,7 +444,7 @@ public final function array<Text> GetGroupsNames()
* contain command's name and it's parameters. * contain command's name and it's parameters.
* @param callerPlayer Player that caused this command call. * @param callerPlayer Player that caused this command call.
*/ */
public final function HandleInput(Parser parser, EPlayer callerPlayer) public final function HandleInputWith(Parser parser, EPlayer callerPlayer)
{ {
local int i; local int i;
local bool foundID; local bool foundID;
@ -435,10 +454,11 @@ public final function HandleInput(Parser parser, EPlayer callerPlayer)
local Command.CallData callData; local Command.CallData callData;
local MutableText commandName; local MutableText commandName;
if (parser == none) return; if (parser == none) return;
if (!parser.Ok()) return; if (callerPlayer == none) return;
if (!parser.Ok()) return;
controller = callerPlayer.GetController(); controller = callerPlayer.GetController();
if (controller == none) return; if (controller == none) return;
steamID = controller.GetPlayerIDHash(); steamID = controller.GetPlayerIDHash();
for (i = 0; i < allowedPlayers.length; i += 1) for (i = 0; i < allowedPlayers.length; i += 1)
@ -486,7 +506,7 @@ private function bool HandleCommands(
return true; return true;
} }
// Pass input to command feature // Pass input to command feature
HandleInput(parser, sender); HandleInputWith(parser, sender);
parser.FreeSelf(); parser.FreeSelf();
return false; return false;
} }
@ -504,7 +524,7 @@ private function HandleMutate(string command, PlayerController sendingPlayer)
parser = _.text.ParseString(command); parser = _.text.ParseString(command);
sender = _.players.FromController(sendingPlayer); sender = _.players.FromController(sendingPlayer);
HandleInput(parser, sender); HandleInputWith(parser, sender);
sender.FreeSelf(); sender.FreeSelf();
parser.FreeSelf(); parser.FreeSelf();
} }

Loading…
Cancel
Save