EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
FactionWarMgrService.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 (outline and 3 calls)
24  Rewrite: Allan
25 */
26 
27 #include "eve-server.h"
28 
29 #include "PyServiceCD.h"
30 #include "cache/ObjCacheService.h"
32 
33 /*
34  * FACWAR__ERROR
35  * FACWAR__WARNING
36  * FACWAR__INFO
37  * FACWAR__MESSAGE
38  * FACWAR__TRACE
39  * FACWAR__CALL
40  * FACWAR__CALL_DUMP
41  * FACWAR__RSP_DUMP
42  */
43 
45 
47 : PyService(mgr, "facWarMgr"),
48  m_dispatch(new Dispatcher(this))
49 {
50  _SetCallDispatcher(m_dispatch);
51 
54  PyCallable_REG_CALL(FactionWarMgrService, GetMyCharacterRankOverview);
55  PyCallable_REG_CALL(FactionWarMgrService, GetMyCharacterRankInfo);
56  PyCallable_REG_CALL(FactionWarMgrService, GetFactionMilitiaCorporation);
57  PyCallable_REG_CALL(FactionWarMgrService, GetCharacterRankInfo);
58  PyCallable_REG_CALL(FactionWarMgrService, GetFactionalWarStatus);
59  PyCallable_REG_CALL(FactionWarMgrService, GetSystemStatus);
61  PyCallable_REG_CALL(FactionWarMgrService, JoinFactionAsCharacter);
62  PyCallable_REG_CALL(FactionWarMgrService, GetCorporationWarFactionID);
63  PyCallable_REG_CALL(FactionWarMgrService, IsEnemyCorporation);
64  PyCallable_REG_CALL(FactionWarMgrService, GetSystemsConqueredThisRun);
65  PyCallable_REG_CALL(FactionWarMgrService, GetFactionCorporations);
66  PyCallable_REG_CALL(FactionWarMgrService, JoinFactionAsCharacterRecommendationLetter);
67  PyCallable_REG_CALL(FactionWarMgrService, JoinFactionAsAlliance);
68  PyCallable_REG_CALL(FactionWarMgrService, JoinFactionAsCorporation);
69  PyCallable_REG_CALL(FactionWarMgrService, GetStats_FactionInfo);
70  PyCallable_REG_CALL(FactionWarMgrService, GetStats_TopAndAllKillsAndVPs);
71  PyCallable_REG_CALL(FactionWarMgrService, GetStats_Character);
72  PyCallable_REG_CALL(FactionWarMgrService, GetStats_Alliance);
73  PyCallable_REG_CALL(FactionWarMgrService, GetStats_Militia);
74  PyCallable_REG_CALL(FactionWarMgrService, GetStats_CorpPilots);
75  PyCallable_REG_CALL(FactionWarMgrService, LeaveFactionAsAlliance);
76  PyCallable_REG_CALL(FactionWarMgrService, LeaveFactionAsCorporation);
77  PyCallable_REG_CALL(FactionWarMgrService, WithdrawJoinFactionAsAlliance);
78  PyCallable_REG_CALL(FactionWarMgrService, WithdrawJoinFactionAsCorporation);
79  PyCallable_REG_CALL(FactionWarMgrService, WithdrawLeaveFactionAsAlliance);
80  PyCallable_REG_CALL(FactionWarMgrService, WithdrawLeaveFactionAsCorporation);
82 
83 }
84 
86 {
87  delete m_dispatch;
88 }
89 
90 PyResult FactionWarMgrService::Handle_GetWarFactions(PyCallArgs &call) {
91  ObjectCachedMethodID method_id(GetName(), "GetWarFactions");
92 
93  if(!m_manager->cache_service->IsCacheLoaded(method_id)) {
94  PyRep *res = m_db.GetWarFactions();
95  if(res == NULL)
96  return nullptr;
97  m_manager->cache_service->GiveCache(method_id, &res);
98  }
99 
101 }
102 
103 PyResult FactionWarMgrService::Handle_GetFWSystems( PyCallArgs& call )
104 {
105  /*
106  [PySubStream 3625 bytes]
107  [PyDict 171 kvp]
108  [PyInt 30002813]
109  [PyDict 2 kvp]
110  [PyString "occupierID"]
111  [PyInt 500001]
112  [PyString "factionID"]
113  [PyInt 500001]
114  [PyInt 30005295]
115  [PyDict 2 kvp]
116  [PyString "occupierID"]
117  [PyInt 500004]
118  [PyString "factionID"]
119  [PyInt 500004]
120  */
121  ObjectCachedMethodID method_id( GetName(), "GetFacWarSystems" );
122 
123  if( !m_manager->cache_service->IsCacheLoaded( method_id ) )
124  {
125  PyRep* res = m_db.GetFacWarSystems();
126  if( res == NULL )
127  return nullptr;
128 
129  m_manager->cache_service->GiveCache( method_id, &res );
130  }
131 
133 }
134 
139 PyResult FactionWarMgrService::Handle_GetMyCharacterRankOverview( PyCallArgs& call ) {
167 // will need data from DB...
168  util_Rowset rs;
169 
170  rs.header.push_back( "currentRank" );
171  rs.header.push_back( "highestRank" );
172  rs.header.push_back( "factionID" );
173  rs.header.push_back( "lastModified" );
174 
175  return rs.Encode();
176 }
177 
178 PyResult FactionWarMgrService::Handle_GetMyCharacterRankInfo( PyCallArgs& call ) {
179  _log(FACWAR__CALL, "FacWarMgr::Handle_GetMyCharacterRankInfo() size= %u", call.tuple->size() );
180  call.Dump(FACWAR__CALL_DUMP);
181  util_Rowset rs;
182 
183  rs.header.push_back( "currentRank" );
184  rs.header.push_back( "highestRank" );
185  rs.header.push_back( "factionID" );
186  rs.header.push_back( "lastModified" );
187 
188  return rs.Encode();
189 }
190 
191 PyResult FactionWarMgrService::Handle_GetFactionMilitiaCorporation(PyCallArgs &call) {
192  /* 05:39:07 [SvcCall] Service facWarMgr: calling GetFactionMilitiaCorporation
193  * 05:39:07 FactionWarMgrService::Handle_GetFactionMilitiaCorporation(): size= 1
194  * 05:39:07 [SvcCall] Call Arguments:
195  * 05:39:07 [SvcCall] Tuple: 1 elements
196  * 05:39:07 [SvcCall] [ 0] Integer field: 500002
197  */
198  _log(FACWAR__CALL, "FacWarMgr::Handle_GetFactionMilitiaCorporation() size= %u", call.tuple->size() );
199  call.Dump(FACWAR__CALL_DUMP);
200  Call_SingleIntegerArg arg;
201  if (!arg.Decode(&call.tuple)) {
202  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
203  return nullptr;
204  }
205  return (new PyInt(m_db.GetFactionMilitiaCorporation(arg.arg)));
206 }
207 
208 PyResult FactionWarMgrService::Handle_GetSystemStatus(PyCallArgs &call) {
209  /*
210  * status = self.facWarMgr.GetSystemStatus(session.solarsystemid2, session.warfactionid)
211  * systemStatus = sm.StartService('facwar').GetSystemStatus()
212  * xtra = ''
213  * if systemStatus == const.contestionStateCaptured:
214  * xtra = localization.GetByLabel('UI/Neocom/SystemLost')
215  * elif systemStatus == const.contestionStateVulnerable:
216  * xtra = localization.GetByLabel('UI/Neocom/Vulnerable')
217  * elif systemStatus == const.contestionStateContested:
218  * xtra = localization.GetByLabel('UI/Neocom/Contested')
219  * elif systemStatus == const.contestionStateNone and returnNone:
220  * xtra = localization.GetByLabel('UI/Neocom/Uncontested')
221  * return xtra
222  */
223 
224  _log(FACWAR__CALL, "FacWarMgr::Handle_GetSystemStatus()");
225  call.Dump(FACWAR__CALL_DUMP);
226  return new PyInt(FacWar::SysStatus::None);
227 }
228 
229 // these next two should use static data or cached data to avoid db hits
230 PyResult FactionWarMgrService::Handle_IsEnemyFaction(PyCallArgs &call) {
231  // return self.facWarMgr.IsEnemyFaction(enemyID, factionID)
232  /*
233  * 05:39:09 L FactionWarMgrService::Handle_IsEnemyFaction(): size=2
234  * 05:39:09 [SvcCall] Call Arguments:
235  * 05:39:09 [SvcCall] Tuple: 2 elements
236  * 05:39:09 [SvcCall] [ 0] Integer field: 500002
237  * 05:39:09 [SvcCall] [ 1] Integer field: 500001 <- this one changes
238  */
239  _log(FACWAR__CALL, "FacWarMgr::Handle_IsEnemyFaction()");
240  call.Dump(FACWAR__CALL_DUMP);
241 
242  // return boolean
243  return PyStatic.NewFalse();
244 }
245 
246 PyResult FactionWarMgrService::Handle_IsEnemyCorporation(PyCallArgs &call) {
247  //return self.facWarMgr.IsEnemyCorporation(enemyID, factionID)
248  _log(FACWAR__CALL, "FacWarMgr::Handle_IsEnemyCorporation()");
249  call.Dump(FACWAR__CALL_DUMP);
250 
251  // return boolean
252  return PyStatic.NewFalse();
253 }
254 
259 PyResult FactionWarMgrService::Handle_GetCharacterRankInfo(PyCallArgs &call) {
260  _log(FACWAR__CALL, "FacWarMgr::Handle_GetCharacterRankInfo()");
261  call.Dump(FACWAR__CALL_DUMP);
262 
263  return nullptr;
264 }
265 
266 //22:48:28 L FactionWarMgrService::Handle_GetFactionalWarStatus(): size= 0
267 PyResult FactionWarMgrService::Handle_GetFactionalWarStatus(PyCallArgs &call) {
268  _log(FACWAR__CALL, "FacWarMgr::Handle_GetFactionalWarStatus()");
269  call.Dump(FACWAR__CALL_DUMP);
270 
271  return nullptr;
272 }
273 
274 PyResult FactionWarMgrService::Handle_JoinFactionAsCharacter(PyCallArgs &call) {
275  _log(FACWAR__CALL, "FacWarMgr::Handle_JoinFactionAsCharacter()");
276  call.Dump(FACWAR__CALL_DUMP);
277 
278  return nullptr;
279 }
280 
281 PyResult FactionWarMgrService::Handle_GetCorporationWarFactionID(PyCallArgs &call) {
282  //ret = self.facWarMgr.GetCorporationWarFactionID(corpID)
283  _log(FACWAR__CALL, "FacWarMgr::Handle_GetCorporationWarFactionID()");
284  call.Dump(FACWAR__CALL_DUMP);
285 
286  return nullptr;
287 }
288 
289 PyResult FactionWarMgrService::Handle_GetSystemsConqueredThisRun(PyCallArgs &call) {
290  /*
291  systemsThatWillSwitchNextDownTime = self.GetSystemsConqueredThisRun()
292  cfg.evelocations.Prime([ d['solarsystemID'] for d in systemsThatWillSwitchNextDownTime ])
293  cfg.eveowners.Prime([ d['occupierID'] for d in systemsThatWillSwitchNextDownTime ])
294  */
295  _log(FACWAR__CALL, "FacWarMgr::Handle_GetSystemsConqueredThisRun()");
296  call.Dump(FACWAR__CALL_DUMP);
297 
298  return nullptr;
299 }
300 
301 PyResult FactionWarMgrService::Handle_GetFactionCorporations(PyCallArgs &call) {
302  //return self.facWarMgr.GetFactionCorporations(factionID)
303  _log(FACWAR__CALL, "FacWarMgr::Handle_GetFactionCorporations()");
304  call.Dump(FACWAR__CALL_DUMP);
305 
306  return nullptr;
307 }
308 
309 PyResult FactionWarMgrService::Handle_JoinFactionAsCharacterRecommendationLetter(PyCallArgs &call) {
310  //self.facWarMgr.JoinFactionAsCharacterRecommendationLetter, factionID, itemID)
311  // if char standing with faction is < 0.5,
312  // they can join provided they have a 'recommendation letter', typeID 30906
313  // dunno if the letter is removed after joining.
314  _log(FACWAR__CALL, "FacWarMgr::Handle_JoinFactionAsCharacterRecommendationLetter()");
315  call.Dump(FACWAR__CALL_DUMP);
316 
317  return nullptr;
318 }
319 
320 PyResult FactionWarMgrService::Handle_JoinFactionAsAlliance(PyCallArgs &call) {
321  //self.facWarMgr.JoinFactionAsAlliance(factionID)
322  _log(FACWAR__CALL, "FacWarMgr::Handle_JoinFactionAsAlliance()");
323  call.Dump(FACWAR__CALL_DUMP);
324 
325  return nullptr;
326 }
327 
328 PyResult FactionWarMgrService::Handle_JoinFactionAsCorporation(PyCallArgs &call) {
329  //self.facWarMgr.JoinFactionAsCorporation(factionID)
330  _log(FACWAR__CALL, "FacWarMgr::Handle_JoinFactionAsCorporation()");
331  call.Dump(FACWAR__CALL_DUMP);
332 
333  return nullptr;
334 }
335 
336 PyResult FactionWarMgrService::Handle_GetStats_FactionInfo(PyCallArgs &call) {
337  //return self.facWarMgr.GetStats_FactionInfo()
338  _log(FACWAR__CALL, "FacWarMgr::Handle_GetStats_FactionInfo()");
339  call.Dump(FACWAR__CALL_DUMP);
340 
341  return nullptr;
342 }
343 
344 PyResult FactionWarMgrService::Handle_GetStats_TopAndAllKillsAndVPs(PyCallArgs &call) {
345  //self.topStats = self.facWarMgr.GetStats_TopAndAllKillsAndVPs()
346  _log(FACWAR__CALL, "FacWarMgr::Handle_GetStats_TopAndAllKillsAndVPs()");
347  call.Dump(FACWAR__CALL_DUMP);
348 
349  return nullptr;
350 }
351 
352 PyResult FactionWarMgrService::Handle_GetStats_Character(PyCallArgs &call) {
353  //for k, v in self.facWarMgr.GetStats_Character().items():
354  _log(FACWAR__CALL, "FacWarMgr::Handle_GetStats_Character()");
355  call.Dump(FACWAR__CALL_DUMP);
356 
357  return nullptr;
358 }
359 
360 PyResult FactionWarMgrService::Handle_GetStats_Corp(PyCallArgs &call) {
361  // for k, v in self.facWarMgr.GetStats_Corp().items():
362  _log(FACWAR__CALL, "FacWarMgr::Handle_GetStats_Corp()");
363  call.Dump(FACWAR__CALL_DUMP);
364 
365  return nullptr;
366 }
367 
368 PyResult FactionWarMgrService::Handle_GetStats_Alliance(PyCallArgs &call) {
369  //for k, v in self.facWarMgr.GetStats_Alliance().items():
370  _log(FACWAR__CALL, "FacWarMgr::Handle_GetStats_Alliance()");
371  call.Dump(FACWAR__CALL_DUMP);
372 
373  return nullptr;
374 }
375 
376 PyResult FactionWarMgrService::Handle_GetStats_Militia(PyCallArgs &call) {
377  //return self.facWarMgr.GetStats_Militia()
378  _log(FACWAR__CALL, "FacWarMgr::Handle_GetStats_Militia()");
379  call.Dump(FACWAR__CALL_DUMP);
380 
381  return nullptr;
382 }
383 
384 PyResult FactionWarMgrService::Handle_GetStats_CorpPilots(PyCallArgs &call) {
385  //return self.facWarMgr.GetStats_CorpPilots()
386  _log(FACWAR__CALL, "FacWarMgr::Handle_GetStats_CorpPilots()");
387  call.Dump(FACWAR__CALL_DUMP);
388 
389  return nullptr;
390 }
391 
392 PyResult FactionWarMgrService::Handle_LeaveFactionAsAlliance(PyCallArgs &call) {
393  //self.facWarMgr.LeaveFactionAsAlliance(factionID)
394  _log(FACWAR__CALL, "FacWarMgr::Handle_LeaveFactionAsAlliance()");
395  call.Dump(FACWAR__CALL_DUMP);
396 
397  return nullptr;
398 }
399 
400 PyResult FactionWarMgrService::Handle_LeaveFactionAsCorporation(PyCallArgs &call) {
401  //self.facWarMgr.LeaveFactionAsCorporation(factionID)
402  _log(FACWAR__CALL, "FacWarMgr::Handle_LeaveFactionAsCorporation()");
403  call.Dump(FACWAR__CALL_DUMP);
404 
405  return nullptr;
406 }
407 
408 PyResult FactionWarMgrService::Handle_WithdrawJoinFactionAsAlliance(PyCallArgs &call) {
409  //self.facWarMgr.WithdrawJoinFactionAsAlliance(factionID)
410  _log(FACWAR__CALL, "FacWarMgr::Handle_WithdrawJoinFactionAsAlliance()");
411  call.Dump(FACWAR__CALL_DUMP);
412 
413  return nullptr;
414 }
415 
416 PyResult FactionWarMgrService::Handle_WithdrawJoinFactionAsCorporation(PyCallArgs &call) {
417  //self.facWarMgr.WithdrawJoinFactionAsCorporation(factionID)
418  _log(FACWAR__CALL, "FacWarMgr::Handle_WithdrawJoinFactionAsCorporation()");
419  call.Dump(FACWAR__CALL_DUMP);
420 
421  return nullptr;
422 }
423 
424 PyResult FactionWarMgrService::Handle_WithdrawLeaveFactionAsAlliance(PyCallArgs &call) {
425  //self.facWarMgr.WithdrawLeaveFactionAsAlliance(factionID)
426  _log(FACWAR__CALL, "FacWarMgr::Handle_WithdrawLeaveFactionAsAlliance()");
427  call.Dump(FACWAR__CALL_DUMP);
428 
429  return nullptr;
430 }
431 
432 PyResult FactionWarMgrService::Handle_WithdrawLeaveFactionAsCorporation(PyCallArgs &call) {
433  //self.facWarMgr.WithdrawLeaveFactionAsCorporation(factionID)
434  _log(FACWAR__CALL, "FacWarMgr::Handle_WithdrawLeaveFactionAsCorporation()");
435  call.Dump(FACWAR__CALL_DUMP);
436 
437  return nullptr;
438 }
439 
440 PyResult FactionWarMgrService::Handle_RefreshCorps(PyCallArgs &call) {
441  //return self.facWarMgr.RefreshCorps()
442  _log(FACWAR__CALL, "FacWarMgr::Handle_RefreshCorps()");
443  call.Dump(FACWAR__CALL_DUMP);
444 
445  return nullptr;
446 }
447 
Base Python wire object.
Definition: PyRep.h:66
Dispatcher *const m_dispatch
#define _log(type, fmt,...)
Definition: logsys.h:124
size_t size() const
Definition: PyRep.h:591
uint32 GetFactionMilitiaCorporation(const uint32 factionID)
const char * GetName() const
Definition: PyService.h:54
Dispatcher *const m_dispatch
#define codelog(type, fmt,...)
Definition: logsys.h:128
Python integer.
Definition: PyRep.h:231
PyRep * GetWarFactions()
PyServiceMgr *const m_manager
Definition: PyService.h:91
#define PyStatic
Definition: PyRep.h:1209
#define PyCallable_REG_CALL(c, m)
Definition: PyServiceCD.h:78
PyCallable_Make_InnerDispatcher(FactionWarMgrService) FactionWarMgrService
void GiveCache(const PyRep *objectID, PyRep **contents)
ObjCacheService * cache_service
Definition: PyServiceMgr.h:78
void Dump(LogType type) const
Definition: PyCallable.cpp:81
PyRep * GetFacWarSystems()
PyObject * MakeObjectCachedMethodCallResult(const PyRep *objectID, const char *versionCheck="run")
bool IsCacheLoaded(const PyRep *objectID) const
PyTuple * tuple
Definition: PyCallable.h:50