Planeshift
AdminCmdTargetParser Class Reference

Class for parsing a target of a admin command. More...

#include <adminmanager.h>

Public Member Functions

 AdminCmdTargetParser (int targetTypes)
 default constructor. More...
 
virtual AccountID GetAccountID (size_t gmClientNum)
 Returns the AccountID when the target is a player. More...
 
virtual csString GetHelpMessagePartForTarget ()
 Returns a helpmessage string for the allowed types of the target. More...
 
bool IsAllowedTargetType (ADMINCMD_TARGET_TYPES targetType)
 Test whether the given target type is allowed or not. More...
 
bool IsOnline ()
 Returns true when the 'target' is online. More...
 
bool IsTargetType (ADMINCMD_TARGET_TYPES targetType)
 Test whether the given target type is of the supplied type or not. More...
 
bool IsTargetTypeUnknown ()
 Test for unparsable targettype. More...
 
virtual bool ParseTarget (AdminManager *msgManager, MsgEntry *me, psAdminCmdMessage &msg, Client *client, csString target)
 Tries to parse the supplied string as a destination. More...
 
virtual ~AdminCmdTargetParser ()
 the default destructor. More...
 

Public Attributes

bool area
 is set to true if a character was found by name and multiple name instances were found. More...
 
bool duplicateActor
 
csString target
 player that is target for the command More...
 
gemActortargetActor
 set to the targets actor when possible More...
 
ClienttargetClient
 set to the targets client when possible More...
 
PID targetID
 stores PID when target is a player/npc/???? specified by PID More...
 
gemObjecttargetObject
 set to the object of the target when possible More...
 

Protected Member Functions

bool GetPlayerAccountIDByName (size_t gmClientNum, const csString &word, bool reporterror)
 Tries to resolve a player name to pid and accountid. More...
 
bool GetPlayerAccountIDByPID (size_t gmClientNum, const csString &word)
 Tries to resolve player by pid:PID to accountid. More...
 
bool GetPlayerAccountIDByPIDFromName (size_t gmClientNum, const csString &word, bool reporterror)
 Tries to resolve a player name to pid and accountid. More...
 
bool GetPlayerClient (AdminManager *msgManager, size_t gmClientNum, const csString &playerName, bool allowduplicate)
 Tries to find a client by name and checks for duplicates. More...
 
virtual void Reset ()
 resets the internal variables to their default values. More...
 

Protected Attributes

int allowedTargetTypes
 allowed destination types More...
 
AccountID targetAccountID
 internal cache value for accountID More...
 
int targetTypes
 type of the parsed target More...
 

Detailed Description

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.

Constructor & Destructor Documentation

AdminCmdTargetParser::AdminCmdTargetParser ( int  targetTypes)
inline

default constructor.

Parameters
targetTypesthe allowed target types

Definition at line 378 of file adminmanager.h.

virtual AdminCmdTargetParser::~AdminCmdTargetParser ( )
inlinevirtual

the default destructor.

Definition at line 387 of file adminmanager.h.

Member Function Documentation

virtual AccountID AdminCmdTargetParser::GetAccountID ( size_t  gmClientNum)
virtual

Returns the AccountID when the target is a player.

Parameters
gmClientNumid of gm client
Returns
AccountiD: valid ID when target is a player, otherwise invalid ID
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.

Returns
csString: containg the helpmessage part for destination
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.

Parameters
gmClientNumid of gm client
wordto check for a playername
reporterrorwhether to send errormsg on not found player, or not
Returns
bool: true, when player found, otherwise false
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

Parameters
gmClientNumid of gm client
wordto check for a playername
Returns
bool: true, when player found, otherwise false
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

Parameters
gmClientNumid of gm client
wordto check for a playername
reporterrorwhether to send errormsg on not found player, or not
Returns
bool: true, when player found, otherwise false
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.

Parameters
msgManageradminmanager that utilizes this function
gmClientNumid of gm client
playerNamename of the player whose client is searched for
allowduplicateis true when playerName can resolve to more than one client
Returns
true when client found, otherwise false
bool AdminCmdTargetParser::IsAllowedTargetType ( ADMINCMD_TARGET_TYPES  targetType)
inline

Test whether the given target type is allowed or not.

Parameters
targetTypeto test
Returns
bool: true if allowed, otherwise false

Definition at line 406 of file adminmanager.h.

bool AdminCmdTargetParser::IsOnline ( )
inline

Returns true when the 'target' is online.

Returns
bool: true when target online, otherwise false

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.

Parameters
targetTypeto test for
Returns
bool: true if allowed, otherwise false

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.

Returns
bool: true when unknown, otherwise false

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.

Parameters
msgManagermessage manager that handles this command
meThe incoming message from the GM
msgpsAdminCmdMessage containing the message
clientclient of the network communication
targetstring to parse as a destination
Returns
false when parsing the supplied string failed, otherwise true
virtual void AdminCmdTargetParser::Reset ( )
protectedvirtual

resets the internal variables to their default values.

Is needed for the case that something is targeted that is not valid

Member Data Documentation

int AdminCmdTargetParser::allowedTargetTypes
protected

allowed destination types

Definition at line 453 of file adminmanager.h.

bool AdminCmdTargetParser::area

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.

bool AdminCmdTargetParser::duplicateActor

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.

gemActor* AdminCmdTargetParser::targetActor

set to the targets actor when possible

Definition at line 365 of file adminmanager.h.

Client* AdminCmdTargetParser::targetClient

set to the targets client when possible

Definition at line 366 of file adminmanager.h.

PID AdminCmdTargetParser::targetID

stores PID when target is a player/npc/???? specified by PID

Definition at line 373 of file adminmanager.h.

gemObject* AdminCmdTargetParser::targetObject

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.


The documentation for this class was generated from the following file: