EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
FleetManager.cpp
Go to the documentation of this file.
1 
12 //work in progress
13 
14 #include "eve-server.h"
15 
16 #include "PyServiceCD.h"
17 #include "fleet/FleetManager.h"
18 
20 
22 : PyService(mgr, "fleetMgr"),
23  m_dispatch(new Dispatcher(this))
24 {
25  _SetCallDispatcher(m_dispatch);
26 
27  PyCallable_REG_CALL(FleetManager, GetActiveStatus);
28  PyCallable_REG_CALL(FleetManager, ForceLeaveFleet);
29  PyCallable_REG_CALL(FleetManager, BroadcastToBubble);
30  PyCallable_REG_CALL(FleetManager, BroadcastToSystem);
31 
32  // stubs
33  PyCallable_REG_CALL(FleetManager, AddToWatchlist);
34  PyCallable_REG_CALL(FleetManager, RemoveFromWatchlist);
35  PyCallable_REG_CALL(FleetManager, RegisterForDamageUpdates);
36 }
37 
39 {
40  delete m_dispatch;
41 }
42 
43 /*
44 FLEET__ERROR
45 FLEET__WARNING
46 FLEET__MESSAGE
47 FLEET__DEBUG
48 FLEET__INFO
49 FLEET__TRACE
50 FLEET__DUMP
51 FLEET__BIND_DUMP
52 */
53 PyResult FleetManager::Handle_ForceLeaveFleet(PyCallArgs &call) {
54  sLog.Warning("FleetManager", "Handle_ForceLeaveFleet() size=%u", call.tuple->size() );
55  call.Dump(FLEET__DUMP);
56 
57  sFltSvc.LeaveFleet(call.client);
58 
59  // returns nothing
60  return nullptr;
61 }
62 
63 PyResult FleetManager::Handle_GetActiveStatus(PyCallArgs &call) {
64  // self.activeStatus = sm.RemoteSvc('fleetMgr').GetActiveStatus()
65  // have seen this return PyNone in logs. dont know why...bad fleetID maybe?
66  sLog.Warning("FleetManager", "Handle_GetActiveStatus() size=%u", call.tuple->size() );
67  call.Dump(FLEET__DUMP);
68 
69  /*
70  [PyTuple 1 items] <- from server
71  [PySubStream 67 bytes]
72  [PyObjectData Name: util.KeyVal]
73  [PyDict 3 kvp]
74  [PyString "fleet"]
75  [PyInt 254] <- spaces left (out of 256)
76  [PyString "wings"]
77  [PyDict 1 kvp]
78  [PyIntegerVar 2013710700300] <- wing id
79  [PyInt 0] <- isActive (integer bool)
80  [PyString "squads"]
81  [PyDict 1 kvp]
82  [PyIntegerVar 3014610700300] <- squad id
83  [PyInt 1] <- isActive (integer bool)
84 
85  */
86 
87  int32 fleetID = call.client->GetChar()->fleetID();
88  if (fleetID == 0)
89  return PyStatic.NewNone();
90 
91  ActiveStatusRSP rsp;
92  rsp.fleetCount = (255 - sFltSvc.GetFleetMemberCount(fleetID)); // this is slots left from max (256)
93 
94  PyDict* wings = new PyDict();
95  PyDict* squads = new PyDict();
96 
97  std::vector< uint32 > wingIDs, squadIDs;
98  sFltSvc.GetWingIDs(fleetID, wingIDs);
99  for (auto wingID : wingIDs) {
100  WingData wData = WingData();
101  sFltSvc.GetWingData(wingID, wData);
102  wings->SetItem(new PyInt(wingID), new PyInt((sFltSvc.IsWingActive(wingID) ? 1 : 0)));
103 
104  sFltSvc.GetSquadIDs(wingID, squadIDs);
105  for (auto squadID : squadIDs) {
106  SquadData sData = SquadData();
107  sFltSvc.GetSquadData(squadID, sData);
108  squads->SetItem(new PyInt(squadID), new PyInt(sData.members.size() > 0 ? 1 : 0));
109  }
110  }
111 
112  PySafeDecRef(rsp.wings);
113  rsp.wings = wings;
114 
115  PySafeDecRef(rsp.squads);
116  rsp.squads = squads;
117 
118  if (is_log_enabled(FLEET__DEBUG))
119  rsp.Dump(FLEET__DEBUG);
120 
121  return rsp.Encode();
122 }
123 
124 PyResult FleetManager::Handle_BroadcastToBubble(PyCallArgs &call) {
125  // sm.RemoteSvc('fleetMgr').BroadcastToBubble(name, self.broadcastScope, itemID)
126  /*
127  * 00:06:49 W FleetManager: Handle_BroadcastToSysBubble() size=3
128  * 00:06:49 [FleetDump] Call Arguments:
129  * 00:06:49 [FleetDump] Tuple: 3 elements
130  * 00:06:49 [FleetDump] [ 0] String: 'HealCapacitor'
131  * 00:06:49 [FleetDump] [ 1] Integer field: 3 <-- groupID
132  * 00:06:49 [FleetDump] [ 2] Integer field: 140006694 <-- charID
133  */
134  sLog.Warning("FleetManager", "Handle_BroadcastToSysBubble() size=%u", call.tuple->size() );
135  call.Dump(FLEET__DUMP);
136 
137  SendBroadCastCall args;
138  if (!args.Decode(&call.tuple)) {
139  codelog(SERVICE__ERROR, "%s: Failed to decode args.", call.client->GetChar()->name());
140  return nullptr;
141  }
142 
143  sFltSvc.FleetBroadcast(call.client, args.itemID, Fleet::BCast::Scope::Bubble, args.group, args.msg);
144 
145  return nullptr;
146 }
147 
148 PyResult FleetManager::Handle_BroadcastToSystem(PyCallArgs &call) {
149  // sm.RemoteSvc('fleetMgr').BroadcastToSystem(name, self.broadcastScope, itemID)
150  sLog.Warning("FleetManager", "Handle_BroadcastToSystem() size=%u", call.tuple->size() );
151  call.Dump(FLEET__DUMP);
152 
153  SendBroadCastCall args;
154  if (!args.Decode(&call.tuple)) {
155  codelog(SERVICE__ERROR, "%s: Failed to decode args.", call.client->GetChar()->name());
156  return nullptr;
157  }
158 
159  sFltSvc.FleetBroadcast(call.client, args.itemID, Fleet::BCast::Scope::System, args.group, args.msg);
160 
161  return nullptr;
162 }
163 
164 PyResult FleetManager::Handle_AddToWatchlist(PyCallArgs &call) {
168  sLog.Warning("FleetManager", "Handle_AddToWatchlist() size=%u", call.tuple->size() );
169  call.Dump(FLEET__DUMP);
170 
171  return nullptr;
172 }
173 
174 PyResult FleetManager::Handle_RemoveFromWatchlist(PyCallArgs &call) {
178  sLog.Warning("FleetManager", "Handle_RemoveFromWatchlist() size=%u", call.tuple->size() );
179  call.Dump(FLEET__DUMP);
180 
181  return nullptr;
182 }
183 
184 PyResult FleetManager::Handle_RegisterForDamageUpdates(PyCallArgs &call) {
194  sLog.Warning("FleetManager", "Handle_RegisterForDamageUpdates() size=%u", call.tuple->size() );
195  call.Dump(FLEET__DUMP);
196 
197  // returns nothing
198  return nullptr;
199 }
Dispatcher *const m_dispatch
Python's dictionary.
Definition: PyRep.h:719
size_t size() const
Definition: PyRep.h:591
PyCallable_Make_InnerDispatcher(FleetManager) FleetManager
const char * name()
CharacterRef GetChar() const
Definition: Client.h:164
void Dump(FILE *into, const char *pfx) const
Dumps object to file.
Definition: PyRep.cpp:84
signed __int32 int32
Definition: eve-compat.h:49
* args
#define is_log_enabled(type)
Definition: logsys.h:78
#define sFltSvc
Definition: FleetService.h:147
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
#define codelog(type, fmt,...)
Definition: logsys.h:128
Python integer.
Definition: PyRep.h:231
#define PyStatic
Definition: PyRep.h:1209
Client *const client
Definition: PyCallable.h:49
#define PyCallable_REG_CALL(c, m)
Definition: PyServiceCD.h:78
void Dump(LogType type) const
Definition: PyCallable.cpp:81
std::map< uint32, Client * > members
Definition: FleetData.h:132
#define PySafeDecRef(op)
Definition: PyRep.h:61
int32 fleetID() const
Definition: Character.h:318
Dispatcher *const m_dispatch
Definition: FleetManager.h:26
void SetItem(PyRep *key, PyRep *value)
SetItem adds or sets a database entry.
Definition: PyRep.cpp:713
PyTuple * tuple
Definition: PyCallable.h:50