EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
JumpCloneService.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: Zhur
24 */
25 
26 #include "eve-server.h"
27 
28 #include "PyBoundObject.h"
29 #include "PyServiceCD.h"
31 
33 : public PyBoundObject
34 {
35 public:
37 
39  : PyBoundObject(mgr),
40  m_db(db),
41  m_dispatch(new Dispatcher(this)),
42  m_locationID(locationID), // station or ship
43  m_locGroupID(EVEDB::invGroups::Station) // solarsystem(for ship) or station
44  {
46 
47  m_strBoundObjectName = "JumpCloneBound";
48 
49  PyCallable_REG_CALL(JumpCloneBound, GetCloneState);
50  PyCallable_REG_CALL(JumpCloneBound, GetShipCloneState);
51  PyCallable_REG_CALL(JumpCloneBound, GetPriceForClone);
52  PyCallable_REG_CALL(JumpCloneBound, InstallCloneInStation);
53  PyCallable_REG_CALL(JumpCloneBound, GetStationCloneState);
54  PyCallable_REG_CALL(JumpCloneBound, OfferShipCloneInstallation);
55  PyCallable_REG_CALL(JumpCloneBound, DestroyInstalledClone);
56  PyCallable_REG_CALL(JumpCloneBound, AcceptShipCloneInstallation);
57  PyCallable_REG_CALL(JumpCloneBound, CancelShipCloneInstallation);
59  /*
60  _ _notifyevents__ = ['OnShipJumpCloneIns*tallationOffered',
61  'OnShipJumpCloneInstallationDone',
62  'OnJumpCloneCacheInvalidated',
63  'OnShipJumpCloneCacheInvalidated',
64  'OnStationJumpCloneCacheInvalidated',
65  'OnShipJumpCloneInstallationCanceled']
66  */
67 
68  if (sDataMgr.IsStation(m_locationID))
70  }
71  virtual ~JumpCloneBound() { delete m_dispatch; }
72  virtual void Release() {
73  //I hate this statement
74  delete this;
75  }
76 
77  PyCallable_DECL_CALL(GetCloneState);
78  PyCallable_DECL_CALL(GetShipCloneState);
79  PyCallable_DECL_CALL(GetPriceForClone);
80  PyCallable_DECL_CALL(InstallCloneInStation);
81  PyCallable_DECL_CALL(GetStationCloneState);
82  PyCallable_DECL_CALL(OfferShipCloneInstallation);
83  PyCallable_DECL_CALL(DestroyInstalledClone);
84  PyCallable_DECL_CALL(AcceptShipCloneInstallation);
85  PyCallable_DECL_CALL(CancelShipCloneInstallation);
86  PyCallable_DECL_CALL(CloneJump);
87 
88 protected:
89  StationDB *const m_db; //we do not own this
90  Dispatcher *const m_dispatch; //we own this
91 
94 };
95 
97 
99 : PyService(mgr, "jumpCloneSvc"),
100  m_dispatch(new Dispatcher(this))
101 {
102  _SetCallDispatcher(m_dispatch);
103 
104  //PyCallable_REG_CALL(JumpCloneService, GetShipCloneState);
105 }
106 
108  delete m_dispatch;
109 }
110 
112 {
113  _log( CLIENT__MESSAGE, "JumpCloneService bind request for:" );
114  bind_args->Dump( CLIENT__MESSAGE, " " );
115 
116  return new JumpCloneBound( m_manager, &m_db, pClient->GetLocationID() );
117 }
118 
119 PyResult JumpCloneBound::Handle_InstallCloneInStation( PyCallArgs &call ) {
120  //19:02:15 W JumpCloneBound::Handle_InstallCloneInStation(): size= 0
121 
122  return nullptr;
123 }
124 
125 PyResult JumpCloneBound::Handle_GetCloneState(PyCallArgs &call) {
126  /* stationClones{jumpCloneID, locationID}
127  * shipClones{jumpCloneID, ownerID, locationID}
128  * cloneImplants{jumpCloneID, implants}
129  */
130 
131  PyDict* dict = new PyDict();
132  PyDict* clones = new PyDict(); //jumpCloneID, locationID [, ownerID - for shipClones only]
133  PyDict* implants = new PyDict(); //jumpCloneID, implants{tuple of implantID?, typeID}
134  //PyTuple* implants = new PyTuple(2);
135 
136  dict->SetItemString( "clones", clones );
137  dict->SetItemString( "implants", implants );
138  dict->SetItemString( "timeLastJump", new PyLong(GetFileTimeNow() -(EvE::Time::Hour *MakeRandomFloat(1, 23))) );
140  return new PyObject( "util.KeyVal", dict );
141 }
142 
143 PyResult JumpCloneBound::Handle_GetShipCloneState(PyCallArgs &call) {
144  _log(CHARACTER__INFO, "JumpCloneBound::Handle_GetShipCloneState()");
145 
146  //Define PyList for ship clones (not dict since client is looking to index through list)
147  PyList* clones = new PyList();
148 
149  // returns list
150  return clones;
151 }
152 
153 PyResult JumpCloneBound::Handle_GetStationCloneState(PyCallArgs &call) {
154  _log(CHARACTER__INFO, "JumpCloneBound::Handle_GetStationCloneState()");
155 
156  PyDict* dict = new PyDict();
157  PyDict* clones = new PyDict(); //jumpCloneID, locationID [, ownerID - for shipClones only]
158  PyDict* implants = new PyDict(); //jumpCloneID, implants{tuple of implantID?, typeID}
159  //PyTuple* implants = new PyTuple(2);
160 
161  dict->SetItemString( "clones", clones );
162  dict->SetItemString( "implants", implants );
163  dict->SetItemString( "timeLastJump", new PyLong(GetFileTimeNow() -(EvE::Time::Hour *MakeRandomFloat(1, 23))) );
165  return new PyObject( "util.KeyVal", dict );
166 }
167 
168 PyResult JumpCloneBound::Handle_GetPriceForClone(PyCallArgs &call) {
169  /* kwargs = {'amount': None, 'player': 140000038}
170  * TypeError: Numeric Formatter expects floating point or signed integer types.
171  */
172 
173  return new PyInt(1000000);
174 }
175 
176 PyResult JumpCloneBound::Handle_OfferShipCloneInstallation(PyCallArgs &call) {
177  // OfferShipCloneInstallation(charID) //offeringCharID, targetCharID, shipID, b (b=unknown)
178  _log(CHARACTER__INFO, "JumpCloneBound::Handle_OfferShipCloneInstallation()");
179 
180  return nullptr;
181 }
182 
183 PyResult JumpCloneBound::Handle_DestroyInstalledClone(PyCallArgs &call) {
184  // lm.DestroyInstalledClone(cloneID)
185  _log(CHARACTER__INFO, "JumpCloneBound::Handle_DestroyInstalledClone()");
186 
187  return nullptr;
188 }
189 
190 PyResult JumpCloneBound::Handle_AcceptShipCloneInstallation(PyCallArgs &call) {
191  //lm.AcceptShipCloneInstallation()
192  _log(CHARACTER__INFO, "JumpCloneBound::Handle_AcceptShipCloneInstallation()");
193 
194  return nullptr;
195 }
196 
197 PyResult JumpCloneBound::Handle_CancelShipCloneInstallation(PyCallArgs &call) {
198  //lm.CancelShipCloneInstallation()
199  _log(CHARACTER__INFO, "JumpCloneBound::Handle_CancelShipCloneInstallation()");
200 
201  return nullptr;
202 }
203 
204 PyResult JumpCloneBound::Handle_CloneJump(PyCallArgs &call) {
205  //lm.CloneJump, destLocationID
206 _log(CHARACTER__INFO, "JumpCloneBound::Handle_CloneJump()");
207 
208  return nullptr;
209 }
210 
Base Python wire object.
Definition: PyRep.h:66
Dispatcher *const m_dispatch
unsigned __int8 uint8
Definition: eve-compat.h:46
uint32 GetLocationID() const
Definition: Client.h:151
#define _log(type, fmt,...)
Definition: logsys.h:124
Python's dictionary.
Definition: PyRep.h:719
double MakeRandomFloat(double low, double high)
Generates random real from interval [low; high].
Definition: misc.cpp:114
std::string m_strBoundObjectName
Definition: PyBoundObject.h:54
void Dump(FILE *into, const char *pfx) const
Dumps object to file.
Definition: PyRep.cpp:84
void _SetCallDispatcher(CallDispatcher *d)
Definition: PyCallable.h:87
Python object.
Definition: PyRep.h:826
Dispatcher *const m_dispatch
Python integer.
Definition: PyRep.h:231
PyServiceMgr *const m_manager
Definition: PyService.h:91
#define PyCallable_REG_CALL(c, m)
Definition: PyServiceCD.h:78
Definition: Client.h:66
unsigned __int32 uint32
Definition: eve-compat.h:50
PyCallable_Make_InnerDispatcher(JumpCloneService) JumpCloneService
virtual PyBoundObject * CreateBoundObject(Client *pClient, const PyRep *bind_args)
double GetFileTimeNow()
Definition: utils_time.cpp:84
StationDB uint32 locationID
StationDB *const m_db
PyCallable_Make_Dispatcher(JumpCloneBound) JumpCloneBound(PyServiceMgr *mgr
virtual ~JumpCloneBound()
virtual void Release()
Dispatcher *const m_dispatch
Python list.
Definition: PyRep.h:639
PyCallable_DECL_CALL(GetCloneState)
void SetItemString(const char *key, PyRep *value)
SetItemString adds or sets a database entry.
Definition: PyRep.h:812
Python long integer.
Definition: PyRep.h:261
#define sDataMgr