EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Structure.h
Go to the documentation of this file.
1 
11 #ifndef EVEMU_POS_STRUCTURE_H_
12 #define EVEMU_POS_STRUCTURE_H_
13 
14 #include "../eve-server.h"
15 
16 #include "packets/POS.h"
17 #include "EVEServerConfig.h"
18 #include "StaticDataMgr.h"
20 #include "pos/PosMgrDB.h"
21 #include "system/SystemBubble.h"
22 #include "system/SystemEntity.h"
23 
24 // TODO: We may need to create StructureTypeData and StructureType classes just as Ship.h/Ship.cpp
25 // has in order to load up type data specific to structures. For now, the generic ItemType class is used.
26 
31 : public InventoryItem
32 {
33  friend class InventoryItem; // to let it construct us
34 
35 public:
36  static StructureItemRef Load( uint32 structureID);
37  static StructureItemRef Spawn( ItemData &data);
38 
39  virtual void Delete();
40  virtual void Rename(std::string name);
41  virtual void AddItem(InventoryItemRef iRef);
42  virtual void RemoveItem(InventoryItemRef iRef);
43 
47  const ItemType & type() const { return InventoryItem::type(); }
48 
50 
51  void SetMySE(SystemEntity* pSE) { mySE = pSE; }
52  SystemEntity* GetMySE() { return mySE; }
53 
54 
55 protected:
56  StructureItem(uint32 _structureID, const ItemType &_itemType, const ItemData &_data);
57  virtual ~StructureItem();
58 
60  virtual bool _Load();
61 
62  template<class _Ty>
63  static RefPtr<_Ty> _LoadItem( uint32 structureID, const ItemType &type, const ItemData &data)
64  {
69  _log(ITEM__ERROR, "Trying to load %s as Structure.", sDataMgr.GetCategoryName(type.categoryID()));
70  if (sConfig.debug.StackTrace)
72  return RefPtr<_Ty>();
73  }
74 
75  return StructureItemRef( new StructureItem(structureID, type, data ) );
76  }
77 
78 private:
80 
81 };
82 
83 
87 class Client;
88 class Missile;
89 class MoonSE;
90 class TowerSE;
91 class TCUSE;
92 class SBUSE;
93 class IHubSE;
94 class JumpBridgeSE;
95 class ArraySE;
96 class BatterySE;
97 class WeaponSE;
99 : public DynamicSystemEntity
100 {
101 public:
102  StructureSE(StructureItemRef structure, PyServiceMgr& services, SystemManager* system, const FactionData& data);
103  virtual ~StructureSE() { /* do nothing here */ }
104 
105  /* class type pointer querys. */
106  virtual StructureSE* GetPOSSE() { return this; }
107  virtual StructureSE* GetOutpostSE() { return (m_outpost ? this : nullptr); }
108  virtual TowerSE* GetTowerSE() { return nullptr; }
109  virtual ArraySE* GetArraySE() { return nullptr; }
110  virtual BatterySE* GetBatterySE() { return nullptr; }
111  virtual WeaponSE* GetWeaponSE() { return nullptr; }
112  virtual ReactorSE* GetReactorSE() { return nullptr; }
113  virtual TCUSE* GetTCUSE() { return nullptr; }
114  virtual SBUSE* GetSBUSE() { return nullptr; }
115  virtual IHubSE* GetIHubSE() { return nullptr; }
116  virtual JumpBridgeSE* GetJumpBridgeSE() { return nullptr; }
117 
118  /* class type tests. */
119  virtual bool IsPOSSE() { return true; }
120  virtual bool IsTCUSE() { return false; }
121  virtual bool IsSBUSE() { return false; }
122  virtual bool IsIHubSE() { return false; }
123  virtual bool IsJammerSE() { return m_jammer; }
124  virtual bool IsCynoGeneratorSE() { return m_generator; }
125  virtual bool IsMoonMiner() { return m_miner; }
126  virtual bool IsOutpostSE() { return m_outpost; }
127  virtual bool IsJumpBridgeSE() { return false; }
128  virtual bool IsTowerSE() { return false; }
129  virtual bool IsArraySE() { return false; }
130  virtual bool IsBatterySE() { return false; }
131  virtual bool IsWeaponSE() { return false; }
132  virtual bool IsReactorSE() { return false; }
133 
134  /* SystemEntity interface */
135  virtual void Process();
136  virtual void EncodeDestiny( Buffer& into );
137  virtual PyDict* MakeSlimItem();
138 
139  /* virtual functions default to base class and overridden as needed */
140  virtual void Killed(Damage &fatal_blow);
141  virtual void Init();
142  virtual void InitData();
143  virtual void Scoop();
144 
145  /* virtual functions to be overridden in derived classes */
146  virtual void MissileLaunched(Missile* pMissile) { /* Do nothing here */ }
147 
148  /* basic structure processing methods */
149  virtual void SetOnline();
150  virtual void SetOffline();
151  virtual void SetInvulnerable();
152  virtual void SetVulnerable();
153  virtual void Online();
154  virtual void SetOperating();
155  virtual void Operating();
156 
157  /* basic tower processing methods */
158  virtual void Reinforced() { /* do nothing here yet */ }
159 
160  /* specific functions handled in this class. */
161  // this is for dropping POS where Init() and Add() each need info from the other.
162  void Drop(SystemBubble* pBubble);
163  void Anchor();
164  void Offline();
165  void PullAnchor();
166  void SetAnchor(Client* pClient, GPoint& pos);
167  void Activate(int32 effectID);
168  void Deactivate(int32 effectID);
169  void GetEffectState(PyList& into);
170  uint8 GetState() const { return m_data.state; }
172  float GetStatus() { return m_data.status; }
173  MoonSE* GetMoonSE() { return m_moonSE; }
174  PlanetSE* GetPlanetSE() { return m_planetSE; } //Planets are required for sovereignty structures
176 
177  inline void SetPOSState(uint8 state) { m_data.state = state; }
178  inline void SetTimer(uint32 time) { m_procTimer.SetTimer(time); }
179 
180  void SetUsageFlags(int8 view=0, int8 take=0, int8 use=0);
181  inline int8 CanUse() { return m_data.use; }
182  inline int8 CanView() { return m_data.view; }
183  inline int8 CanTake() { return m_data.take; }
184 
185  // for orbital infrastructure
186  void SetPlanet(uint32 planetID) { m_anchorPointID = planetID; }
188 
189  // structure update methods....may not use like this
192 
193  // for targetMgr
195 
196  void SendSlimUpdate();
197 
198 protected:
199  void SendEffectUpdate(int16 effectID, bool active);
200 
202 
203  MoonSE* m_moonSE; /* moonSE this structure is orbiting. */
204  PlanetSE* m_planetSE; /* planetSE this structure is orbiting. (for sovereignty structures) */
205  TowerSE* m_towerSE; /* controlling towerSE for this structure */
206  TCUSE* m_tcuSE; /* controlling TCUs */
211 
213 
214  int8 m_procState; /* internal state data for processing mode changes */
215 
216  // this is time shown in structure status (time left until current state completes)
218 
219  // for orbital infrastructure (customs office and moon miner)
220  GVector m_rotation; /* direction to planet (for correct orientation) */
222 
223 private:
224  uint32 m_duration; // module duration in ms
225 
226  Timer m_procTimer; // module state timer
227 
228  bool m_tcu :1; // Territorial Claim Unit
229  bool m_sbu :1; // System Blockade Unit
230  bool m_ihub :1; // Infrastructure Hub
231  bool m_tower :1; // Control Tower
232  bool m_miner :1; // Moon Miner
233  bool m_bridge :1; // Jump Bridge
234  bool m_jammer :1; // Cyno Jammer
235  bool m_generator :1; // Cyno Generator
236  bool m_loaded :1;
237  bool m_module :1; // any structure requiring a control tower
238  bool m_reactor :1;
239  bool m_outpost :1;
240 
241 };
242 
243 #endif // EVEMU_POS_STRUCTURE_H_
244 
245  /*
246  self.variance = sm.GetService('clientDogmaStaticSvc').GetTypeAttribute(self.typeID, const.attributeReinforcementVariance)
247  self.reinforceHours = [ ('%.2d:00 - %.2d:00' % ((x - self.variance / 3600) % 24, (x + self.variance / 3600) % 24), x) for x in xrange(0, 24) ]
248  reinforceValue = 0-23
249 
250  with a variance of 3600, reinforceValue of 0 sets hours of 23:00 to 01:00
251  */
252 
253  /*{'FullPath': u'UI/Messages', 'messageID': 256800, 'label': u'ClaimMarkerNoAllianceOnlinedBody'}(u'The {structure} can not be put online because the owner is not part of an alliance.', None, {u'{structure}': {'conditionalValues': [], 'variableType': 10, 'propertyName': None, 'args': 0, 'kwargs': {}, 'variableName': 'structure'}})
254  { 'Fu*llPath': u'UI/Messages', 'messageID': 256801, 'label': u'ClaimMarkerNoAllianceAnchoredBody'}(u'The {structure} can not be anchored because the owner is not part of an alliance.', None, {u'{structure}': {'conditionalValues': [], 'variableType': 10, 'propertyName': None, 'args': 0, 'kwargs': {}, 'variableName': 'structure'}})
255  {'FullPath': u'UI/Messages', 'messageID': 256802, 'label': u'EffectAlreadyActive2Body'}(u'{modulename} is already active', None, {u'{modulename}': {'conditionalValues': [], 'variableType': 10, 'propertyName': None, 'args': 0, 'kwargs': {}, 'variableName': 'modulename'}})
256  {'FullPath': u'UI/Messages', 'messageID': 256803, 'label': u'CantAnchorInfrasturctureHubWrongAllianceBody'}(u'Sovereignty has not been claimed in this system by your alliance!', None, None)
257  {'FullPath': u'UI/Messages', 'messageID': 256804, 'label': u'CantAnchorNoInfrastructureHubBody'}(u'This structure can only be anchored in a system that has a infrastructure hub!', None, None)
258  {'FullPath': u'UI/Messages', 'messageID': 256805, 'label': u'NotAllProbesReturnedSuccessfullyBody'}(u'Not all probes were called back. You possibly do not have room for all of them in your cargo hold.', None, None)
259  {'FullPath': u'UI/Messages', 'messageID': 256806, 'label': u'ConfirmBreakCourierPackageTitle'}(u'Fail contract?', None, None)
260  {'FullPath': u'UI/Messages', 'messageID': 256807, 'label': u'ConfirmBreakCourierPackageBody'}(u'Breaking this courier package will make it impossible to complete the courier contract. Are you sure you want to do this?', None, None)
261  {'FullPath': u'UI/Messages', 'messageID': 256808, 'label': u'CantAnchorInfrastructureHubNoPlanetBody'}(u'You can not anchor Infrastructure Hub here. It needs to be close to a planet that has no station near it.', None, None)
262  {'FullPath': u'UI/Messages', 'messageID': 256809, 'label': u'CantAnchorInfrastructureHubNearAStationBody'}(u'You can not anchor Infrastructure Hub near a station.', None, None)
263  {'FullPath': u'UI/Messages', 'messageID': 256810, 'label': u'CantOnlineInfrastructureHubAlreadyInSystemBody'}(u'This Infrastructure Hub cannot be onlined since there is another one operating in the system already.', None, None)
264  {'FullPath': u'UI/Messages', 'messageID': 256811, 'label': u'ChannelTryingToCreateTitle'}(u'Create Channel', None, None)
265  {'FullPath': u'UI/Messages', 'messageID': 256812, 'label': u'ChannelTryingToCreateBody'}(u'Attempting to create a channel', None, None)
266  {'FullPath': u'UI/Messages', 'messageID': 256813, 'label': u'ChannelTryingToJoinTitle'}(u'Join Channel', None, None)
267  {'FullPath': u'UI/Messages', 'messageID': 256814, 'label': u'ChannelTryingToJoinBody'}(u'Attempting to join a channel', None, None)
268  {'FullPath': u'UI/Messages', 'messageID': 256815, 'label': u'CantOnlineNoInfrastructureHubBody'}(u'This structure can only be onlined in a system that has a infrastructure hub!', None, None)
269  {'FullPath': u'UI/Messages', 'messageID': 256816, 'label': u'CantAnchorInfrastructureHubAnotherHubPresentBody'}(u'The Infrastructure Hub fails to anchor as there is another hub active in the system.', None, None)
270  {'FullPath': u'UI/Messages', 'messageID': 256817, 'label': u'CanOnlyInstallStructureUpgradeToIHBody'}(u'You can only install structure upgrades to the infrastructure hub.', None, None)
271  {'FullPath': u'UI/Messages', 'messageID': 256837, 'label': u'CantAnchorInfrastructureHubNearStationBody'}(u'You cannot anchor the Infrastructure Hub near a station. Try another planet which does not have a station in orbit around it.', None, None)
272  {'FullPath': u'UI/Messages', 'messageID': 256875, 'label': u'CantAnchorToFarFromSunBody'}(u'The Territorial Claim Unit cannot be anchored this far from the sun, move it closer to less than 300 AU.', None, None)
273  {'FullPath': u'UI/Messages', 'messageID': 256876, 'label': u'CantOnlineAnotherClaimMarkerOnliningBody'}(u'Your corporation can only online one Territorial Claim Unit per system.', None, None)
274  {'FullPath': u'UI/Messages', 'messageID': 256877, 'label': u'CantOnlineInfrastructureDontOwnFlagBody'}(u"You can not online a infrastructure hub because your corporation doesn't own the Territorial Claim Unit.", None, None)
275  {'FullPath': u'UI/Messages', 'messageID': 256878, 'label': u'CantOnlineSovereigntyAlreadyClaimedBody'}(u'The Territorial Claim Unit cannot online because sovereignty has already been claimed in this system.', None, None)
276  {'FullPath': u'UI/Messages', 'messageID': 256879, 'label': u'CantAnchorDisruptorIHProtectingBody'}(u'There is a infrastructure hub that is preventing you from anchoring the Sovereignty Blockade Unit.', None, None)
277  {'FullPath': u'UI/Messages', 'messageID': 256880, 'label': u'CantAnchorDisruptorOutpostProtectingBody'}(u'The sovereignty holder holds the outpost, you can not anchor Sovereignty Blockade Unit while this is true.', None, None)
278  {'FullPath': u'UI/Messages', 'messageID': 256881, 'label': u'CantAnchoredDisruptorNotClaimedBody'}(u'The Sovereignty Blockade Unit cannot be anchored because sovereignty has not been claimed in this system.', None, None)
279  {'FullPath': u'UI/Messages', 'messageID': 256882, 'label': u'CantOnlineDisruptorOutpostProtectingBody'}(u'The sovereignty holder holds an outpost in the solar system. You cannot online the Sovereignty Blockade Unit while this is true.', None, None)
280  {'FullPath': u'UI/Messages', 'messageID': 256892, 'label': u'CantAnchorDefenseBunkerNotHereBody'}(u'Defense bunkers must be anchored withing 50 - 100 km of a stargate, station, control tower, or infrastructure hub.', None, None)
281  {'FullPath': u'UI/Messages', 'messageID': 257374, 'label': u'StructureNotControllableUntilOnlineBody'}(u'You cannot assume control of the {item} until it has been put online.', None, {u'{item}': {'conditionalValues': [], 'variableType': 10, 'propertyName': None, 'args': 0, 'kwargs': {}, 'variableName': 'item'}})
282 
283 
284 
285  */
Definition: IHub.h:15
bool m_loaded
Definition: Structure.h:236
#define sConfig
A macro for easier access to the singleton.
virtual StructureSE * GetPOSSE()
Definition: Structure.h:106
bool m_tower
Definition: Structure.h:231
unsigned __int8 uint8
Definition: eve-compat.h:46
void Anchor()
Definition: Structure.cpp:1378
bool m_outpost
Definition: Structure.h:239
PlanetSE * GetPlanetSE()
Definition: Structure.h:174
virtual void Reinforced()
Definition: Structure.h:158
virtual bool IsJammerSE()
Definition: Structure.h:123
uint32 GetPlanetID()
Definition: Structure.h:187
static StructureItemRef Load(uint32 structureID)
Definition: Structure.cpp:58
void SetTimer(uint32 time)
Definition: Structure.h:178
void UpdateUsageFlags()
Definition: Structure.h:191
int8 GetProcState()
Definition: Structure.h:171
#define _log(type, fmt,...)
Definition: logsys.h:124
SBUSE * m_sbuSE
Definition: Structure.h:207
Definition: SBU.h:15
SystemEntity * mySE
Definition: Structure.h:79
void SetPOSState(uint8 state)
Definition: Structure.h:177
void Drop(SystemBubble *pBubble)
Definition: Structure.cpp:561
MoonSE * GetMoonSE()
Definition: Structure.h:173
virtual void SetInvulnerable()
Definition: Structure.cpp:901
void SetPlanet(uint32 planetID)
Definition: Structure.h:186
Python's dictionary.
Definition: PyRep.h:719
void SetTimer(uint32 setTimerTime=0)
Definition: timer.cpp:102
uint8 GetState() const
Definition: Structure.h:170
virtual void SetOperating()
Definition: Structure.cpp:931
PyObject * StructureGetInfo()
Definition: Structure.cpp:139
uint32 m_delayTime
Definition: Structure.h:217
const ItemType & type() const
Definition: Structure.h:47
virtual TowerSE * GetTowerSE()
Definition: Structure.h:108
IHubSE * m_ihubSE
Definition: Structure.h:208
StructureSE(StructureItemRef structure, PyServiceMgr &services, SystemManager *system, const FactionData &data)
Definition: Structure.cpp:193
StargateSE * m_gateSE
Definition: Structure.h:210
virtual bool _Load()
bool m_ihub
Definition: Structure.h:230
bool m_reactor
Definition: Structure.h:238
virtual void SetOnline()
Definition: Structure.cpp:869
Timer m_procTimer
Definition: Structure.h:226
int8 m_procState
Definition: Structure.h:214
void GetEffectState(PyList &into)
Definition: Structure.cpp:1182
void UpdateTimeStamp()
Definition: Structure.h:190
const char * name()
virtual ArraySE * GetArraySE()
Definition: Structure.h:109
uint32 m_duration
Definition: Structure.h:224
virtual bool IsBatterySE()
Definition: Structure.h:130
virtual ~StructureSE()
Definition: Structure.h:103
signed __int8 int8
Definition: eve-compat.h:45
uint8 categoryID() const
Definition: ItemType.h:66
virtual bool IsArraySE()
Definition: Structure.h:129
virtual bool IsIHubSE()
Definition: Structure.h:122
virtual SBUSE * GetSBUSE()
Definition: Structure.h:114
bool m_jammer
Definition: Structure.h:234
signed __int32 int32
Definition: eve-compat.h:49
virtual bool IsPOSSE()
Definition: Structure.h:119
const ItemType & type() const
bool m_generator
Definition: Structure.h:235
virtual ~StructureItem()
Definition: Structure.cpp:53
virtual void MissileLaunched(Missile *pMissile)
Definition: Structure.h:146
bool m_tcu
Definition: Structure.h:228
PlanetSE * m_planetSE
Definition: Structure.h:204
Definition: gpoint.h:33
void Deactivate(int32 effectID)
Definition: Structure.cpp:856
Generic class for buffers.
Definition: Buffer.h:40
virtual bool IsTowerSE()
Definition: Structure.h:128
Python object.
Definition: PyRep.h:826
void PullAnchor()
Definition: Structure.cpp:734
virtual void Delete()
Definition: Structure.cpp:131
int8 CanTake()
Definition: Structure.h:183
virtual void Killed(Damage &fatal_blow)
Definition: Structure.cpp:1208
Definition: Damage.h:33
void Activate(int32 effectID)
Definition: Structure.cpp:775
virtual bool IsReactorSE()
Definition: Structure.h:132
virtual void Rename(std::string name)
Definition: Structure.cpp:179
virtual bool IsWeaponSE()
Definition: Structure.h:131
Definition: Array.h:18
JumpBridgeSE * m_bridgeSE
Definition: Structure.h:209
TowerSE * m_towerSE
Definition: Structure.h:205
void SetUsageFlags(int8 view=0, int8 take=0, int8 use=0)
Definition: Structure.cpp:958
virtual void InitData()
Definition: Structure.cpp:240
void Offline()
Definition: Structure.cpp:1381
EVEPOS::StructureData m_data
Definition: Structure.h:212
void SendEffectUpdate(int16 effectID, bool active)
Definition: Structure.cpp:989
float GetStatus()
Definition: Structure.h:172
virtual void Online()
Definition: Structure.cpp:918
Definition: Client.h:66
void SetAnchor(Client *pClient, GPoint &pos)
Definition: Structure.cpp:600
virtual void Process()
Definition: Structure.cpp:458
unsigned __int32 uint32
Definition: eve-compat.h:50
virtual bool IsCynoGeneratorSE()
Definition: Structure.h:124
virtual JumpBridgeSE * GetJumpBridgeSE()
Definition: Structure.h:116
virtual PyDict * MakeSlimItem()
Definition: Structure.cpp:1112
virtual void Scoop()
Definition: Structure.cpp:449
virtual void SetOffline()
Definition: Structure.cpp:888
virtual bool IsOutpostSE()
Definition: Structure.h:126
GVector m_rotation
Definition: Structure.h:220
virtual void EncodeDestiny(Buffer &into)
Definition: Structure.cpp:1017
virtual bool IsJumpBridgeSE()
Definition: Structure.h:127
virtual bool IsMoonMiner()
Definition: Structure.h:125
virtual StructureSE * GetOutpostSE()
Definition: Structure.h:107
virtual bool IsTCUSE()
Definition: Structure.h:120
TCUSE * m_tcuSE
Definition: Structure.h:206
bool m_miner
Definition: Structure.h:232
void SendSlimUpdate()
Definition: Structure.cpp:966
virtual bool _Load()
Definition: Structure.cpp:63
RefPtr< StructureItem > StructureItemRef
Definition: ItemRef.h:60
void SetMySE(SystemEntity *pSE)
Definition: Structure.h:51
MoonSE * m_moonSE
Definition: Structure.h:203
virtual bool IsSBUSE()
Definition: Structure.h:121
signed __int16 int16
Definition: eve-compat.h:47
virtual void Operating()
Definition: Structure.cpp:945
Definition: TCU.h:15
Definition: Moon.h:28
bool m_sbu
Definition: Structure.h:229
virtual void RemoveItem(InventoryItemRef iRef)
Definition: Structure.cpp:171
void traceStack(void)
Definition: misc.cpp:169
static RefPtr< _Ty > _LoadItem(uint32 structureID, const ItemType &type, const ItemData &data)
Definition: Structure.h:63
virtual void SetVulnerable()
Definition: Structure.cpp:909
Definition: Tower.h:19
void UpdateUsageFlags(int32 itemID, EVEPOS::StructureData &data)
Definition: PosMgrDB.cpp:447
StargateSE * GetGateSE()
Definition: Structure.h:175
SystemEntity * GetMySE()
Definition: Structure.h:52
Definition: gpoint.h:70
PosMgrDB m_db
Definition: Structure.h:201
StructureItem(uint32 _structureID, const ItemType &_itemType, const ItemData &_data)
Definition: Structure.cpp:45
Definition: timer.h:30
void UpdateTimeStamp(int32 itemID, EVEPOS::StructureData &data)
Definition: PosMgrDB.cpp:386
virtual TCUSE * GetTCUSE()
Definition: Structure.h:113
bool m_module
Definition: Structure.h:237
virtual IHubSE * GetIHubSE()
Definition: Structure.h:115
int8 CanUse()
Definition: Structure.h:181
int8 CanView()
Definition: Structure.h:182
entityID heal the character with the entityID note giving you detailed ship status information gives a list of all dynamic entities and players and their destinyState in this bubble shows some current destiny variables save all kick all and halt server immediate command list all items in current location s gives list of cargo contents and volumes in all holds list current session values show current ship DNA show current objects in their destiny state
virtual BatterySE * GetBatterySE()
Definition: Structure.h:110
static StructureItemRef Spawn(ItemData &data)
Definition: Structure.cpp:71
bool IsReinforced()
Definition: Structure.h:194
uint32 m_anchorPointID
Definition: Structure.h:221
bool m_bridge
Definition: Structure.h:233
Python list.
Definition: PyRep.h:639
virtual void Init()
Definition: Structure.cpp:275
virtual ReactorSE * GetReactorSE()
Definition: Structure.h:112
virtual WeaponSE * GetWeaponSE()
Definition: Structure.h:111
virtual void AddItem(InventoryItemRef iRef)
Definition: Structure.cpp:158
Reference-counting-based smart pointer.
Definition: RefPtr.h:133
#define sDataMgr