Planeshift
|
Class for parsing a target of a admin command. More...
#include <adminmanager.h>
Public Member Functions | |
AdminCmdTargetParser (int targetTypes) | |
default constructor. | |
virtual AccountID | GetAccountID (size_t gmClientNum) |
Returns the AccountID when the target is a player. | |
virtual csString | GetHelpMessagePartForTarget () |
Returns a helpmessage string for the allowed types of the target. | |
bool | IsAllowedTargetType (ADMINCMD_TARGET_TYPES targetType) |
Test whether the given target type is allowed or not. | |
bool | IsOnline () |
Returns true when the 'target' is online. | |
bool | IsTargetType (ADMINCMD_TARGET_TYPES targetType) |
Test whether the given target type is of the supplied type or not. | |
bool | IsTargetTypeUnknown () |
Test for unparsable targettype. | |
virtual bool | ParseTarget (AdminManager *msgManager, MsgEntry *me, psAdminCmdMessage &msg, Client *client, csString target) |
Tries to parse the supplied string as a destination. | |
virtual | ~AdminCmdTargetParser () |
the default destructor. | |
Public Attributes | |
bool | area |
is set to true if a character was found by name and multiple name instances were found. | |
bool | duplicateActor |
csString | target |
player that is target for the command | |
gemActor * | targetActor |
set to the targets actor when possible | |
Client * | targetClient |
set to the targets client when possible | |
PID | targetID |
stores PID when target is a player/npc/???? specified by PID | |
gemObject * | targetObject |
set to the object of the target when possible | |
Protected Member Functions | |
bool | GetPlayerAccountIDByName (size_t gmClientNum, const csString &word, bool reporterror) |
Tries to resolve a player name to pid and accountid. | |
bool | GetPlayerAccountIDByPID (size_t gmClientNum, const csString &word) |
Tries to resolve player by pid:PID to accountid. | |
bool | GetPlayerAccountIDByPIDFromName (size_t gmClientNum, const csString &word, bool reporterror) |
Tries to resolve a player name to pid and accountid. | |
bool | GetPlayerClient (AdminManager *msgManager, size_t gmClientNum, const csString &playerName, bool allowduplicate) |
Tries to find a client by name and checks for duplicates. | |
virtual void | Reset () |
resets the internal variables to their default values. | |
Protected Attributes | |
int | allowedTargetTypes |
allowed destination types | |
AccountID | targetAccountID |
internal cache value for accountID | |
int | targetTypes |
type of the parsed target |
Class for parsing a target of a admin command.
The class handles the parsing related to the possible targets for the commands. Supported targets are: target (declares explicitly the clients target as a target), pid:PID, area:Area, me, playername, npcname, objectname, accountname, string. The types that the object actually recognizes as correct targets are set in the allowedTypes variables. Recognition is executed in the already given order.
Definition at line 361 of file adminmanager.h.
AdminCmdTargetParser::AdminCmdTargetParser | ( | int | targetTypes | ) | [inline] |
default constructor.
targetTypes | the allowed target types |
Definition at line 378 of file adminmanager.h.
virtual AdminCmdTargetParser::~AdminCmdTargetParser | ( | ) | [inline, virtual] |
the default destructor.
Definition at line 387 of file adminmanager.h.
virtual AccountID AdminCmdTargetParser::GetAccountID | ( | size_t | gmClientNum | ) | [virtual] |
Returns the AccountID when the target is a player.
gmClientNum | id of gm client |
virtual csString AdminCmdTargetParser::GetHelpMessagePartForTarget | ( | ) | [virtual] |
Returns a helpmessage string for the allowed types of the target.
Automatically generates a help message for the allowed types of the target.
bool AdminCmdTargetParser::GetPlayerAccountIDByName | ( | size_t | gmClientNum, |
const csString & | word, | ||
bool | reporterror | ||
) | [protected] |
Tries to resolve a player name to pid and accountid.
Queries the database, no checks are done that the player is offline does not set targettypes, etc. (or any other internal variable) targetAccountID is the only exception, it is set when a valid one was found.
gmClientNum | id of gm client |
word | to check for a playername |
reporterror | whether to send errormsg on not found player, or not |
bool AdminCmdTargetParser::GetPlayerAccountIDByPID | ( | size_t | gmClientNum, |
const csString & | word | ||
) | [protected] |
Tries to resolve player by pid:PID to accountid.
Queries the database for the user
gmClientNum | id of gm client |
word | to check for a playername |
bool AdminCmdTargetParser::GetPlayerAccountIDByPIDFromName | ( | size_t | gmClientNum, |
const csString & | word, | ||
bool | reporterror | ||
) | [protected] |
Tries to resolve a player name to pid and accountid.
Queries the database, no checks are done that the player is offline
gmClientNum | id of gm client |
word | to check for a playername |
reporterror | whether to send errormsg on not found player, or not |
bool AdminCmdTargetParser::GetPlayerClient | ( | AdminManager * | msgManager, |
size_t | gmClientNum, | ||
const csString & | playerName, | ||
bool | allowduplicate | ||
) | [protected] |
Tries to find a client by name and checks for duplicates.
msgManager | adminmanager that utilizes this function |
gmClientNum | id of gm client |
playerName | name of the player whose client is searched for |
allowduplicate | is true when playerName can resolve to more than one client |
bool AdminCmdTargetParser::IsAllowedTargetType | ( | ADMINCMD_TARGET_TYPES | targetType | ) | [inline] |
Test whether the given target type is allowed or not.
targetType | to test |
Definition at line 406 of file adminmanager.h.
bool AdminCmdTargetParser::IsOnline | ( | ) | [inline] |
Returns true when the 'target' is online.
Definition at line 447 of file adminmanager.h.
bool AdminCmdTargetParser::IsTargetType | ( | ADMINCMD_TARGET_TYPES | targetType | ) | [inline] |
Test whether the given target type is of the supplied type or not.
targetType | to test for |
Definition at line 415 of file adminmanager.h.
bool AdminCmdTargetParser::IsTargetTypeUnknown | ( | ) | [inline] |
Test for unparsable targettype.
When no target is detected. This happens when the supplied word is empty or the word does not contain any of the possible (allowed) targettypes.
Definition at line 397 of file adminmanager.h.
virtual bool AdminCmdTargetParser::ParseTarget | ( | AdminManager * | msgManager, |
MsgEntry * | me, | ||
psAdminCmdMessage & | msg, | ||
Client * | client, | ||
csString | target | ||
) | [virtual] |
Tries to parse the supplied string as a destination.
msgManager | message manager that handles this command |
me | The incoming message from the GM |
msg | psAdminCmdMessage containing the message |
client | client of the network communication |
target | string to parse as a destination |
virtual void AdminCmdTargetParser::Reset | ( | ) | [protected, virtual] |
resets the internal variables to their default values.
Is needed for the case that something is targeted that is not valid
int AdminCmdTargetParser::allowedTargetTypes [protected] |
allowed destination types
Definition at line 453 of file adminmanager.h.
is set to true if a character was found by name and multiple name instances were found.
Indicates that this is an area target so requires special handling.
Definition at line 370 of file adminmanager.h.
Definition at line 371 of file adminmanager.h.
csString AdminCmdTargetParser::target |
player that is target for the command
Definition at line 372 of file adminmanager.h.
AccountID AdminCmdTargetParser::targetAccountID [protected] |
internal cache value for accountID
Definition at line 455 of file adminmanager.h.
set to the targets actor when possible
Definition at line 365 of file adminmanager.h.
set to the targets client when possible
Definition at line 366 of file adminmanager.h.
stores PID when target is a player/npc/???? specified by PID
Definition at line 373 of file adminmanager.h.
set to the object of the target when possible
Definition at line 364 of file adminmanager.h.
int AdminCmdTargetParser::targetTypes [protected] |
type of the parsed target
Definition at line 454 of file adminmanager.h.