Planeshift

psserverchar.h

Go to the documentation of this file.
00001 /*
00002  * psserverchar.h
00003  *
00004  * Copyright (C) 2002 Atomic Blue ([email protected], http://www.atomicblue.org)
00005  *
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation (version 2 of the License)
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017  *
00018  */
00019 #ifndef PS_SERVER_CHAR_MANAGER_H
00020 #define PS_SERVER_CHAR_MANAGER_H
00021 //=============================================================================
00022 // Crystal Space Includes
00023 //=============================================================================
00024 #include <iutil/vfs.h>
00025 #include <csutil/ref.h>
00026 #include <csutil/xmltiny.h>
00027 
00028 //=============================================================================
00029 // Project Includes
00030 //=============================================================================
00031 #include "util/slots.h"
00032 
00033 //=============================================================================
00034 // Local Includes
00035 //=============================================================================
00036 #include "msgmanager.h"
00037 
00038 class MsgEntry;
00039 class Client;
00040 class psItem;
00041 class SlotManager;
00042 class gemActor;
00043 class gemObject;
00044 class psCharacter;
00045 
00046 struct psItemCategory;
00047 class psGUIMerchantMessage;
00048 class psGUIStorageMessage;
00049 class psMerchantInfo;
00050 
00051 
00053 
00058 class ServerCharManager : public MessageManager<ServerCharManager>
00059 {
00060 public:
00061 
00062     ServerCharManager(CacheManager* cachemanager, GEMSupervisor* gemsupervisor);
00063     virtual ~ServerCharManager();
00064 
00065     bool Initialize();
00066 
00068     virtual bool SendInventory(uint32_t clientNum, bool sendUpdatesOnly=true);
00069 
00070     void SendPlayerMoney(Client* client, bool storage = false);
00071 
00073     virtual bool UpdateItemViews(uint32_t clientNum);
00074 
00079     void SendOutPlaySoundMessage(uint32_t clientNum, const char* itemsound, const char* action);
00080 
00096     void SendOutEquipmentMessages(gemActor* actor,
00097                                   INVENTORY_SLOT_NUMBER slotID,
00098                                   psItem* item,
00099                                   int equipped);
00100 
00101     void ViewItem(Client* client, int containerID, INVENTORY_SLOT_NUMBER slotID);
00102 
00109     static bool TradingCheck(Client* client, gemObject* target, csString* errorMessage = NULL);
00110 
00114     void BeginTrading(Client* client, gemObject* target, const csString &type);
00115 
00121     void BeginStoring(Client* client, gemObject* target, const csString &type);
00122 
00123     bool IsBanned(const char* name);
00124 
00126     bool HasConnected(csString name);
00127 
00128 protected:
00129 
00130     void HandleBookWrite(MsgEntry* me, Client* client);
00131     void HandleCraftTransInfo(MsgEntry* me, Client* client);
00133     void HandleInventoryMessage(MsgEntry* me, Client* client);
00134     void HandleFaction(MsgEntry* me, Client* client);
00135     void ViewItem(MsgEntry* me, Client* client);
00136     void UpdateSketch(MsgEntry* me, Client* client);
00137     void UpdateMusicalSheet(MsgEntry* me, Client* client);
00138 
00139     // -------------------Merchant Handling -------------------------------
00140     int CalculateMerchantPrice(psItem* item, Client* client, bool sellPrice);
00141     bool SendMerchantItems(Client* client, psCharacter* merchant, psItemCategory* category);
00142     void HandleMerchantMessage(MsgEntry* me, Client* client);
00143     void HandleMerchantRequest(psGUIMerchantMessage &msg, Client* client);
00144     void HandleMerchantCategory(psGUIMerchantMessage &msg, Client* client);
00145     void HandleMerchantBuy(psGUIMerchantMessage &msg, Client* client);
00146     void HandleMerchantSell(psGUIMerchantMessage &msg, Client* client);
00147     void HandleMerchantView(psGUIMerchantMessage &msg, Client* client);
00148     // ------------------Storage Handling----------------------------------
00153     void HandleStorageMessage(MsgEntry* me, Client* client);
00154 
00163     bool SendStorageItems(Client* client, psCharacter* character, psItemCategory* category);
00164 
00169     void HandleStorageRequest(psGUIStorageMessage &msg, Client* client);
00174     void HandleStorageCategory(psGUIStorageMessage &msg, Client* client);
00179     void HandleStorageWithdraw(psGUIStorageMessage &msg, Client* client);
00184     void HandleStorageStore(psGUIStorageMessage &msg, Client* client);
00189     void HandleStorageView(psGUIStorageMessage &msg, Client* client);
00190     // --------------------------------------------------------------------
00191 
00192     bool SendPlayerItems(Client* client, psItemCategory* category, bool storage);
00193 
00194 
00196     bool VerifyTrade(Client* client, psCharacter* character, psCharacter** merchant, psMerchantInfo** info,
00197                      const char* trade, const char* itemName, PID merchantID);
00198 
00200     bool VerifyStorage(Client* client, psCharacter* character, psCharacter** storage,
00201                        const char* trade, const char* itemName, PID storageID);
00202 
00204     bool VerifyGoal(Client* client, psCharacter* character, psItem* goal);
00205 
00206 //    ClientConnectionSet*    clients;
00207 
00208     SlotManager* slotManager;
00209     CacheManager* cacheManager;
00210     GEMSupervisor* gemSupervisor;
00211 
00212     MathScript* calc_item_merchant_price_buy;
00213     MathScript* calc_item_merchant_price_sell;
00214 };
00215 
00216 #endif
00217 
00218