EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
IndexManager.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 "PyServiceCD.h"
29 #include "system/IndexManager.h"
32 
34 
36 : PyService(mgr, "devIndexManager"),
37  m_dispatch(new Dispatcher(this))
38 {
39  _SetCallDispatcher(m_dispatch);
40 
41  PyCallable_REG_CALL(IndexManager, GetAllDevelopmentIndices);
42  PyCallable_REG_CALL(IndexManager, GetDevelopmentIndicesForSystem);
43 }
44 
46  delete m_dispatch;
47 }
48 
49 PyResult IndexManager::Handle_GetAllDevelopmentIndices( PyCallArgs& call ) {
50 
51  /*
52 22:49:13 L IndexManager::Handle_GetAllDevelopmentIndices(): size= 0
53  for indexInfo in sm.RemoteSvc('devIndexManager').GetAllDevelopmentIndices():
54  systemToIndexMap[indexInfo.solarSystemID] = {const.attributeDevIndexMilitary: indexInfo.militaryPoints,
55  const.attributeDevIndexIndustrial: indexInfo.industrialPoints,
56  const.attributeDevIndexSovereignty: indexInfo.claimedFor * CLAIM_DAYS_TO_SECONDS}
57  */
58  return nullptr;
59 }
60 
61 PyResult IndexManager::Handle_GetDevelopmentIndicesForSystem( PyCallArgs& call ) {
62  Call_SingleIntegerArg args;
63  if (!args.Decode(&call.tuple)) {
64  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
65  return nullptr;
66  }
67 
68  DBRowDescriptor *header = new DBRowDescriptor();
69  header->AddColumn("attributeID", DBTYPE_I4);
70  header->AddColumn("points", DBTYPE_I2);
71  header->AddColumn("increasing", DBTYPE_BOOL);
72  //CRowSet *rowset = new CRowSet(&header);
73 
74  SovereigntyData sovData = svDataMgr.GetSovereigntyData(args.arg);
75  PyPackedRow *row1 = new PyPackedRow(header);
76  PyPackedRow *row2 = new PyPackedRow(header);
77  PyPackedRow *row3 = new PyPackedRow(header);
78 
79  // Strategic
80  row1->SetField("attributeID", new PyInt(EveAttrEnum::AttrdevIndexSovereignty));
81  double daysSinceClaim = (GetFileTimeNow() - sovData.claimTime) / Win32Time_Day;
82  row1->SetField("points", new PyInt(uint32(daysSinceClaim)));
83  row1->SetField("increasing", new PyBool(false));
84 
85  // Military
86  row2->SetField("attributeID", new PyInt(EveAttrEnum::AttrdevIndexMilitary));
87  row2->SetField("points", new PyInt(sovData.militaryPoints));
88  row2->SetField("increasing", new PyBool(false));
89 
90  // Industrial
91  row3->SetField("attributeID", new PyInt(EveAttrEnum::AttrdevIndexIndustrial));
92  row3->SetField("points", new PyInt(sovData.industrialPoints));
93  row3->SetField("increasing", new PyBool(false));
94 
95  PyDict* dict = new PyDict();
99 
100  return dict;
101 }
102 
103 /*
104 developmentIndices = [attributeDevIndexMilitary, attributeDevIndexIndustrial, attributeDevIndexSovereignty]
105 attributeDevIndexMilitary = 1583
106 attributeDevIndexIndustrial = 1584
107 attributeDevIndexSovereignty = 1615
108 */
Dispatcher *const m_dispatch
Python's dictionary.
Definition: PyRep.h:719
virtual ~IndexManager()
void AddColumn(const char *name, DBTYPE type)
Definition: PyDatabase.cpp:96
Dispatcher *const m_dispatch
Definition: IndexManager.h:38
const char * GetName() const
Definition: PyService.h:54
* args
Python boolean.
Definition: PyRep.h:323
const int64 Win32Time_Day
Definition: utils_time.cpp:41
Python object "blue.DBRowDescriptor".
Definition: PyDatabase.h:41
PyCallable_Make_InnerDispatcher(IndexManager) IndexManager
#define codelog(type, fmt,...)
Definition: logsys.h:128
Python integer.
Definition: PyRep.h:231
#define PyCallable_REG_CALL(c, m)
Definition: PyServiceCD.h:78
unsigned __int32 uint32
Definition: eve-compat.h:50
double GetFileTimeNow()
Definition: utils_time.cpp:84
bool SetField(uint32 index, PyRep *value)
Definition: PyRep.cpp:1031
Packed row.
Definition: PyRep.h:961
#define svDataMgr
void SetItem(PyRep *key, PyRep *value)
SetItem adds or sets a database entry.
Definition: PyRep.cpp:713
PyTuple * tuple
Definition: PyCallable.h:50