EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
StationOffice.cpp
Go to the documentation of this file.
1 
11 #include "station/StationDataMgr.h"
12 
13 #include "database/EVEDBUtils.h"
14 
15 
16 #include "eve-server.h"
17 
18 #include "Client.h"
19 #include "EntityList.h"
20 #include "EVEServerConfig.h"
21 #include "station/StationOffice.h"
22 
23 /*
24  * StationOffice
25  */
26 StationOffice::StationOffice(uint32 _officeID, const ItemType& _containerType, const ItemData& _data, const OfficeData& _odata)
27 : InventoryItem(_officeID, _containerType, _data),
28 m_data(_odata)
29 {
30  m_loaded = false;
32  _log(ITEM__TRACE, "Created StationOffice object for item %s (%u).", name(), itemID());
33 }
34 
36 {
37  if (pInventory != nullptr)
38  pInventory->Unload();
40 }
41 
43 {
44  return InventoryItem::Load<StationOffice>(officeID );
45 }
46 
51 /*
52 bool StationOffice::_Load() {
53  if (!pInventory->LoadContents())
54  return false;
55  return InventoryItem::_Load();
56 }*/
57 
59  uint32 officeID = StationDB::CreateOffice(idata, odata);
60  if (officeID == 0 )
61  return StationOfficeRef(nullptr);
62 
63  return StationOffice::Load(officeID );
64 }
65 
67  if (!m_loaded)
68  return; // make error here?
69 
70  pInventory->HasAvailableSpace(flag, iRef);
71 }
72 
74  if (!pInventory->LoadContents( ) ) {
75  codelog( ITEM__ERROR, "%s (%u): Failed to load contents for StationOfficeGetInfo", name(), m_itemID );
76  return nullptr;
77  }
78 
79  Rsp_CommonGetInfo result;
80  Rsp_CommonGetInfo_Entry entry;
81 
82  //first populate the StationOffice.
83  if (!Populate( entry ) )
84  return nullptr; //print already done.
85 
86  result.items[ m_itemID ] = entry.Encode();
87 
88  return result.Encode();
89 }
90 
92 {
93  if (!m_loaded)
94  return; // make error here?
95 
96  if (iRef.get() == nullptr)
97  return;
98 
100 }
101 
103 {
104  if (!m_loaded)
105  return; // make error here?
106 
107  if (iRef.get() == nullptr)
108  return;
109 
111 }
RefPtr< StationOffice > StationOfficeRef
Definition: ItemRef.h:67
StationOffice(uint32 _officeID, const ItemType &_itemType, const ItemData &_data, const OfficeData &_odata)
#define _log(type, fmt,...)
Definition: logsys.h:124
virtual void RemoveItem(InventoryItemRef iRef)
virtual void AddItem(InventoryItemRef iRef)
bool HasAvailableSpace(EVEItemFlags flag, InventoryItemRef iRef) const
Definition: Inventory.cpp:625
EVEItemFlags
Definition: EVE_Flags.h:13
static StationOfficeRef Load(uint32 officeID)
const char * name()
void SafeDelete(T *&p)
Deletes and nullifies a pointer.
Definition: SafeMem.h:83
virtual ~StationOffice()
void Unload()
Definition: Inventory.cpp:62
PyObject * StationOfficeGetInfo()
Python object.
Definition: PyRep.h:826
Inventory * pInventory
#define codelog(type, fmt,...)
Definition: logsys.h:128
X * get() const
Definition: RefPtr.h:213
bool Populate(Rsp_CommonGetInfo_Entry &into)
unsigned __int32 uint32
Definition: eve-compat.h:50
RefPtr< InventoryItem > InventoryItemRef
Definition: ItemRef.h:52
bool LoadContents()
Definition: Inventory.cpp:113
static StationOfficeRef Spawn(ItemData &idata, OfficeData &odata)
static uint32 CreateOffice(ItemData &idata, OfficeData &odata)
Definition: StationDB.cpp:17
uint32 itemID() const
Definition: InventoryItem.h:98
virtual void AddItem(InventoryItemRef item)
Reference-counting-based smart pointer.
Definition: RefPtr.h:133
virtual void RemoveItem(InventoryItemRef item)
void ValidateAddItem(EVEItemFlags flag, InventoryItemRef item) const