EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
WormholeMgr.cpp
Go to the documentation of this file.
1 
12 #include "eve-server.h"
13 
14 #include "EVEServerConfig.h"
15 #include "PyServiceMgr.h"
16 #include "StaticDataMgr.h"
18 #include "system/SystemBubble.h"
19 #include "system/SystemManager.h"
22 
23 /* this class will need to keep track of all WH in universe, what systems they connect to, and how long they last.
24  *
25  * it will need access to the system manager, a list of systems, and a way to boot a new system when needed.
26  *
27  * this class will also need access to the wspace system manager (which may be same sysmgr)
28  * with a way to access/track/boot as needed.
29  *
30  * when one WH collapses, it will be in charge of creating new WH in the place of the old
31  * one, making approprate connections, and tracking any other changes in the WH itself
32  *
33  * this class is also in charge of all dynamic WH data in the db
34  *
35  */
36 
38 : m_updateTimer(0),
39  m_services(nullptr)
40 {
41  m_initalized = false;
42 }
43 
45 {
46  /* nothing to do here */
47 }
48 
50  m_services = svc;
51 
52  m_updateTimer.Start(300000); // arbitrary 5m default
53 
54  m_initalized = true;
55 
56  /* load current data, start timers, process current data, and create new items, if needed */
57 
58  sLog.Blue(" Wormhole Manager", "Wormhole Manager Initialized.");
59 }
60 
61 // this is called on a minute timer from EntityList
63  if (!m_initalized)
64  return;
65  if (m_updateTimer.Check(false)) {
66  /* do something useful here */
67  }
68 }
69 
71 {
72  // this really isnt needed. may need later
74  return;
75 
80  /*
81  * Band 1/5 1/10 1/15 1/20 1/25 1/40 1/45 1/60 1/80
82  * Percentage 20.0% 10.0% 6.67% 5.0% 4.0% 2.5% 2.22% 1.67% 1.25%
83  * Base sigStrength
84  * k-space
85  * 1/10 = exit(k162), hi>hi(a641), lo>c3(x702), lo>lo(x944)
86  * 1/15 = hi>c1(z971)
87  * 1/20 = hi>c2(r943),lo>c1(r943)
88  * 1/25 = hi>c3(x702),hi>lo(r051),null>c3(x702),null>lo(n944)
89  * 1/40 = hi>c4(o128),lo>c4(o128),lo>hi(b449),hi>null(v283),null>c1(z971),null>hi(b449)
90  * 1/45 = null>c2(r943),null>c4(o128)
91  * 1/60 = hi>c5(m555),lo>c5(n432),lo>null(s199),null>c5(n432)
92  * 1/80 = hi>c6(b041)
93  *
94  * w-space
95  * 1/10 = c1*hi(n110),c1>c1(h121),c2*hi(b274),c2>c1(z647),c3*lo(u210),c3>c3(n968),c4*c3(c247),c5*c5(h296),c5>null(z142),c6*c5(v911),c6>null(z142)
96  * 1/15 = c1>c2(c125),c2>c2(d382),c3>c43(t405),c4*c4(x877),c5*c6(v753),c6*c6(w237)
97  * 1/20 = c1*lo(j244),c1>c3(o883),c2*lo(a239),c2>c3(o477),c3*hi(d845),c3>c1(v301),c4*c1(p060),c5>lo(c140),c6*c3(l477),c6>lo(c140)
98  * 1/25 = c1>c4(m609),c2>c4(y683),c3>c2(i182),c4*c2(n766),c6*c4(z457)
99  * 1/40 = c1*null(z060),c1>c5(l614),c2*null(e545),c2>c5(n062),c3*null(k346),c3>c5(n770),c4*c5(h900),c5*c1(y790),c5>hi(d792),c6*c1(q317),c6>hi(d792)
100  * 1/45 = c2>c6(r474),c3>c6(a982)
101  * 1/60 = c5*c3(m267),c5*c4(e175),
102  * 1/80 = c1>c6(s804),c4*c6(u574),c5*c2(d364),c6*c2(g024)
103  *
104  * note: * instead of > means static
105  * wh to class 1,2,3,4 have 16h lifetime
106  * others have 24h lifetime
107  */
108  sig.sigStrength = 0.1;
109 
110  // create k162 here
111  sig.sigName = "WormHole K162";
112  GPoint pos(sig.position);
113  ItemData wData(30831, sig.ownerID, sig.systemID, flagNone, sig.sigName.c_str(), pos);
114  InventoryItemRef iRef = InventoryItem::SpawnItem(sItemFactory.GetNextTempID(), wData);
115  if (iRef.get() == nullptr) // we'll survive...anomaly is temp item, so not worried about deleting it here.
116  return;
117 
118  // verify system is loaded
119  SystemManager* pSysMgr = sEntityList.FindOrBootSystem(sig.systemID);
120  if (pSysMgr == nullptr) {
121  _log(COSMIC_MGR__ERROR, "WormholeMgr::Create() - Boot failure for system %u", sig.systemID);
122  return;
123  }
124 
125  CelestialSE* wSE = new CelestialSE(iRef, *(pSysMgr->GetServiceMgr()), pSysMgr);
126  if (wSE == nullptr) {
127  _log(COSMIC_MGR__ERROR, "WormholeMgr::Create() - SE Create failure for %s(%u)", iRef->name(), iRef->itemID());
128  return;
129  }
130  // set itemID to return to anomaly mgr after creation succeeds
131  sig.sigItemID = iRef->itemID();
132  // add wormhole to system (signal added to AnomalyMgr on successful return)
133  pSysMgr->AddEntity(wSE, false);
134  sig.bubbleID = wSE->SysBubble()->GetID();
135  // add exit to vector
136  m_wormholes.push_back(iRef->itemID());
137 
138  _log(COSMIC_MGR__TRACE, "WormholeMgr::Create() - Created %s in %s(%u) with %.3f%% sigStrength.", \
139  iRef->name(), pSysMgr->GetName(), sig.systemID, sig.sigStrength *100);
140 }
141 
143 {
144  // compile data for exit
146  /*
147  sig.sigID = sEntityList.GetAnomalyID();
148  sig.systemID = pToSys->GetID();
149  sig.dungeonType = Dungeon::Type::Wormhole;
150 
151  sig.sigItemID = 0;
152  sig.sigName = "WormHole K162 ";
153  //default to 1/80
154  sig.sigStrength = 0.0125;
155 
156  // determine owner - default to sleeper drones. may change later
157  sig.ownerID = factionSleepers;
158  if (MakeRandomFloat() > 0.1) // 10% chance to be rogue drones
159  sig.ownerID = sDataMgr.GetRegionRatFaction(pToSys->GetRegionID());
160 
161  sig.position = m_gp.GetAnomalyPoint(pToSys);
162 
163  // send data to Create() for processing
164  Create(sig);
165 */
166  _log(COSMIC_MGR__TRACE, "WormholeMgr::CreateExit() - Creating Exit from %s(%u) to %s(%u)", \
167  pFromSys->GetName(), pFromSys->GetID(), pToSys->GetName(), pToSys->GetID());
168 }
169 
170 //SELECT `locationID`, `wormholeClassID` FROM `mapLocationWormholeClasses`
171 
172 
175 /* attributeID attributeName attributeCategory attributeIdx description categoryID
176 1381 wormholeTargetSystemClass 4 0 Target System Class for wormholes 7
177 1382 wormholeMaxStableTime 5 0 The maximum amount of time a wormhole will stay open 7
178 1383 wormholeMaxStableMass 5 0 The maximum amount of mass a wormhole can transit before collapsing 7
179 1384 wormholeMassRegeneration 5 0 The amount of mass a wormhole regenerates per cycle 7
180 1385 wormholeMaxJumpMass 5 0 The maximum amount of mass that can transit a wormhole in one go 7
181 1386 wormholeTargetRegion1 4 0 Specific target region 1 for wormholes 7
182 1387 wormholeTargetRegion2 4 0 Specific target region 2 for wormholes 7
183 1388 wormholeTargetRegion3 4 0 Specific target region 3 for wormholes 7
184 1389 wormholeTargetRegion4 4 0 Specific target region 4 for wormholes 7
185 1390 wormholeTargetRegion5 4 0 Specific target region 5 for wormholes 7
186 1391 wormholeTargetRegion6 4 0 Specific target region 6 for wormholes 7
187 1392 wormholeTargetRegion7 4 0 Specific target region 7 for wormholes 7
188 1393 wormholeTargetRegion8 4 0 Specific target region 8 for wormholes 7
189 1394 wormholeTargetRegion9 4 0 Specific target region 9 for wormholes 7
190 1395 wormholeTargetConstellation1 5 0 Specific target constellation 1 for wormholes 7
191 1396 wormholeTargetConstellation2 4 0 Specific target constellation 2 for wormholes 7
192 1397 wormholeTargetConstellation3 4 0 Specific target constellation 3 for wormholes 7
193 1398 wormholeTargetConstellation4 4 0 Specific target constellation 4 for wormholes 7
194 1399 wormholeTargetConstellation5 4 0 Specific target constellation 5 for wormholes 7
195 1400 wormholeTargetConstellation6 4 0 Specific target constellation 6 for wormholes 7
196 1401 wormholeTargetConstellation7 4 0 Specific target constellation 7 for wormholes 7
197 1402 wormholeTargetConstellation8 4 0 Specific target constellation 8 for wormholes 7
198 1403 wormholeTargetConstellation9 4 0 Specific target constellation 9 for wormholes 7
199 1404 wormholeTargetSystem1 4 0 Specific target system 1 for wormholes 7
200 1405 wormholeTargetSystem2 4 0 Specific target system 2 for wormholes 7
201 1406 wormholeTargetSystem3 4 0 Specific target system 3 for wormholes 7
202 1407 wormholeTargetSystem4 4 0 Specific target system 4 for wormholes 7
203 1408 wormholeTargetSystem5 4 0 Specific target system 5 for wormholes 7
204 1409 wormholeTargetSystem6 4 0 Specific target system 6 for wormholes 7
205 1410 wormholeTargetSystem7 4 0 Specific target system 7 for wormholes 7
206 1411 wormholeTargetSystem8 4 0 Specific target system 8 for wormholes 7
207 1412 wormholeTargetSystem9 4 0 Specific target system 9 for wormholes 7
208 1457 wormholeTargetDistribution 4 0 This is the distribution ID of the target wormhole distribution 7
209  */
210 
211 /* WH groupID: 988
212  * 70 items in db
213  *
214  * graphicIDs - 3715 (lt blue, red center)
215  * 2017
216  * 2013
217  * 2010
218  * 2009 (dark, single point center with light to rbottom)
219  * 2008
220  * 2007
221  */
222 
223 /* typeID typeName graphicID
224 30463 Test wormhole 2907
225 30579 Wormhole Z971 3715
226 30583 Wormhole R943 3715
227 30584 Wormhole X702 3715
228 30642 Wormhole O128 3715
229 30643 Wormhole N432 3715
230 30644 Wormhole M555 3715
231 30645 Wormhole B041 3715
232 30646 Wormhole U319 3715
233 30647 Wormhole B449 3715
234 30648 Wormhole N944 3715
235 30649 Wormhole S199 3715
236 30657 Wormhole A641 3715
237 30658 Wormhole R051 3715
238 30659 Wormhole V283 3715
239 30660 Wormhole H121 3715
240 30661 Wormhole C125 3715
241 30662 Wormhole O883 3715
242 30663 Wormhole M609 3715
243 30664 Wormhole L614 3715
244 30665 Wormhole S804 3715
245 30666 Wormhole N110 3715
246 30667 Wormhole J244 3715
247 30668 Wormhole Z060 3715
248 30671 Wormhole Z647 3715
249 30672 Wormhole D382 3715
250 30673 Wormhole O477 3715
251 30674 Wormhole Y683 3715
252 30675 Wormhole N062 3715
253 30676 Wormhole R474 3715
254 30677 Wormhole B274 3715
255 30678 Wormhole A239 3715
256 30679 Wormhole E545 3715
257 30680 Wormhole V301 3715
258 30681 Wormhole I182 3715
259 30682 Wormhole N968 3715
260 30683 Wormhole T405 3715
261 30684 Wormhole N770 3715
262 30685 Wormhole A982 3715
263 30686 Wormhole S047 3715
264 30687 Wormhole U210 3715
265 30688 Wormhole K346 3715
266 30689 Wormhole P060 3715
267 30690 Wormhole N766 3715
268 30691 Wormhole C247 3715
269 30692 Wormhole X877 3715
270 30693 Wormhole H900 3715
271 30694 Wormhole U574 3715
272 30695 Wormhole D845 3715
273 30696 Wormhole N290 3715
274 30697 Wormhole K329 3715
275 30698 Wormhole Y790 3715
276 30699 Wormhole D364 3715
277 30700 Wormhole M267 3715
278 30701 Wormhole E175 3715
279 30702 Wormhole H296 3715
280 30703 Wormhole V753 3715
281 30704 Wormhole D792 3715
282 30705 Wormhole C140 3715
283 30706 Wormhole Z142 3715
284 30707 Wormhole Q317 3715
285 30708 Wormhole G024 3715
286 30709 Wormhole L477 3715
287 30710 Wormhole Z457 3715
288 30711 Wormhole V911 3715
289 30712 Wormhole W237 3715
290 30713 Wormhole B520 3715
291 30714 Wormhole C391 3715
292 30715 Wormhole C248 3715
293 30831 Wormhole K162 3715
294 */
void AddEntity(SystemEntity *pSE, bool addSignal=true)
static InventoryItemRef SpawnItem(uint32 itemID, const ItemData &data)
#define _log(type, fmt,...)
Definition: logsys.h:124
SystemBubble * SysBubble()
Definition: SystemEntity.h:195
#define sEntityList
Definition: EntityList.h:208
uint32 GetID() const
Definition: SystemManager.h:80
std::string sigName
void Initialize(PyServiceMgr *svc)
Definition: WormholeMgr.cpp:49
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
Definition: gpoint.h:33
uint16 GetID()
Definition: SystemBubble.h:91
bool Check(bool reset=true)
Definition: timer.cpp:62
bool m_initalized
Definition: WormholeMgr.h:51
PyServiceMgr * GetServiceMgr()
Definition: SystemManager.h:88
void Create(CosmicSignature &sig)
Definition: WormholeMgr.cpp:70
Timer m_updateTimer
Definition: WormholeMgr.h:49
const char * GetName() const
Definition: SystemManager.h:84
std::vector< uint32 > m_wormholes
Definition: WormholeMgr.h:54
void Process()
Definition: WormholeMgr.cpp:62
#define sItemFactory
Definition: ItemFactory.h:165
void CreateExit(SystemManager *pFromSys, SystemManager *pToSys)
PyServiceMgr * m_services
Definition: WormholeMgr.h:47
void Start(uint32 setTimerTime=0, bool changeResetTimer=true)
Definition: timer.cpp:81