EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ConfigService.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  Updates: Allan
25 */
26 
27 #include "eve-server.h"
28 
29 #include "PyServiceCD.h"
30 #include "config/ConfigService.h"
31 
33 
35 : PyService(mgr, "config"),
36  m_dispatch(new Dispatcher(this))
37 {
38  _SetCallDispatcher(m_dispatch);
39 
40  PyCallable_REG_CALL(ConfigService, GetMultiOwnersEx);
41  PyCallable_REG_CALL(ConfigService, GetMultiLocationsEx);
42  PyCallable_REG_CALL(ConfigService, GetMultiStationEx);
43  PyCallable_REG_CALL(ConfigService, GetMultiAllianceShortNamesEx);
44  PyCallable_REG_CALL(ConfigService, GetMultiCorpTickerNamesEx);
47  PyCallable_REG_CALL(ConfigService, GetMapOffices);
48  PyCallable_REG_CALL(ConfigService, GetMapObjects);
49  PyCallable_REG_CALL(ConfigService, GetMapConnections);
50  PyCallable_REG_CALL(ConfigService, GetMultiGraphicsEx);
51  PyCallable_REG_CALL(ConfigService, GetMultiInvTypesEx);
52  PyCallable_REG_CALL(ConfigService, GetStationSolarSystemsByOwner);
53  PyCallable_REG_CALL(ConfigService, GetCelestialStatistic);
54  PyCallable_REG_CALL(ConfigService, GetDynamicCelestials);
55  PyCallable_REG_CALL(ConfigService, GetMapLandmarks);
56  PyCallable_REG_CALL(ConfigService, SetMapLandmarks);
57 }
58 
60  delete m_dispatch;
61 }
62 
64 PyResult ConfigService::Handle_GetUnits(PyCallArgs &call) {
65  return m_db.GetUnits();
66 }
67 
68 PyResult ConfigService::Handle_GetMapLandmarks(PyCallArgs &call) {
69  return m_db.GetMapLandmarks();
70 }
71 
72 PyResult ConfigService::Handle_GetMultiOwnersEx(PyCallArgs &call) {
73  /*
74 23:14:21 L ConfigService: Handle_GetMultiOwnersEx
75 23:14:21 [SvcCall] Call Arguments:
76 23:14:21 [SvcCall] Tuple: 1 elements
77 23:14:21 [SvcCall] [ 0] List: 1 elements
78 23:14:21 [SvcCall] [ 0] [ 0] Integer field: 140000053
79  */
80  _log(CACHE__DUMP, "ConfigService::Handle_GetMultiOwnersEx" );
81  call.Dump(CACHE__DUMP);
82 
83  Call_SingleIntList arg;
84  if (!arg.Decode(&call.tuple)) {
85  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
86  return nullptr;
87  }
88 
89  return m_db.GetMultiOwnersEx(arg.ints);
90 }
91 
92 PyResult ConfigService::Handle_GetMultiAllianceShortNamesEx(PyCallArgs &call) {
93  Call_SingleIntList arg;
94  if (!arg.Decode(&call.tuple)) {
95  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
96  return nullptr;
97  }
98 
99  return m_db.GetMultiAllianceShortNamesEx(arg.ints);
100 }
101 
102 
103 PyResult ConfigService::Handle_GetMultiLocationsEx(PyCallArgs &call) { // now working correctly -allan 25April
104  _log(CACHE__DUMP, "ConfigService::Handle_GetMultiLocationsEx" );
105  call.Dump(CACHE__DUMP);
106  Call_SingleIntList arg;
107  if (!arg.Decode(&call.tuple)) {
108  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
109  return nullptr;
110  }
111 
112  return m_db.GetMultiLocationsEx(arg.ints);
113 }
114 
115 PyResult ConfigService::Handle_GetMultiStationEx(PyCallArgs &call) {
116  _log(CACHE__DUMP, "ConfigService::Handle_GetMultiStationEx" );
117  call.Dump(CACHE__DUMP);
118  Call_SingleIntList arg;
119  if (!arg.Decode(&call.tuple)) {
120  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
121  return nullptr;
122  }
123 
124  return m_db.GetMultiStationEx(arg.ints);
125 }
126 
127 PyResult ConfigService::Handle_GetMultiCorpTickerNamesEx(PyCallArgs &call) {
128  Call_SingleIntList arg;
129  if (!arg.Decode(&call.tuple)) {
130  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
131  return nullptr;
132  }
133 
134  return m_db.GetMultiCorpTickerNamesEx(arg.ints);
135 }
136 
137 PyResult ConfigService::Handle_GetMultiGraphicsEx(PyCallArgs &call) {
138  Call_SingleIntList arg;
139  if (!arg.Decode(&call.tuple)) {
140  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
141  return nullptr;
142  }
143 
144  return m_db.GetMultiGraphicsEx(arg.ints);
145 }
146 
147 PyResult ConfigService::Handle_GetMap(PyCallArgs &call) {
148  Call_SingleIntegerArg args;
149  if (!args.Decode(&call.tuple)) {
150  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
151  return nullptr;
152  }
153 
154  return m_db.GetMap(args.arg);
155 }
156 
157 PyResult ConfigService::Handle_GetMapOffices(PyCallArgs &call) {
158  /*
159 22:38:58 [SvcCall] Service config: calling GetMapOffices
160 22:38:58 [SvcCall] Call Arguments:
161 22:38:58 [SvcCall] Tuple: 1 elements
162 22:38:58 [SvcCall] [ 0] Integer field: 30002507 -solarSystemID
163 22:38:58 [SvcCall] Call Named Arguments:
164 22:38:58 [SvcCall] Argument 'machoVersion':
165 22:38:58 [SvcCall] Integer field: 1
166  */
167  Call_SingleIntegerArg args;
168  if (!args.Decode(&call.tuple)) {
169  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
170  return nullptr;
171  }
172 
173  return m_db.GetMapOffices(args.arg);
174 }
175 
176 PyResult ConfigService::Handle_GetMapObjects(PyCallArgs &call) {
177  Call_GetMapObjects args;
178  if (!args.Decode(&call.tuple)) {
179  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
180  return nullptr;
181  }
182 
183  return m_db.GetMapObjects( args.systemID, args.reg, args.con, args.sys, args.sta);
184 }
185 
186 PyResult ConfigService::Handle_GetMultiInvTypesEx(PyCallArgs &call) {
187  _log(CACHE__DUMP, "ConfigService::Handle_GetMultiInvTypesEx" );
188  call.Dump(CACHE__DUMP);
189 
190  //parse the PyRep to get the list of IDs to query.
191  Call_SingleIntList arg;
192  if (!arg.Decode(&call.tuple)) {
193  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
194  return nullptr;
195  }
196 
197  return m_db.GetMultiInvTypesEx(arg.ints);
198 }
199 
200 
201 //02:10:35 L ConfigService::Handle_GetMapConnections(): size= 6
202 //15:12:56 W ConfigDB::GetMapConnections: DB query - System:20000307, B1:0, B2:0, B3:1, Cel:0, _c:1 <-- this means cached
203 PyResult ConfigService::Handle_GetMapConnections(PyCallArgs &call) {
207  Call_GetMapConnections args;
208  if (!args.Decode(&call.tuple)) {
209  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
210  return nullptr;
211  }
212 
214  if(args.id == 9 || args.sol) {
215  //sLog.Warning( "ConfigService::Handle_GetMapConnections()::args.id = 9 | args.sol");
216  return m_db.GetMapConnections(call.client->GetSystemID(), args.sol, args.reg, args.con, args.cel, args._c);
217  } else {
218  return m_db.GetMapConnections(args.id, args.sol, args.reg, args.con, args.cel, args._c);
219  }
220 }
221 
222 PyResult ConfigService::Handle_GetStationSolarSystemsByOwner(PyCallArgs &call) {
223  // solorSys = sm.RemoteSvc('config').GetStationSolarSystemsByOwner(itemID)
224  // solarSys.solarSystemID
225  Call_SingleIntegerArg arg;
226  if (!arg.Decode(&call.tuple)) {
227  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
228  return nullptr;
229  }
230 
231  // this seems to ONLY return solarSystemIDs
232  return m_db.GetStationSolarSystemsByOwner(arg.arg);
233 }
234 
235 PyResult ConfigService::Handle_GetCelestialStatistic(PyCallArgs &call) {
236  Call_SingleIntegerArg arg;
237  if (!arg.Decode(&call.tuple)) {
238  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
239  return nullptr;
240  }
241 
242  return m_db.GetCelestialStatistic(arg.arg);
243 }
244 
245 PyResult ConfigService::Handle_GetDynamicCelestials(PyCallArgs &call) {
246  Call_SingleIntegerArg arg;
247  if (!arg.Decode(&call.tuple)) {
248  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
249  return nullptr;
250  }
251 
252  if(sDataMgr.IsSolarSystem(arg.arg)) {
253  //sLog.Green("GetDynamicCelesitals", " IsSolarSystem %u", arg.arg);
254  return m_db.GetDynamicCelestials(arg.arg);
255  } else {
256  sLog.Error("GetDynamicCelesitals", "!IsSolarSystem %u", arg.arg);
257  return new PyInt( 0 );
258  }
259 }
260 
261 PyResult ConfigService::Handle_SetMapLandmarks(PyCallArgs &call) {
272  _log(CACHE__DUMP, "MapService::Handle_SetMapLandmarks()");
273  call.Dump(CACHE__DUMP);
274 
275  return nullptr;
276 }
277 
Dispatcher *const m_dispatch
uint32 GetSystemID() const
Definition: Client.h:152
#define _log(type, fmt,...)
Definition: logsys.h:124
PyRep * GetMultiGraphicsEx(const std::vector< int32 > &entityIDs)
Definition: ConfigDB.cpp:283
PyObject * GetMapLandmarks()
Definition: ConfigDB.cpp:546
Dispatcher *const m_dispatch
Definition: ConfigService.h:40
PyRep * GetDynamicCelestials(uint32 solarSystemID)
Retrieves dynamic, celestial objects for a given solar system.
Definition: ConfigDB.cpp:450
PyObject * GetMapOffices(uint32)
Definition: ConfigDB.cpp:510
PyRep * GetStationSolarSystemsByOwner(uint32 ownerID)
Definition: ConfigDB.cpp:400
const char * GetName() const
Definition: PyService.h:54
PyRep * GetMultiOwnersEx(const std::vector< int32 > &entityIDs)
Definition: ConfigDB.cpp:31
* args
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
virtual ~ConfigService()
#define codelog(type, fmt,...)
Definition: logsys.h:128
PyObject * GetUnits()
Definition: ConfigDB.cpp:303
PyRep * GetCelestialStatistic(uint32 celestialID)
Definition: ConfigDB.cpp:415
Python integer.
Definition: PyRep.h:231
PyRep * GetMultiAllianceShortNamesEx(const std::vector< int32 > &entityIDs)
Definition: ConfigDB.cpp:165
Client *const client
Definition: PyCallable.h:49
#define PyCallable_REG_CALL(c, m)
Definition: PyServiceCD.h:78
PyRep * GetMultiCorpTickerNamesEx(const std::vector< int32 > &entityIDs)
Definition: ConfigDB.cpp:262
PyRep * GetMultiInvTypesEx(const std::vector< int32 > &typeIDs)
Definition: ConfigDB.cpp:381
ConfigDB m_db
Definition: ConfigService.h:43
PyObject * GetMap(uint32 solarSystemID)
Definition: ConfigDB.cpp:344
PyObject * GetMapConnections(uint32, bool, bool, bool, uint16, uint16)
Definition: ConfigDB.cpp:521
PyRep * GetMultiStationEx(const std::vector< int32 > &entityIDs)
Definition: ConfigDB.cpp:249
void Dump(LogType type) const
Definition: PyCallable.cpp:81
PyRep * GetMultiLocationsEx(const std::vector< int32 > &entityIDs)
Definition: ConfigDB.cpp:177
PyCallable_Make_InnerDispatcher(ConfigService) ConfigService
PyObjectEx * GetMapObjects(uint32 entityID, bool wantRegions, bool wantConstellations, bool wantSystems, bool wantStations)
Definition: ConfigDB.cpp:314
PyTuple * tuple
Definition: PyCallable.h:50
#define sDataMgr