EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SystemBubble.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 #ifndef __SYSTEMBUBBLE_H_INCL__
27 #define __SYSTEMBUBBLE_H_INCL__
28 
29 #include <map>
30 #include <vector>
31 
32 #include "eve-core.h"
33 
34 
35 class Client;
36 class SetState;
37 class PyTuple;
38 class ContainerSE;
39 class SystemEntity;
40 class SystemManager;
41 class Timer;
42 class TowerSE;
43 class TCUSE;
44 class SBUSE;
45 class IHubSE;
46 class DroneSE;
47 class PyObject;
48 
49 class SystemBubble {
50 public:
51  SystemBubble(SystemManager* pSystem, const GPoint& center, double radius);
52  ~SystemBubble() noexcept;
53 
54  SystemEntity* const GetEntity(uint32 entityID) const;
55  SystemManager* const GetSystem() const { return m_system; }
56 
57  /* for spawn system -allan 15July15 */
58  void Process();
59  void SetBelt(InventoryItemRef itemRef);
60  void SetGate(uint32 gateID);
61  void ResetBubbleRatSpawn();
62 
63  bool IsIce() { return m_ice; }
64  bool IsBelt() { return m_belt; }
65  bool IsGate() { return m_gate; }
66  bool IsAnomaly() { return m_anomaly; }
67  bool IsMission() { return m_mission; }
68  bool IsIncursion() { return m_incursion; }
69  bool IsSpawned() { return m_spawned; }
70 
71  // these are set in spawnMgr.
72  void SetAnomaly(bool set=true) { m_anomaly = set; }
73  void SetMission(bool set=true) { m_mission = set; }
74  void SetIncursion(bool set=true) { m_incursion = set; }
75  void SetSpawned(bool set=true) { m_spawned = set; }
76  void SetSpawnTimer(bool isBelt=false);
77 
78  /* various count queries */
79  uint32 CountNPCs();
80  uint32 CountPlayers() { return m_players.size(); }
81  uint32 CountDynamics() { return m_dynamicEntities.size(); }
82 
83  /* used for bubble management */
84  bool IsEmpty() const { return (m_entities.empty() ? m_dynamicEntities.empty() : false); }
85  bool HasPlayers() const { return !m_players.empty(); }
86  bool HasStatics() const { return !m_entities.empty(); }
87  bool HasDynamics() const { return !m_dynamicEntities.empty(); }
88  double x() const { return m_center.x; }
89  double y() const { return m_center.y; }
90  double z() const { return m_center.z; }
91  uint16 GetID() { return m_bubbleID; }
93  GPoint GetCenter() { return m_center; }
95 
96  void clear();
97  void PrintEntityList();
98 
99  void Add(SystemEntity* pSE);
100  void Remove(SystemEntity* pSE);
101  void ProcessWander(std::vector< SystemEntity* >& wanderers);
102 
103  void SendAddBalls(SystemEntity* to_who);
104  void SendAddBalls2(SystemEntity* to_who);
105  void RemoveExclusive(SystemEntity* pSE);
106  void AddBallExclusive(SystemEntity* about_who);
107 
108  //send a set of destiny events and updates to every client in the bubble.
109  void BubblecastDestiny(std::vector<PyTuple*> &updates, std::vector<PyTuple*> &events, const char* desc) const;
110  //send a set of destiny updates to every client in the bubble.
111  void BubblecastDestinyUpdate(std::vector<PyTuple*> &updates, const char* desc) const;
112  //send a set of destiny events to every client in the bubble.
113  void BubblecastDestinyEvent(std::vector<PyTuple*> &events, const char* desc) const;
114  //send a destiny update to every client in the bubble.
115  void BubblecastDestinyUpdate(PyTuple** payload, const char* desc) const;
116  //send a destiny event to every client in the bubble.
117  void BubblecastDestinyEvent(PyTuple** payload, const char* desc) const;
118  void BubblecastSendNotification(const char *notifyType, const char *idType, PyTuple **payload, bool seq=true);
119  //send a destiny update to every client in the bubble EXCLUDING the given SystemEntity 'pSE'
120  void BubblecastDestinyUpdateExclusive(PyTuple** payload, const char* desc, SystemEntity* pSE) const;
121 
122  bool InBubble(const GPoint &pt, bool inWarp=false) const;
123  bool IsOverlap(const GPoint &pt) const;
124  void MarkCenter();
125  void RemoveMarkers();
126 
127  /* for warp bubble checks */
128  bool HasWarpBubble() { return m_hasBubble; }
129  void SetWarpBubble(bool set=false) { m_hasBubble = set; }
130  /* for SetState */
131  void GetEntities(std::map< uint32, SystemEntity* >& into) const; // this one only sends visible entities
132  /* for ??? */
133  void GetAllEntities(std::map< uint32, SystemEntity* >& into) const; // this one gets all entities regardless of visibility
134  /* for targeting purposes */
135  void GetPlayers(std::vector<Client*> &into) const;
136  /* for scanning */
137  void GetEntityVec(std::vector<SystemEntity*> &into) const;
139 
140  /* for towers/ship abandoning */
141  bool HasTower() { return (m_towerSE != nullptr); }
142  TowerSE* GetTowerSE() { return m_towerSE; }
143  void SetTowerSE(TowerSE* pTower) { m_towerSE = pTower; }
144 
145  /* for setting TCU in bubble */
146  bool HasTCU() { return (m_tcuSE != nullptr); }
147  TCUSE* GetTCUSE() { return m_tcuSE; }
148  void SetTCUSE(TCUSE* pTCU) { m_tcuSE = pTCU; }
149 
150  bool HasSBU() { return (m_sbuSE != nullptr); }
151  SBUSE* GetSBUSE() { return m_sbuSE; }
152  void SetSBUSE(SBUSE* pSBU) { m_sbuSE = pSBU; }
153 
154  bool HasIHub() { return (m_ihubSE != nullptr); }
155  IHubSE* GetIHubSE() { return m_ihubSE; }
156  void SetIHubSE(IHubSE* pIHub) { m_ihubSE = pIHub; }
157 
158  /* for system setstate */
159  PyObject* GetDroneState() const;
160 
161  /* for command .syncloc - updates all players in bubble with positions of all dSE */
162  void SyncPos();
163  /* for command dropLoot - commands all npcs in bubble to jettison loot */
164  void CmdDropLoot();
165 
166 protected:
168  const double m_radius;
169 
170  // remove all balls in bubble for this SE
171  void RemoveBall(SystemEntity* about_who);
172  void RemoveBalls(SystemEntity* to_who);
173  // remove this ball from bubble. update all clients in bubble this SE has left.
174  void RemoveBallExclusive(SystemEntity* about_who);
175 
176  void MarkBubble(const GPoint& position, std::string& name, std::string& desc, bool center=false);
177 
178 private:
185 
186  bool m_hasMarkers :1;
187  bool m_hasBubble :1; // for warp disruption bubbles (placeholder for later)
188 
191 
192  std::map<uint32, Client*> m_players; // testing with bubble player list (in std::map)
193  std::map<uint32, SystemEntity*> m_markers; // bubble marker cans. we do own these.
194  std::map<uint32, SystemEntity*> m_dynamicEntities; //entities which may/may not move. we do not own these.
195  std::map<uint32, SystemEntity*> m_entities; //we do not own these.
196  std::map<uint32, DroneSE*> m_drones; //we do not own these.
197 
198  // for spawn system -allan 15July15
200  bool m_ice :1;
201  bool m_belt :1;
202  bool m_gate :1;
203  bool m_anomaly :1;
204  bool m_mission :1;
205  bool m_incursion :1;
206  bool m_spawned :1;
207 };
208 
209 #endif
Definition: IHub.h:15
const GPoint m_center
Definition: SystemBubble.h:167
double y() const
Definition: SystemBubble.h:89
TowerSE * m_towerSE
Definition: SystemBubble.h:182
bool IsBelt()
Definition: SystemBubble.h:64
void MarkBubble(const GPoint &position, std::string &name, std::string &desc, bool center=false)
std::map< uint32, SystemEntity * > m_dynamicEntities
Definition: SystemBubble.h:194
uint16 m_bubbleID
Definition: SystemBubble.h:189
std::map< uint32, SystemEntity * > m_markers
Definition: SystemBubble.h:193
void GetEntityVec(std::vector< SystemEntity * > &into) const
void BubblecastDestinyUpdateExclusive(PyTuple **payload, const char *desc, SystemEntity *pSE) const
void AddBallExclusive(SystemEntity *about_who)
void SendAddBalls(SystemEntity *to_who)
bool IsIce()
Definition: SystemBubble.h:63
void SetWarpBubble(bool set=false)
Definition: SystemBubble.h:129
Definition: SBU.h:15
bool IsMission()
Definition: SystemBubble.h:67
bool IsAnomaly()
Definition: SystemBubble.h:66
uint32 GetSystemID()
Definition: SystemBubble.h:92
const double m_radius
Definition: SystemBubble.h:168
~SystemBubble() noexcept
void PrintEntityList()
bool InBubble(const GPoint &pt, bool inWarp=false) const
void GetEntities(std::map< uint32, SystemEntity * > &into) const
void SetIHubSE(IHubSE *pIHub)
Definition: SystemBubble.h:156
void SendAddBalls2(SystemEntity *to_who)
uint32 CountDynamics()
Definition: SystemBubble.h:81
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
void BubblecastSendNotification(const char *notifyType, const char *idType, PyTuple **payload, bool seq=true)
std::map< uint32, DroneSE * > m_drones
Definition: SystemBubble.h:196
SystemManager *const GetSystem() const
Definition: SystemBubble.h:55
void CmdDropLoot()
SBUSE * m_sbuSE
Definition: SystemBubble.h:180
bool IsIncursion()
Definition: SystemBubble.h:68
double x() const
Definition: SystemBubble.h:88
PyObject * GetDroneState() const
Python tuple.
Definition: PyRep.h:567
GaFloat x
Definition: GaTypes.h:207
TCUSE * m_tcuSE
Definition: SystemBubble.h:179
TCUSE * GetTCUSE()
Definition: SystemBubble.h:147
SystemBubble(SystemManager *pSystem, const GPoint &center, double radius)
void SetMission(bool set=true)
Definition: SystemBubble.h:73
TowerSE * GetTowerSE()
Definition: SystemBubble.h:142
SystemEntity * GetRandomEntity()
SBUSE * GetSBUSE()
Definition: SystemBubble.h:151
Definition: gpoint.h:33
void BubblecastDestiny(std::vector< PyTuple * > &updates, std::vector< PyTuple * > &events, const char *desc) const
uint32 CountPlayers()
Definition: SystemBubble.h:80
void RemoveBallExclusive(SystemEntity *about_who)
void GetAllEntities(std::map< uint32, SystemEntity * > &into) const
void SetAnomaly(bool set=true)
Definition: SystemBubble.h:72
void SetGate(uint32 gateID)
void BubblecastDestinyEvent(std::vector< PyTuple * > &events, const char *desc) const
Python object.
Definition: PyRep.h:826
void SetIncursion(bool set=true)
Definition: SystemBubble.h:74
uint16 GetID()
Definition: SystemBubble.h:91
void SetBelt(InventoryItemRef itemRef)
Timer m_spawnTimer
Definition: SystemBubble.h:199
void SetSBUSE(SBUSE *pSBU)
Definition: SystemBubble.h:152
void SetSpawnTimer(bool isBelt=false)
bool HasWarpBubble()
Definition: SystemBubble.h:128
bool HasPlayers() const
Definition: SystemBubble.h:85
bool HasStatics() const
Definition: SystemBubble.h:86
ContainerSE * GetCenterMarker()
Definition: SystemBubble.h:94
IHubSE * m_ihubSE
Definition: SystemBubble.h:181
std::map< uint32, Client * > m_players
Definition: SystemBubble.h:192
void ResetBubbleRatSpawn()
bool IsOverlap(const GPoint &pt) const
bool HasIHub()
Definition: SystemBubble.h:154
Definition: Client.h:66
void RemoveExclusive(SystemEntity *pSE)
Definition: Drone.h:46
unsigned __int32 uint32
Definition: eve-compat.h:50
uint32 CountNPCs()
bool IsSpawned()
Definition: SystemBubble.h:69
bool HasDynamics() const
Definition: SystemBubble.h:87
bool IsGate()
Definition: SystemBubble.h:65
double z() const
Definition: SystemBubble.h:90
GaFloat y
Definition: GaTypes.h:207
void RemoveBall(SystemEntity *about_who)
void SetTCUSE(TCUSE *pTCU)
Definition: SystemBubble.h:148
void ProcessWander(std::vector< SystemEntity * > &wanderers)
void Remove(SystemEntity *pSE)
bool HasTower()
Definition: SystemBubble.h:141
void SetTowerSE(TowerSE *pTower)
Definition: SystemBubble.h:143
uint32 m_systemID
Definition: SystemBubble.h:190
void SetSpawned(bool set=true)
Definition: SystemBubble.h:75
Definition: TCU.h:15
SystemEntity *const GetEntity(uint32 entityID) const
std::map< uint32, SystemEntity * > m_entities
Definition: SystemBubble.h:195
void RemoveBalls(SystemEntity *to_who)
ContainerSE * m_centerSE
Definition: SystemBubble.h:184
Definition: Tower.h:19
SystemManager * m_system
Definition: SystemBubble.h:183
void BubblecastDestinyUpdate(std::vector< PyTuple * > &updates, const char *desc) const
Definition: timer.h:30
IHubSE * GetIHubSE()
Definition: SystemBubble.h:155
unsigned __int16 uint16
Definition: eve-compat.h:48
void Add(SystemEntity *pSE)
bool IsEmpty() const
Definition: SystemBubble.h:84
GPoint GetCenter()
Definition: SystemBubble.h:93
GaFloat z
Definition: GaTypes.h:207
void GetPlayers(std::vector< Client * > &into) const
void RemoveMarkers()