EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
AgentMgrService.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 - 2011 The EVEmu Team
7  For the latest information visit http://evemu.org
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  Rewrite: Allan
25 */
26 
27 /*
28  * AgentMgr bound(agentID):
29  * -> DoAction(actionID or None)
30  * -> WarpToLocation(locationType, locationNumber, warpRange, is_gang)
31  *
32  * Also sent an OnRemoteMessage(AgtMissionOfferWarning)
33  *
34  * and various OnAgentMissionChange()
35  *
36 */
37 
38 /*
39  * # Agent Logging:
40  * AGENT__ERROR
41  * AGENT__WARNING
42  * AGENT__MESSAGE
43  * AGENT__DEBUG
44  * AGENT__INFO
45  * AGENT__TRACE
46  * AGENT__DUMP
47  * AGENT__RSP_DUMP
48  */
49 
50 #include "eve-server.h"
51 
52 #include "EntityList.h"
53 #include "PyBoundObject.h"
54 #include "PyServiceCD.h"
55 #include "StaticDataMgr.h"
56 #include "cache/ObjCacheService.h"
57 #include "agents/Agent.h"
58 #include "agents/AgentBound.h"
59 #include "agents/AgentMgrService.h"
61 
63 
65 : PyService(mgr, "agentMgr"),
66  m_dispatch(new Dispatcher(this))
67 {
68  _SetCallDispatcher(m_dispatch);
69 
71  PyCallable_REG_CALL(AgentMgrService, GetCareerAgents);
72  PyCallable_REG_CALL(AgentMgrService, GetMyJournalDetails);
73  PyCallable_REG_CALL(AgentMgrService, GetSolarSystemOfAgent);
74  PyCallable_REG_CALL(AgentMgrService, GetMyEpicJournalDetails);
75 }
76 
78  delete m_dispatch;
79 }
80 
81 // need a way to check created objects for client/agent combinations to avoid duplicates.
82 // also need a way to check/delete released objects/agents
84  if (!bind_args->IsInt()) {
85  _log(SERVICE__ERROR, "%s: Non-integer argument '%s'", pClient->GetName(), bind_args->TypeString());
86  return nullptr;
87  }
88 
89  uint32 agentID(bind_args->AsInt()->value());
90  Agent* pAgent(sEntityList.GetAgent(agentID));
91  if (pAgent == nullptr) {
92  _log(AGENT__ERROR, "%s: Unable to obtain agent %u", pClient->GetName(), agentID);
93  return nullptr;
94  }
95 
96  return new AgentBound(m_manager, pAgent);
97 }
98 
99 PyResult AgentMgrService::Handle_GetAgents(PyCallArgs &call) {
100  // this is cached on client side...
101  return sDataMgr.GetAgents();
102 }
103 
104 PyResult AgentMgrService::Handle_GetSolarSystemOfAgent(PyCallArgs &call)
105 {
106  Call_SingleIntegerArg args;
107  if (!args.Decode(&call.tuple)) {
108  _log(SERVICE__ERROR, "%s: Failed to decode arguments.", GetName());
109  return nullptr;
110  }
111 
112  return sDataMgr.GetAgentSystemID(args.arg);
113 }
114 
115 PyResult AgentMgrService::Handle_GetMyJournalDetails(PyCallArgs &call) {
116 // note: this will show mission data in journal AND "offered" msg in agent data bloc on agent tab in station
117 
118  _log(AGENT__INFO, "AgentMgrService::Handle_GetMyJournalDetails() - size= %u", call.tuple->size() );
119  call.Dump(AGENT__DUMP);
120 
137  PyTuple *tuple = new PyTuple(2);
138  //missions:
139  PyList* missions = new PyList();
140  std::vector<MissionOffer> data;
141  sMissionDataMgr.LoadMissionOffers(call.client->GetCharacterID(), data);
142  for (auto cur : data) {
143  PyTuple* mData = new PyTuple(9);
144  mData->SetItem(0, new PyInt(cur.stateID)); //missionState .. these may be wrong also.
145  mData->SetItem(1, new PyInt(cur.important?1:0)); //importantMission -- integer boolean
146  mData->SetItem(2, new PyString(sMissionDataMgr.GetTypeLabel(cur.typeID))); //missionTypeLabel
147  mData->SetItem(3, new PyString(cur.name)); //missionName
148  mData->SetItem(4, new PyInt(cur.agentID)); //agentID
149  mData->SetItem(5, new PyLong(cur.expiryTime)); //expirationTime
150  mData->SetItem(6, cur.bookmarks->Clone()); //bookmarks -- if populated, this is PyList of PyDicts as defined below...
151  mData->SetItem(7, new PyBool(cur.remoteOfferable)); //remoteOfferable
152  mData->SetItem(8, new PyBool(cur.remoteCompletable)); //remoteCompletable
153  missions->AddItem(mData);
154  }
155  tuple->SetItem(0, missions);
156 
157  //research:
158  PyList* research = new PyList();
159  tuple->SetItem(1, research);
160 
161  if (is_log_enabled(AGENT__RSP_DUMP))
162  tuple->Dump(AGENT__RSP_DUMP, " ");
163  return tuple;
164  /*
165  [PySubStream 59 bytes]
166  [PyTuple 2 items]
167  [PyList 1 items]
168  [PyTuple 9 items]
169  [PyInt 1]
170  [PyInt 0]
171  [PyString "Encounter"]
172  [PyString "Seek and Destroy"]
173  [PyInt 3010819]
174  [PyIntegerVar 129495559223373466]
175  [PyList 0 items]
176  [PyBool False]
177  [PyBool False]
178  [PyList 0 items]
179 
180  [PyTuple 1 items]
181  [PySubStream 53 bytes]
182  [PyTuple 2 items]
183  [PyList 1 items]
184  [PyTuple 9 items]
185  [PyInt 1]
186  [PyInt 0]
187  [PyString "Courier"]
188  [PyString "Good Harvest"]
189  [PyInt 3010819]
190  [PyIntegerVar 129495553039999957]
191  [PyList 0 items]
192  [PyBool False]
193  [PyBool False]
194  [PyList 0 items]
195 
196 
197  [PySubStream 513 bytes]
198  [PyTuple 2 items]
199  [PyList 1 items]
200  [PyTuple 9 items]
201  [PyInt 2]
202  [PyInt 0]
203  [PyString "Courier"]
204  [PyString "Good Harvest"]
205  [PyInt 3010819]
206  [PyIntegerVar 129495553802043094]
207  [PyList 2 items]
208  [PyObjectData Name: util.KeyVal]
209  [PyDict 15 kvp]
210  [PyString "itemID"]
211  [PyInt 60014683]
212  [PyString "typeID"]
213  [PyInt 1529]
214  [PyString "agentID"]
215  [PyInt 3010819]
216  [PyString "hint"]
217  [PyString "Objective (Pick Up) & Agent Base - Annaro VIII - Moon 4 - State War Academy School"]
218  [PyString "locationType"]
219  [PyString "objective.source"]
220  [PyString "memo"]
221  [PyString ""]
222  [PyString "created"]
223  [PyIntegerVar 129489505802043094]
224  [PyString "locationNumber"]
225  [PyInt 0]
226  [PyString "flag"]
227  [PyNone]
228  [PyString "locationID"]
229  [PyInt 30002776]
230  [PyString "ownerID"]
231  [PyInt 1661059544]
232  [PyString "y"]
233  [PyInt 0]
234  [PyString "x"]
235  [PyInt 0]
236  [PyString "solarsystemID"]
237  [PyInt 30002776]
238  [PyString "z"]
239  [PyInt 0]
240  [PyObjectData Name: util.KeyVal]
241  [PyDict 15 kvp]
242  [PyString "itemID"]
243  [PyInt 60000016]
244  [PyString "typeID"]
245  [PyInt 1531]
246  [PyString "agentID"]
247  [PyInt 3010819]
248  [PyString "hint"]
249  [PyString "Objective (Drop Off) - Tasabeshi VIII - Moon 13 - CBD Corporation Storage"]
250  [PyString "locationType"]
251  [PyString "objective.destination"]
252  [PyString "memo"]
253  [PyString ""]
254  [PyString "created"]
255  [PyIntegerVar 129489505802043094]
256  [PyString "locationNumber"]
257  [PyInt 0]
258  [PyString "flag"]
259  [PyNone]
260  [PyString "locationID"]
261  [PyInt 30002778]
262  [PyString "solarsystemID"]
263  [PyInt 30002778]
264  [PyString "ownerID"]
265  [PyInt 1661059544]
266  [PyString "y"]
267  [PyInt 0]
268  [PyString "x"]
269  [PyInt 0]
270  [PyString "z"]
271  [PyInt 0]
272  [PyBool False]
273  [PyBool False]
274  [PyList 0 items]
275  */
276 
277 }
278 
279 
281 PyResult AgentMgrService::Handle_GetMyEpicJournalDetails( PyCallArgs& call )
282 {
283  //no args
284  _log(AGENT__INFO, "AgentMgrBound::Handle_GetMyEpicJournalDetails() - size= %u", call.tuple->size() );
285 
286  return new PyList();
287 }
288 
289 PyResult AgentMgrService::Handle_GetCareerAgents(PyCallArgs &call)
290 {
291  _log(AGENT__INFO, "AgentMgrBound::Handle_GetCareerAgents() - size= %u", call.tuple->size() );
292  call.Dump(AGENT__DUMP);
293 
294  return PyStatic.NewZero();
295 }
296 
297 
299 
301 : PyService(mgr, "epicArcStatus"),
302  m_dispatch(new Dispatcher(this))
303 {
304  _SetCallDispatcher(m_dispatch);
305 
306  PyCallable_REG_CALL(EpicArcService, AgentHasEpicMissionsForCharacter);
307 }
308 
310  delete m_dispatch;
311 }
312 
313 PyResult EpicArcService::Handle_AgentHasEpicMissionsForCharacter(PyCallArgs &call) {
317  _log(AGENT__INFO, "EpicArcService::Handle_AgentHasEpicMissionsForCharacter() - size= %u", call.tuple->size() );
318  call.Dump(AGENT__DUMP);
319 
320  // return boolean
321  return PyStatic.NewFalse();
322 
323 }
Base Python wire object.
Definition: PyRep.h:66
Dispatcher *const m_dispatch
#define _log(type, fmt,...)
Definition: logsys.h:124
Dispatcher *const m_dispatch
Python string.
Definition: PyRep.h:430
int32 value() const
Definition: PyRep.h:247
size_t size() const
Definition: PyRep.h:591
int32 GetCharacterID() const
Definition: Client.h:113
#define sEntityList
Definition: EntityList.h:208
PyCallable_Make_InnerDispatcher(AgentMgrService) AgentMgrService
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
void AddItem(PyRep *i)
Definition: PyRep.h:701
virtual PyBoundObject * CreateBoundObject(Client *pClient, const PyRep *bind_args)
* args
Python boolean.
Definition: PyRep.h:323
#define is_log_enabled(type)
Definition: logsys.h:78
Definition: Agent.h:21
void SetItem(size_t index, PyRep *object)
Stores Python object.
Definition: PyRep.h:610
virtual ~AgentMgrService()
Python integer.
Definition: PyRep.h:231
PyServiceMgr *const m_manager
Definition: PyService.h:91
#define PyStatic
Definition: PyRep.h:1209
const char * GetName() const
Definition: Client.h:94
#define sMissionDataMgr
Client *const client
Definition: PyCallable.h:49
#define PyCallable_REG_CALL(c, m)
Definition: PyServiceCD.h:78
Definition: Client.h:66
Dispatcher *const m_dispatch
unsigned __int32 uint32
Definition: eve-compat.h:50
void Dump(LogType type) const
Definition: PyCallable.cpp:81
bool IsInt() const
Definition: PyRep.h:100
virtual ~EpicArcService()
PyInt * AsInt()
Definition: PyRep.h:122
const char * TypeString() const
Definition: PyRep.cpp:76
Python list.
Definition: PyRep.h:639
Python long integer.
Definition: PyRep.h:261
PyTuple * tuple
Definition: PyCallable.h:50
#define sDataMgr