Planeshift
psserverchar.h
Go to the documentation of this file.
1 /*
2  * psserverchar.h
3  *
4  * Copyright (C) 2002 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 #ifndef PS_SERVER_CHAR_MANAGER_H
20 #define PS_SERVER_CHAR_MANAGER_H
21 //=============================================================================
22 // Crystal Space Includes
23 //=============================================================================
24 #include <iutil/vfs.h>
25 #include <csutil/ref.h>
26 #include <csutil/xmltiny.h>
27 
28 //=============================================================================
29 // Project Includes
30 //=============================================================================
31 #include "util/slots.h"
32 
33 //=============================================================================
34 // Local Includes
35 //=============================================================================
36 #include "msgmanager.h"
37 
38 class MsgEntry;
39 class Client;
40 class psItem;
41 class SlotManager;
42 class gemActor;
43 class gemObject;
44 class psCharacter;
45 
46 struct psItemCategory;
49 class psMerchantInfo;
50 
51 
53 
58 class ServerCharManager : public MessageManager<ServerCharManager>
59 {
60 public:
61 
62  ServerCharManager(CacheManager* cachemanager, GEMSupervisor* gemsupervisor);
63  virtual ~ServerCharManager();
64 
65  bool Initialize();
66 
68  virtual bool SendInventory(uint32_t clientNum, bool sendUpdatesOnly=true);
69 
70  void SendPlayerMoney(Client* client, bool storage = false);
71 
73  virtual bool UpdateItemViews(uint32_t clientNum);
74 
79  void SendOutPlaySoundMessage(uint32_t clientNum, const char* itemsound, const char* action);
80 
97  INVENTORY_SLOT_NUMBER slotID,
98  psItem* item,
99  int equipped);
100 
101  void ViewItem(Client* client, int containerID, INVENTORY_SLOT_NUMBER slotID);
102 
109  static bool TradingCheck(Client* client, gemObject* target, csString* errorMessage = NULL);
110 
114  void BeginTrading(Client* client, gemObject* target, const csString &type);
115 
121  void BeginStoring(Client* client, gemObject* target, const csString &type);
122 
123  bool IsBanned(const char* name);
124 
126  bool HasConnected(csString name);
127 
128 protected:
129 
130  void HandleBookWrite(MsgEntry* me, Client* client);
131  void HandleCraftTransInfo(MsgEntry* me, Client* client);
133  void HandleInventoryMessage(MsgEntry* me, Client* client);
134  void HandleFaction(MsgEntry* me, Client* client);
135  void ViewItem(MsgEntry* me, Client* client);
136  void UpdateSketch(MsgEntry* me, Client* client);
137  void UpdateMusicalSheet(MsgEntry* me, Client* client);
138 
139  // -------------------Merchant Handling -------------------------------
140  int CalculateMerchantPrice(psItem* item, Client* client, bool sellPrice);
141  bool SendMerchantItems(Client* client, psCharacter* merchant, psItemCategory* category);
142  void HandleMerchantMessage(MsgEntry* me, Client* client);
145  void HandleMerchantBuy(psGUIMerchantMessage &msg, Client* client);
146  void HandleMerchantSell(psGUIMerchantMessage &msg, Client* client);
147  void HandleMerchantView(psGUIMerchantMessage &msg, Client* client);
148  // ------------------Storage Handling----------------------------------
153  void HandleStorageMessage(MsgEntry* me, Client* client);
154 
163  bool SendStorageItems(Client* client, psCharacter* character, psItemCategory* category);
164 
169  void HandleStorageRequest(psGUIStorageMessage &msg, Client* client);
184  void HandleStorageStore(psGUIStorageMessage &msg, Client* client);
189  void HandleStorageView(psGUIStorageMessage &msg, Client* client);
190  // --------------------------------------------------------------------
191 
192  bool SendPlayerItems(Client* client, psItemCategory* category, bool storage);
193 
194 
196  bool VerifyTrade(Client* client, psCharacter* character, psCharacter** merchant, psMerchantInfo** info,
197  const char* trade, const char* itemName, PID merchantID);
198 
200  bool VerifyStorage(Client* client, psCharacter* character, psCharacter** storage,
201  const char* trade, const char* itemName, PID storageID);
202 
204  bool VerifyGoal(Client* client, psCharacter* character, psItem* goal);
205 
206 // ClientConnectionSet* clients;
207 
211 
214 };
215 
216 #endif
217 
218 
Handles Drag and Drop Messages from the client.
Definition: slotmanager.h:40
void HandleStorageStore(psGUIStorageMessage &msg, Client *client)
Handles the request to store an item from the player.
GUI Merchant Message.
Definition: messages.h:2083
SlotManager * slotManager
Definition: psserverchar.h:208
MathScript * calc_item_merchant_price_sell
Definition: psserverchar.h:213
void BeginStoring(Client *client, gemObject *target, const csString &type)
Handles a storing beginning.
void HandleMerchantView(psGUIMerchantMessage &msg, Client *client)
void HandleStorageRequest(psGUIStorageMessage &msg, Client *client)
Handles the request to access the storage from the player.
void ViewItem(Client *client, int containerID, INVENTORY_SLOT_NUMBER slotID)
void HandleMerchantSell(psGUIMerchantMessage &msg, Client *client)
void SendOutEquipmentMessages(gemActor *actor, INVENTORY_SLOT_NUMBER slotID, psItem *item, int equipped)
Sends out equipment messages to all the people around client.
A MathScript is a mini-program to run.
Definition: mathscript.h:442
INVENTORY_SLOT_NUMBER
Holds a list of the possible socket identifiers that items can be attached to.
Definition: slots.h:32
void HandleCraftTransInfo(MsgEntry *me, Client *client)
The structure of 1 queue entry (pointer to a message)
Definition: message.h:143
bool VerifyTrade(Client *client, psCharacter *character, psCharacter **merchant, psMerchantInfo **info, const char *trade, const char *itemName, PID merchantID)
Return true if all trade params are ok.
void HandleStorageView(psGUIStorageMessage &msg, Client *client)
Handles the request to check informations about a stored item.
virtual bool UpdateItemViews(uint32_t clientNum)
Update all views with items.
Manages character details over the net.
Definition: psserverchar.h:58
bool IsBanned(const char *name)
void HandleMerchantRequest(psGUIMerchantMessage &msg, Client *client)
bool HasConnected(csString name)
Checked if the character exists still or if it hasn&#39;t connected in two months.
void HandleMerchantMessage(MsgEntry *me, Client *client)
Any semi-autonomous object, either a player or an NPC.
Definition: gem.h:1170
void HandleFaction(MsgEntry *me, Client *client)
bool VerifyGoal(Client *client, psCharacter *character, psItem *goal)
verifies that item dropped in mind slot is a valid goal
void HandleInventoryMessage(MsgEntry *me, Client *client)
Handles any incoming messages about the character gui.
ServerCharManager(CacheManager *cachemanager, GEMSupervisor *gemsupervisor)
void UpdateSketch(MsgEntry *me, Client *client)
bool VerifyStorage(Client *client, psCharacter *character, psCharacter **storage, const char *trade, const char *itemName, PID storageID)
Return true if all storage params are ok.
This class collects data of a netclient.
Definition: client.h:95
bool SendMerchantItems(Client *client, psCharacter *merchant, psItemCategory *category)
bool SendStorageItems(Client *client, psCharacter *character, psItemCategory *category)
Sends to the client the stored items for this category.
void SendOutPlaySoundMessage(uint32_t clientNum, const char *itemsound, const char *action)
Sends out sound messages to the client.
virtual bool SendInventory(uint32_t clientNum, bool sendUpdatesOnly=true)
Sends the client an inventory.
void BeginTrading(Client *client, gemObject *target, const csString &type)
Start trading.
void UpdateMusicalSheet(MsgEntry *me, Client *client)
This class manages the caching of data that is unchanging during server operation.
Definition: cachemanager.h:234
CacheManager * cacheManager
Definition: psserverchar.h:209
int CalculateMerchantPrice(psItem *item, Client *client, bool sellPrice)
void HandleBookWrite(MsgEntry *me, Client *client)
A gemObject is any solid, graphical object visible in PS with normal physics and normal collision det...
Definition: gem.h:314
This class holds the refs to the core factories, etc in CEL.
Definition: gem.h:126
void HandleStorageWithdraw(psGUIStorageMessage &msg, Client *client)
Handles the request to withdraw an item from the NPC.
bool SendPlayerItems(Client *client, psItemCategory *category, bool storage)
void SendPlayerMoney(Client *client, bool storage=false)
MathScript * calc_item_merchant_price_buy
Definition: psserverchar.h:212
This class retrieves the merchant categories for an NPC.
void HandleMerchantBuy(psGUIMerchantMessage &msg, Client *client)
static bool TradingCheck(Client *client, gemObject *target, csString *errorMessage=NULL)
Check if trading is allowed.
GUI Exchange Message.
Definition: messages.h:2027
void HandleStorageCategory(psGUIStorageMessage &msg, Client *client)
Handles the request to change category from the player.
void HandleMerchantCategory(psGUIMerchantMessage &msg, Client *client)
GEMSupervisor * gemSupervisor
Definition: psserverchar.h:210
This class embodies item instances in the game.
Definition: psitem.h:238
virtual ~ServerCharManager()
void HandleStorageMessage(MsgEntry *me, Client *client)
Handles a message coming from the client for making operations with his storage.
Provides a manager to facilitate subscriptions.
Definition: msgmanager.h:106