EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Celestial.cpp
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: Bloody.Rabbit
24  Update/Rewrite: Allan
25 */
26 
27 #include "eve-server.h"
28 
29 #include "StaticDataMgr.h"
30 #include "system/Celestial.h"
31 #include "system/SystemManager.h"
32 
33 /*
34  * CelestialObjectData
35  */
36 CelestialObjectData::CelestialObjectData(double _radius, double _security, uint8 _celestialIndex, uint8 _orbitIndex)
37 : radius(_radius),
38  security(_security),
39  celestialIndex(_celestialIndex),
40  orbitIndex(_orbitIndex)
41 {
42 }
43 
44 /*
45  * CelestialObject
46  */
47 CelestialObject::CelestialObject(uint32 _celestialID, const ItemType &_type, const ItemData &_data)
48 : InventoryItem(_celestialID, _type, _data),
49  m_radius( 0.0 ),
50  m_security( 0.0 ),
51  m_celestialIndex( 0 ),
52  m_orbitIndex( 0 )
53  {
54  _log(ITEM__TRACE, "Created Default CelestialObject %p for item %s (%u).", this, name(), itemID());
55 }
56 
57 CelestialObject::CelestialObject(uint32 _celestialID, const ItemType &_type, const ItemData &_data, const CelestialObjectData &_cData)
58 : InventoryItem(_celestialID, _type, _data),
59  m_radius(_cData.radius), // no longer needed here
60  m_security(_cData.security),
61  m_celestialIndex(_cData.celestialIndex),
62  m_orbitIndex(_cData.orbitIndex)
63 {
64  _log(ITEM__TRACE, "Created CelestialObject %p for %s (%u) with radius of %.1f.", this, name(), itemID(), m_radius);
65 }
66 
68 {
69  return InventoryItem::Load<CelestialObject>(celestialID );
70 }
71 
73  uint32 celestialID = CelestialObject::CreateItemID(data);
74  if (celestialID == 0 )
75  return CelestialObjectRef(nullptr);
76 
77  CelestialObjectRef celestialRef = CelestialObject::Load(celestialID);
78 
79  if ((celestialRef->type().groupID() == EVEDB::invGroups::Beacon)
80  or (celestialRef->type().groupID() == EVEDB::invGroups::Effect_Beacon))
81  celestialRef->SetAttribute(AttrIsGlobal, EvilOne);
82 
83  return celestialRef;
84 }
85 
87  return InventoryItem::CreateItemID(data);
88 }
89 
92 }
93 
94 
96 : ItemSystemEntity(self, services, system)
97 {
98  _log(SE__DEBUG, "Created CSE for item %s (%u) with radius of %.1f.", self->name(), self->itemID(), m_radius);
99 }
100 
101 void CelestialSE::MakeDamageState(DoDestinyDamageState &into)
102 {
103  double shield = 1.0, armor = 1.0, structure = 1.0, recharge = 1000000;
112 
113  into.armor = armor;
114  into.shield = shield;
115  into.recharge = recharge;
116  into.structure = structure;
117  into.timestamp = GetFileTimeNow();
118 }
119 
120 
122 : CelestialSE(self, services, system)
123 {
124 
125 }
126 
128 {
129  using namespace Destiny;
130  BallHeader head = BallHeader();
131  head.entityID = m_self->itemID();
132  head.mode = Ball::Mode::STOP;
133  head.radius = m_radius;
134  head.posX = x();
135  head.posY = y();
136  head.posZ = z();
137  head.flags = 0;
138  into.Append( head );
139  MassSector mass = MassSector();
140  mass.mass = 10000000000; // as seen in packets
141  mass.cloak = 0;
142  mass.harmonic = m_harmonic;
143  mass.corporationID = -1;
144  mass.allianceID = -1;
145  into.Append( mass );
147  main.formationID = 0xFF;
148  into.Append( main );
149 
150  _log(SE__DESTINY, "AnomalySE::EncodeDestiny(): %s - id:%li, mode:%u, flags:0x%X", GetName(), head.entityID, head.mode, head.flags);
151 }
152 
154 {
155  _log(SE__SLIMITEM, "MakeSlimItem for AnomalySE %s(%u)", GetName(), m_self->itemID());
156  PyDict *slim = new PyDict();
157  slim->SetItemString("itemID", new PyLong(m_self->itemID()));
158  slim->SetItemString("typeID", new PyInt(m_self->typeID()));
159  slim->SetItemString("dungeonDataID", new PyInt(0)); //? seen 2990651
160  slim->SetItemString("ownerID", new PyInt(m_ownerID));
161  return slim;
162 }
163 
165 : CelestialSE(self, services, system)
166 {
167  m_count = 0;
170  // just guessing here....
172  m_nebulaType = 11785; // data found in eveGraphics table. yes. 11781 - 11786 (class 1-6) -3715 doesnt work
173  // no clue what this is...may not be used. seen 33, 263, 27 in logs
174  m_dunSpawnID = 0;
175 
176 }
177 
179 {
180  using namespace Destiny;
181  BallHeader head = BallHeader();
182  head.entityID = m_self->itemID();
183  head.mode = Ball::Mode::STOP;
184  head.radius = m_radius;
185  head.posX = x();
186  head.posY = y();
187  head.posZ = z();
188  head.flags = 0;
189  into.Append( head );
190  MassSector mass = MassSector();
191  mass.mass = 10000000000; // as seen in packets
192  mass.cloak = 0;
193  mass.harmonic = m_harmonic;
194  mass.corporationID = -1;
195  mass.allianceID = -1;
196  into.Append( mass );
198  main.formationID = 0xFF;
199  into.Append( main );
200  _log(SE__DESTINY, "WormholeSE::EncodeDestiny(): %s - id:%li, mode:%u, flags:0x%X", GetName(), head.entityID, head.mode, head.flags);
201 }
202 
204 {
205  _log(SE__SLIMITEM, "MakeSlimItem for WormholeSE %s(%u)", GetName(), m_self->itemID());
206  PyDict *slim = new PyDict();
207  slim->SetItemString("itemID", new PyLong(m_self->itemID()));
208  slim->SetItemString("typeID", new PyInt(m_self->typeID()));
209  slim->SetItemString("ownerID", new PyInt(m_ownerID));
210  slim->SetItemString("otherSolarSystemClass", new PyInt(sDataMgr.GetWHSystemClass(m_system->GetID())));
211  slim->SetItemString("wormholeSize", new PyFloat(m_wormholeSize));
212  slim->SetItemString("wormholeAge", new PyInt(m_wormholeAge));
213  slim->SetItemString("count", new PyInt(m_count)); //ships jumped thru?
214  slim->SetItemString("dunSpawnID", new PyInt(m_dunSpawnID));
215  slim->SetItemString("nebulaType", new PyInt(m_nebulaType));
216  slim->SetItemString("expiryDate", new PyLong(m_expiryDate));
217  return slim;
218 }
void Append(const T &value)
Appends a single value to buffer.
Definition: Buffer.h:437
virtual void EncodeDestiny(Buffer &into)
Definition: Celestial.cpp:127
unsigned __int8 uint8
Definition: eve-compat.h:46
AnomalySE(CelestialObjectRef self, PyServiceMgr &services, SystemManager *system)
Definition: Celestial.cpp:121
static CelestialObjectRef Load(uint32 celestialID)
Definition: Celestial.cpp:67
#define _log(type, fmt,...)
Definition: logsys.h:124
static uint32 CreateItemID(ItemData &data)
Definition: Celestial.cpp:86
Python's dictionary.
Definition: PyRep.h:719
uint32 m_ownerID
Definition: SystemEntity.h:283
bool HasAttribute(const uint16 attrID) const
CelestialObjectData(double _radius=0.0, double _security=0.0, uint8 _celestialIndex=0, uint8 _orbitIndex=0)
Definition: Celestial.cpp:36
double y()
Definition: SystemEntity.h:214
uint16 m_count
Definition: Celestial.h:165
Python floating point number.
Definition: PyRep.h:292
static CelestialObjectRef Spawn(ItemData &data)
Definition: Celestial.cpp:72
uint32 GetID() const
Definition: SystemManager.h:80
RefPtr< CelestialObject > CelestialObjectRef
Definition: ItemRef.h:55
const char * name()
int32 m_harmonic
Definition: SystemEntity.h:276
CelestialObject(uint32 _celestialID, const ItemType &_type, const ItemData &_data)
Definition: Celestial.cpp:47
float m_wormholeSize
Definition: Celestial.h:163
uint16 m_nebulaType
Definition: Celestial.h:167
InventoryItemRef m_self
Definition: SystemEntity.h:269
Generic class for buffers.
Definition: Buffer.h:40
PyTuple * MakeDamageState()
uint16 m_dunSpawnID
Definition: Celestial.h:166
Python integer.
Definition: PyRep.h:231
SystemManager * m_system
Definition: SystemEntity.h:263
double z()
Definition: SystemEntity.h:215
int64 Win32TimeNow()
Definition: utils_time.cpp:70
const char * GetName() const
Definition: SystemEntity.h:210
double x()
Definition: SystemEntity.h:213
unsigned __int32 uint32
Definition: eve-compat.h:50
double m_radius
Definition: Celestial.h:101
virtual PyDict * MakeSlimItem()
Definition: Celestial.cpp:153
double GetFileTimeNow()
Definition: utils_time.cpp:84
WormholeSE(CelestialObjectRef self, PyServiceMgr &services, SystemManager *system)
Definition: Celestial.cpp:164
int main(int argc, char *argv[])
CelestialSE(InventoryItemRef self, PyServiceMgr &services, SystemManager *system)
Definition: Celestial.cpp:95
int64 m_expiryDate
Definition: Celestial.h:164
static uint32 CreateItemID(ItemData &data)
EvilNumber GetAttribute(const uint16 attrID) const
virtual void EncodeDestiny(Buffer &into)
Definition: Celestial.cpp:178
virtual PyDict * MakeSlimItem()
Definition: Celestial.cpp:203
virtual void Delete()
EvilNumber EvilOne
Definition: EvilNumber.cpp:34
float get_float()
Definition: EvilNumber.cpp:184
int8 m_wormholeAge
Definition: Celestial.h:162
uint16 typeID() const
double m_radius
Definition: SystemEntity.h:273
uint32 itemID() const
Definition: InventoryItem.h:98
Python long integer.
Definition: PyRep.h:261
Reference-counting-based smart pointer.
Definition: RefPtr.h:133
#define sDataMgr