EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
EntityService.cpp
Go to the documentation of this file.
1 
10 #include "eve-server.h"
11 
12 #include "PyBoundObject.h"
13 #include "PyServiceCD.h"
14 
15 #include "EVEServerConfig.h"
16 #include "npc/EntityService.h"
17 #include "system/SystemManager.h"
18 
19 
21 
23 : PyService(mgr, "entity"),
24 m_dispatch(new Dispatcher(this))
25 {
26  _SetCallDispatcher(m_dispatch);
27 
28 }
29 
31  delete m_dispatch;
32 }
33 
34 /* drone states...
35 namespace DroneAI {
36  namespace State {
37  enum {
38  Invalid = -1,
39  // defined in client
40  Idle = 0, // not doing anything....idle.
41  Combat = 1, // fighting - needs targetID
42  Mining = 2, // unsure - needs targetID
43  Approaching = 3, // too close to chase, but to far to engage
44  Departing = 4, // return to ship
45  Departing2 = 5, // leaving. different from Departing
46  Pursuit = 6, // target out of range to attack/follow, but within npc sight range....use mwd/ab if equiped
47  Fleeing = 7, // running away
48  Operating = 9, // whats diff from engaged here?
49  Engaged = 10, // non-combat? - needs targetID
50  // internal only
51  Unknown = 8, // as stated
52  Guarding = 11,
53  Assisting = 12,
54  Incapacicated = 13 //
55  };
56  }
57 }
58 */
59 
60 /*
61 DRONE__ERROR
62 DRONE__WARNING
63 DRONE__MESSAGE
64 DRONE__INFO
65 DRONE__TRACE
66 DRONE__DUMP
67 DRONE__AI_TRACE
68 */
69 
72  _log(DRONE__DUMP, "EntityService bind request");
73  bind_args->Dump(DRONE__DUMP, " ");
74  if (!bind_args->IsInt()) {
75  codelog(SERVICE__ERROR, "%s: Non-integer bind argument '%s'", pClient->GetName(), bind_args->TypeString());
76  return nullptr;
77  }
78 
79  uint32 systemID = bind_args->AsInt()->value();
80  if (!sDataMgr.IsSolarSystem(systemID)) {
81  codelog(SERVICE__ERROR, "%s: Expected systemID, but got %u.", pClient->GetName(), systemID);
82  return nullptr;
83  }
84 
85  return new EntityBound(m_manager, pClient->SystemMgr(), systemID);
86 }
87 
88 EntityBound::EntityBound(PyServiceMgr *mgr, SystemManager* systemMgr, uint32 systemID)
89 : PyBoundObject(mgr),
90 m_sysMgr(systemMgr),
91 m_systemID(systemID),
92 m_dispatch(new Dispatcher(this))
93 {
95 
96  m_strBoundObjectName = "EntityBound";
97 
98  PyCallable_REG_CALL(EntityBound, CmdEngage);
99  PyCallable_REG_CALL(EntityBound, CmdRelinquishControl);
100  PyCallable_REG_CALL(EntityBound, CmdDelegateControl);
101  PyCallable_REG_CALL(EntityBound, CmdAssist);
102  PyCallable_REG_CALL(EntityBound, CmdGuard);
104  PyCallable_REG_CALL(EntityBound, CmdMineRepeatedly);
105  PyCallable_REG_CALL(EntityBound, CmdUnanchor);
106  PyCallable_REG_CALL(EntityBound, CmdReturnHome);
107  PyCallable_REG_CALL(EntityBound, CmdReturnBay);
108  PyCallable_REG_CALL(EntityBound, CmdAbandonDrone);
109  PyCallable_REG_CALL(EntityBound, CmdReconnectToDrones);
110 }
111 
112 PyResult EntityBound::Handle_CmdEngage(PyCallArgs &call) {
113  // ret = entity.CmdEngage(droneIDs, targetID)
114  /*
115  [PySubStream 104 bytes]
116  [PyTuple 4 items]
117  [PyInt 1]
118  [PyString "MachoBindObject"]
119  [PyTuple 2 items]
120  [PyInt 30000302]
121  [PyTuple 3 items]
122  [PyString "CmdEngage"]
123  [PyTuple 2 items]
124  [PyList 5 items]
125  [PyIntegerVar 1005909162494]
126  [PyIntegerVar 1005902743336]
127  [PyIntegerVar 1005909162497]
128  [PyIntegerVar 1005909162499]
129  [PyIntegerVar 1005909162492]
130  [PyIntegerVar 9000000000001190095]
131  [PyDict 0 kvp]
132  */
133  /*
134  [PySubStream 258 bytes]
135  [PyTuple 2 items]
136  [PySubStruct]
137  [PySubStream 31 bytes]
138  [PyTuple 2 items]
139  [PyString "N=790408:2886"]
140  [PyIntegerVar 129756560501538126]
141  [PyDict 5 kvp]
142  [PyIntegerVar 1005909162494]
143  [PyTuple 2 items]
144  [PyString "EntityTargetTooDistant"]
145  [PyDict 2 kvp]
146  [PyString "targetTypeName"]
147  [PyTuple 2 items]
148  [PyInt 7]
149  [PyInt 561]
150  [PyString "distance"]
151  [PyFloat 45000]
152  */
153  /*
154  [PySubStream 42 bytes]
155  [PyTuple 2 items]
156  [PySubStruct]
157  [PySubStream 31 bytes]
158  [PyTuple 2 items]
159  [PyString "N=790408:2886"]
160  [PyIntegerVar 129756560847182701]
161  [PyDict 0 kvp]
162  */
163  /*
164  if (tSE->SysBubble()->HasTower()) {
165  TowerSE* ptSE = tSE->SysBubble()->GetTowerSE();
166  if (ptSE->HasForceField())
167  if (tSE->GetPosition().distance(ptSE->GetPosition()) < ptSE->GetSOI()) {
168  std::map<std::string, PyRep *> arg;
169  arg["target"] = new PyInt(args.arg);
170  throw PyException( MakeUserError("DeniedDroneTargetForceField", arg ));
171  }
172  }
173  */
174 
175  _log(DRONE__TRACE, "EntityBound::Handle_CmdEngage()");
176  call.Dump(DRONE__DUMP);
177 
178  call.client->SendNotifyMsg("Drone Control is not implemented yet.");
179  return new PyDict();
180 }
181 
182 PyResult EntityBound::Handle_CmdRelinquishControl(PyCallArgs &call) {
183  // ret = entity.CmdRelinquishControl(IDs)
184  _log(DRONE__TRACE, "EntityBound::Handle_CmdRelinquishControl()");
185  call.Dump(DRONE__DUMP);
186 
187  call.client->SendNotifyMsg("Drone Control is not implemented yet.");
188  return new PyDict();
189 }
190 
191 PyResult EntityBound::Handle_CmdDelegateControl(PyCallArgs &call) {
192  // ret = entity.CmdDelegateControl(droneIDs, controllerID)
193  _log(DRONE__TRACE, "EntityBound::Handle_CmdDelegateControl()");
194  call.Dump(DRONE__DUMP);
195 
196  call.client->SendNotifyMsg("Drone Control is not implemented yet.");
197  return new PyDict();
198 }
199 
200 PyResult EntityBound::Handle_CmdAssist(PyCallArgs &call) {
201  // ret = entity.CmdAssist(assistID, droneIDs)
202  _log(DRONE__TRACE, "EntityBound::Handle_CmdAssist()");
203  call.Dump(DRONE__DUMP);
204 
205  call.client->SendNotifyMsg("Drone Control is not implemented yet.");
206  return new PyDict();
207 }
208 
209 PyResult EntityBound::Handle_CmdGuard(PyCallArgs &call) {
210  // ret = entity.CmdGuard(guardID, droneIDs)
211  _log(DRONE__TRACE, "EntityBound::Handle_CmdGuard()");
212  call.Dump(DRONE__DUMP);
213 
214  call.client->SendNotifyMsg("Drone Control is not implemented yet.");
215  return new PyDict();
216 }
217 
218 PyResult EntityBound::Handle_CmdMine(PyCallArgs &call) {
219  // ret = entity.CmdMine(droneIDs, targetID)
220  /*
221  * 16:19:14 [DroneTrace] EntityBound::Handle_CmdMine()
222  * 16:19:14 [DroneDump] Call Arguments:
223  * 16:19:14 [DroneDump] Tuple: 2 elements
224  * 16:19:14 [DroneDump] [ 0] List: 5 elements
225  * 16:19:14 [DroneDump] [ 0] [ 0] Integer: 140024264
226  * 16:19:14 [DroneDump] [ 0] [ 1] Integer: 140024265
227  * 16:19:14 [DroneDump] [ 0] [ 2] Integer: 140024261
228  * 16:19:14 [DroneDump] [ 0] [ 3] Integer: 140024262
229  * 16:19:14 [DroneDump] [ 0] [ 4] Integer: 140024263
230  * 16:19:14 [DroneDump] [ 1] Integer: 450000587
231  */
232 
233  _log(DRONE__TRACE, "EntityBound::Handle_CmdMine()");
234  call.Dump(DRONE__DUMP);
235 
238  call.client->SendNotifyMsg("Drone Control is not implemented yet.");
239  return new PyDict();
240 }
241 
242 PyResult EntityBound::Handle_CmdMineRepeatedly(PyCallArgs &call) {
243  // ret = entity.CmdMineRepeatedly(droneIDs, targetID)
244  /*)
245  * 16:20:28 [DroneTrace] EntityBound::Handle_CmdMineRepeatedly()
246  * 16:20:28 [DroneDump] Call Arguments:
247  * 16:20:28 [DroneDump] Tuple: 2 elements
248  * 16:20:28 [DroneDump] [ 0] List: 5 elements
249  * 16:20:28 [DroneDump] [ 0] [ 0] Integer: 140024264
250  * 16:20:28 [DroneDump] [ 0] [ 1] Integer: 140024265
251  * 16:20:28 [DroneDump] [ 0] [ 2] Integer: 140024261
252  * 16:20:28 [DroneDump] [ 0] [ 3] Integer: 140024262
253  * 16:20:28 [DroneDump] [ 0] [ 4] Integer: 140024263
254  * 16:20:28 [DroneDump] [ 1] Integer: 450000587
255  */
256  _log(DRONE__TRACE, "EntityBound::Handle_CmdMineRepeatedly()");
257  call.Dump(DRONE__DUMP);
258 
261  call.client->SendNotifyMsg("Drone Control is not implemented yet.");
262  return new PyDict();
263 }
264 
265 PyResult EntityBound::Handle_CmdUnanchor(PyCallArgs &call) {
266  // ret = entity.CmdUnanchor(droneIDs, targetID)
267  _log(DRONE__TRACE, "EntityBound::Handle_CmdUnanchor()");
268  call.Dump(DRONE__DUMP);
269 
270  call.client->SendNotifyMsg("Drone Control is not implemented yet.");
271  return new PyDict();
272 }
273 
274 PyResult EntityBound::Handle_CmdReturnHome(PyCallArgs &call) {
275  // ret = entity.CmdReturnHome(droneIDs)
276  // this is return and orbit command
277  /*
278 02:18:26 [DroneTrace] EntityBound::Handle_CmdReturnHome()
279 02:18:26 [DroneDump] Call Arguments:
280 02:18:26 [DroneDump] Tuple: 1 elements
281 02:18:26 [DroneDump] [ 0] List: 1 elements
282 02:18:26 [DroneDump] [ 0] [ 0] Integer: 140001219
283 */
284  call.Dump(DRONE__DUMP);
285 
286  //Drone* pDrone = m_sysMgr->GetSE()->GetDroneSE();
287  //pDrone->DestinyMgr()->Orbit(pShipSE, 800);
288 
289 
290  call.client->SendNotifyMsg("Drone Control is not implemented yet.");
291  return new PyDict();
292 }
293 
294 PyResult EntityBound::Handle_CmdReturnBay(PyCallArgs &call) {
295  // ret = entity.CmdReturnBay(droneIDs)
296  /*
297  [PySubStream 97 bytes]
298  [PyTuple 4 items]
299  [PyInt 1]
300  [PyString "MachoBindObject"]
301  [PyTuple 2 items]
302  [PyInt 30000302]
303  [PyTuple 3 items]
304  [PyString "CmdReturnBay"]
305  [PyTuple 1 items]
306  [PyList 5 items]
307  [PyIntegerVar 1005909162494]
308  [PyIntegerVar 1005902743336]
309  [PyIntegerVar 1005909162497]
310  [PyIntegerVar 1005909162499]
311  [PyIntegerVar 1005909162492]
312  [PyDict 0 kvp]
313 
314  [PyTuple 1 items]
315  [PySubStream 42 bytes]
316  [PyTuple 2 items]
317  [PySubStruct]
318  [PySubStream 31 bytes]
319  [PyTuple 2 items]
320  [PyString "N=790408:2886"]
321  [PyIntegerVar 129756563162318175]
322  [PyDict 0 kvp]
323  */
324  _log(DRONE__TRACE, "EntityBound::Handle_CmdReturnBay()");
325  call.Dump(DRONE__DUMP);
326 
327  call.client->SendNotifyMsg("Drone Control is not implemented yet.");
328 
329  // returns nodeID and timestamp and dict of error msg
330  /*
331  PyDict* dict = new PyDict();
332  PyTuple* tuple = new PyTuple(2);
333  tuple->SetItem(0, new PyString(GetBindStr())); // node info here
334  tuple->SetItem(1, new PyLong(GetFileTimeNow()));
335  PySubStruct* str = new PySubStruct(new PySubStream(tuple));
336  PyTuple* tuple1 = new PyTuple(2);
337  tuple1->SetItem(0, str);
338  tuple1->SetItem(1, dict);
339  return tuple1;
340  */
341  return new PyDict();
342 }
343 
344 PyResult EntityBound::Handle_CmdAbandonDrone(PyCallArgs &call) {
345  // ret = entity.CmdAbandonDrone(droneIDs)
346  /*
347  * 16:23:23 [DroneTrace] EntityBound::Handle_CmdAbandonDrone()
348  * 16:23:23 [DroneDump] Call Arguments:
349  * 16:23:23 [DroneDump] Tuple: 1 elements
350  * 16:23:23 [DroneDump] [ 0] List: 1 elements
351  * 16:23:23 [DroneDump] [ 0] [ 0] Integer: 140024263
352  */
353  _log(DRONE__TRACE, "EntityBound::Handle_CmdAbandonDrone()");
354  call.Dump(DRONE__DUMP);
355 
356  call.client->SendNotifyMsg("Drone Control is not implemented yet.");
357  return new PyDict();
358 }
359 
360 PyResult EntityBound::Handle_CmdReconnectToDrones(PyCallArgs &call) {
361  // ret = entity.CmdReconnectToDrones(droneCandidates)
362  // for errStr, dicty in ret.iteritems():
363  // this sends a list of drones in local space owned by calling character
364  /*
365  * 09:09:48 [DroneDump] Call Arguments:
366  * 09:09:48 [DroneDump] Tuple: 1 elements
367  * 09:09:48 [DroneDump] [ 0] List: 1 elements
368  * 09:09:48 [DroneDump] [ 0] [ 0] Integer: 140007055
369  */
370  _log(DRONE__TRACE, "EntityBound::Handle_CmdReconnectToDrones()");
371  call.Dump(DRONE__DUMP);
372 
373  call.client->SendNotifyMsg("Drone Control is not implemented yet.");
374  return new PyDict();
375 }
Base Python wire object.
Definition: PyRep.h:66
Dispatcher *const m_dispatch
#define _log(type, fmt,...)
Definition: logsys.h:124
int32 value() const
Definition: PyRep.h:247
Python's dictionary.
Definition: PyRep.h:719
virtual PyBoundObject * CreateBoundObject(Client *pClient, const PyRep *bind_args)
void SendNotifyMsg(const char *fmt,...)
Definition: Client.cpp:2776
void Dump(FILE *into, const char *pfx) const
Dumps object to file.
Definition: PyRep.cpp:84
void _SetCallDispatcher(CallDispatcher *d)
Definition: PyCallable.h:87
#define codelog(type, fmt,...)
Definition: logsys.h:128
SystemManager * SystemMgr() const
Definition: Client.h:92
PyCallable_Make_InnerDispatcher(EntityService) EntityService
PyServiceMgr *const m_manager
Definition: PyService.h:91
const char * GetName() const
Definition: Client.h:94
Client *const client
Definition: PyCallable.h:49
#define PyCallable_REG_CALL(c, m)
Definition: PyServiceCD.h:78
Definition: Client.h:66
unsigned __int32 uint32
Definition: eve-compat.h:50
Dispatcher *const m_dispatch
Definition: EntityService.h:27
void Dump(LogType type) const
Definition: PyCallable.cpp:81
bool IsInt() const
Definition: PyRep.h:100
PyInt * AsInt()
Definition: PyRep.h:122
const char * TypeString() const
Definition: PyRep.cpp:76
#define sDataMgr
virtual ~EntityService()