Planeshift
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes

AdminCmdTargetParser Class Reference

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

#include <adminmanager.h>

List of all members.

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
gemActortargetActor
 set to the targets actor when possible
ClienttargetClient
 set to the targets client when possible
PID targetID
 stores PID when target is a player/npc/???? specified by PID
gemObjecttargetObject
 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

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 ( ) [inline, virtual]

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 ( ) [protected, virtual]

resets the internal variables to their default values.

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


Member Data Documentation

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.

player that is target for the command

Definition at line 372 of file adminmanager.h.

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.

type of the parsed target

Definition at line 454 of file adminmanager.h.


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