EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
AllianceRegistry.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  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16  * You should have received a copy of the GNU Lesser General Public License along with
17  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
18  * Place - Suite 330, Boston, MA 02111-1307, USA, or go to
19  * http://www.gnu.org/copyleft/lesser.txt.
20  * ------------------------------------------------------------------------------------
21  * Author: Allan
22  * Updates: James
23  */
24 
25 //work in progress
28 #include "eve-server.h"
29 
30 #include "PyServiceCD.h"
32 
33 /*
34  * ALLY__ERROR
35  * ALLY__WARNING
36  * ALLY__INFO
37  * ALLY__MESSAGE
38  * ALLY__TRACE
39  * ALLY__CALL
40  * ALLY__CALL_DUMP
41  * ALLY__RSP_DUMP
42  */
43 
45 
47 : PyService(mgr, "allianceRegistry"),
48 m_dispatch(new Dispatcher(this))
49 {
50  _SetCallDispatcher(m_dispatch);
51 
52  PyCallable_REG_CALL(AllianceRegistry, GetAlliance); // bound object call
53  PyCallable_REG_CALL(AllianceRegistry, GetRankedAlliances);
54  PyCallable_REG_CALL(AllianceRegistry, GetEmploymentRecord);
55  PyCallable_REG_CALL(AllianceRegistry, GetAllianceMembers);
56 }
57 
59 {
60  delete m_dispatch;
61 }
62 
64 {
65  if (!bind_args->IsTuple()){
66  sLog.Error( "AllianceRegistry::CreateBoundObject", "%s: bind_args is not tuple: '%s'. ", pClient->GetName(), bind_args->TypeString() );
67  pClient->SendErrorMsg("Could not bind object for Ally Registry. Ref: ServerError 02808.");
68  return nullptr;
69  }
70 
71  return new AllianceBound(m_manager, m_db, PyRep::IntegerValue(bind_args->AsTuple()->GetItem(0)));
72 }
73 
74 // this is the bind call. do it like fleet
75 PyResult AllianceRegistry::Handle_GetAlliance(PyCallArgs &call) {
76  //alliance = sm.RemoteSvc('allianceRegistry').GetAlliance(allianceID)
77  /*
78  * 01:22:07 [SvcCall] Service allianceRegistry::MachoResolveObject()
79  * 01:22:07 [SvcCall] Service allianceRegistry::MachoBindObject()
80  * 01:22:07 [SvcError] allianceRegistry Service: allan: Unable to create bound object for:
81  * 01:22:07 [SvcError] Tuple: 2 elements
82  * 01:22:07 [SvcError] [ 0] Integer: 0
83  * 01:22:07 [SvcError] [ 1] Integer: 1
84  */
85 
86  _log(ALLY__CALL, "AllianceRegistry::Handle_GetAlliance() size=%u", call.tuple->size() );
87  call.Dump(ALLY__CALL_DUMP);
88 
89  Call_SingleIntegerArg args;
90  if (!args.Decode(&call.tuple)) {
91  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
92  return nullptr;
93  }
94  return m_db.GetAlliance(args.arg);
95 }
96 
97 PyResult AllianceRegistry::Handle_GetAllianceMembers(PyCallArgs &call) {
98  // members = sm.RemoteSvc('allianceRegistry').GetAllianceMembers(itemID) <-- returns dict of corpIDs
99  _log(ALLY__CALL, "AllianceRegistry::Handle_GetAllianceMembers() size=%u", call.tuple->size() );
100  call.Dump(ALLY__CALL_DUMP);
101 
102  Call_SingleIntegerArg args;
103  if (!args.Decode(&call.tuple)) {
104  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
105  return nullptr;
106  }
107  return m_db.GetAllianceMembers(args.arg);
108 }
109 
110 PyResult AllianceRegistry::Handle_GetRankedAlliances(PyCallArgs &call) {
111  /*
112  * self.rankedAlliances.alliances = sm.RemoteSvc('allianceRegistry').GetRankedAlliances(maxLen)
113  * self.rankedAlliances.standings = {}
114  * for a in self.rankedAlliances.alliances:
115  * s = sm.GetService('standing').GetStanding(eve.session.corpid, a.allianceID)
116  * self.rankedAlliances.standings[a.allianceID] = s
117  */
118 
119  _log(ALLY__CALL, "AllianceRegistry::Handle_GetRankedAlliances() size=%u", call.tuple->size() );
120  call.Dump(ALLY__CALL_DUMP);
121 
122  return m_db.GetRankedAlliances();
123 }
124 
125 //Not sure why this doesn't work
126 PyResult AllianceRegistry::Handle_GetEmploymentRecord(PyCallArgs &call) {
127  // allianceHistory = sm.RemoteSvc('allianceRegistry').GetEmploymentRecord(itemID)
128  _log(ALLY__CALL, "AllianceRegistry::Handle_GetEmploymentRecord() size=%u", call.tuple->size() );
129  call.Dump(ALLY__CALL_DUMP);
130 
131  Call_SingleIntegerArg arg;
132  if (!arg.Decode(&call.tuple)) {
133  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
134  return nullptr;
135  }
136 
137  return m_db.GetEmploymentRecord(arg.arg);
138 }
Base Python wire object.
Definition: PyRep.h:66
PyTuple * AsTuple()
Definition: PyRep.h:138
Dispatcher *const m_dispatch
PyCallable_Make_InnerDispatcher(AllianceRegistry) AllianceRegistry
void SendErrorMsg(const char *fmt,...)
Definition: Client.cpp:2719
#define _log(type, fmt,...)
Definition: logsys.h:124
PyRep * GetItem(size_t index) const
Returns Python object.
Definition: PyRep.h:602
size_t size() const
Definition: PyRep.h:591
bool IsTuple() const
Definition: PyRep.h:108
const char * GetName() const
Definition: PyService.h:54
PyRep * GetAllianceMembers(uint32 allyID)
Definition: AllianceDB.cpp:484
* args
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
PyRep * GetRankedAlliances()
Definition: AllianceDB.cpp:501
#define codelog(type, fmt,...)
Definition: logsys.h:128
PyRep * GetAlliance(uint32 allyID)
Definition: AllianceDB.cpp:58
PyServiceMgr *const m_manager
Definition: PyService.h:91
const char * GetName() const
Definition: Client.h:94
#define PyCallable_REG_CALL(c, m)
Definition: PyServiceCD.h:78
Definition: Client.h:66
PyRep * GetEmploymentRecord(uint32 corpID)
Definition: AllianceDB.cpp:316
void Dump(LogType type) const
Definition: PyCallable.cpp:81
virtual PyBoundObject * CreateBoundObject(Client *pClient, const PyRep *bind_args)
static int64 IntegerValue(PyRep *pRep)
Definition: PyRep.cpp:118
Dispatcher *const m_dispatch
const char * TypeString() const
Definition: PyRep.cpp:76
PyTuple * tuple
Definition: PyCallable.h:50