EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Station.h
Go to the documentation of this file.
1 /*
2  ------------------------------------------------------------------------------------
3  LICENSE:
4  ------------------------------------------------------------------------------------
5  This file is part of EVEmu: EVE Online Server Emulator
6  Copyright 2006 - 2021 The EVEmu Team
7  For the latest information visit https://evemu.dev
8  ------------------------------------------------------------------------------------
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13 
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License along with
19  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20  Place - Suite 330, Boston, MA 02111-1307, USA, or go to
21  http://www.gnu.org/copyleft/lesser.txt.
22  ------------------------------------------------------------------------------------
23  Author: Bloody.Rabbit
24 */
25 
26 #ifndef __STATION__H__INCL__
27 #define __STATION__H__INCL__
28 
29 #include "StaticDataMgr.h"
30 #include "inventory/ItemType.h"
31 #include "system/Celestial.h"
32 
37 : public ItemType
38 {
39  friend class ItemType; // to let it construct us
40 public:
41 
42  static StationType *Load(uint16 stationTypeID);
43 
44 protected:
45  StationType(uint16 _id, const Inv::TypeData &_data);
46 
47  /*
48  * Member functions:
49  */
50  using ItemType::_Load;
51 
52  // Template loader:
53  template<class _Ty>
54  static _Ty *_LoadType(uint16 stationTypeID, const Inv::TypeData &data)
55  {
56  if (data.groupID != EVEDB::invGroups::Station) {
57  _log(ITEM__ERROR, "Trying to load %s as StationType.", sDataMgr.GetGroupName(data.groupID));
58  if (sConfig.debug.StackTrace)
60  return nullptr;
61  }
62 
63  return new StationType(stationTypeID, data);
64  }
65 };
66 
71 : public CelestialObject
72 {
73  friend class InventoryItem; // to let it construct us
74  friend class CelestialObject; // to let it construct us
75 
76 public:
84  static StationItemRef Load( uint32 stationID);
85 
89 
90  // station methods here for offices, reprocessing, and docking.
91  PyRep* GetOffices() { PyIncRef(m_officePyData); return m_officePyData; } // cached officeData for client call
95  uint32 GetID() { return m_data.stationID; }
96  void RentOffice(OfficeData& odata);
97  uint32 GetOfficeID(uint32 corpID);
98 
99  void LoadStationOffice(uint32 corpID);
100  void AddLoadedOffice(uint32 officeID);
101  void RemoveLoadedOffice(uint32 officeID);
102 
103  bool IsLoaded() { return m_loaded; }
104  bool IsOfficeLoaded(uint32 officeID);
105 
106  void GetGuestList(std::vector<Client*>& cVec);
107  void AddGuest(Client* pClient);
108  void RemoveGuest(Client* pClient);
109 
110  void GetRefineData(uint32& stationCorpID, float& staEfficiency, float& tax);
111 
112  // does client have a ship in this station?
113  bool HasShip(Client* pClient);
114 
115  // will need methods/table for updated station data
116 
117 protected:
118  StationItem(uint32 stationID, const StationType &type, const ItemData &data, const CelestialObjectData &cData);
119  virtual ~StationItem();
120  /*
121  * Member functions:
122  */
123  using InventoryItem::_Load;
124  virtual bool _Load();
125 
126  // Template loader:
127  template<class _Ty>
128  static RefPtr<_Ty> _LoadItem( uint32 stationID, const ItemType &type, const ItemData &data)
129  {
130  if (type.groupID() != EVEDB::invGroups::Station) {
131  _log(ITEM__ERROR, "Trying to load %s as Station.", sDataMgr.GetGroupName(type.groupID()));
132  if (sConfig.debug.StackTrace)
133  EvE::traceStack();
134  return RefPtr<_Ty>();
135  }
136  // cast the type
137  const StationType &stType = static_cast<const StationType &>( type );
138 
139  // load celestial data
141  if (!sItemFactory.db()->GetCelestialObject(stationID, cData))
142  return RefPtr<_Ty>();
143 
144  return StationItemRef(new StationItem(stationID, stType, data, cData));
145  }
146 
147  static uint32 CreateItemID( ItemData &data);
148 
149  // internal office methods
150  void SendBill();
151  void ImpoundOffice(uint32 officeID);
152  void RecoverOffice(uint32 officeID);
153 
154 private:
158 
159  bool m_loaded; // are offices loaded?
161 
162  std::map<uint32, Client*> m_guestList; // charID/Client*
163 
164  std::map<uint32, OfficeData> m_officeMap; // officeID/data
165  std::map<uint32, bool> m_officeLoaded;
166 
167 };
168 
169 
173 class PyServiceMgr;
174 class SystemManager;
175 
177 : public StaticSystemEntity
178 {
179 public:
181  virtual ~StationSE() { /* Do nothing here */ }
182 
183  /* class type pointer querys. */
184  virtual StationSE* GetStationSE() { return this; }
185  /* Static */
186  virtual bool IsStationSE() { return true; }
187 
188  /* virtual functions to be overridden in derived classes */
189  //virtual void Process();
190  virtual PyDict* MakeSlimItem();
191  virtual void EncodeDestiny( Buffer& into );
192 
193  /* specific functions handled here. */
194  void UnloadStation();
195 
196 };
197 
198 #endif /* !__STATION__H__INCL__ */
199 
200 
Base Python wire object.
Definition: PyRep.h:66
CargoContainerRef GetContainerFromInventory(uint32 contID)
Definition: Station.cpp:259
#define sConfig
A macro for easier access to the singleton.
bool IsOfficeLoaded(uint32 officeID)
Definition: Station.cpp:127
RefPtr< StationItem > StationItemRef
Definition: ItemRef.h:66
virtual bool _Load()
Definition: Station.cpp:87
int32 officeRentalFee
void AddGuest(Client *pClient)
Definition: Station.cpp:219
uint32 corporationID
#define _log(type, fmt,...)
Definition: logsys.h:124
std::map< uint32, bool > m_officeLoaded
Definition: Station.h:165
static _Ty * _LoadType(uint16 stationTypeID, const Inv::TypeData &data)
Definition: Station.h:54
void LoadStationOffice(uint32 corpID)
Definition: Station.cpp:144
Python's dictionary.
Definition: PyRep.h:719
uint16 groupID() const
Definition: ItemType.h:64
static StationItemRef Load(uint32 stationID)
Definition: Station.cpp:82
uint32 GetOwnerID()
Definition: Station.h:94
StationSE(StationItemRef station, PyServiceMgr &services, SystemManager *system)
Definition: Station.cpp:268
void GetRefineData(uint32 &stationCorpID, float &staEfficiency, float &tax)
Definition: Station.cpp:235
std::map< uint32, OfficeData > m_officeMap
Definition: Station.h:164
virtual bool _Load()
StationType m_stationType
Definition: Station.h:156
static RefPtr< _Ty > _LoadItem(uint32 stationID, const ItemType &type, const ItemData &data)
Definition: Station.h:128
int8 GetAvalibleOfficeCount()
Definition: Station.h:92
signed __int8 int8
Definition: eve-compat.h:45
void GetGuestList(std::vector< Client * > &cVec)
Definition: Station.cpp:224
signed __int32 int32
Definition: eve-compat.h:49
virtual bool _Load()
Definition: ItemType.cpp:114
const ItemType & type() const
bool IsLoaded()
Definition: Station.h:103
bool HasShip(Client *pClient)
Definition: Station.cpp:242
PyRep * m_officePyData
Definition: Station.h:155
static StationType * Load(uint16 stationTypeID)
Definition: Station.cpp:51
void RemoveLoadedOffice(uint32 officeID)
Definition: Station.cpp:137
StationType * GetStationType()
Definition: Station.h:86
Generic class for buffers.
Definition: Buffer.h:40
void ImpoundOffice(uint32 officeID)
Definition: Station.cpp:163
uint32 stationID
std::map< uint32, Client * > m_guestList
Definition: Station.h:162
virtual PyDict * MakeSlimItem()
Definition: Station.cpp:316
void UnloadStation()
Definition: Station.cpp:333
#define maxRentableOffices
Definition: EVE_Defines.h:80
Definition: Client.h:66
ShipItemRef GetShipFromInventory(uint32 shipID)
Definition: Station.cpp:254
unsigned __int32 uint32
Definition: eve-compat.h:50
#define PyIncRef(op)
Definition: PyRep.h:56
void RemoveGuest(Client *pClient)
Definition: Station.cpp:230
bool m_loaded
Definition: Station.h:159
static uint32 CreateItemID(ItemData &data)
Definition: Station.cpp:106
PyRep * GetOffices()
Definition: Station.h:91
virtual void EncodeDestiny(Buffer &into)
Definition: Station.cpp:286
void AddLoadedOffice(uint32 officeID)
Definition: Station.cpp:120
void traceStack(void)
Definition: misc.cpp:169
StationType(uint16 _id, const Inv::TypeData &_data)
Definition: Station.cpp:43
virtual StationSE * GetStationSE()
Definition: Station.h:184
virtual ~StationSE()
Definition: Station.h:181
#define sItemFactory
Definition: ItemFactory.h:165
virtual ~StationItem()
Definition: Station.cpp:71
void RentOffice(OfficeData &odata)
Definition: Station.cpp:178
int32 GetOfficeRentalFee()
Definition: Station.h:93
void SendBill()
Definition: Station.cpp:214
uint32 GetID()
Definition: Station.h:95
StationData m_data
Definition: Station.h:157
unsigned __int16 uint16
Definition: eve-compat.h:48
void RecoverOffice(uint32 officeID)
Definition: Station.cpp:170
uint32 m_stationID
Definition: Station.h:160
#define sDataMgr
uint32 GetOfficeID(uint32 corpID)
Definition: Station.cpp:110
StationItem(uint32 stationID, const StationType &type, const ItemData &data, const CelestialObjectData &cData)
Definition: Station.cpp:59
virtual bool IsStationSE()
Definition: Station.h:186