EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PlanetORBBound.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: Allan
24 */
25 
26 #include "eve-server.h"
27 
28 #include "EntityList.h"
29 #include "PyBoundObject.h"
30 #include "PyServiceCD.h"
31 #include "packets/Planet.h"
32 #include "planet/PlanetORBBound.h"
33 #include "planet/CustomsOffice.h"
34 #include "system/SystemManager.h"
35 
37 : public PyBoundObject
38 {
39 public:
41 
43  : PyBoundObject(mgr),
44  m_dispatch(new Dispatcher(this))
45  {
47 
48  m_strBoundObjectName = "PlanetORBBound";
49 
51  PyCallable_REG_CALL(PlanetORBBound, UpdateSettings);
52  PyCallable_REG_CALL(PlanetORBBound, GetSettingsInfo);
53  PyCallable_REG_CALL(PlanetORBBound, GMChangeSpaceObjectOwner);
54 
56  }
57  virtual ~PlanetORBBound() { delete m_dispatch; }
58  virtual void Release() {
59  //He hates this statement
60  delete this;
61  }
62 
63  PyCallable_DECL_CALL(GetTaxRate);
64  PyCallable_DECL_CALL(UpdateSettings);
65  PyCallable_DECL_CALL(GetSettingsInfo);
66  PyCallable_DECL_CALL(GMChangeSpaceObjectOwner);
67 
68 protected:
69  Dispatcher* const m_dispatch;
71 
72 private:
74 };
75 
77 
78 
80 : PyService(mgr, "planetOrbitalRegistryBroker"),
81  m_dispatch(new Dispatcher(this))
82 {
83  _SetCallDispatcher(m_dispatch);
84 
85  //PyCallable_REG_CALL(PlanetORB, );
86  //PyCallable_REG_CALL(PlanetORB, );
87 }
88 
90  delete m_dispatch;
91 }
92 
94  _log(PLANET__INFO, "PlanetORB bind request for:"); // sends systemID in request
95  bind_args->Dump(PLANET__INFO, " ");
96  if(!bind_args->IsInt()) {
97  codelog(SERVICE__ERROR, "%s Service: invalid bind argument type %s", GetName(), bind_args->TypeString());
98  return nullptr;
99  }
100 
101  return new PlanetORBBound(m_manager, bind_args->AsInt()->value());
102 }
103 
104 PyResult PlanetORBBound::Handle_GetTaxRate( PyCallArgs& call )
105 {
106  // taxRate = moniker.GetPlanetOrbitalRegistry(session.solarsystemid).GetTaxRate(itemID)
107  // NOTE: "return PyNone()" = access denied to customs office.
108 
109  Call_SingleIntegerArg args;
110  if (!args.Decode(&call.tuple)) {
111  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
112  return nullptr;
113  }
114 
115  CustomsSE* pCOSE = sEntityList.FindOrBootSystem(m_systemID)->GetSE(args.arg)->GetCOSE();
116 
118  if (IsPlayerCorp(pCOSE->GetOwnerID()))
119  if (call.client->GetCorporationID() != pCOSE->GetOwnerID())
120  return PyStatic.NewNone();
121 
122  return new PyFloat(pCOSE->GetTaxRate(call.client));
123 }
124 
125 PyResult PlanetORBBound::Handle_GetSettingsInfo( PyCallArgs& call )
126 {
127  /* self.orbitalData = self.remoteOrbitalRegistry.GetSettingsInfo(self.orbitalID) << for customs offices
128  * self.selectedHour, self.taxRateValues, self.standingLevel, self.allowAlliance, self.allowStandings = self.orbitalData
129  */
130  Call_SingleIntegerArg args;
131  if (!args.Decode(&call.tuple)) {
132  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
133  return nullptr;
134  }
135 
136  CustomsSE* pCOSE = sEntityList.FindOrBootSystem(m_systemID)->GetSE(args.arg)->GetCOSE();
137  return pCOSE->GetSettingsInfo();
138 }
139 
140 PyResult PlanetORBBound::Handle_UpdateSettings( PyCallArgs& call )
141 {
142  //remoteOrbitalRegistry.UpdateSettings(self.orbitalID, reinforceValue, taxRateValues, standingValue, allowAllianceValue, allowStandingsValue)
143  _log(INV__MESSAGE, "Calling PlanetORBBound::UpdateSettings()");
144  call.Dump(PLANET__DUMP);
145 
146  Call_UpdateSettings args;
147  if (!args.Decode(&call.tuple)) {
148  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
149  return nullptr;
150  }
151 
152  PyDict* input = args.taxRateValues->AsObject()->arguments()->AsDict();
153  Call_TaxRateValuesDict dict;
154  if (!dict.Decode(input)) {
155  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
156  return nullptr;
157  }
158 
159  CustomsSE* pCOSE = sEntityList.FindOrBootSystem(m_systemID)->GetSE(args.orbitalID)->GetCOSE();
160  pCOSE->UpdateSettings(args.reinforceValue, args.standingValue, args.allowAlliance, args.allowStandings, dict);
161 
162  return nullptr;
163 }
164 
165 PyResult PlanetORBBound::Handle_GMChangeSpaceObjectOwner( PyCallArgs& call )
166 {
167  // this is called when taking ownership of control tower
168  // sends itemID, corpID
169  /*
170  state = slimItem.orbitalState
171  if state in (entities.STATE_UNANCHORING,
172  entities.STATE_ONLINING,
173  entities.STATE_ANCHORING,
174  entities.STATE_OPERATING,
175  entities.STATE_OFFLINING,
176  entities.STATE_SHIELD_REINFORCE):
177  stateText = pos.DISPLAY_NAMES[pos.Entity2DB(state)]
178  gm.append(('End orbital state change (%s)' % stateText, self.CompleteOrbitalStateChange, (itemID,)))
179  elif state == entities.STATE_ANCHORED:
180  upgradeType = sm.GetService('godma').GetTypeAttribute2(slimItem.typeID, const.attributeConstructionType)
181  if upgradeType is not None:
182  gm.append(('Upgrade to %s' % cfg.invtypes.Get(upgradeType).typeName, self.GMUpgradeOrbital, (itemID,)))
183  gm.append(('GM: Take Control', self.TakeOrbitalOwnership, (itemID, slimItem.planetID)))
184 
185  def TakeOrbitalOwnership(self, itemID, planetID):
186  registry = moniker.GetPlanetOrbitalRegistry(session.solarsystemid)
187  registry.GMChangeSpaceObjectOwner(itemID, session.corpid)
188  */
189  _log(PLANET__DEBUG, "PlanetORBBound::Handle_GMChangeSpaceObjectOwner - size %u", call.tuple->size() );
190  call.Dump(PLANET__DUMP);
191 
192  return PyStatic.NewNone();
193 }
194 
195 
Base Python wire object.
Definition: PyRep.h:66
Dispatcher *const m_dispatch
#define _log(type, fmt,...)
Definition: logsys.h:124
float GetTaxRate(Client *pClient)
PyCallable_DECL_CALL(GetTaxRate)
int32 value() const
Definition: PyRep.h:247
Dispatcher *const m_dispatch
Python's dictionary.
Definition: PyRep.h:719
virtual void Release()
size_t size() const
Definition: PyRep.h:591
uint32 GetOwnerID()
Definition: SystemEntity.h:219
Python floating point number.
Definition: PyRep.h:292
void UpdateSettings(int8 selectedHour, int8 standingValue, bool ally, bool standings, Call_TaxRateValuesDict &taxRateValues)
int32 GetCorporationID() const
Definition: Client.h:123
#define sEntityList
Definition: EntityList.h:208
PyObject * AsObject()
Definition: PyRep.h:152
std::string m_strBoundObjectName
Definition: PyBoundObject.h:54
const char * GetName() const
Definition: PyService.h:54
void Dump(FILE *into, const char *pfx) const
Dumps object to file.
Definition: PyRep.cpp:84
PyRep * arguments() const
Definition: PyRep.h:845
PyCallable_Make_Dispatcher(PlanetORBBound) PlanetORBBound(PyServiceMgr *mgr
void _SetCallDispatcher(CallDispatcher *d)
Definition: PyCallable.h:87
* args
PyCallable_Make_InnerDispatcher(PlanetORB) PlanetORB
virtual PyBoundObject * CreateBoundObject(Client *pClient, const PyRep *bind_args)
PyRep * GetSettingsInfo()
#define codelog(type, fmt,...)
Definition: logsys.h:128
PyDict * AsDict()
Definition: PyRep.h:142
PyServiceMgr *const m_manager
Definition: PyService.h:91
#define PyStatic
Definition: PyRep.h:1209
#define IsPlayerCorp(itemID)
Definition: EVE_Defines.h:241
Client *const client
Definition: PyCallable.h:49
#define PyCallable_REG_CALL(c, m)
Definition: PyServiceCD.h:78
Definition: Client.h:66
virtual ~PlanetORB()
unsigned __int32 uint32
Definition: eve-compat.h:50
void Dump(LogType type) const
Definition: PyCallable.cpp:81
virtual ~PlanetORBBound()
bool IsInt() const
Definition: PyRep.h:100
Dispatcher *const m_dispatch
PyInt * AsInt()
Definition: PyRep.h:122
const char * TypeString() const
Definition: PyRep.cpp:76
const char * GetName() const
Definition: PyBoundObject.h:44
PyTuple * tuple
Definition: PyCallable.h:50