EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SystemManager.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: Zhur
24  Rewrite: Allan
25 */
26 
27 #ifndef __SYSTEMMANAGER_H_INCL__
28 #define __SYSTEMMANAGER_H_INCL__
29 
30 #include "system/SystemGPoint.h"
31 #include "system/BubbleManager.h"
32 #include "system/SolarSystem.h"
33 #include "system/SystemDB.h"
34 
35 
36 class PyRep;
37 class PyDict;
38 class PyTuple;
39 class PyList;
40 class Client;
41 class NPC;
42 class InventoryItem;
43 class SystemEntity;
44 class SystemBubble;
45 class SetState;
46 class DestinyManager;
47 
48 class AnomalyMgr;
49 class BeltMgr;
50 class DungeonMgr;
51 class SpawnMgr;
52 class PyServiceMgr;
53 
55 public:
56  // you MUST call (your SystemManager)->AddEntity([this returned object]) after this to actually put the entity in space
57  static SystemEntity* BuildEntity(SystemManager& pSysMgr, const DBSystemDynamicEntity& entity);
58 };
59 
61 {
62 public:
63  SystemManager(uint32 systemID, PyServiceMgr &svc);//, ItemData idata);
65 
66  bool ProcessTic(); // called at 1Hz.
67  bool BootSystem();
68  void UnloadSystem();
69  void UpdateData(); // called from EntityList every 5m for active systems
70 
71  bool IsLoaded() { return m_loaded; }
72 
73  SystemEntity* GetSE(uint32 entityID) const;
74  NPC* GetNPCSE(uint32 entityID) const;
78 
79 
80  uint32 GetID() const { return m_data.systemID; }
83  const std::string& GetNameStr() const { return m_data.name; }
84  const char* GetName() const { return m_data.name.c_str(); }
85  const char* GetSystemSecurityClass() { return m_data.securityClass.c_str(); }
86  const float GetSystemSecurityRating() { return m_data.securityRating; }
87 
91 
92  // for spawn system -allan 15July15 (not complete)
93  typedef std::map<uint32, SystemBubble*> SpawnBubbleMap;
94  void RemoveSpawnBubble(SystemBubble* pBubble);
95  void GetSpawnBubbles(SpawnBubbleMap* bubbleMap);
106  uint32 GetSysNPCCount() { return m_npcs.size(); }
107 
108  // CosmicMgr interface
109  BeltMgr* GetBeltMgr() { return m_beltMgr; }
113 
114  // range is 0.1 for 1.0 system to 2.0 for -0.9 system
115  float GetSecValue() { return m_secValue; }
116 
117  bool BuildDynamicEntity(const DBSystemDynamicEntity& entity, uint32 launcherID=0);
118 
119  void AddNPC(NPC* pNPC);
120  void RemoveNPC(NPC* pNPC);
121  void AddEntity(SystemEntity* pSE, bool addSignal=true); // add entity to system, and (optionally) add signal to AnomalyMgr
122  void RemoveEntity(SystemEntity* pSE); // this also removes SE* from bubble and sig from AnomalyMgr (if applicable)
123  void AddClient(Client* pClient, bool count=false, bool jump=false);
124  void AddMarker(SystemEntity* pSE, bool sendBall=false, bool addSignal=false); // rather specific here.
125  void RemoveClient(Client* pClient, bool count=false, bool jump=false);
126  void SetDockCount(Client* pClient, bool docked=false);
127 
130  void DoSpawnForBubble(SystemBubble* pBubble);
131 
132  /* this is to send new global ball added to system AFTER SetState has been sent */
133  void SendStaticBall(SystemEntity* pSE);
134  void MakeSetState(const SystemBubble* pBubble, SetState& into) const;
135 
137  uint32 GetClosestPlanetID(const GPoint& myPos);
138 
139  // system bounty timer system. 20m delay
140  void AddBounty(uint32 charID, BountyData& data);
141 
142  SystemEntity* GetClosestMoonSE(const GPoint& myPos);
143  SystemEntity* GetClosestPlanetSE(const GPoint& myPos);
144  SystemEntity* GetClosestGateSE(const GPoint& myPos);
145 
146  // this returns entities in range for display on dscan.
147  void DScan(int64 range, const GPoint& pos, std::vector< SystemEntity* >& vector);
148  // this returns entities in system for display on Groove's Entity Map in client
150  // this returns entities in system for display on ship scanner when enabled.
151  void GetAllEntities(std::vector<CosmicSignature>& vector);
152 
153  std::map<uint32, SystemEntity*> GetOperationalStatics() { return m_opStaticEntities; }
154  std::map<uint32, SystemEntity*> GetGates() { return m_gateMap; }
155 
156  void GetClientList(std::vector<Client*>& cVec);
157 
158  std::map< uint32, SystemEntity* > GetEntities() { return m_entities; }
159 
160  SystemEntity* GetPlanet(uint32 planetID);
161 
162 
163 protected:
165  void PayBounties();
166 
167  /* hack to avoid errors with dock count */
168  void GetDockedCount();
169  void GetPlayerCount();
170 
171  bool LoadCosmicMgrs();
172  bool LoadSystemStatics();
173  bool LoadSystemDynamics();
174  bool LoadPlayerDynamics();
175 
176 private:
177  AnomalyMgr* m_anomMgr; //we own this, never NULL.
178  BeltMgr* m_beltMgr; //we own this, never NULL.
179  DungeonMgr* m_dungMgr; //we own this, never NULL.
180  SpawnMgr* m_spawnMgr; //we own this, never NULL.
181 
184 
186 
187  // static system data
189 
190  float m_secValue; // range is 0.1 for 1.0 system to 2.0 for -0.9 system
191 
192  // for dynamic data system -allan 10June2019
195  void ManipulateTimeData();
196  std::map<uint32, uint8> m_jumpMap; // timestamp/jumps
197  // may have to do kill data like jumps above
198 
199  // for spawn systems -allan 15July15
205  std::vector<uint32> m_beltVector;
206  SpawnBubbleMap m_ratBubbles; // map of id/bubble with rat spawns - not actually used yet
207  SpawnBubbleMap m_roidBubbles; // map of id/bubble with roid spawns - not actually used yet
208 
209  // for POS system -allan 23July17
210  std::map<uint32, SystemEntity*> m_moonMap; // our container, but we DONT own the SE*
211  std::map<uint32, SystemEntity*> m_planetMap; // our container, but we DONT own the SE*
212  std::map<uint32, SystemEntity*> m_gateMap; // our container, but we DONT own the SE*
213 
214  // for grid Unloading system -allan 27June2015
215  bool m_loaded;
216  bool SystemActivity();
217  bool SafeToUnload();
218  uint16 m_players; // current total count
220 
221  // system entity lists:
223  std::map<uint32, NPC*> m_npcs;
224  std::map<uint32, Client*> m_clients;
225  std::map<uint32, SystemEntity*> m_entities; // this list is all entities in this system. we own these.
226  std::map<uint32, SystemEntity*> m_ticEntities; // this list is for entities that need process tics (objects, npc, client ships)
227  std::map<uint32, SystemEntity*> m_staticEntities; // this list is for static entities to send in setstate
228  std::map<uint32, SystemEntity*> m_opStaticEntities; // this list is for static entities which are operational and need to be initialized and operated upon even when system is empty
229 
230  // for bounty processing (20m timer)
232  typedef std::map<uint16, uint8> RatDataMap; // typeID/amt
233  std::map<uint32, BountyData> m_bountyMap; // charID/data
234  std::map<uint32, RatDataMap> m_ratMap; // charID/rat data
235 
236  // for PI timing
239 
240  // check for null iterator. this will need to be moved to a memory code file eventually.
241  // unfortunately, this is very specific for which iterators it can check. see notes in code.
242  bool IsNull(std::map<uint32, SystemEntity*>::iterator& i);
243 };
244 
245 #endif
Base Python wire object.
Definition: PyRep.h:66
bool LoadSystemDynamics()
unsigned __int8 uint8
Definition: eve-compat.h:46
void RemoveNPC(NPC *pNPC)
SpawnBubbleMap m_roidBubbles
SystemEntity * GetSE(uint32 entityID) const
void AddEntity(SystemEntity *pSE, bool addSignal=true)
void RemoveClient(Client *pClient, bool count=false, bool jump=false)
std::map< uint32, SystemEntity * > GetGates()
void IncRatSpawnCount()
Definition: SystemManager.h:96
Python's dictionary.
Definition: PyRep.h:719
std::map< uint32, SystemEntity * > GetEntities()
NPC * GetNPCSE(uint32 entityID) const
std::string name
SystemGPoint mGP
void RemoveSpawnBubble(SystemBubble *pBubble)
std::map< uint32, SystemEntity * > m_opStaticEntities
void IncRoidSpawnCount()
uint8 GetRatSpawnCount()
uint8 m_activeGateSpawns
itemID[count] Create count or of the specified() x() entityID Translocate to the specified entity Immediately stops setting then Sends Bubble AddBalls and Destiny SetState(resets spaceview with current server data)" ) COMMAND( sendstate
SystemEntity * GetClosestGateSE(const GPoint &myPos)
uint32 GetSysNPCCount()
const std::string & GetNameStr() const
Definition: SystemManager.h:83
DungeonMgr * m_dungMgr
std::map< uint32, RatDataMap > m_ratMap
std::map< uint32, BountyData > m_bountyMap
std::map< uint32, SystemEntity * > m_gateMap
const float GetSystemSecurityRating()
Definition: SystemManager.h:86
void GetClientList(std::vector< Client * > &cVec)
uint32 GetID() const
Definition: SystemManager.h:80
uint32 GetRandBeltID()
SystemEntity * GetPlanet(uint32 planetID)
void AddMarker(SystemEntity *pSE, bool sendBall=false, bool addSignal=false)
bool IsNull(std::map< uint32, SystemEntity * >::iterator &i)
Python tuple.
Definition: PyRep.h:567
uint32 GetClosestPlanetID(const GPoint &myPos)
bool BuildDynamicEntity(const DBSystemDynamicEntity &entity, uint32 launcherID=0)
itemID[count] Create count or of the specified item(from Insider)" ) COMMAND( goto
SolarSystemRef GetSystemRef()
Definition: SystemManager.h:90
bool LoadPlayerDynamics()
void DecGateSpawnCount()
Definition: SystemManager.h:99
std::map< uint16, uint8 > RatDataMap
PyRep * GetCurrentEntities()
Definition: gpoint.h:33
ShipItemRef GetShipFromInventory(uint32 shipID)
std::map< uint32, uint8 > m_jumpMap
SystemData m_data
bool LoadSystemStatics()
std::map< uint32, SystemEntity * > m_ticEntities
std::map< uint32, Client * > m_clients
std::map< uint32, SystemEntity * > m_planetMap
Inventory * GetSystemInv()
Definition: SystemManager.h:89
AnomalyMgr * GetAnomMgr()
CargoContainerRef GetContainerFromInventory(uint32 contID)
void AddBounty(uint32 charID, BountyData &data)
SpawnBubbleMap m_ratBubbles
static SystemEntity * BuildEntity(SystemManager &pSysMgr, const DBSystemDynamicEntity &entity)
void RemoveEntity(SystemEntity *pSE)
SystemEntity * GetClosestPlanetSE(const GPoint &myPos)
uint32 PlayerCount()
BeltMgr * GetBeltMgr()
void SetDockCount(Client *pClient, bool docked=false)
SpawnMgr * m_spawnMgr
std::vector< uint32 > m_beltVector
void RemoveItemFromInventory(InventoryItemRef item)
float GetSecValue()
BeltMgr * m_beltMgr
void AddClient(Client *pClient, bool count=false, bool jump=false)
Definition: NPC.h:41
DungeonMgr * GetDungMgr()
void GetAllEntities(std::vector< CosmicSignature > &vector)
Definition: Client.h:66
SystemEntity * GetClosestMoonSE(const GPoint &myPos)
StationItemRef GetStationFromInventory(uint32 stationID)
unsigned __int32 uint32
Definition: eve-compat.h:50
uint32 systemID
uint32 regionID
PyServiceMgr * GetServiceMgr()
Definition: SystemManager.h:88
void AddItemToInventory(InventoryItemRef item)
SpawnMgr * GetSpawnMgr()
void SendStaticBall(SystemEntity *pSE)
std::map< uint32, SystemEntity * > GetOperationalStatics()
void AddNPC(NPC *pNPC)
void IncGateSpawnCount()
Definition: SystemManager.h:98
float securityRating
const char * GetName() const
Definition: SystemManager.h:84
void ManipulateTimeData()
signed __int64 int64
Definition: eve-compat.h:51
void MakeSetState(const SystemBubble *pBubble, SetState &into) const
void DecRatSpawnCount()
Definition: SystemManager.h:97
std::map< uint32, SystemBubble * > SpawnBubbleMap
Definition: SystemManager.h:93
void DScan(int64 range, const GPoint &pos, std::vector< SystemEntity * > &vector)
uint8 m_activeRatSpawns
AnomalyMgr * m_anomMgr
void DoSpawnForBubble(SystemBubble *pBubble)
uint32 GetRegionID()
Definition: SystemManager.h:81
SystemKillData m_killData
void GetSpawnBubbles(SpawnBubbleMap *bubbleMap)
SolarSystemRef m_solarSystemRef
uint32 m_activityTime
std::map< uint32, SystemEntity * > m_entities
Definition: timer.h:30
PyServiceMgr & m_services
std::map< uint32, NPC * > m_npcs
uint8 BeltCount()
uint32 GetConstellationID()
Definition: SystemManager.h:82
Inventory * GetMyInventory()
Definition: InventoryItem.h:91
unsigned __int16 uint16
Definition: eve-compat.h:48
void DecRoidSpawnCount()
SystemManager(uint32 systemID, PyServiceMgr &svc)
std::map< uint32, SystemEntity * > m_staticEntities
uint16 m_activeRoidSpawns
Python list.
Definition: PyRep.h:639
std::string securityClass
uint16 GetRoidSpawnCount()
const char * GetSystemSecurityClass()
Definition: SystemManager.h:85
std::map< uint32, SystemEntity * > m_moonMap