Planeshift
usermanager.h
Go to the documentation of this file.
1 /*
2  * usermanager.h - Author: Keith Fulton
3  *
4  * Copyright (C) 2001 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 
20 
26 #ifndef __USERMANAGER_H__
27 #define __USERMANAGER_H__
28 
29 //=============================================================================
30 // Crystal Space Includes
31 //=============================================================================
32 
33 //=============================================================================
34 // Project Includes
35 //=============================================================================
36 
37 //=============================================================================
38 // Local Includes
39 //=============================================================================
40 #include "msgmanager.h" // Parent class
41 
43 // FORWARD DECLARATIONS
46 class PendingDuelInvite;
47 class BankManager;
48 class EntityManager;
49 
53 class UserManager : public MessageManager<UserManager>
54 {
55 public:
56 
57  UserManager(ClientConnectionSet* pCCS, CacheManager* cachemanager, BankManager* bankmanager, EntityManager* entitymanager);
58  virtual ~UserManager();
59 
60  virtual bool Initialize(GEMSupervisor* gemsupervisor)
61  {
62  gem = gemsupervisor;
63  return true;
64  }
65 
74  void NotifyBuddies(Client* client, bool loggedon);
75 
84  void NotifyPlayerBuddies(Client* client, bool loggedon);
85 
92  void NotifyGuildBuddies(Client* client, bool loggedon);
93 
102  void NotifyAllianceBuddies(Client* client, bool loggedon);
103 
104  enum
105  {
108  };
109 
119  void BuddyList(Client* client, int clientnum, bool filter);
120 
121  void UserStatRegeneration();
122  void Ready();
123 
129  void AcceptDuel(PendingDuelInvite* invite);
130 
135  void CalculateComparativeDifference(psCharacter* myCharData, psCharacter* theirCharData,
136  int &theirPhysicalLevel, int &theirMagicalLevel,
137  int &physicalDiff, int &magicalDiff, int &overallLevelComparison);
138 
144  void SendCharacterDescription(Client* client, gemActor* actor, bool full, bool simple, const csString &requestor);
145 
146  void Attack(Stance stance, Client* client);
147 
148  void SendPlayerMoney(Client* client);
149 
150 
157  void HandleLoot(psUserCmdMessage &msg, Client* client);
158 
165  bool CheckTargetLootable(gemActor* actor, Client* client);
166 
174  void Loot(Client* client);
175 
184  void LootMoney(gemActor* actor, Client* client);
185 
197  void LootItems(gemActor* actor, Client* client, csString categories = "all", uint8_t lootAction = 0);
198 
206  bool LoadEmotes(const char* xmlfile, iVFS* vfs);
207 
215  bool CheckForEmote(csString command, bool execute, gemActor* actor);
216 
225  void Emote(csString general, csString specific, csString animation, gemActor* actor);
226 
231  bool Animation(csString animation, gemActor* actor);
232 
238  void Mount(gemActor* rider, gemActor* mount);
239 
240 protected:
249  void Who(psUserCmdMessage &msg, Client* client);
250 
251 
262  bool WhoProcessClient(Client* curr, int guildId, csString* message, csString filter, bool check, unsigned* count);
263 
269  void StrToLowerCase(csString &str);
270 
279  void Buddy(psUserCmdMessage &msg,Client* client);
280 
281  enum
282  {
285  };
286 
287 
294  void RollDice(psUserCmdMessage &msg, Client* client);
295 
296 
303  void ReportPosition(psUserCmdMessage &msg, Client* client);
304 
305 
306  /*
307  * Moves a player back to the default start point for their race.
308  *
309  * @param msg The incoming user command message.
310  * @param client The client that request the command..
311  *
312  void MoveToSpawnPos(psUserCmdMessage& msg,Client *client,int clientnum); */
313 
320  void HandleUnstick(psUserCmdMessage &msg,Client* client);
321 
327  void LogStuck(Client* client);
328 
334  void StopAllCombat(Client* client);
335 
343  void HandleAttack(psUserCmdMessage &msg, Client* client);
344 
345 
352  void HandleQueueAttack(psUserCmdMessage& msg, Client *client);
353 
359  void HandleStopAttack(psUserCmdMessage& msg,Client *client);
360 
361 
368  void ChallengeToDuel(psUserCmdMessage &msg, Client* client);
369 
375  void YieldDuel(Client* client);
376 
383  void HandleYield(psUserCmdMessage &msg, Client* client);
384 
388  void StartTrading(psUserCmdMessage &msg, Client* client);
389 
393  void StopTrading(psUserCmdMessage &msg, Client* client);
394 
401  void HandleMarriage(psUserCmdMessage &msg,Client* client);
402 
408  void HandleQuests(Client* client);
409 
416  void HandleQuestsCommand(psUserCmdMessage &msg,Client* client);
417 
423  void HandleGMEvents(Client* client);
424 
431  void GiveTip(psUserCmdMessage &msg, Client* client);
432 
439  void GiveMOTD(psUserCmdMessage &msg, Client* client);
440 
447  void ShowNpcMenu(psUserCmdMessage &msg, Client* client);
448 
455  void HandleSit(psUserCmdMessage &msg, Client* client);
456 
463  void HandleAdminCommand(psUserCmdMessage &msg, Client* client);
464 
471  void HandleStand(psUserCmdMessage &msg, Client* client);
472 
479  void HandleDie(psUserCmdMessage &msg, Client* client);
480 
487  void HandleTraining(psUserCmdMessage &msg, Client* client);
488 
495  void HandleBanking(psUserCmdMessage &msg, Client* client);
496 
500  void HandlePickup(psUserCmdMessage &msg, Client* client);
501 
508  void Pickup(Client* client, csString target);
509 
516  void HandleMount(psUserCmdMessage &msg, Client* client);
517 
524  void HandleUnmount(psUserCmdMessage &msg, Client* client);
525 
529  void HandleGuard(psUserCmdMessage &msg, Client* client);
530 
541  void Guard(Client* client, gemObject* object, csString action);
542 
546  void HandleRotate(psUserCmdMessage &msg, Client* client);
547 
555  void Rotate(Client* client, gemObject* target, csString action);
556 
563  void HandleUse(Client* client, bool on);
564 
571  void Assist(psUserCmdMessage &msg, Client* client);
572 
579  void HandleMOTDRequest(MsgEntry* me,Client* client);
580 
584  void HandleUserCommand(MsgEntry* me,Client* client);
585 
589  void HandleCharDescUpdate(MsgEntry* me,Client* client);
590 
594  void HandleCharDetailsRequest(MsgEntry* me,Client* client);
595 
599  void HandleTargetEvent(MsgEntry* me,Client* client);
600 
604  void HandleEntranceMessage(MsgEntry* me, Client* client);
605 
609  void HandleClientReady(MsgEntry* me, Client* client);
610 
617  void HandleTakeAll(psUserCmdMessage &me, Client* client);
618 
625  void HandleTakeStackAll(psUserCmdMessage &me, Client* client);
626 
630  void SwitchAttackTarget(Client* targeter, Client* targeted);
631  void HandleRename(psUserCmdMessage &msg, Client* client);
632 
633  void Rename(Client *client, csString *target, psItem *item);
634 
636  struct EMOTE
637  {
638  csString command;
639  csString general;
640  csString specific;
641  csString anim;
642  };
643 
644  csHash<EMOTE*, csString> emoteHash;
645 
647 
649  typedef void (UserManager::*userCmdPointer)(psUserCmdMessage &msg, Client* client);
651  csHash<userCmdPointer, csString> userCommandHash;
652 
657 };
658 
659 #endif
void HandleTraining(psUserCmdMessage &msg, Client *client)
Handles a player command to start training with targeted entity.
void HandleGMEvents(Client *client)
Sends a client a list of their current assigned event.
void Guard(Client *client, gemObject *object, csString action)
Handles a player command to guard/unguard an item.
Manages CEL entities on the server.
Definition: entitymanager.h:77
void HandleMarriage(psUserCmdMessage &msg, Client *client)
Command to marry/divorce someone.
void Assist(psUserCmdMessage &msg, Client *client)
Handles an /Assist command comming from the client.
void HandleUserCommand(MsgEntry *me, Client *client)
Take a user command from a client, and send it to be handled by a function.
void HandleEntranceMessage(MsgEntry *me, Client *client)
void HandleBanking(psUserCmdMessage &msg, Client *client)
Handles a player command to start banking with the targeted entity.
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 l...
void HandleStopAttack(psUserCmdMessage &msg, Client *client)
Command to stop attacking your target.
void Emote(csString general, csString specific, csString animation, gemActor *actor)
Process an emote command.
CacheManager * cacheManager
Definition: usermanager.h:653
csHash< EMOTE *, csString > emoteHash
Definition: usermanager.h:644
Used to manage incoming user commands from a client.
Definition: usermanager.h:53
void RollDice(psUserCmdMessage &msg, Client *client)
Calculates a dice roll from a player based on number of die and sides.
void HandleAttack(psUserCmdMessage &msg, Client *client)
Command to start attacking something.
void HandleUnmount(psUserCmdMessage &msg, Client *client)
Handles a player command to unmount.
void StopTrading(psUserCmdMessage &msg, Client *client)
Handle the /stoptrading command.
The structure of 1 queue entry (pointer to a message)
Definition: message.h:143
void HandleLoot(psUserCmdMessage &msg, Client *client)
Handles a /loot command from a player to loot something.
void LootMoney(gemActor *actor, Client *client)
Attempt to loot money from the target.
void StartTrading(psUserCmdMessage &msg, Client *client)
Handle the /starttrading command.
void HandleQuests(Client *client)
Sends a client a list of their current assigned quests.
void HandleDie(psUserCmdMessage &msg, Client *client)
Handles a player command to die.
void Ready()
void ChallengeToDuel(psUserCmdMessage &msg, Client *client)
Command to challenge someone to a duel.
void Mount(gemActor *rider, gemActor *mount)
Handles the /mount command.
virtual ~UserManager()
void BuddyList(Client *client, int clientnum, bool filter)
Send a buddy list to a player.
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 o...
void Pickup(Client *client, csString target)
Handles a player command to pickup an item.
virtual bool Initialize(GEMSupervisor *gemsupervisor)
Definition: usermanager.h:60
void ReportPosition(psUserCmdMessage &msg, Client *client)
Sends the player their current position and sector.
void GiveTip(psUserCmdMessage &msg, Client *client)
Give a tip from the database to the client.
void HandleTakeStackAll(psUserCmdMessage &me, Client *client)
Handle taking all items from a container ignoring some qualities when stacking.
void HandleGuard(psUserCmdMessage &msg, Client *client)
Handle the /guard command, send it to Guard()
Any semi-autonomous object, either a player or an NPC.
Definition: gem.h:1170
void HandleCharDetailsRequest(MsgEntry *me, Client *client)
Handle a request to send a character description.
void HandleUse(Client *client, bool on)
Handles a player request to &#39;use&#39; the targeted item.
void HandleAdminCommand(psUserCmdMessage &msg, Client *client)
Handles the /admin command.
void HandleQueueAttack(psUserCmdMessage &msg, Client *client)
command to add an attack to the attackQueue
void HandleMount(psUserCmdMessage &msg, Client *client)
Handles a player command to mount.
void HandleRotate(psUserCmdMessage &msg, Client *client)
Handle the /rotate command, send it to Rotate()
void HandleTakeAll(psUserCmdMessage &me, Client *client)
Handle taking all items from a container.
void UserStatRegeneration()
void AcceptDuel(PendingDuelInvite *invite)
This is called by the Pending Invite if the duel is accepted.
void HandleRename(psUserCmdMessage &msg, Client *client)
void YieldDuel(Client *client)
Command to surrender to someone in a duel.
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 HandleTargetEvent(MsgEntry *me, Client *client)
void SendCharacterDescription(Client *client, gemActor *actor, bool full, bool simple, const csString &requestor)
Sends detail information about &#39;charData&#39; to &#39;client&#39;.
void HandleUnstick(psUserCmdMessage &msg, Client *client)
Moves a player back to his last valid position.
void SendPlayerMoney(Client *client)
UserManager(ClientConnectionSet *pCCS, CacheManager *cachemanager, BankManager *bankmanager, EntityManager *entitymanager)
csHash< userCmdPointer, csString > userCommandHash
Hash of the user commands, the key is the command name.
Definition: usermanager.h:651
void ShowNpcMenu(psUserCmdMessage &msg, Client *client)
Handles a player command to show the popup dialog menu of the currently targeted NPC, if any.
EntityManager * entityManager
Definition: usermanager.h:656
This class collects data of a netclient.
Definition: client.h:95
void HandleClientReady(MsgEntry *me, Client *client)
void Rename(Client *client, csString *target, psItem *item)
void LootItems(gemActor *actor, Client *client, csString categories="all", uint8_t lootAction=0)
Attempt to loot all or certain items from target.
void Loot(Client *client)
Attempt to loot the target using the loot window.
bool CheckTargetLootable(gemActor *actor, Client *client)
Checks whether target is lootable.
void Attack(Stance stance, Client *client)
void HandleStand(psUserCmdMessage &msg, Client *client)
Handles a player command to stand up.
BankManager * bankManager
Definition: usermanager.h:655
User commands.
Definition: messages.h:1249
void HandlePickup(psUserCmdMessage &msg, Client *client)
Handle the /pickup command, send it to Pickup()
This class manages the caching of data that is unchanging during server operation.
Definition: cachemanager.h:234
void LogStuck(Client *client)
Helper function to log a stuck character&#39;s details.
A gemObject is any solid, graphical object visible in PS with normal physics and normal collision det...
Definition: gem.h:314
void HandleYield(psUserCmdMessage &msg, Client *client)
Handle the yield command.
This class holds the refs to the core factories, etc in CEL.
Definition: gem.h:126
void NotifyAllianceBuddies(Client *client, bool loggedon)
Send a notification to all clients on a person alliance if they log on/off.
void HandleMOTDRequest(MsgEntry *me, Client *client)
Sends to client the MOTD and tip, and his guild&#39;s MOTD if needed.
void(UserManager::* userCmdPointer)(psUserCmdMessage &msg, Client *client)
pointer to member function typedef, improves readability
Definition: usermanager.h:649
void SwitchAttackTarget(Client *targeter, Client *targeted)
void StopAllCombat(Client *client)
Helper function to make the character stop attacking.
This class is a list of several CLient objects, it&#39;s designed for finding clients very fast based on ...
Definition: clients.h:58
void HandleCharDescUpdate(MsgEntry *me, Client *client)
Handle a message to update a character&#39;s description.
void Rotate(Client *client, gemObject *target, csString action)
Handles a player command to rotate an item.
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...
void StrToLowerCase(csString &str)
Converts a string to lowercase.
void HandleSit(psUserCmdMessage &msg, Client *client)
Handles a player command to sit down.
void Buddy(psUserCmdMessage &msg, Client *client)
Adds/removes a person to a player&#39;s buddy list.
void GiveMOTD(psUserCmdMessage &msg, Client *client)
Sends the MOTD to the client.
void Who(psUserCmdMessage &msg, Client *client)
Send a list of the players that are online to a client.
Struct to hold our emote data.
Definition: usermanager.h:636
void HandleQuestsCommand(psUserCmdMessage &msg, Client *client)
Sends a client a list of their current assigned quests and events.
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.
bool CheckForEmote(csString command, bool execute, gemActor *actor)
Check to see if command is an emote.
bool LoadEmotes(const char *xmlfile, iVFS *vfs)
Load emotes from xml.
ClientConnectionSet * clients
Definition: usermanager.h:646
This class embodies item instances in the game.
Definition: psitem.h:238
GEMSupervisor * gem
Definition: usermanager.h:654
Provides a manager to facilitate subscriptions.
Definition: msgmanager.h:106