EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
BubbleManager.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 */
25 #ifndef __BUBBLEMANAGER_H_INCL__
26 #define __BUBBLEMANAGER_H_INCL__
27 
28 
29 #include <unordered_map>
30 #include "system/SystemEntity.h"
31 
32 static const float BUBBLE_RADIUS_METERS = 300000.0f; // EVE retail uses 250km and allows grid manipulation NOTE: this is based on testing for best results. -allan
33 static const float BUBBLE_HYSTERESIS_METERS = 5000.0f; // How far out of the existing bubble a ship needs to fly before being placed into a new or different bubble
34 
35 class SystemBubble;
36 class GPoint;
37 
38 //the purpose of this object is to make a nice container for
39 //any of the optimized space searching algorithms which we
40 // may develop based on bubbles.
41 //
42 // Right now it is stupid and searches for a bubble using a
43 // linear search. obviously a much better spacial partitioning
44 // scheme could be written later (octtree or quadtree maybe?)
45 // and this would be the place to put it.
47 : public Singleton<BubbleManager>
48 {
49 public:
50  BubbleManager();
52 
53  int Initialize();
54  void Process();
55 
56  // call to check for and remove empty bubbles from bubble vector
57  void RemoveEmpty();
58  //call whenever an entity may have left its bubble.
59  void CheckBubble(SystemEntity* ent);
60  //call when an entity is added to the system.
61  void Add(SystemEntity* pSE, bool isPostWarp = false);
62  //call to find the bubble containing the SystemEntity specified, if no bubble does, return NULL
64  //call to find the bubble containing the GPoint specified, if no bubble does, return NULL
65  SystemBubble* FindBubble(uint32 systemID, const GPoint &pos) const;
67  //find the bubble containing the GPoint specified. will call create to make new bubble if none found.
68  // this is preferred method to create new bubble.
69  SystemBubble* GetBubble(SystemManager* sysMgr, const GPoint &pos);
70  //call to calculate new bubble's center from entity's velocity:
71  void NewBubbleCenter(GVector shipVelocity, GPoint& newBubbleCenter);
72  //call when an entity is removed from the system.
73  void Remove(SystemEntity* ent);
74  void clear();
75  void ClearSystemBubbles(uint32 systemID);
76  void RemoveBubble(uint32 systemID, SystemBubble* pSB);
77 
78  uint32 Count() { return m_bubbles.size(); }
79  uint32 GetBubbleID() { return ++m_bubbleID; }
80 
81  // for spawn system -allan 15April16
82  void AddSpawnID(uint16 bubbleID, uint32 spawnID);
83  void RemoveSpawnID(uint16 bubbleID, uint32 spawnID);
84  uint32 GetBeltID(uint16 bubbleID);
85 
86  // for .list command
87  uint32 GetBubbleCount(uint32 systemID);
88 
89  // for .bubbletrack command
90  void MarkCenters(); // for all bubbles, across all systems
91  void RemoveMarkers();// for all bubbles, across all systems
92  void MarkCenters(uint32 systemID); // for bubbles in given system
93  void RemoveMarkers(uint32 systemID);// for bubbles in given system
94 
95  // for showing bubble centers in scan window (using .showall)
96  void GetBubbleCenterMarkers(std::vector<CosmicSignature>& anom);
97  void GetBubbleCenterMarkers(uint32 systemID, std::vector<CosmicSignature>& anom);
98 
99 protected:
101 
102 private:
105 
107 
108  /* map of bubbleID, spawnID */
109  std::map<uint16, uint32> m_spawnIDs;
110 
111  std::list<SystemBubble*> m_bubbles; //for proc only.
112  std::vector<SystemEntity*> m_wanderers; //entities that are no longer in their bubble, but not removed
113 
114  std::map<uint32, SystemBubble*> m_bubbleIDMap; // bubbleID/bubble*
115 
116  std::unordered_multimap<uint32, SystemBubble*> m_sysBubbleMap; // systemID/bubble*
117 };
118 
119 //Singleton
120 #define sBubbleMgr \
121 ( BubbleManager::get() )
122 
123 
124 #endif
uint32 Count()
Definition: BubbleManager.h:78
SystemBubble * MakeBubble(SystemManager *sysMgr, GPoint pos)
void RemoveBubble(uint32 systemID, SystemBubble *pSB)
std::vector< SystemEntity * > m_wanderers
SystemBubble * FindBubbleByID(uint16 bubbleID)
void RemoveSpawnID(uint16 bubbleID, uint32 spawnID)
void AddSpawnID(uint16 bubbleID, uint32 spawnID)
void GetBubbleCenterMarkers(std::vector< CosmicSignature > &anom)
static const float BUBBLE_HYSTERESIS_METERS
Definition: BubbleManager.h:33
uint32 GetBubbleID()
Definition: BubbleManager.h:79
Definition: gpoint.h:33
std::map< uint32, SystemBubble * > m_bubbleIDMap
SystemBubble * FindBubble(SystemEntity *ent) const
void ClearSystemBubbles(uint32 systemID)
void NewBubbleCenter(GVector shipVelocity, GPoint &newBubbleCenter)
void Remove(SystemEntity *ent)
unsigned __int32 uint32
Definition: eve-compat.h:50
SystemBubble * GetBubble(SystemManager *sysMgr, const GPoint &pos)
std::list< SystemBubble * > m_bubbles
uint32 GetBeltID(uint16 bubbleID)
void CheckBubble(SystemEntity *ent)
void Add(SystemEntity *pSE, bool isPostWarp=false)
Template used for singleton classes.
Definition: Singleton.h:43
std::map< uint16, uint32 > m_spawnIDs
Definition: gpoint.h:70
Definition: timer.h:30
unsigned __int16 uint16
Definition: eve-compat.h:48
uint32 GetBubbleCount(uint32 systemID)
std::unordered_multimap< uint32, SystemBubble * > m_sysBubbleMap
static const float BUBBLE_RADIUS_METERS
Definition: BubbleManager.h:32