Planeshift
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes

UserManager Class Reference

Used to manage incoming user commands from a client. More...

#include <usermanager.h>

List of all members.

Classes

struct  EMOTE
 Struct to hold our emote data. More...

Public Types

enum  { LOGGED_OFF = 0, LOGGED_ON = 1 }

Public Member Functions

void AcceptDuel (PendingDuelInvite *invite)
 This is called by the Pending Invite if the duel is accepted.
bool Animation (csString animation, gemActor *actor)
 This function will start an animation on the actor, it will not repeat, so if you need an animation loop, just call it repeatedly from a script.
void Attack (Stance stance, Client *client)
void BuddyList (Client *client, int clientnum, bool filter)
 Send a buddy list to a player.
void CalculateComparativeDifference (psCharacter *myCharData, psCharacter *theirCharData, int &theirPhysicalLevel, int &theirMagicalLevel, int &physicalDiff, int &magicalDiff, int &overallLevelComparison)
 Calcualte a comarative difference between two characters for physical, magical, and overall level.
bool CheckForEmote (csString command, bool execute, gemActor *actor)
 Check to see if command is an emote.
bool CheckTargetLootable (gemActor *actor, Client *client)
 Checks whether target is lootable.
void Emote (csString general, csString specific, csString animation, gemActor *actor)
 Process an emote command.
void HandleLoot (psUserCmdMessage &msg, Client *client)
 Handles a /loot command from a player to loot something.
virtual bool Initialize (GEMSupervisor *gemsupervisor)
bool LoadEmotes (const char *xmlfile, iVFS *vfs)
 Load emotes from xml.
void Loot (Client *client)
 Attempt to loot the target using the loot window.
void LootItems (gemActor *actor, Client *client, csString categories="all", uint8_t lootAction=0)
 Attempt to loot all or certain items from target.
void LootMoney (gemActor *actor, Client *client)
 Attempt to loot money from the target.
void Mount (gemActor *rider, gemActor *mount)
 Handles the /mount command.
void NotifyAllianceBuddies (Client *client, bool loggedon)
 Send a notification to all clients on a person alliance if they log on/off.
void NotifyBuddies (Client *client, bool loggedon)
 Send a notification to all clients on a person buddy list if they log on/off.
void NotifyGuildBuddies (Client *client, bool loggedon)
 Send a notification to all clients on a person guild if they log on/off.
void NotifyPlayerBuddies (Client *client, bool loggedon)
 Send a notification to all player (non GM/Dev) clients on a person buddy list that they have logged on/off.
void Ready ()
void SendCharacterDescription (Client *client, gemActor *actor, bool full, bool simple, const csString &requestor)
 Sends detail information about 'charData' to 'client'.
void SendPlayerMoney (Client *client)
 UserManager (ClientConnectionSet *pCCS, CacheManager *cachemanager, BankManager *bankmanager, EntityManager *entitymanager)
void UserStatRegeneration ()
virtual ~UserManager ()

Protected Types

enum  { ALL_PLAYERS = 0, PLAYER_BUDDIES = 1 }
typedef void(UserManager::* userCmdPointer )(psUserCmdMessage &msg, Client *client)
 pointer to member function typedef, improves readability

Protected Member Functions

void Assist (psUserCmdMessage &msg, Client *client)
 Handles an /Assist command comming from the client.
void Buddy (psUserCmdMessage &msg, Client *client)
 Adds/removes a person to a player's buddy list.
void ChallengeToDuel (psUserCmdMessage &msg, Client *client)
 Command to challenge someone to a duel.
void GiveMOTD (psUserCmdMessage &msg, Client *client)
 Sends the MOTD to the client.
void GiveTip (psUserCmdMessage &msg, Client *client)
 Give a tip from the database to the client.
void Guard (Client *client, gemObject *object, csString action)
 Handles a player command to guard/unguard an item.
void HandleAdminCommand (psUserCmdMessage &msg, Client *client)
 Handles the /admin command.
void HandleAttack (psUserCmdMessage &msg, Client *client)
 Command to start attacking something.
void HandleBanking (psUserCmdMessage &msg, Client *client)
 Handles a player command to start banking with the targeted entity.
void HandleCharDescUpdate (MsgEntry *me, Client *client)
 Handle a message to update a character's description.
void HandleCharDetailsRequest (MsgEntry *me, Client *client)
 Handle a request to send a character description.
void HandleClientReady (MsgEntry *me, Client *client)
void HandleDie (psUserCmdMessage &msg, Client *client)
 Handles a player command to die.
void HandleEntranceMessage (MsgEntry *me, Client *client)
void HandleGMEvents (Client *client)
 Sends a client a list of their current assigned event.
void HandleGuard (psUserCmdMessage &msg, Client *client)
 Handle the /guard command, send it to Guard()
void HandleMarriage (psUserCmdMessage &msg, Client *client)
 Command to marry/divorce someone.
void HandleMOTDRequest (MsgEntry *me, Client *client)
 Sends to client the MOTD and tip, and his guild's MOTD if needed.
void HandleMount (psUserCmdMessage &msg, Client *client)
 Handles a player command to mount.
void HandlePickup (psUserCmdMessage &msg, Client *client)
 Handle the /pickup command, send it to Pickup()
void HandleQuests (Client *client)
 Sends a client a list of their current assigned quests.
void HandleQuestsCommand (psUserCmdMessage &msg, Client *client)
 Sends a client a list of their current assigned quests and events.
void HandleQueueAttack (psUserCmdMessage &msg, Client *client)
 command to add an attack to the attackQueue
void HandleRename (psUserCmdMessage &msg, Client *client)
void HandleRotate (psUserCmdMessage &msg, Client *client)
 Handle the /rotate command, send it to Rotate()
void HandleSit (psUserCmdMessage &msg, Client *client)
 Handles a player command to sit down.
void HandleStand (psUserCmdMessage &msg, Client *client)
 Handles a player command to stand up.
void HandleStopAttack (psUserCmdMessage &msg, Client *client)
 Command to stop attacking your target.
void HandleTakeAll (psUserCmdMessage &me, Client *client)
 Handle taking all items from a container.
void HandleTakeStackAll (psUserCmdMessage &me, Client *client)
 Handle taking all items from a container ignoring some qualities when stacking.
void HandleTargetEvent (MsgEntry *me, Client *client)
void HandleTraining (psUserCmdMessage &msg, Client *client)
 Handles a player command to start training with targeted entity.
void HandleUnmount (psUserCmdMessage &msg, Client *client)
 Handles a player command to unmount.
void HandleUnstick (psUserCmdMessage &msg, Client *client)
 Moves a player back to his last valid position.
void HandleUse (Client *client, bool on)
 Handles a player request to 'use' the targeted item.
void HandleUserCommand (MsgEntry *me, Client *client)
 Take a user command from a client, and send it to be handled by a function.
void HandleYield (psUserCmdMessage &msg, Client *client)
 Handle the yield command.
void LogStuck (Client *client)
 Helper function to log a stuck character's details.
void Pickup (Client *client, csString target)
 Handles a player command to pickup an item.
void Rename (Client *client, csString *target, psItem *item)
void ReportPosition (psUserCmdMessage &msg, Client *client)
 Sends the player their current position and sector.
void RollDice (psUserCmdMessage &msg, Client *client)
 Calculates a dice roll from a player based on number of die and sides.
void Rotate (Client *client, gemObject *target, csString action)
 Handles a player command to rotate an item.
void ShowNpcMenu (psUserCmdMessage &msg, Client *client)
 Handles a player command to show the popup dialog menu of the currently targeted NPC, if any.
void StartTrading (psUserCmdMessage &msg, Client *client)
 Handle the /starttrading command.
void StopAllCombat (Client *client)
 Helper function to make the character stop attacking.
void StopTrading (psUserCmdMessage &msg, Client *client)
 Handle the /stoptrading command.
void StrToLowerCase (csString &str)
 Converts a string to lowercase.
void SwitchAttackTarget (Client *targeter, Client *targeted)
void Who (psUserCmdMessage &msg, Client *client)
 Send a list of the players that are online to a client.
bool WhoProcessClient (Client *curr, int guildId, csString *message, csString filter, bool check, unsigned *count)
 Formats output of a player and adds it to a message.
void YieldDuel (Client *client)
 Command to surrender to someone in a duel.

Protected Attributes

BankManagerbankManager
CacheManagercacheManager
ClientConnectionSetclients
csHash< EMOTE *, csString > emoteHash
EntityManagerentityManager
GEMSupervisorgem
csHash< userCmdPointer, csString > userCommandHash
 Hash of the user commands, the key is the command name.

Detailed Description

Used to manage incoming user commands from a client.

Most commands are in the format of /command param1 param2 ... paramN

Definition at line 53 of file usermanager.h.


Member Typedef Documentation

typedef void(UserManager::* UserManager::userCmdPointer)(psUserCmdMessage &msg, Client *client) [protected]

pointer to member function typedef, improves readability

Definition at line 649 of file usermanager.h.


Member Enumeration Documentation

anonymous enum
Enumerator:
LOGGED_OFF 
LOGGED_ON 

Definition at line 104 of file usermanager.h.

anonymous enum [protected]
Enumerator:
ALL_PLAYERS 
PLAYER_BUDDIES 

Definition at line 281 of file usermanager.h.


Constructor & Destructor Documentation

UserManager::UserManager ( ClientConnectionSet pCCS,
CacheManager cachemanager,
BankManager bankmanager,
EntityManager entitymanager 
)
virtual UserManager::~UserManager ( ) [virtual]

Member Function Documentation

void UserManager::AcceptDuel ( PendingDuelInvite *  invite)

This is called by the Pending Invite if the duel is accepted.

Parameters:
inviteThis is the invitemanager structure used to invoke the invitation.
bool UserManager::Animation ( csString  animation,
gemActor actor 
)

This function will start an animation on the actor, it will not repeat, so if you need an animation loop, just call it repeatedly from a script.

void UserManager::Assist ( psUserCmdMessage msg,
Client client 
) [protected]

Handles an /Assist command comming from the client.

Parameters:
msgThe incoming command message
clientA pointer to the client struct.
void UserManager::Attack ( Stance  stance,
Client client 
)
void UserManager::Buddy ( psUserCmdMessage msg,
Client client 
) [protected]

Adds/removes a person to a player's buddy list.

This does a database hit to add/remove to the buddy table.

Parameters:
msgThe incoming user command message.
clientThe client that request the /buddy.
void UserManager::BuddyList ( Client client,
int  clientnum,
bool  filter 
)

Send a buddy list to a player.

Sends a list of all the players that are currently on a player's buddy list.

Parameters:
clientThe client that request the command..
clientnumThe client id number of the requesting client.
filterTrue if show only buddies online. Else show all buddies.
void UserManager::CalculateComparativeDifference ( psCharacter myCharData,
psCharacter theirCharData,
int theirPhysicalLevel,
int theirMagicalLevel,
int physicalDiff,
int magicalDiff,
int overallLevelComparison 
)

Calcualte a comarative difference between two characters for physical, magical, and overall level.

void UserManager::ChallengeToDuel ( psUserCmdMessage msg,
Client client 
) [protected]

Command to challenge someone to a duel.

Parameters:
msgThe incoming user command message.
clientThe client that request the command..
bool UserManager::CheckForEmote ( csString  command,
bool  execute,
gemActor actor 
)

Check to see if command is an emote.

Parameters:
commandThe command in question.
executeExecute the emote or not.
actorThe actor.
bool UserManager::CheckTargetLootable ( gemActor actor,
Client client 
)

Checks whether target is lootable.

Parameters:
actorThe actor which is looting
clientThe client where the loot command came from.
void UserManager::Emote ( csString  general,
csString  specific,
csString  animation,
gemActor actor 
)

Process an emote command.

Parameters:
generalThe phrase to broadcast if no target is selected.
specificThe phrase to broadcast if a target is selected.
animationThe animation for the emote. If there isn't one pass "noanim".
actorThe actor.
void UserManager::GiveMOTD ( psUserCmdMessage msg,
Client client 
) [protected]

Sends the MOTD to the client.

Parameters:
msgThe incoming user command message
clientthe client who sit
void UserManager::GiveTip ( psUserCmdMessage msg,
Client client 
) [protected]

Give a tip from the database to the client.

Parameters:
msgThe incoming user command message
clientThe client who sit
void UserManager::Guard ( Client client,
gemObject object,
csString  action 
) [protected]

Handles a player command to guard/unguard an item.

If the action parameter is empty, the guarding status of the item will be toggled.

Parameters:
clientThe client that issued the command.
objectpointer to the item to be guarded/unguarded.
actionvalue can be "on" or "off"
void UserManager::HandleAdminCommand ( psUserCmdMessage msg,
Client client 
) [protected]

Handles the /admin command.

Parameters:
msgThe incoming user command message.
clientThe client who issues the admin command.
void UserManager::HandleAttack ( psUserCmdMessage msg,
Client client 
) [protected]

Command to start attacking something.

Starts the combat manager working.

Parameters:
msgThe incoming user command message.
clientThe client that request the command.
void UserManager::HandleBanking ( psUserCmdMessage msg,
Client client 
) [protected]

Handles a player command to start banking with the targeted entity.

Parameters:
msgThe incoming user command message
clientThe client that issued the command.
void UserManager::HandleCharDescUpdate ( MsgEntry me,
Client client 
) [protected]

Handle a message to update a character's description.

void UserManager::HandleCharDetailsRequest ( MsgEntry me,
Client client 
) [protected]

Handle a request to send a character description.

void UserManager::HandleClientReady ( MsgEntry me,
Client client 
) [protected]
void UserManager::HandleDie ( psUserCmdMessage msg,
Client client 
) [protected]

Handles a player command to die.

Parameters:
msgThe incoming user command message
clientThe client who die
void UserManager::HandleEntranceMessage ( MsgEntry me,
Client client 
) [protected]
void UserManager::HandleGMEvents ( Client client) [protected]

Sends a client a list of their current assigned event.

Parameters:
clientThe requesting client.
void UserManager::HandleGuard ( psUserCmdMessage msg,
Client client 
) [protected]

Handle the /guard command, send it to Guard()

void UserManager::HandleLoot ( psUserCmdMessage msg,
Client client 
)

Handles a /loot command from a player to loot something.

Parameters:
msgThe incoming user command message
clientThe client that request the /who
void UserManager::HandleMarriage ( psUserCmdMessage msg,
Client client 
) [protected]

Command to marry/divorce someone.

Parameters:
msgThe incoming user command message.
clientThe client that request the command..
void UserManager::HandleMOTDRequest ( MsgEntry me,
Client client 
) [protected]

Sends to client the MOTD and tip, and his guild's MOTD if needed.

Parameters:
meThe incoming message
clientthe client to send the message to
void UserManager::HandleMount ( psUserCmdMessage msg,
Client client 
) [protected]

Handles a player command to mount.

Parameters:
msgthe user command message
clientThe client that issued the command.
void UserManager::HandlePickup ( psUserCmdMessage msg,
Client client 
) [protected]

Handle the /pickup command, send it to Pickup()

void UserManager::HandleQuests ( Client client) [protected]

Sends a client a list of their current assigned quests.

Parameters:
clientThe requesting client.
void UserManager::HandleQuestsCommand ( psUserCmdMessage msg,
Client client 
) [protected]

Sends a client a list of their current assigned quests and events.

Parameters:
msgThe incoming user command message.
clientThe requesting client.
void UserManager::HandleQueueAttack ( psUserCmdMessage msg,
Client client 
) [protected]

command to add an attack to the attackQueue

Parameters:
msgThe incoming user command message.
clientThe client that request the command.
void UserManager::HandleRename ( psUserCmdMessage msg,
Client client 
) [protected]
void UserManager::HandleRotate ( psUserCmdMessage msg,
Client client 
) [protected]

Handle the /rotate command, send it to Rotate()

void UserManager::HandleSit ( psUserCmdMessage msg,
Client client 
) [protected]

Handles a player command to sit down.

Parameters:
msgThe incoming user command message
clientThe client who sit
void UserManager::HandleStand ( psUserCmdMessage msg,
Client client 
) [protected]

Handles a player command to stand up.

Parameters:
msgThe incoming user command message.
clientThe client who stand.
void UserManager::HandleStopAttack ( psUserCmdMessage msg,
Client client 
) [protected]

Command to stop attacking your target.

Parameters:
msgThe incoming user command message.
clientThe client that request the command.
void UserManager::HandleTakeAll ( psUserCmdMessage me,
Client client 
) [protected]

Handle taking all items from a container.

Parameters:
meThe message from the client which will be analyzed.
clientThe client which sent the message.
void UserManager::HandleTakeStackAll ( psUserCmdMessage me,
Client client 
) [protected]

Handle taking all items from a container ignoring some qualities when stacking.

Parameters:
meThe message from the client which will be analyzed.
clientThe client which sent the message.
void UserManager::HandleTargetEvent ( MsgEntry me,
Client client 
) [protected]
void UserManager::HandleTraining ( psUserCmdMessage msg,
Client client 
) [protected]

Handles a player command to start training with targeted entity.

Parameters:
msgThe user command message
clientThe client that issued the command.
void UserManager::HandleUnmount ( psUserCmdMessage msg,
Client client 
) [protected]

Handles a player command to unmount.

Parameters:
msgthe user command message
clientThe client that issued the command.
void UserManager::HandleUnstick ( psUserCmdMessage msg,
Client client 
) [protected]

Moves a player back to his last valid position.

Parameters:
msgThe incoming user command message.
clientThe client that request the command.
void UserManager::HandleUse ( Client client,
bool  on 
) [protected]

Handles a player request to 'use' the targeted item.

Parameters:
clientThe client that issued the command.
onToggle for start/stop using.
void UserManager::HandleUserCommand ( MsgEntry me,
Client client 
) [protected]

Take a user command from a client, and send it to be handled by a function.

void UserManager::HandleYield ( psUserCmdMessage msg,
Client client 
) [protected]

Handle the yield command.

Parameters:
msgThe incoming user command message.
clientThe client that request the command..
virtual bool UserManager::Initialize ( GEMSupervisor gemsupervisor) [inline, virtual]

Definition at line 60 of file usermanager.h.

bool UserManager::LoadEmotes ( const char *  xmlfile,
iVFS *  vfs 
)

Load emotes from xml.

Parameters:
xmlfileA point to a string containing the xml file.
vfsA pointer to an iVFS object.
Returns:
bool FALSE if there were problems with the passed xml file.
void UserManager::LogStuck ( Client client) [protected]

Helper function to log a stuck character's details.

Parameters:
clientThe client that requested to be unstuck.
void UserManager::Loot ( Client client)

Attempt to loot the target using the loot window.

Sends the lootable items to the client and calls LootMoney(CLient *client)

Parameters:
clientThe client where the loot command came from.
void UserManager::LootItems ( gemActor actor,
Client client,
csString  categories = "all",
uint8_t  lootAction = 0 
)

Attempt to loot all or certain items from target.

Tries to loot the items which fit the specified categories (if any). Also handles group looting and rolling, if a group is present

Parameters:
actorThe actor which is looting
clientThe client where the loot command came from.
categoriesOnly items of given categories are looted (e.g. "weapons, gems")
lootActionEither 0 for LOOT_SELF or 1 for LOOT_ROLL (only works when in a group)
void UserManager::LootMoney ( gemActor actor,
Client client 
)

Attempt to loot money from the target.

Takes money from the target and splits it across the group (if any)

Parameters:
actorThe actor which is looting
clientThe client where the loot command came from.
void UserManager::Mount ( gemActor rider,
gemActor mount 
)

Handles the /mount command.

Parameters:
riderThe actor which is going to mount
mountThe actor which is going to be mounted.
void UserManager::NotifyAllianceBuddies ( Client client,
bool  loggedon 
)

Send a notification to all clients on a person alliance if they log on/off.

Note:
This function excludes the same guild to avoid repetitions with notifyGuildBuddies.
Parameters:
clientThe client that has logged in/out.
loggedonTrue if the player has logged on. False if logged off.
void UserManager::NotifyBuddies ( Client client,
bool  loggedon 
)

Send a notification to all clients on a person buddy list if they log on/off.

This does a database hit.

Parameters:
clientThe client that has logged in/out.
loggedonTrue if the player has logged on. False if logged off.
void UserManager::NotifyGuildBuddies ( Client client,
bool  loggedon 
)

Send a notification to all clients on a person guild if they log on/off.

Parameters:
clientThe client that has logged in/out.
loggedonTrue if the player has logged on. False if logged off.
void UserManager::NotifyPlayerBuddies ( Client client,
bool  loggedon 
)

Send a notification to all player (non GM/Dev) clients on a person buddy list that they have logged on/off.

This does a database hit.

Parameters:
clientThe client that has logged in/out.
loggedonTrue if the player has logged on. False if logged off.
void UserManager::Pickup ( Client client,
csString  target 
) [protected]

Handles a player command to pickup an item.

Parameters:
clientThe client that issued the command.
targetdescription of the item to be picked up.
void UserManager::Ready ( )
void UserManager::Rename ( Client client,
csString *  target,
psItem item 
) [protected]
void UserManager::ReportPosition ( psUserCmdMessage msg,
Client client 
) [protected]

Sends the player their current position and sector.

Parameters:
msgThe incoming user command message.
clientThe client that request the command.
void UserManager::RollDice ( psUserCmdMessage msg,
Client client 
) [protected]

Calculates a dice roll from a player based on number of die and sides.

Parameters:
msgThe incoming user command message.
clientThe client that request the command.
void UserManager::Rotate ( Client client,
gemObject target,
csString  action 
) [protected]

Handles a player command to rotate an item.

Parameters:
clientThe client that issued the command.
targetpointer to the item to be rotated.
actionrotation data
void UserManager::SendCharacterDescription ( Client client,
gemActor actor,
bool  full,
bool  simple,
const csString &  requestor 
)

Sends detail information about 'charData' to 'client'.

If 'full' is true, it contains info about HP and basic stats like Strength.

void UserManager::SendPlayerMoney ( Client client)
void UserManager::ShowNpcMenu ( psUserCmdMessage msg,
Client client 
) [protected]

Handles a player command to show the popup dialog menu of the currently targeted NPC, if any.

Parameters:
msgThe incoming user command message
clientThe client that issued the command.
void UserManager::StartTrading ( psUserCmdMessage msg,
Client client 
) [protected]

Handle the /starttrading command.

void UserManager::StopAllCombat ( Client client) [protected]

Helper function to make the character stop attacking.

Parameters:
clientThe client that needs to stop attacking.
void UserManager::StopTrading ( psUserCmdMessage msg,
Client client 
) [protected]

Handle the /stoptrading command.

void UserManager::StrToLowerCase ( csString &  str) [protected]

Converts a string to lowercase.

Parameters:
strThe string.
void UserManager::SwitchAttackTarget ( Client targeter,
Client targeted 
) [protected]
void UserManager::UserStatRegeneration ( )
void UserManager::Who ( psUserCmdMessage msg,
Client client 
) [protected]

Send a list of the players that are online to a client.

Sends the name/guild/rank of all players in the world.

Parameters:
msgThe incoming user command message
clientThe client that request the /who
bool UserManager::WhoProcessClient ( Client curr,
int  guildId,
csString *  message,
csString  filter,
bool  check,
unsigned count 
) [protected]

Formats output of a player and adds it to a message.

Parameters:
currThe client that is to be formated
guildIdThe guildId of the caller
messageThe target csString object
filterWhat clients
checkIf a check against filter should be done
countCOunter to be increased in case of a successfull match
void UserManager::YieldDuel ( Client client) [protected]

Command to surrender to someone in a duel.

Parameters:
clientThe client that request the command..

Member Data Documentation

Definition at line 655 of file usermanager.h.

Definition at line 653 of file usermanager.h.

Definition at line 646 of file usermanager.h.

csHash<EMOTE*, csString> UserManager::emoteHash [protected]

Definition at line 644 of file usermanager.h.

Definition at line 656 of file usermanager.h.

Definition at line 654 of file usermanager.h.

csHash<userCmdPointer, csString> UserManager::userCommandHash [protected]

Hash of the user commands, the key is the command name.

Definition at line 651 of file usermanager.h.


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