EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Standing.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 "standing/Standing.h"
28 
29 /* re-write of standing system -allan 10Apr15
30  * see notes in StandingDB.cpp
31  */
32 
33 /*
34  * STANDING__ERROR
35  * STANDING__WARNING
36  * STANDING__MESSAGE
37  * STANDING__DEBUG
38  * STANDING__INFO
39  * STANDING__TRACE
40  * STANDING__DUMP
41  * STANDING__RSPDUMP
42  */
43 
45 
47 : PyService(mgr, "standing2"),
48  m_dispatch(new Dispatcher(this))
49 {
50  _SetCallDispatcher(m_dispatch);
51 
52  PyCallable_REG_CALL(Standing, GetSecurityRating);
53  PyCallable_REG_CALL(Standing, GetMyKillRights);
54  PyCallable_REG_CALL(Standing, GetCharStandings);
55  PyCallable_REG_CALL(Standing, GetCorpStandings);
56  PyCallable_REG_CALL(Standing, GetNPCNPCStandings);
57  PyCallable_REG_CALL(Standing, GetStandingTransactions);
58  PyCallable_REG_CALL(Standing, GetStandingCompositions);
59 
60 }
61 
63  delete m_dispatch;
64 }
65 
66 PyResult Standing::Handle_GetCharStandings(PyCallArgs &call) {
67  return m_db.GetCharStandings(call.client);
68 }
69 
70 PyResult Standing::Handle_GetCorpStandings(PyCallArgs &call) {
71  return m_db.GetCorpStandings(call.client);
72 }
73 
74 PyResult Standing::Handle_GetNPCNPCStandings(PyCallArgs &call) {
75  return sStandingMgr.GetFactionStandings();
76 }
77 
80 PyResult Standing::Handle_GetSecurityRating(PyCallArgs &call) {
81  Call_SingleIntegerArg arg;
82  if (!arg.Decode(&call.tuple)) {
83  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
84  return nullptr;
85  }
86 
87  CharacterRef cRef = sItemFactory.GetCharacter( arg.arg );
88  if (cRef.get() == nullptr) {
89  _log(STANDING__WARNING, "Character %u not found.", arg.arg);
90  return nullptr;
91  }
92 
93  return new PyFloat( cRef->GetSecurityRating() );
94 }
95 
96 PyResult Standing::Handle_GetMyKillRights(PyCallArgs &call) {
97  // self.killRightsCache, self.killedRightsCache = sm.RemoteSvc('standing2').GetMyKillRights()
98  // each cache holds k,v where key is toID or fromID
99  _log(STANDING__MESSAGE, "Standing::Handle_GetMyKillRights()");
100  PyTuple* KillRights = new PyTuple(2);
101  PyDict* killRightsCache = new PyDict();
102  PyDict* killedRightsCache = new PyDict();
103  KillRights->items[0] = killRightsCache;
104  KillRights->items[1] = killedRightsCache;
105 
106  if (is_log_enabled(STANDING__RSPDUMP)) {
107  _log(STANDING__RSPDUMP, "Standing::Handle_GetMyKillRights() RSP:" );
108  KillRights->Dump(STANDING__RSPDUMP, " ");
109  }
110 
111  return KillRights;
112 }
113 
114 PyResult Standing::Handle_GetStandingTransactions(PyCallArgs &call) {
115  // data = sm.RemoteSvc('standing2').GetStandingTransactions(fromID, toID, direction, eventID, eventType, eventDateTime)
116  _log(STANDING__MESSAGE, "Standing::Handle_GetStandingTransactions()");
117  call.Dump(STANDING__DUMP);
118 
119  Call_GetStandingTransactions args;
120  if (!args.Decode(&call.tuple)) {
121  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
122  return nullptr;
123  }
124 
125  return m_db.GetStandingTransactions(args);
126 }
127 
128 PyResult Standing::Handle_GetStandingCompositions(PyCallArgs &call) {
137  _log(STANDING__MESSAGE, "Standing::Handle_GetStandingCompositions()");
138  call.Dump(STANDING__DUMP);
139 
140  Call_GetStandingComposition args;
141  if (!args.Decode(&call.tuple)) {
142  codelog(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
143  return nullptr;
144  }
145 
146  return m_db.GetStandingCompositions(args.toID, args.fromID);
147 }
Dispatcher *const m_dispatch
float GetSecurityRating() const
Definition: Character.h:289
#define _log(type, fmt,...)
Definition: logsys.h:124
Python's dictionary.
Definition: PyRep.h:719
Python floating point number.
Definition: PyRep.h:292
Dispatcher *const m_dispatch
Definition: Standing.h:43
StandingDB m_db
Definition: Standing.h:46
#define sStandingMgr
Definition: StandingMgr.h:52
Python tuple.
Definition: PyRep.h:567
const char * GetName() const
Definition: PyService.h:54
void Dump(FILE *into, const char *pfx) const
Dumps object to file.
Definition: PyRep.cpp:84
* args
#define is_log_enabled(type)
Definition: logsys.h:78
#define codelog(type, fmt,...)
Definition: logsys.h:128
PyRep * GetStandingTransactions(Call_GetStandingTransactions &args)
Definition: StandingDB.cpp:112
X * get() const
Definition: RefPtr.h:213
Client *const client
Definition: PyCallable.h:49
#define PyCallable_REG_CALL(c, m)
Definition: PyServiceCD.h:78
PyRep * GetCorpStandings(Client *pClient)
Definition: StandingDB.cpp:79
PyCallable_Make_InnerDispatcher(Standing) Standing
Definition: Standing.cpp:44
PyRep * GetCharStandings(Client *pClient)
Definition: StandingDB.cpp:71
virtual ~Standing()
Definition: Standing.cpp:62
PyRep * GetStandingCompositions(uint32 fromID, uint32 toID)
Definition: StandingDB.cpp:184
void Dump(LogType type) const
Definition: PyCallable.cpp:81
#define sItemFactory
Definition: ItemFactory.h:165
storage_type items
Definition: PyRep.h:628
PyTuple * tuple
Definition: PyCallable.h:50