EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
NetService.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 "NetService.h"
30 #include "PyServiceCD.h"
31 #include "cache/ObjCacheService.h"
32 
34 
36 : PyService(mgr, "machoNet"),
37  m_dispatch(new Dispatcher(this))
38 {
39  _SetCallDispatcher(m_dispatch);
40 
42  PyCallable_REG_CALL(NetService, GetInitVals);
43  PyCallable_REG_CALL(NetService, GetClusterSessionStatistics);
44 }
45 
47  delete m_dispatch;
48 }
49 
50 PyResult NetService::Handle_GetTime(PyCallArgs &call) {
51  return new PyLong(GetFileTimeNow());
52 }
53 
54 PyResult NetService::Handle_GetClusterSessionStatistics(PyCallArgs &call)
55 {
56  // got this shit working once i understood what the client wanted....only took 4 years
57  DBQueryResult res;
58  sDatabase.RunQuery(res, "SELECT solarSystemID, pilotsInSpace, pilotsDocked FROM mapDynamicData"); // WHERE active = 1");
63  uint16 system(0);
64  PyDict* sol = new PyDict();
65  PyDict* sta = new PyDict();
66 
67  DBResultRow row;
68  while (res.GetRow(row)) {
69  system = row.GetUInt(0) - 30000000;
70  sol->SetItem(new PyInt(system), new PyInt(row.GetUInt(1) + row.GetUInt(2))); // inspace + docked = total
71  sta->SetItem(new PyInt(system), new PyInt(row.GetUInt(2))); // total - docked
72  }
73 
74  PyTuple *result = new PyTuple(3);
75  result->SetItem(0, sol);
76  result->SetItem(1, sta);
77  result->SetItem(2, new PyFloat(1)); //statDivisor
78 
79  return result;
80 }
81 
83 PyResult NetService::Handle_GetInitVals(PyCallArgs &call) {
84  PyString* str = new PyString( "machoNet.serviceInfo" );
85 
86  PyRep* serverinfo(m_manager->cache_service->GetCacheHint(str));
87  PyDecRef( str );
88 
89  PyDict* initvals = new PyDict();
90  PyTuple* result = new PyTuple( 2 );
91  result->SetItem( 0, serverinfo );
92  result->SetItem( 1, initvals );
93  return result;
94 }
Base Python wire object.
Definition: PyRep.h:66
Dispatcher *const m_dispatch
#define sDatabase
Definition: dbcore.h:199
Python string.
Definition: PyRep.h:430
Python's dictionary.
Definition: PyRep.h:719
uint32 GetUInt(uint32 index) const
Definition: dbcore.cpp:658
Python floating point number.
Definition: PyRep.h:292
PyRep * GetCacheHint(const PyRep *objectID)
Python tuple.
Definition: PyRep.h:567
Dispatcher *const m_dispatch
Definition: NetService.h:38
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
void SetItem(size_t index, PyRep *object)
Stores Python object.
Definition: PyRep.h:610
Python integer.
Definition: PyRep.h:231
PyServiceMgr *const m_manager
Definition: PyService.h:91
#define PyDecRef(op)
Definition: PyRep.h:57
#define PyCallable_REG_CALL(c, m)
Definition: PyServiceCD.h:78
double GetFileTimeNow()
Definition: utils_time.cpp:84
ObjCacheService * cache_service
Definition: PyServiceMgr.h:78
PyCallable_Make_InnerDispatcher(NetService) NetService
Definition: NetService.cpp:33
unsigned __int16 uint16
Definition: eve-compat.h:48
void SetItem(PyRep *key, PyRep *value)
SetItem adds or sets a database entry.
Definition: PyRep.cpp:713
Python long integer.
Definition: PyRep.h:261