EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Container.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 - 2008 The EVEmu Team
7  For the latest information visit http://evemu.mmoforge.org
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: Aknor Jaden
24  Updates: Allan
25 */
26 
27 #ifndef __CONTAINER__H__INCL__
28 #define __CONTAINER__H__INCL__
29 
30 
31 #include "EVEServerConfig.h"
32 #include "StaticDataMgr.h"
34 #include "system/SystemEntity.h"
35 
40 : public InventoryItem
41 {
42  friend class InventoryItem; // to let it construct us
43 public:
44  CargoContainer(uint32 _containerID, const ItemType &_containerType, const ItemData &_data);
45  virtual ~CargoContainer();
46 
53  static CargoContainerRef Load( uint32 containerID);
60  static CargoContainerRef Spawn( ItemData &data);
61  static CargoContainerRef SpawnTemp( ItemData &data);
62 
63  /*
64  * Primary public interface:
65  */
66  virtual void Delete();
67 
68  double GetCapacity(EVEItemFlags flag) const;
69  /*
70  * _ExecAdd validation interface:
71  */
73 
74  virtual void RemoveItem(InventoryItemRef iRef);
75 
76  // also used for jetcans to NOT delete when empty.
77  bool IsAnchored() { return m_isAnchored; }
78  void SetAnchor(bool set=false) { m_isAnchored = set; }
79 
80  /*
81  * Public fields:
82  */
83  const ItemType &type() const { return InventoryItem::type(); }
84 
85  /*
86  * Primary public packet builders:
87  */
89 
90  virtual void MakeDamageState(DoDestinyDamageState &into) const;
91 
92  bool IsEmpty() { return GetMyInventory()->IsEmpty(); }
93  void SetMySE(SystemEntity* pSE) { mySE = pSE;}
94 
95 protected:
97 
98  /*
99  * Member functions:
100  */
101  using InventoryItem::_Load;
102  virtual bool _Load();
103 
104  // Template loader:
105  template<class _Ty>
106  static RefPtr<_Ty> _LoadItem( uint32 containerID, const ItemType &type, const ItemData &data) {
112  {
113  _log(ITEM__ERROR, "Trying to load %s as Container.", sDataMgr.GetCategoryName(type.categoryID()));
114  if (sConfig.debug.StackTrace)
115  EvE::traceStack();
116  return RefPtr<_Ty>();
117  }
118  return CargoContainerRef( new CargoContainer(containerID, type, data ) );
119  }
120 
121  static uint32 CreateItemID( ItemData &data);
122 
123  virtual PyRep* GetItem() const { return GetItemRow(); }
124 
125 private:
127 };
128 
129 
133 class PyServiceMgr;
134 class Item;
135 class DestinyManager;
136 class SystemManager;
137 class ServiceDB;
138 
140 : public ItemSystemEntity
141 {
142 public:
144  virtual ~ContainerSE();
145 
146  /* Base */
147  virtual bool isGlobal() { return m_global; }
148  /* class type pointer querys. */
149  virtual ContainerSE* GetContSE() { return this; }
150  /* class type tests. */
151  virtual bool IsContainerSE() { return true; }
152 
153  /* SystemEntity interface */
154  virtual void Process();
155  virtual void EncodeDestiny(Buffer& into);
156  virtual PyDict* MakeSlimItem();
157  virtual void MakeDamageState(DoDestinyDamageState &into);
158 
159  /* specific functions handled in this class. */
160  void Activate(int32 effectID);
161  void Deactivate(int32 effectID);
162  void AnchorContainer();
163  bool IsEmpty() { return m_contRef->IsEmpty(); }
164  bool IsAnchored() { return m_contRef->IsAnchored(); }
165 
166  void SetGlobal(bool set=false) { m_global = set; }
167 
168 protected:
170 
172 
173  bool m_global; // for making bubble centers global
174 
177  double m_hullDamage;
178 };
179 
185 : public InventoryItem
186 {
187  friend class InventoryItem; // to let it construct us
188 public:
189  // put factionID in item's CustomInfo field to allow salvage
190  WreckContainer(uint32 _containerID, const ItemType &_containerType, const ItemData &_data);
191  virtual ~WreckContainer();
192 
193  static WreckContainerRef Load( uint32 containerID);
194  static WreckContainerRef Spawn( ItemData &data);
195 
196  virtual void Delete();
197  virtual void RemoveItem(InventoryItemRef iRef);
198 
199  double GetCapacity(EVEItemFlags flag) const;
201 
202  const ItemType &type() const { return InventoryItem::type(); }
203 
205 
206  bool IsEmpty() { return pInventory->IsEmpty(); }
207  void MakeSlimItemChange();
208  void SetMySE(SystemEntity* pSE) { mySE = pSE;}
209  void Salvaged() { m_salvaged = true; }
210 
211 protected:
212  using InventoryItem::_Load;
213  virtual bool _Load();
214 
215  // Template loader:
216  template<class _Ty>
217  static RefPtr<_Ty> _LoadItem( uint32 containerID, const ItemType &type, const ItemData &data) {
218  if (type.groupID() != EVEDB::invGroups::Wreck) {
219  _log(ITEM__ERROR, "Trying to load %s as Wreck.", sDataMgr.GetCategoryName(type.categoryID()));
220  if (sConfig.debug.StackTrace)
221  EvE::traceStack();
222  return RefPtr<_Ty>();
223  }
224  return WreckContainerRef( new WreckContainer(containerID, type, data ) );
225  }
226 
227  static uint32 CreateItemID( ItemData &data );
228 
229 private:
231  bool m_delete;
233 };
234 
240 class WreckSE
241 : public DynamicSystemEntity
242 {
243 public:
244  // put factionID in item's CustomInfo field to allow salvage
245  WreckSE(WreckContainerRef self, PyServiceMgr& services, SystemManager* system, const FactionData& data);
246  virtual ~WreckSE();
247 
248  /* class type pointer querys. */
249  virtual WreckSE* GetWreckSE() { return this; }
250  /* class type tests. */
251  virtual bool IsWreckSE() { return true; }
252 
253  /* SystemEntity interface */
254  virtual void Process();
255  virtual void EncodeDestiny(Buffer& into);
256  virtual PyDict* MakeSlimItem();
257 
258  /* virtual functions default to base class and overridden as needed */
259  virtual void Abandon();
260 
261  /* specific functions handled in this class. */
262  void Salvaged() { m_contRef->Salvaged(); }
263  void SetLaunchedByID(uint32 launcherID) { m_launchedByID = launcherID; }
264  bool IsEmpty() { return m_contRef->IsEmpty(); }
265 
267  double GetOwnerBounty() { return 0; }
268 
269 protected:
271 
273 
275 
276 private:
278 
279 };
280 
281 #endif /* !__CONTAINER__H__INCL__ */
282 
283 
Base Python wire object.
Definition: PyRep.h:66
bool IsEmpty()
Definition: Container.h:206
#define sConfig
A macro for easier access to the singleton.
PyPackedRow * GetItemRow() const
void SetGlobal(bool set=false)
Definition: Container.h:166
ContainerSE(CargoContainerRef self, PyServiceMgr &services, SystemManager *system, const FactionData &data)
Definition: Container.cpp:229
double GetCapacity(EVEItemFlags flag) const
Definition: Container.cpp:441
virtual void RemoveItem(InventoryItemRef iRef)
Definition: Container.cpp:155
PyObject * CargoContainerGetInfo()
Definition: Container.cpp:137
WreckContainerRef m_contRef
Definition: Container.h:270
#define _log(type, fmt,...)
Definition: logsys.h:124
Python's dictionary.
Definition: PyRep.h:719
uint16 groupID() const
Definition: ItemType.h:64
virtual ~CargoContainer()
Definition: Container.cpp:51
void Salvaged()
Definition: Container.h:209
static uint32 CreateItemID(ItemData &data)
Definition: Container.cpp:109
PyObject * WreckContainerGetInfo()
Definition: Container.cpp:446
EVEItemFlags
Definition: EVE_Flags.h:13
virtual ~WreckContainer()
Definition: Container.cpp:391
virtual void EncodeDestiny(Buffer &into)
Definition: Container.cpp:549
WreckSE(WreckContainerRef self, PyServiceMgr &services, SystemManager *system, const FactionData &data)
Definition: Container.cpp:508
static CargoContainerRef SpawnTemp(ItemData &data)
Definition: Container.cpp:87
double GetCapacity(EVEItemFlags flag) const
Definition: Container.cpp:128
void Deactivate(int32 effectID)
Definition: Container.cpp:299
virtual bool _Load()
static uint32 CreateItemID(ItemData &data)
Definition: Container.cpp:427
void SetAnchor(bool set=false)
Definition: Container.h:78
virtual bool IsWreckSE()
Definition: Container.h:251
double GetOwnerBounty()
Definition: Container.h:267
virtual WreckSE * GetWreckSE()
Definition: Container.h:249
virtual void Abandon()
Definition: Container.cpp:543
bool IsAnchored()
Definition: Container.h:77
itemID[count] Create count or of the specified item(from Insider)" ) COMMAND( goto
virtual ~ContainerSE()
Definition: Container.cpp:258
RefPtr< WreckContainer > WreckContainerRef
Definition: ItemRef.h:62
virtual void EncodeDestiny(Buffer &into)
Definition: Container.cpp:311
virtual bool IsContainerSE()
Definition: Container.h:151
virtual void RemoveItem(InventoryItemRef iRef)
Definition: Container.cpp:474
RefPtr< CargoContainer > CargoContainerRef
Definition: ItemRef.h:61
uint8 categoryID() const
Definition: ItemType.h:66
CargoContainerRef m_contRef
Definition: Container.h:169
void AnchorContainer()
Definition: Container.cpp:305
signed __int32 int32
Definition: eve-compat.h:49
bool IsEmpty()
Definition: Container.h:163
const ItemType & type() const
const ItemType & type() const
Definition: Container.h:202
bool m_abandoned
Definition: Container.h:277
virtual PyRep * GetItem() const
Definition: Container.h:123
double m_armorDamage
Definition: Container.h:176
bool IsAnchored()
Definition: Container.h:164
Generic class for buffers.
Definition: Buffer.h:40
virtual void MakeDamageState(DoDestinyDamageState &into) const
Definition: Container.cpp:190
Python object.
Definition: PyRep.h:826
PyTuple * MakeDamageState()
void ValidateAddItem(EVEItemFlags flag, InventoryItemRef item) const
Definition: Container.cpp:133
Inventory * pInventory
bool m_isAnchored
Definition: Container.h:96
void Salvaged()
Definition: Container.h:262
static CargoContainerRef Spawn(ItemData &data)
Definition: Container.cpp:70
virtual PyDict * MakeSlimItem()
Definition: Container.cpp:356
virtual void Delete()
Definition: Container.cpp:114
void ValidateAddItem(EVEItemFlags flag, InventoryItemRef item) const
Definition: Container.cpp:465
static WreckContainerRef Spawn(ItemData &data)
Definition: Container.cpp:410
static RefPtr< _Ty > _LoadItem(uint32 containerID, const ItemType &type, const ItemData &data)
Definition: Container.h:106
virtual bool _Load()
Definition: Container.cpp:63
virtual ContainerSE * GetContSE()
Definition: Container.h:149
void MakeSlimItemChange()
Definition: Container.cpp:490
unsigned __int32 uint32
Definition: eve-compat.h:50
EVEItemFlags flag() const
bool m_global
Definition: Container.h:173
virtual void Process()
Definition: Container.cpp:532
void Activate(int32 effectID)
Definition: Container.cpp:282
virtual PyDict * MakeSlimItem()
Definition: Container.cpp:583
SystemEntity * mySE
Definition: Container.h:126
Timer m_deleteTimer
Definition: Container.h:272
static CargoContainerRef Load(uint32 containerID)
Definition: Container.cpp:58
virtual void Process()
Definition: Container.cpp:271
WreckContainer(uint32 _containerID, const ItemType &_containerType, const ItemData &_data)
Definition: Container.cpp:381
void traceStack(void)
Definition: misc.cpp:169
bool IsEmpty()
Definition: Inventory.h:55
CargoContainer(uint32 _containerID, const ItemType &_containerType, const ItemData &_data)
Definition: Container.cpp:43
static RefPtr< _Ty > _LoadItem(uint32 containerID, const ItemType &type, const ItemData &data)
Definition: Container.h:217
double m_hullDamage
Definition: Container.h:177
Definition: timer.h:30
void SetMySE(SystemEntity *pSE)
Definition: Container.h:93
virtual bool _Load()
Definition: Container.cpp:403
void SetMySE(SystemEntity *pSE)
Definition: Container.h:208
virtual ~WreckSE()
Definition: Container.cpp:525
virtual bool isGlobal()
Definition: Container.h:147
Inventory * GetMyInventory()
Definition: InventoryItem.h:91
bool IsEmpty()
Definition: Container.h:92
bool IsEmpty()
Definition: Container.h:264
Timer m_deleteTimer
Definition: Container.h:171
SystemEntity * mySE
Definition: Container.h:230
double m_shieldCharge
Definition: Container.h:175
uint32 m_launchedByID
Definition: Container.h:274
virtual void Delete()
Definition: Container.cpp:432
void SetLaunchedByID(uint32 launcherID)
Definition: Container.h:263
#define sDataMgr
const ItemType & type() const
Definition: Container.h:83
static WreckContainerRef Load(uint32 containerID)
Definition: Container.cpp:398