EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
BubbleManager Class Reference

#include "BubbleManager.h"

Inheritance diagram for BubbleManager:
Collaboration diagram for BubbleManager:

Public Member Functions

 BubbleManager ()
 
 ~BubbleManager ()
 
int Initialize ()
 
void Process ()
 
void RemoveEmpty ()
 
void CheckBubble (SystemEntity *ent)
 
void Add (SystemEntity *pSE, bool isPostWarp=false)
 
SystemBubbleFindBubble (SystemEntity *ent) const
 
SystemBubbleFindBubble (uint32 systemID, const GPoint &pos) const
 
SystemBubbleFindBubbleByID (uint16 bubbleID)
 
SystemBubbleGetBubble (SystemManager *sysMgr, const GPoint &pos)
 
void NewBubbleCenter (GVector shipVelocity, GPoint &newBubbleCenter)
 
void Remove (SystemEntity *ent)
 
void clear ()
 
void ClearSystemBubbles (uint32 systemID)
 
void RemoveBubble (uint32 systemID, SystemBubble *pSB)
 
uint32 Count ()
 
uint32 GetBubbleID ()
 
void AddSpawnID (uint16 bubbleID, uint32 spawnID)
 
void RemoveSpawnID (uint16 bubbleID, uint32 spawnID)
 
uint32 GetBeltID (uint16 bubbleID)
 
uint32 GetBubbleCount (uint32 systemID)
 
void MarkCenters ()
 
void RemoveMarkers ()
 
void MarkCenters (uint32 systemID)
 
void RemoveMarkers (uint32 systemID)
 
void GetBubbleCenterMarkers (std::vector< CosmicSignature > &anom)
 
void GetBubbleCenterMarkers (uint32 systemID, std::vector< CosmicSignature > &anom)
 
- Public Member Functions inherited from Singleton< BubbleManager >
 Singleton ()
 Primary constructor. More...
 

Protected Member Functions

SystemBubbleMakeBubble (SystemManager *sysMgr, GPoint pos)
 

Private Attributes

Timer m_emptyTimer
 
Timer m_wanderTimer
 
uint32 m_bubbleID
 
std::map< uint16, uint32m_spawnIDs
 
std::list< SystemBubble * > m_bubbles
 
std::vector< SystemEntity * > m_wanderers
 
std::map< uint32, SystemBubble * > m_bubbleIDMap
 
std::unordered_multimap
< uint32, SystemBubble * > 
m_sysBubbleMap
 

Additional Inherited Members

- Static Public Member Functions inherited from Singleton< BubbleManager >
static BubbleManagerget ()
 
- Static Protected Attributes inherited from Singleton< BubbleManager >
static std::shared_ptr
< BubbleManager
mInstance
 

Detailed Description

Definition at line 46 of file BubbleManager.h.

Constructor & Destructor Documentation

BubbleManager::BubbleManager ( )

Definition at line 42 of file BubbleManager.cpp.

References m_bubbleIDMap, m_bubbles, m_sysBubbleMap, and m_wanderers.

43 : m_wanderTimer(0),
44 m_emptyTimer(0),
45 m_bubbleID(0)
46 {
47  m_bubbles.clear();
48  m_wanderers.clear();
49  m_bubbleIDMap.clear();
50  m_sysBubbleMap.clear();
51 }
std::vector< SystemEntity * > m_wanderers
std::map< uint32, SystemBubble * > m_bubbleIDMap
std::list< SystemBubble * > m_bubbles
std::unordered_multimap< uint32, SystemBubble * > m_sysBubbleMap
BubbleManager::~BubbleManager ( )

Definition at line 53 of file BubbleManager.cpp.

53  {
54 }

Member Function Documentation

void BubbleManager::Add ( SystemEntity pSE,
bool  isPostWarp = false 
)

Definition at line 155 of file BubbleManager.cpp.

References _log, SystemBubble::Add(), SystemEntity::DestinyMgr(), GetBubble(), SystemManager::GetID(), SystemBubble::GetID(), SystemEntity::GetID(), SystemManager::GetName(), SystemEntity::GetName(), SystemEntity::GetPosition(), SystemGPoint::GetRandPointOnPlanet(), SystemBubble::GetSystemID(), SystemEntity::GetVelocity(), SystemBubble::InBubble(), Ga::GaVec3::isZero(), NewBubbleCenter(), SystemBubble::Remove(), DestinyManager::SetPosition(), SystemEntity::SysBubble(), and SystemEntity::SystemMgr().

Referenced by CheckBubble().

155  {
156  if (pSE == nullptr)
157  return;
158 
159  if (pSE->GetPosition().isZero()) {
160  SystemGPoint sGP;
162  }
163 
164  GPoint center(pSE->GetPosition());
165  if (isPostWarp) {
166  // Calculate new bubble's center based on entity's velocity and current position
167  NewBubbleCenter( pSE->GetVelocity(), center );
168  }
169 
170  SystemBubble* pBubble(GetBubble(pSE->SystemMgr(), center));
171  if (pBubble != nullptr) {
172  if (pSE->SysBubble() != nullptr) {
173  if (pBubble->GetSystemID() != pSE->SystemMgr()->GetID()) {
174  // this is an error. bad bubble
175  _log(DESTINY__ERROR, "BubbleManager::Add(): bubble SysID %u != pSE SysID %u", pBubble->GetSystemID(), pSE->SystemMgr()->GetID() );
176  pSE->SysBubble()->Remove(pSE);
177  } else if (pSE->SysBubble() != pBubble) {
178  _log(DESTINY__BUBBLE_TRACE, "BubbleManager::Add(): bubbleID %u != pSE bubbleID %u", pBubble->GetID(), pSE->SysBubble()->GetID() );
179  pSE->SysBubble()->Remove(pSE);
180  } else if (pSE->SysBubble()->InBubble(pSE->GetPosition())) {
181  _log(DESTINY__BUBBLE_TRACE, "BubbleManager::Add(): Entity %s(%u) still in Bubble %u", pSE->GetName(), pSE->GetID(), pBubble->GetID() );
182  return;
183  }
184  }
185  _log(DESTINY__BUBBLE_TRACE, "BubbleManager::Add(): Entity %s(%u) being added to Bubble %u", pSE->GetName(), pSE->GetID(), pBubble->GetID() );
186  pBubble->Add(pSE);
187  } else {
188  _log(DESTINY__ERROR, "BubbleManager::Add(): GetBubble() returned nullptr for %s:%u, at (%.2f, %.2f, %.2f).", \
189  pSE->SystemMgr()->GetName(), pSE->SystemMgr()->GetID(), center.x, center.y, center.z );
190  }
191 }
#define _log(type, fmt,...)
Definition: logsys.h:124
SystemBubble * SysBubble()
Definition: SystemEntity.h:195
bool InBubble(const GPoint &pt, bool inWarp=false) const
uint32 GetID() const
Definition: SystemManager.h:80
const GPoint & GetPosition() const
Definition: SystemEntity.h:211
const GVector & GetVelocity()
Definition: SystemEntity.h:240
const GPoint GetRandPointOnPlanet(uint32 systemID)
Definition: gpoint.h:33
DestinyManager * DestinyMgr()
Definition: SystemEntity.h:198
SystemManager * SystemMgr()
Definition: SystemEntity.h:196
uint16 GetID()
Definition: SystemBubble.h:91
void NewBubbleCenter(GVector shipVelocity, GPoint &newBubbleCenter)
uint32 GetID()
Definition: SystemEntity.h:207
const char * GetName() const
Definition: SystemEntity.h:210
void SetPosition(const GPoint &pt, bool update=false)
SystemBubble * GetBubble(SystemManager *sysMgr, const GPoint &pos)
const char * GetName() const
Definition: SystemManager.h:84
void Remove(SystemEntity *pSE)
GaExpInl bool isZero() const
Definition: GaTypes.h:188

Here is the call graph for this function:

Here is the caller graph for this function:

void BubbleManager::AddSpawnID ( uint16  bubbleID,
uint32  spawnID 
)

Definition at line 300 of file BubbleManager.cpp.

References m_spawnIDs.

301 {
302  m_spawnIDs.emplace(bubbleID, spawnID);
303 }
std::map< uint16, uint32 > m_spawnIDs
void BubbleManager::CheckBubble ( SystemEntity ent)

Definition at line 121 of file BubbleManager.cpp.

References _log, Add(), SystemEntity::GetID(), SystemEntity::GetName(), SystemEntity::GetPosition(), SystemBubble::InBubble(), SystemBubble::Remove(), SystemEntity::SysBubble(), SystemBubble::x(), Ga::GaVec3::x, SystemBubble::y(), Ga::GaVec3::y, SystemBubble::z(), and Ga::GaVec3::z.

Referenced by Process().

121  {
122  SystemBubble *pBubble = pSE->SysBubble();
123  if (pBubble != nullptr) {
124  if (pBubble->InBubble(pSE->GetPosition())) {
125  _log(DESTINY__BUBBLE_DEBUG, "BubbleManager::CheckBubble() - Entity '%s'(%u) at (%.2f,%.2f,%.2f) is still located in bubble %u at %.2f,%.2f,%.2f.",\
126  pSE->GetName(), pSE->GetID(), pSE->GetPosition().x, pSE->GetPosition().y, pSE->GetPosition().z,\
127  pBubble->GetID(), pBubble->x(), pBubble->y(), pBubble->z());
128  return;
129  }
130 
131  _log(DESTINY__BUBBLE_DEBUG, "BubbleManager::CheckBubble() - Entity '%s'(%u) at (%.2f,%.2f,%.2f) is no longer located in bubble %u at %.2f,%.2f,%.2f. Removing...",\
132  pSE->GetName(), pSE->GetID(), pSE->GetPosition().x, pSE->GetPosition().y, pSE->GetPosition().z,\
133  pBubble->GetID(), pBubble->x(), pBubble->y(), pBubble->z());
134  pBubble->Remove(pSE);
135  }
136 
137  _log(DESTINY__BUBBLE_DEBUG, "BubbleManager::CheckBubble() - SystemEntity '%s'(%u) not currently in any Bubble...adding", pSE->GetName(), pSE->GetID() );
138  Add(pSE);
139 }
double y() const
Definition: SystemBubble.h:89
#define _log(type, fmt,...)
Definition: logsys.h:124
bool InBubble(const GPoint &pt, bool inWarp=false) const
double x() const
Definition: SystemBubble.h:88
double z() const
Definition: SystemBubble.h:90
void Remove(SystemEntity *pSE)
void Add(SystemEntity *pSE, bool isPostWarp=false)

Here is the call graph for this function:

Here is the caller graph for this function:

void BubbleManager::clear ( )

Definition at line 65 of file BubbleManager.cpp.

References m_bubbles, SafeDelete(), and sLog.

65  {
66  for (auto cur : m_bubbles)
67  SafeDelete(cur);
68 
69  sLog.Warning(" BubbleMgr", "Bubble Manager has been closed." );
70 }
void SafeDelete(T *&p)
Deletes and nullifies a pointer.
Definition: SafeMem.h:83
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
std::list< SystemBubble * > m_bubbles

Here is the call graph for this function:

void BubbleManager::ClearSystemBubbles ( uint32  systemID)

Definition at line 275 of file BubbleManager.cpp.

References m_bubbleIDMap, m_bubbles, and m_sysBubbleMap.

276 {
277  auto range = m_sysBubbleMap.equal_range(systemID);
278  for (auto itr = range.first; itr != range.second; ++itr){
279  m_bubbles.remove(itr->second);
280  m_bubbleIDMap.erase(itr->second->GetID());
281  }
282 
283  m_sysBubbleMap.erase(systemID);
284 }
std::map< uint32, SystemBubble * > m_bubbleIDMap
std::list< SystemBubble * > m_bubbles
std::unordered_multimap< uint32, SystemBubble * > m_sysBubbleMap
uint32 BubbleManager::Count ( )
inline

Definition at line 78 of file BubbleManager.h.

References m_bubbles.

78 { return m_bubbles.size(); }
std::list< SystemBubble * > m_bubbles
SystemBubble * BubbleManager::FindBubble ( SystemEntity ent) const

UPDATE large items, (sun, planet, moons) are no longer in bubbles. this cuts number of bubbles drastically, dropping average to 10bbl/system, and allowing a much larger amount of bubbles per system without introducing lag from bubble processing.

NOTE: these are only used here...

Definition at line 215 of file BubbleManager.cpp.

References SystemManager::GetID(), SystemEntity::GetPosition(), and SystemEntity::SystemMgr().

Referenced by GetBubble().

215  {
216  return FindBubble(ent->SystemMgr()->GetID(), ent->GetPosition());
217 }
uint32 GetID() const
Definition: SystemManager.h:80
const GPoint & GetPosition() const
Definition: SystemEntity.h:211
SystemManager * SystemMgr()
Definition: SystemEntity.h:196
SystemBubble * FindBubble(SystemEntity *ent) const

Here is the call graph for this function:

Here is the caller graph for this function:

SystemBubble * BubbleManager::FindBubble ( uint32  systemID,
const GPoint pos 
) const

Definition at line 219 of file BubbleManager.cpp.

References _log, m_sysBubbleMap, Ga::GaVec3::x, Ga::GaVec3::y, and Ga::GaVec3::z.

219  {
220  // Finds a range containing all elements whose key is k.
221  // pair<iterator, iterator> equal_range(const key_type& k)
222  _log(DESTINY__BUBBLE_DEBUG, "BubbleManager::FindBubble() - Searching point %.1f, %.1f, %.1f in system %u.", \
223  pos.x, pos.y, pos.z, systemID);
224 
225  auto range = m_sysBubbleMap.equal_range(systemID);
226  for ( auto itr = range.first; itr != range.second; ++itr )
227  if (itr->second->InBubble(pos))
228  return itr->second;
229 
230  //not in any existing bubble.
231  return nullptr;
232 }
#define _log(type, fmt,...)
Definition: logsys.h:124
GaFloat x
Definition: GaTypes.h:207
GaFloat y
Definition: GaTypes.h:207
GaFloat z
Definition: GaTypes.h:207
std::unordered_multimap< uint32, SystemBubble * > m_sysBubbleMap
SystemBubble * BubbleManager::FindBubbleByID ( uint16  bubbleID)

Definition at line 267 of file BubbleManager.cpp.

References m_bubbleIDMap.

268 {
269  std::map<uint32, SystemBubble*>::iterator itr = m_bubbleIDMap.find(bubbleID);
270  if (itr != m_bubbleIDMap.end())
271  return itr->second;
272  return nullptr;
273 }
std::map< uint32, SystemBubble * > m_bubbleIDMap
uint32 BubbleManager::GetBeltID ( uint16  bubbleID)

Definition at line 316 of file BubbleManager.cpp.

References m_spawnIDs.

317 {
318  std::map<uint16, uint32>::iterator itr = m_spawnIDs.find(bubbleID);
319  if (itr == m_spawnIDs.end())
320  return 0;
321  return itr->second;
322 }
std::map< uint16, uint32 > m_spawnIDs
SystemBubble * BubbleManager::GetBubble ( SystemManager sysMgr,
const GPoint pos 
)

Definition at line 234 of file BubbleManager.cpp.

References FindBubble(), SystemManager::GetID(), and MakeBubble().

Referenced by Add().

235 {
236  SystemBubble* pBubble(FindBubble(sysMgr->GetID(), pos));
237  if (pBubble == nullptr)
238  pBubble = MakeBubble(sysMgr, pos);
239 
240  return pBubble;
241 }
SystemBubble * MakeBubble(SystemManager *sysMgr, GPoint pos)
uint32 GetID() const
Definition: SystemManager.h:80
SystemBubble * FindBubble(SystemEntity *ent) const

Here is the call graph for this function:

Here is the caller graph for this function:

void BubbleManager::GetBubbleCenterMarkers ( std::vector< CosmicSignature > &  anom)

Definition at line 332 of file BubbleManager.cpp.

References AttrScanMagnetometricStrength, EVEDB::invTypes::CosmicSignature, InventoryItem::customInfo(), SystemEntity::GetID(), SystemEntity::GetName(), SystemEntity::GetOwnerID(), SystemEntity::GetPosition(), SystemEntity::GetSelf(), m_sysBubbleMap, CosmicSignature::ownerID, CosmicSignature::position, CosmicSignature::scanAttributeID, CosmicSignature::scanGroupID, CosmicSignature::sigID, CosmicSignature::sigItemID, CosmicSignature::sigName, Scanning::Group::Signature, CosmicSignature::sigStrength, and CosmicSignature::systemID.

332  {
333  ContainerSE* cSE(nullptr);
334  for (auto cur : m_sysBubbleMap) {
335  cSE = cur.second->GetCenterMarker();
336  if (cSE == nullptr)
337  continue;
339  sig.ownerID = cSE->GetOwnerID();
340  sig.sigID = cSE->GetSelf()->customInfo(); // result.id
341  sig.sigItemID = cSE->GetID();
342  sig.sigName = cSE->GetName(); // result.DungeonName
343  //sig.sigGroupID = EVEDB::invGroups::Cosmic_Anomaly; // result.groupID
344  sig.sigStrength = 1.0;
345  //sig.sigTypeID = EVEDB::invTypes::CosmicAnomaly; // result.typeID
346  sig.systemID = cur.first;
347  sig.position = cSE->GetPosition();
348  sig.scanAttributeID = AttrScanMagnetometricStrength; // result.strengthAttributeID
350  anom.push_back(sig);
351  cSE = nullptr;
352  }
353 }
std::string sigID
std::string sigName
std::unordered_multimap< uint32, SystemBubble * > m_sysBubbleMap

Here is the call graph for this function:

void BubbleManager::GetBubbleCenterMarkers ( uint32  systemID,
std::vector< CosmicSignature > &  anom 
)

Definition at line 355 of file BubbleManager.cpp.

References AttrScanMagnetometricStrength, EVEDB::invTypes::CosmicSignature, InventoryItem::customInfo(), SystemEntity::GetID(), SystemEntity::GetName(), SystemEntity::GetOwnerID(), SystemEntity::GetPosition(), SystemEntity::GetSelf(), m_sysBubbleMap, CosmicSignature::ownerID, CosmicSignature::position, CosmicSignature::scanAttributeID, CosmicSignature::scanGroupID, CosmicSignature::sigID, CosmicSignature::sigItemID, CosmicSignature::sigName, Scanning::Group::Signature, CosmicSignature::sigStrength, and CosmicSignature::systemID.

355  {
356  ContainerSE* cSE(nullptr);
357  auto range = m_sysBubbleMap.equal_range(systemID);
358  for (auto itr = range.first; itr != range.second; ++itr) {
359  cSE = itr->second->GetCenterMarker();
360  if (cSE == nullptr)
361  continue;
363  sig.ownerID = cSE->GetOwnerID();
364  sig.sigID = cSE->GetSelf()->customInfo();
365  sig.sigItemID = cSE->GetID();
366  sig.sigName = cSE->GetName();
367  //sig.sigGroupID = EVEDB::invGroups::Cosmic_Anomaly;
368  sig.sigStrength = 1.0;
369  //sig.sigTypeID = EVEDB::invTypes::CosmicAnomaly;
370  sig.systemID = systemID;
371  sig.position = cSE->GetPosition();
374  anom.push_back(sig);
375  cSE = nullptr;
376  }
377 }
std::string sigID
std::string sigName
std::unordered_multimap< uint32, SystemBubble * > m_sysBubbleMap

Here is the call graph for this function:

uint32 BubbleManager::GetBubbleCount ( uint32  systemID)

Definition at line 324 of file BubbleManager.cpp.

References m_sysBubbleMap.

324  {
325  uint32 count = 0;
326  auto range = m_sysBubbleMap.equal_range(systemID);
327  for (auto itr = range.first; itr != range.second; ++itr)
328  ++count;
329  return count;
330 }
unsigned __int32 uint32
Definition: eve-compat.h:50
std::unordered_multimap< uint32, SystemBubble * > m_sysBubbleMap
uint32 BubbleManager::GetBubbleID ( )
inline

Definition at line 79 of file BubbleManager.h.

References m_bubbleID.

79 { return ++m_bubbleID; }
int BubbleManager::Initialize ( )

Definition at line 56 of file BubbleManager.cpp.

References m_emptyTimer, m_wanderTimer, sLog, and Timer::Start().

56  {
57  // start timers
58  m_emptyTimer.Start(60000); //60s
59  m_wanderTimer.Start(60000); //60s
60 
61  sLog.Blue(" BubbleMgr", "Bubble Manager Initialized.");
62  return 1;
63 }
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
void Start(uint32 setTimerTime=0, bool changeResetTimer=true)
Definition: timer.cpp:81

Here is the call graph for this function:

SystemBubble * BubbleManager::MakeBubble ( SystemManager sysMgr,
GPoint  pos 
)
protected

Definition at line 243 of file BubbleManager.cpp.

References _log, BUBBLE_RADIUS_METERS, SystemManager::GetID(), SystemBubble::GetID(), m_bubbleIDMap, m_bubbles, m_sysBubbleMap, SystemBubble::MarkCenter(), Ga::GaVec3::normalize(), and sConfig.

Referenced by GetBubble().

243  {
244  // determine if new center (pos) is within 2x radius of another bubble center. (overlap)
245  auto range = m_sysBubbleMap.equal_range(sysMgr->GetID());
246  for ( auto itr = range.first; itr != range.second; ++itr )
247  if (itr->second->IsOverlap(pos)) {
248  GVector dir(itr->second->GetCenter(), pos);
249  dir.normalize();
250  _log(DESTINY__BUBBLE_DEBUG, "BubbleManager::MakeBubble()::IsOverlap() - dir: %.3f,%.3f,%.3f", dir.x, dir.y, dir.z);
251  // move pos away from center
252  pos = itr->second->GetCenter() + (dir * (BUBBLE_RADIUS_METERS * 2));
253  break;
254  }
255 
256  SystemBubble* pBubble = new SystemBubble(sysMgr, pos, BUBBLE_RADIUS_METERS);
257  if (pBubble != nullptr) {
258  m_bubbles.push_back(pBubble);
259  m_bubbleIDMap.emplace(pBubble->GetID(), pBubble);
260  m_sysBubbleMap.emplace(sysMgr->GetID(), pBubble);
261  if (sConfig.debug.BubbleTrack)
262  pBubble->MarkCenter();
263  }
264  return pBubble;
265 }
#define sConfig
A macro for easier access to the singleton.
#define _log(type, fmt,...)
Definition: logsys.h:124
uint32 GetID() const
Definition: SystemManager.h:80
GaExpInl GaFloat normalize()
Definition: GaTypes.h:163
std::map< uint32, SystemBubble * > m_bubbleIDMap
uint16 GetID()
Definition: SystemBubble.h:91
std::list< SystemBubble * > m_bubbles
Definition: gpoint.h:70
std::unordered_multimap< uint32, SystemBubble * > m_sysBubbleMap
static const float BUBBLE_RADIUS_METERS
Definition: BubbleManager.h:32

Here is the call graph for this function:

Here is the caller graph for this function:

void BubbleManager::MarkCenters ( )

Definition at line 380 of file BubbleManager.cpp.

References m_sysBubbleMap.

380  {
381  for (auto cur : m_sysBubbleMap)
382  cur.second->MarkCenter();
383 }
std::unordered_multimap< uint32, SystemBubble * > m_sysBubbleMap
void BubbleManager::MarkCenters ( uint32  systemID)

Definition at line 390 of file BubbleManager.cpp.

References m_sysBubbleMap.

390  {
391  auto range = m_sysBubbleMap.equal_range(systemID);
392  for (auto itr = range.first; itr != range.second; ++itr)
393  itr->second->MarkCenter();
394 }
std::unordered_multimap< uint32, SystemBubble * > m_sysBubbleMap
void BubbleManager::NewBubbleCenter ( GVector  shipVelocity,
GPoint newBubbleCenter 
)

Definition at line 193 of file BubbleManager.cpp.

References BUBBLE_RADIUS_METERS, and Ga::GaVec3::normalize().

Referenced by Add().

193  {
194  shipVelocity.normalize();
195  newCenter += (shipVelocity * (BUBBLE_RADIUS_METERS /2));
196 }
GaExpInl GaFloat normalize()
Definition: GaTypes.h:163
static const float BUBBLE_RADIUS_METERS
Definition: BubbleManager.h:32

Here is the call graph for this function:

Here is the caller graph for this function:

void BubbleManager::Process ( )

Definition at line 72 of file BubbleManager.cpp.

References _log, Profile::bubbles, Timer::Check(), CheckBubble(), GetTimeUSeconds(), m_bubbles, m_emptyTimer, m_wanderers, m_wanderTimer, RemoveEmpty(), sConfig, and sProfiler.

72  {
73  double profileStartTime = GetTimeUSeconds();
74 
75  for (auto cur : m_bubbles) {
76  // process each belt and gate bubble for spawns
77  if (cur->IsBelt() or cur->IsGate())
78  cur->Process();
79  // process each mission and incursion bubble -placeholder
80  if (cur->IsMission() or cur->IsIncursion())
81  cur->Process();
82  }
83 
84  if (m_wanderTimer.Check()) { //60s
85  m_wanderers.clear();
86  std::list<SystemBubble*>::iterator itr = m_bubbles.begin();
87  while (itr != m_bubbles.end()) {
88  if (*itr == nullptr) {
89  itr = m_bubbles.erase(itr);
90  continue;
91  }
92  if ((*itr)->HasDynamics())
93  (*itr)->ProcessWander(m_wanderers);
94  ++itr;
95  }
96 
97  if (!m_wanderers.empty()) {
98  for (auto cur : m_wanderers) {
99  // do we really want to check this?
100  if (cur->GetPosition().isNaN() or cur->GetPosition().isInf() or cur->GetPosition().isZero()) {
101  // position error. this will screw things up. if haspilot, send error.
102  if (cur->HasPilot())
103  cur->GetPilot()->SendErrorMsg("Internal Server Error. Ref: ServerError 35148<br>Please either dock or relog.");
104  continue;
105  }
106  _log(DESTINY__WARNING, "BubbleManager::Process() - Wanderer %s(%u) in system %s(%u) is being added to a bubble.", \
107  cur->GetName(), cur->GetID(), cur->SystemMgr()->GetName(), cur->SystemMgr()->GetID());
108  CheckBubble(cur);
109  }
110  m_wanderers.clear();
111  }
112  }
113 
114  if (m_emptyTimer.Check()) //60s
115  RemoveEmpty();
116 
117  if (sConfig.debug.UseProfiling)
118  sProfiler.AddTime(Profile::bubbles, GetTimeUSeconds() - profileStartTime);
119 }
#define sConfig
A macro for easier access to the singleton.
#define _log(type, fmt,...)
Definition: logsys.h:124
std::vector< SystemEntity * > m_wanderers
#define sProfiler
Definition: dbcore.cpp:39
double GetTimeUSeconds()
Definition: utils_time.cpp:116
bool Check(bool reset=true)
Definition: timer.cpp:62
std::list< SystemBubble * > m_bubbles
void CheckBubble(SystemEntity *ent)

Here is the call graph for this function:

void BubbleManager::Remove ( SystemEntity ent)

Definition at line 198 of file BubbleManager.cpp.

References _log, SystemBubble::GetID(), SystemEntity::GetID(), SystemEntity::GetName(), SystemBubble::Remove(), and SystemEntity::SysBubble().

198  {
199  // suns, planets and moons arent in bubbles
200  //if (ent->IsStaticEntity())
201  // return;
202  if (ent->SysBubble() != nullptr) {
203  _log(DESTINY__BUBBLE_TRACE, "BubbleManager::Remove(): Entity %s(%u) being removed from Bubble %u", ent->GetName(), ent->GetID(), ent->SysBubble()->GetID() );
204  ent->SysBubble()->Remove(ent);
205  }
206 }
#define _log(type, fmt,...)
Definition: logsys.h:124
SystemBubble * SysBubble()
Definition: SystemEntity.h:195
uint16 GetID()
Definition: SystemBubble.h:91
uint32 GetID()
Definition: SystemEntity.h:207
const char * GetName() const
Definition: SystemEntity.h:210
void Remove(SystemEntity *pSE)

Here is the call graph for this function:

void BubbleManager::RemoveBubble ( uint32  systemID,
SystemBubble pSB 
)

Definition at line 286 of file BubbleManager.cpp.

References SystemBubble::GetID(), m_bubbleIDMap, and m_sysBubbleMap.

Referenced by RemoveEmpty().

287 {
288  auto range = m_sysBubbleMap.equal_range(systemID);
289  for (auto itr = range.first; itr != range.second; ++itr)
290  if (itr->second == pSB) {
291  m_sysBubbleMap.erase(itr);
292  return;
293  }
294  std::map<uint32, SystemBubble*>::iterator itr = m_bubbleIDMap.find(pSB->GetID());
295  if (itr != m_bubbleIDMap.end())
296  m_bubbleIDMap.erase(itr);
297 }
std::map< uint32, SystemBubble * > m_bubbleIDMap
uint16 GetID()
Definition: SystemBubble.h:91
std::unordered_multimap< uint32, SystemBubble * > m_sysBubbleMap

Here is the call graph for this function:

Here is the caller graph for this function:

void BubbleManager::RemoveEmpty ( )

Definition at line 141 of file BubbleManager.cpp.

References _log, m_bubbles, and RemoveBubble().

Referenced by Process().

142 {
143  std::list<SystemBubble*>::iterator itr = m_bubbles.begin();
144  while (itr != m_bubbles.end()) {
145  if ((*itr)->IsEmpty()) {
146  _log(DESTINY__BUBBLE_DEBUG, "BubbleManager::RemoveEmpty() - Bubble %u is empty and is being deleted from the system.", (*itr)->GetID() );
147  RemoveBubble((*itr)->GetSystem()->GetID(), (*itr));
148  itr = m_bubbles.erase(itr);
149  } else {
150  ++itr;
151  }
152  }
153 }
void RemoveBubble(uint32 systemID, SystemBubble *pSB)
#define _log(type, fmt,...)
Definition: logsys.h:124
std::list< SystemBubble * > m_bubbles

Here is the call graph for this function:

Here is the caller graph for this function:

void BubbleManager::RemoveMarkers ( )

Definition at line 385 of file BubbleManager.cpp.

References m_sysBubbleMap.

385  {
386  for (auto cur : m_sysBubbleMap)
387  cur.second->RemoveMarkers();
388 }
std::unordered_multimap< uint32, SystemBubble * > m_sysBubbleMap
void BubbleManager::RemoveMarkers ( uint32  systemID)

Definition at line 396 of file BubbleManager.cpp.

References m_sysBubbleMap.

396  {
397  auto range = m_sysBubbleMap.equal_range(systemID);
398  for (auto itr = range.first; itr != range.second; ++itr)
399  itr->second->RemoveMarkers();
400 }
std::unordered_multimap< uint32, SystemBubble * > m_sysBubbleMap
void BubbleManager::RemoveSpawnID ( uint16  bubbleID,
uint32  spawnID 
)

Definition at line 305 of file BubbleManager.cpp.

References m_spawnIDs.

306 {
307  // is this right??
308  auto range = m_spawnIDs.equal_range(bubbleID);
309  for (auto itr = range.first; itr != range.second; ++itr )
310  if (itr->second == spawnID) {
311  m_spawnIDs.erase(itr);
312  return;
313  }
314 }
std::map< uint16, uint32 > m_spawnIDs

Member Data Documentation

uint32 BubbleManager::m_bubbleID
private

Definition at line 106 of file BubbleManager.h.

Referenced by GetBubbleID().

std::map<uint32, SystemBubble*> BubbleManager::m_bubbleIDMap
private
std::list<SystemBubble*> BubbleManager::m_bubbles
private
Timer BubbleManager::m_emptyTimer
private

Definition at line 103 of file BubbleManager.h.

Referenced by Initialize(), and Process().

std::map<uint16, uint32> BubbleManager::m_spawnIDs
private

Definition at line 109 of file BubbleManager.h.

Referenced by AddSpawnID(), GetBeltID(), and RemoveSpawnID().

std::unordered_multimap<uint32, SystemBubble*> BubbleManager::m_sysBubbleMap
private
std::vector<SystemEntity*> BubbleManager::m_wanderers
private

Definition at line 112 of file BubbleManager.h.

Referenced by BubbleManager(), and Process().

Timer BubbleManager::m_wanderTimer
private

Definition at line 104 of file BubbleManager.h.

Referenced by Initialize(), and Process().


The documentation for this class was generated from the following files: