EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
FleetBound.cpp
Go to the documentation of this file.
1 
14 //work in progress
15 
16 #include "eve-server.h"
17 
18 #include "PyServiceCD.h"
19 #include "PyBoundObject.h"
20 #include "fleet/FleetBound.h"
21 
22 /*
23 FLEET__ERROR
24 FLEET__WARNING
25 FLEET__MESSAGE
26 FLEET__DEBUG
27 FLEET__INFO
28 FLEET__TRACE
29 FLEET__DUMP
30 FLEET__BIND_DUMP
31 */
32 
34 
36 : PyBoundObject(mgr),
37 m_dispatch(new Dispatcher(this))
38 {
39  _SetCallDispatcher(m_dispatch);
40 
41  m_strBoundObjectName = "FleetBound";
42 
43  m_fleetID = fleetID;
44 
46  PyCallable_REG_CALL(FleetBound, GetInitState);
47  PyCallable_REG_CALL(FleetBound, GetFleetID);
49  PyCallable_REG_CALL(FleetBound, AcceptInvite);
50  PyCallable_REG_CALL(FleetBound, RejectInvite);
51  PyCallable_REG_CALL(FleetBound, ChangeWingName);
52  PyCallable_REG_CALL(FleetBound, ChangeSquadName);
53  PyCallable_REG_CALL(FleetBound, SetOptions);
55  PyCallable_REG_CALL(FleetBound, MakeLeader);
56  PyCallable_REG_CALL(FleetBound, SetBooster);
57  PyCallable_REG_CALL(FleetBound, MoveMember);
59  PyCallable_REG_CALL(FleetBound, CreateWing);
60  PyCallable_REG_CALL(FleetBound, CreateSquad);
61  PyCallable_REG_CALL(FleetBound, DeleteWing);
62  PyCallable_REG_CALL(FleetBound, DeleteSquad);
63  PyCallable_REG_CALL(FleetBound, LeaveFleet);
64  PyCallable_REG_CALL(FleetBound, GetFleetComposition);
65  PyCallable_REG_CALL(FleetBound, GetJoinRequests);
66  PyCallable_REG_CALL(FleetBound, RejectJoinRequest);
67  PyCallable_REG_CALL(FleetBound, SendBroadcast);
68  PyCallable_REG_CALL(FleetBound, SetMotdEx);
70  PyCallable_REG_CALL(FleetBound, UpdateMemberInfo);
71 
72  // stubs
73  PyCallable_REG_CALL(FleetBound, Reconnect);
74  PyCallable_REG_CALL(FleetBound, AddToVoiceChat);
75  PyCallable_REG_CALL(FleetBound, SetVoiceMuteStatus);
76  PyCallable_REG_CALL(FleetBound, ExcludeFromVoiceMute);
77 }
78 
80 {
81  delete m_dispatch;
82 }
83 
84 PyResult FleetBound::Handle_GetFleetID(PyCallArgs &call) {
85  return new PyInt(m_fleetID);
86 }
87 
88 PyResult FleetBound::Handle_Init(PyCallArgs &call) {
89  //self.fleet.Init(self.GetMyShipTypeID())
90  // this only sends ship typeID when inspace.
91  sLog.Warning("FleetBound", "Handle_Init() size=%u", call.tuple->size() );
92  call.Dump(FLEET__DUMP);
93 
94 /*
95  FleetInitCall args;
96  if (!args.Decode(&call.tuple)) {
97  codelog(SERVICE__ERROR, "Failed to decode bind args from '%s'", call.client->GetName());
98  // this should throw an error here...
99  return nullptr;
100  }
101  args.myShipTypeID
102  args.unknownDict
103  */
104 
105  Client* pClient = call.client;
106  if (pClient == nullptr)
107  return new PyLong(GetFileTimeNow());
108 
109  Character* pChar = pClient->GetChar().get();
110  if (pChar == nullptr)
111  return new PyLong(GetFileTimeNow());
112 
113  // member is already added here, so cannot use sFltSvc.AddMember()
114  JoinFleetRSP join;
115  join.charID = pClient->GetCharacterID();
116  join.clientID = pClient->GetClientID();
117  join.job = pChar->fleetJob();
118  join.role = pChar->fleetRole();
119  join.shipTypeID = pClient->GetShip()->typeID();
120  join.skillFleetCommand = pChar->GetSkillLevel(EvESkill::FleetCommand);
121  join.skillLeadership = pChar->GetSkillLevel(EvESkill::Leadership);
122  join.skillWingCommand = pChar->GetSkillLevel(EvESkill::WingCommand);
123  join.squadID = pChar->squadID();
124  join.roleBooster = pChar->fleetBooster();
125  join.solarSystemID = pClient->GetSystemID();
126  join.wingID = pChar->wingID();
127  join.timestamp = pChar->fleetJoinTime();
128  PyTuple* res = new PyTuple(1);
129  res->SetItem(0, join.Encode());
130  if (is_log_enabled(FLEET__DEBUG)) {
131  _log(FLEET__UPDATE_DUMP, "OnFleetJoin");
132  res->Dump(FLEET__UPDATE_DUMP, " ");
133  }
134  pClient->SendNotification("OnFleetJoin", "clientid", &res, true);
135 
136  PyDict* dict = new PyDict();
137  dict->SetItemString("targetTags", new PyDict());
138  PyTuple* obj = new PyTuple(1);
139  obj->SetItem(0, new PyObject("util.KeyVal", dict));
140  _log(FLEET__UPDATE_DUMP, "OnFleetStateChange");
141  obj->Dump(FLEET__UPDATE_DUMP, " ");
142  pClient->SendNotification("OnFleetStateChange", "clientid", obj, true);
143 
144  PyTuple* count = new PyTuple(1);
145  count->SetItem(0, new PyInt(254));
146  _log(FLEET__UPDATE_DUMP, "OnFleetActive");
147  count->Dump(FLEET__UPDATE_DUMP, " ");
148  pClient->SendNotification("OnFleetActive", "clientid", count, true);
149 
150  //response should be OID
151  /*
152  [PyDict 1 kvp]
153  [PyString "OID+"]
154  [PyDict 1 kvp]
155  [PyString "N=790423:223898"] "N=%u:%u", &nodeID, &bindID
156  [PyIntegerVar 129756560170416597]
157  */
158  return new PyLong(GetFileTimeNow());
159 }
160 
161 PyResult FleetBound::Handle_GetInitState(PyCallArgs &call) {
162  FleetData fData = FleetData();
163  sFltSvc.GetFleetData(m_fleetID, fData);
164 
165  GetInitStateRSP rsp;
166  rsp.fleetID = m_fleetID;
167  rsp.isFreeMove = fData.isFreeMove;
168  rsp.isLootLogging = fData.isLootLogging;
169  rsp.isRegistered = fData.isRegistered;
170  rsp.isVoiceEnabled = fData.isVoiceEnabled;
171  rsp.motd = fData.motd;
172  rsp.name = fData.name;
173 
174  PyDict* muteDict = new PyDict();
175  for (auto cur : fData.isExcludedFromMuting)
176  muteDict->SetItem(new PyInt(cur.first), new PyInt(cur.second));
177  PySafeDecRef(rsp.isExcludedFromMuting);
178  rsp.isExcludedFromMuting = muteDict;
179 
180  PyDict* lMuteDict = new PyDict();
181  for (auto cur : fData.isMutedByLeader)
182  lMuteDict->SetItem(new PyInt(cur.first), new PyInt(cur.second));
183  PySafeDecRef(rsp.isMutedByLeader);
184  rsp.isMutedByLeader = lMuteDict;
185 
186  std::vector< uint32 > wingIDs, squadIDs;
187  wingIDs.clear();
188  sFltSvc.GetWingIDs(m_fleetID, wingIDs);
189  PyDict* dict1 = new PyDict();
190  for (auto wingID : wingIDs) {
191  WingData wData = WingData();
192  sFltSvc.GetWingData(wingID, wData);
193  WingRSP wing;
194  wing.name = wData.name;
195  wing.wingID = wingID;
196 
197  squadIDs.clear();
198  sFltSvc.GetSquadIDs(wingID, squadIDs);
199 
200  PyDict* dict = new PyDict();
201  for (auto squadID : squadIDs) {
202  SquadData sData = SquadData();
203  sFltSvc.GetSquadData(squadID, sData);
204  SquadRSP squad;
205  squad.name = sData.name;
206  squad.squadID = squadID;
207  dict->SetItem(new PyInt(squadID), squad.Encode());
208  }
209  PySafeDecRef(wing.squads);
210  wing.squads = dict;
211  dict1->SetItem(new PyInt(wingID), wing.Encode());
212  }
213  PySafeDecRef(rsp.wings);
214  rsp.wings = dict1;
215 
216  std::vector<Client*> members;
217  sFltSvc.GetMemeberVec(m_fleetID, members);
218  PyDict* dict2 = new PyDict();
219  for (auto cur : members) {
220  MemberRSP member;
221  member.charID = cur->GetCharacterID();
222  member.clientID = cur->GetClientID();
223  member.job = cur->GetChar()->fleetJob();
224  member.role = cur->GetChar()->fleetRole();
225  member.shipTypeID = cur->GetShip()->typeID();
226  member.skillFleetCommand = cur->GetChar()->GetSkillLevel(EvESkill::FleetCommand);
227  member.skillLeadership = cur->GetChar()->GetSkillLevel(EvESkill::Leadership);
228  member.skillWingCommand = cur->GetChar()->GetSkillLevel(EvESkill::WingCommand);
229  member.squadID = cur->GetChar()->squadID();
230  member.roleBooster = cur->GetChar()->fleetBooster();
231  member.solarSystemID = cur->GetSystemID();
232  member.wingID = cur->GetChar()->wingID();
233  member.timestamp = cur->GetChar()->fleetJoinTime();
234  dict2->SetItem(new PyInt(member.charID), member.Encode());
235  }
236 
237  rsp.members = dict2;
238  if (is_log_enabled(FLEET__DEBUG))
239  rsp.Dump(FLEET__DEBUG);
240 
241  //response should be sequenced
242  return rsp.Encode();
243 }
244 
245 PyResult FleetBound::Handle_Invite(PyCallArgs &call) {
246  sLog.Warning("FleetBound", "Handle_Invite() size=%u", call.tuple->size() );
247  call.Dump(FLEET__DUMP);
248 
249  FleetInviteCall args;
250  if (!args.Decode(&call.tuple)) {
251  codelog(SERVICE__ERROR, "%s: Failed to decode args.", call.client->GetChar()->name());
252  return PyStatic.NewNone();
253  }
254 
255  Client* pClient = sEntityList.FindClientByCharID(args.charID);
256  if (pClient == nullptr)
257  return PyStatic.NewNone();
258  if (pClient->GetChar()->fleetID()) {
259  call.client->SendNotifyMsg("%s is already in a fleet. Denying Fleet Invite issue.", pClient->GetChar()->name());
260  return PyStatic.NewNone();
261  }
262 
263  InviteData data = InviteData();
264  data.inviteBy = call.client;
265  data.invited = pClient;
266  data.wingID = args.wingID; // default sends 0
267  data.squadID = args.squadID; // default sends 0
268  data.role = args.role;
269 
270  if (data.role == Fleet::Role::FleetLeader) {
271  data.wingID = -1;
272  data.squadID = -1;
273  _log(FLEET__MESSAGE, "Fleet Invite: Role: %s, WingID: %i, SquadID: %i", sFltSvc.GetRoleName(data.role).c_str(), data.wingID, data.squadID);
274  } else if (data.role == Fleet::Role::WingLeader) {
275  // wing should be populated at this point
276  data.squadID = -1;
277  _log(FLEET__MESSAGE, "Fleet Invite: Role: %s, WingID: %i, SquadID: %i", sFltSvc.GetRoleName(data.role).c_str(), data.wingID, data.squadID);
278  } else if (data.role == Fleet::Role::SquadLeader) {
279  // wing and squad should both be populated at this point
280  _log(FLEET__MESSAGE, "Fleet Invite: Role: %s, WingID: %i, SquadID: %i", sFltSvc.GetRoleName(data.role).c_str(), data.wingID, data.squadID);
281  } else if ((data.wingID == 0) and (data.squadID == 0)) {// char invited as generic squad member, no specific position
282  sFltSvc.GetRandUnitIDs(m_fleetID, data.wingID, data.squadID);
283  _log(FLEET__MESSAGE, "Fleet Invite: Role: %s, WingID: %i, SquadID: %i", sFltSvc.GetRoleName(data.role).c_str(), data.wingID, data.squadID);
284  } else {
285  _log(FLEET__ERROR, "Fleet Invite Role/UnitID error. Role: %s, WingID: %i, SquadID: %i", sFltSvc.GetRoleName(data.role).c_str(), data.wingID, data.squadID);
286  }
287 
288  if (!sFltSvc.SaveInviteData(args.charID, data)) {
289  call.client->SendNotifyMsg("%s is invited to another fleet. That invite must be rejected before another can be issued.", pClient->GetCharName().c_str());
290  return PyStatic.NewNone();
291  }
292 
293  // join requests are accepted via invite. delete request on invite
294  sFltSvc.RemoveJoinRequest(m_fleetID, pClient);
295 
296  PyTuple* tuple = new PyTuple(4);
297  tuple->SetItem(0, new PyInt(m_fleetID));
298  tuple->SetItem(1, new PyInt(data.inviteBy->GetCharacterID()));
299  tuple->SetItem(2, new PyString("AskJoinFleet"));
300  PyTuple* tuple2 = new PyTuple(2);
301  tuple2->SetItem(0, new PyInt(call.client->GetChar()->fleetJob()));
302  tuple2->SetItem(1, new PyInt(data.inviteBy->GetCharacterID()));
303  PyDict* dict = new PyDict();
304  dict->SetItemString("name", tuple2);
305  tuple->SetItem(3, dict);
306  if (is_log_enabled(FLEET__UPDATE_DUMP)) {
307  _log(FLEET__UPDATE_DUMP, "OnFleetInvite");
308  tuple->Dump(FLEET__UPDATE_DUMP, " ");
309  }
310  pClient->SendNotification("OnFleetInvite", "clientID", &tuple, true);
311 
312  // returns nothing
313  return nullptr;
314 }
315 
316 PyResult FleetBound::Handle_AcceptInvite(PyCallArgs &call) {
317  sLog.Warning("FleetBound", "Handle_AcceptInvite() size=%u", call.tuple->size() );
318  call.Dump(FLEET__DUMP);
319 
320  Character* pChar = call.client->GetChar().get();
321  if (pChar == nullptr)
322  return new PyLong(GetFileTimeNow());
323 
324  InviteData data = InviteData();
325  if (!sFltSvc.GetInviteData(pChar->itemID(), data)){
326  call.client->SendNotifyMsg("You do not have an outstanding Fleet Invite on issue.");
327  return new PyLong(GetFileTimeNow());
328  }
329 
330  int8 booster = Fleet::Booster::No;
331  switch (data.role) {
333  FleetData fData = FleetData();
334  sFltSvc.GetFleetData(m_fleetID, fData);
335  if (fData.booster == nullptr)
336  booster = Fleet::Booster::Fleet;
337  } break;
339  WingData wData = WingData();
340  sFltSvc.GetWingData(data.wingID, wData);
341  if (wData.booster == nullptr)
342  booster = Fleet::Booster::Wing;
343  } break;
345  SquadData sData = SquadData();
346  sFltSvc.GetSquadData(data.squadID, sData);
347  if (sData.booster == nullptr)
348  booster = Fleet::Booster::Squad;
349  } break;
350  }
351 
352  sFltSvc.AddMember(call.client, m_fleetID, data.wingID, data.squadID, Fleet::Job::None, data.role, booster);
353  sFltSvc.RemoveInviteData(pChar->itemID());
354 
355  // returns nodeID and timestamp
356  PyTuple* tuple = new PyTuple(2);
357  tuple->SetItem(0, new PyString(GetBindStr())); // node info here
358  tuple->SetItem(1, new PyLong(GetFileTimeNow()));
359  return tuple;
360 }
361 
362 PyResult FleetBound::Handle_RejectInvite(PyCallArgs &call) {
363  sLog.Warning("FleetBound", "Handle_RejectInvite() size=%u", call.tuple->size() );
364  call.Dump(FLEET__DUMP);
365 
366  Character* pChar = call.client->GetChar().get();
367  if (pChar == nullptr)
368  return new PyLong(GetFileTimeNow());
369 
370  bool rejected = false;
371  if (call.tuple->AsTuple()->GetItem(0)->IsBool())
372  rejected = call.tuple->AsTuple()->GetItem(0)->AsBool()->value();
373 
374  InviteData data = InviteData();
375  if (!sFltSvc.GetInviteData(pChar->itemID(), data)) {
376  call.client->SendNotifyMsg("You do not have an outstanding Fleet Invite on issue.");
377  return new PyLong(GetFileTimeNow());
378  }
379 
380  if (rejected) {
381  data.inviteBy->SendNotifyMsg("%s has rejected your fleet invite.", data.invited->GetChar()->name());
382  } else {
383  data.inviteBy->SendNotifyMsg("%s has auto-rejected your fleet invite.", data.invited->GetChar()->name());
384  }
385  sFltSvc.RemoveInviteData(pChar->itemID());
386 
387  // returns nodeID and timestamp
388  PyTuple* tuple = new PyTuple(2);
389  tuple->SetItem(0, new PyString(GetBindStr())); // node info here
390  tuple->SetItem(1, new PyLong(GetFileTimeNow()));
391  return tuple;
392 }
393 
394 
395 PyResult FleetBound::Handle_ChangeWingName(PyCallArgs &call) {
396  // self.fleet.ChangeWingName(wingID, ret[:MAX_NAME_LENGTH])
397  sLog.Warning("FleetBound", "Handle_ChangeWingName() size=%u", call.tuple->size() );
398  call.Dump(FLEET__DUMP);
399 
400  RenameCall args;
401  if (!args.Decode(&call.tuple)) {
402  codelog(SERVICE__ERROR, "%s: Failed to decode args.", call.client->GetChar()->name());
403  return PyStatic.NewNone();
404  }
405 
406  if (args.name->IsWString()) {
407  sFltSvc.RenameWing(args.unitID, args.name->AsWString()->content());
408  } else if (args.name->IsString()) {
409  sFltSvc.RenameWing(args.unitID, args.name->AsString()->content());
410  } else {
411  _log(FLEET__ERROR, "ChangeWingName - args.name is of the wrong type: '%s'. Expected PyString or PyWString.", args.name->TypeString());
412  }
413 
414  // returns nothing
415  return nullptr;
416 }
417 
418 PyResult FleetBound::Handle_ChangeSquadName(PyCallArgs &call) {
419  // self.fleet.ChangeSquadName(squadID, ret[:MAX_NAME_LENGTH])
420  sLog.Warning("FleetBound", "Handle_ChangeSquadName() size=%u", call.tuple->size() );
421  call.Dump(FLEET__DUMP);
422 
423  RenameCall args;
424  if (!args.Decode(&call.tuple)) {
425  codelog(SERVICE__ERROR, "%s: Failed to decode args.", call.client->GetChar()->name());
426  return PyStatic.NewNone();
427  }
428 
429  if (args.name->IsWString()) {
430  sFltSvc.RenameSquad(args.unitID, args.name->AsWString()->content());
431  } else if (args.name->IsString()) {
432  sFltSvc.RenameSquad(args.unitID, args.name->AsString()->content());
433  } else {
434  _log(FLEET__ERROR, "ChangeSquadName - args.name is of the wrong type: '%s'. Expected PyString or PyWString.", args.name->TypeString());
435  }
436 
437  // returns nothing
438  return nullptr;
439 }
440 
441 PyResult FleetBound::Handle_SetOptions(PyCallArgs &call) {
442  // self.fleet.SetOptions(options)
443  sLog.Warning("FleetBound", "Handle_SetOptions() size=%u", call.tuple->size() );
444  call.Dump(FLEET__DUMP);
445 
446  PyDict* dict = call.tuple->AsTuple()->GetItem(0)->AsObject()->arguments()->AsDict();
447  bool isFreeMove = dict->GetItemString("isFreeMove")->AsBool()->value();
448  bool isRegistered = dict->GetItemString("isRegistered")->AsBool()->value();
449  bool isVoiceEnabled = (dict->GetItemString("isVoiceEnabled")->AsBool()->value() ? sConfig.chat.EnableVoiceChat : false);
450 
451  sFltSvc.UpdateOptions(m_fleetID, isFreeMove, isRegistered, isVoiceEnabled);
452 
453  // returns nothing
454  return nullptr;
455 }
456 
457 PyResult FleetBound::Handle_GetJoinRequests(PyCallArgs &call) {
458  // self.fleet.GetJoinRequests()
459  /* 20:12:59 W FleetBound: Handle_GetJoinRequests() size=0
460  * 20:12:59 [FleetDump] Call Arguments:
461  * 20:12:59 [FleetDump] Tuple: Empty
462  */
463  sLog.Warning("FleetBound", "Handle_GetJoinRequests() size=%u", call.tuple->size() );
464  call.Dump(FLEET__DUMP);
465 
466  std::vector<Client*> cVec;
467  sFltSvc.GetJoinRequests(call.client->GetChar()->fleetID(), cVec);
468 
469  PyDict* rsp = new PyDict();
470  for (auto cur : cVec) {
471  PyDict* dict = new PyDict();
472  dict->SetItemString("charID", new PyInt(cur->GetCharacterID()));
473  rsp->SetItem(new PyInt(cur->GetCharacterID()), new PyObject("util.KeyVal", dict));
474  }
475 
476  if (is_log_enabled(FLEET__DEBUG))
477  rsp->Dump(FLEET__DEBUG, " ");
478  return rsp;
479 }
480 
481 PyResult FleetBound::Handle_RejectJoinRequest(PyCallArgs &call) {
482  // self.fleet.RejectJoinRequest(charID)
483  sLog.Warning("FleetBound", "Handle_RejectJoinRequest() size=%u", call.tuple->size() );
484  call.Dump(FLEET__DUMP);
485 
486  Call_SingleIntegerArg arg;
487  if (!arg.Decode(&call.tuple)) {
488  codelog(SERVICE__ERROR, "%s: Failed to decode args.", call.client->GetChar()->name());
489  return PyStatic.NewNone();
490  }
491 
492  Client* pClient = sEntityList.FindClientByCharID(arg.arg);
493  sFltSvc.RemoveJoinRequest(call.client->GetChar()->fleetID(), pClient);
494 
495  pClient->SendInfoModalMsg("Your fleet join request was denied by %s", call.client->GetName());
496 
497  // returns nothing
498  return nullptr;
499 }
500 
501 PyResult FleetBound::Handle_GetFleetComposition(PyCallArgs &call) {
502  sLog.Warning("FleetBound", "Handle_GetFleetComposition() size=%u", call.tuple->size() );
503  call.Dump(FLEET__DUMP);
504 
505  Character* pChar(nullptr);
506  PyList* list = new PyList();
507  std::vector<Client*> members;
508  sFltSvc.GetMemeberVec(m_fleetID, members);
509  for (auto cur : members) {
510  pChar = cur->GetChar().get();
511  if (pChar == nullptr)
512  continue;
513  PyDict* dict = new PyDict();
514  dict->SetItemString("characterID", new PyInt(cur->GetCharacterID()));
515  dict->SetItemString("shipTypeID", new PyInt(cur->GetShip()->typeID()));
516  dict->SetItemString("solarSystemID", new PyInt(cur->GetSystemID()));
518  PyTuple* skills = new PyTuple(3);
519  skills->SetItem(0, new PyInt(pChar->GetSkillLevel(EvESkill::Leadership)));
520  skills->SetItem(1, new PyInt(pChar->GetSkillLevel(EvESkill::FleetCommand)));
521  skills->SetItem(2, new PyInt(pChar->GetSkillLevel(EvESkill::WingCommand)));
522  dict->SetItemString("skills", skills);
523  PyTuple* skillIDs = new PyTuple(3);
524  skillIDs->SetItem(0, new PyInt(EvESkill::Leadership));
525  skillIDs->SetItem(1, new PyInt(EvESkill::FleetCommand));
526  skillIDs->SetItem(2, new PyInt(EvESkill::WingCommand));
527  dict->SetItemString("skillIDs", skillIDs);
528  }
529  list->AddItem(new PyObject("util.KeyVal", dict));
530  pChar = nullptr;
531  }
532 
533  if (is_log_enabled(FLEET__DEBUG))
534  list->Dump(FLEET__DEBUG, " ");
535  return list;
536 }
537 
538 PyResult FleetBound::Handle_GetWings(PyCallArgs &call) {
539  // self.fleet.GetWings()
540  sLog.Warning("FleetBound", "Handle_GetWings() size=%u", call.tuple->size() );
541  call.Dump(FLEET__DUMP);
542 
543  return sFltSvc.GetWings(m_fleetID);
544 }
545 
546 // this is fleet-wide
547 PyResult FleetBound::Handle_SendBroadcast(PyCallArgs &call) {
548  // self.fleet.SendBroadcast(name, self.broadcastScope, itemID)
549  sLog.Warning("FleetBound", "Handle_SendBroadcast() size=%u", call.tuple->size() );
550  call.Dump(FLEET__DUMP);
551 
552  SendBroadCastCall args;
553  if (!args.Decode(&call.tuple)) {
554  codelog(SERVICE__ERROR, "%s: Failed to decode args.", call.client->GetChar()->name());
555  return nullptr;
556  }
557 
558  sFltSvc.FleetBroadcast(call.client, args.itemID, Fleet::BCast::Scope::Universe, args.group, args.msg);
559 
560  // returns nothing
561  return nullptr;
562 }
563 
564 PyResult FleetBound::Handle_UpdateMemberInfo(PyCallArgs &call) {
565  // self.fleet.UpdateMemberInfo(self.GetMyShipTypeID())
566  /*
567  * 13:26:54 W FleetBound: Handle_UpdateMemberInfo() size=1
568  * 13:26:54 [FleetDump] Call Arguments:
569  * 13:26:54 [FleetDump] Tuple: 1 elements
570  * 13:26:54 [FleetDump] [ 0] (None)
571  */
572  sLog.Warning("FleetBound", "Handle_UpdateMemberInfo() size=%u", call.tuple->size() );
573  //call.Dump(FLEET__DUMP);
574 
575  // returns nothing
576  return nullptr;
577 }
578 
579 PyResult FleetBound::Handle_SetMotdEx(PyCallArgs &call) {
580  // self.fleet.SetMotdEx(motd)
581  sLog.Warning("FleetBound", "Handle_SetMotdEx() size=%u", call.tuple->size() );
582  call.Dump(FLEET__DUMP);
583 
585 
586  // returns nothing
587  return nullptr;
588 }
589 
590 PyResult FleetBound::Handle_GetMotd(PyCallArgs &call) {
591  // self.motd = self.fleet.GetMotd()
592  sLog.Warning("FleetBound", "Handle_GetMotd() size=%u", call.tuple->size() );
593  call.Dump(FLEET__DUMP);
594 
595  return sFltSvc.GetMOTD(m_fleetID);
596 }
597 
598 PyResult FleetBound::Handle_LeaveFleet(PyCallArgs &call) {
599  // self.fleet.LeaveFleet()
600  sLog.Warning("FleetBound", "Handle_LeaveFleet() size=%u", call.tuple->size() );
601  call.Dump(FLEET__DUMP);
602 
603  sFltSvc.LeaveFleet(call.client);
604 
605  // returns nothing
606  return nullptr;
607 }
608 
609 PyResult FleetBound::Handle_MakeLeader(PyCallArgs &call) {
610  /* self.fleet.MakeLeader(charID) */
611  sLog.Warning("FleetBound", "Handle_MakeLeader() size=%u", call.tuple->size() );
612  call.Dump(FLEET__DUMP);
613 
614  Call_SingleIntegerArg arg;
615  if (!arg.Decode(&call.tuple)) {
616  codelog(SERVICE__ERROR, "%s: Failed to decode arg.", call.client->GetChar()->name());
617  return PyStatic.NewNone();
618  }
619 
620  // leaders will keep existing fleetJob.
621 
622  // get existing leader to remove current Role, if applicable
623  Client* pClient = sFltSvc.GetFleetLeader(m_fleetID);
624  if (pClient != nullptr) {
625  Character* pCharOld = pClient->GetChar().get();
626  if (pCharOld == nullptr)
627  return PyStatic.NewNone();
628  int32 wingID = 0, squadID = 0;
629  sFltSvc.GetRandUnitIDs(m_fleetID, wingID, squadID);
630  sFltSvc.UpdateMember(pCharOld->itemID(), m_fleetID, wingID, squadID, pCharOld->fleetJob(), Fleet::Role::Member, pCharOld->fleetBooster());
631  }
632 
633  // update new leader
634  Character* pCharNew = sEntityList.FindClientByCharID(arg.arg)->GetChar().get();
635  if (pCharNew == nullptr)
636  return PyStatic.NewNone();
637  sFltSvc.UpdateMember(arg.arg, m_fleetID, -1, -1, pCharNew->fleetJob(), Fleet::Role::FleetLeader, pCharNew->fleetBooster());
638 
639  // returns nothing
640  return nullptr;
641 }
642 
643 PyResult FleetBound::Handle_SetBooster(PyCallArgs &call) {
644  /*self.fleet.SetBooster(charID, roleBooster): */
645  sLog.Warning("FleetBound", "Handle_SetBooster() size=%u", call.tuple->size() );
646  call.Dump(FLEET__DUMP);
647 
648  SetBoosterCall args;
649  if (!args.Decode(&call.tuple)) {
650  codelog(SERVICE__ERROR, "%s: Failed to decode args.", call.client->GetChar()->name());
651  return PyStatic.NewFalse();
652  }
653 
654  Character* pOldChar(nullptr);
655  Character* pChar = sEntityList.FindClientByCharID(args.charID)->GetChar().get();
656  if (pChar == nullptr)
657  return PyStatic.NewFalse();
658 
659  // there can be only one booster per each fleet/wing/squad
660  switch (args.booster) {
661  case Fleet::Booster::Fleet: {
662  FleetData fData = FleetData();
663  sFltSvc.GetFleetData(m_fleetID, fData);
664  if ((fData.booster != nullptr) and ((pOldChar = fData.booster->GetChar().get()) != nullptr)) {
665  if (!sFltSvc.UpdateMember(pOldChar->itemID(), m_fleetID, pOldChar->wingID(), pOldChar->squadID(), pOldChar->fleetJob(), pOldChar->fleetRole(), Fleet::Booster::No))
666  return PyStatic.NewFalse();
667  }
668  } break;
669  case Fleet::Booster::Wing: {
670  WingData wData = WingData();
671  sFltSvc.GetWingData(pChar->wingID(), wData);
672  if ((wData.booster != nullptr) and ((pOldChar = wData.booster->GetChar().get()) != nullptr)) {
673  if (!sFltSvc.UpdateMember(pOldChar->itemID(), m_fleetID, pOldChar->wingID(), pOldChar->squadID(), pOldChar->fleetJob(), pOldChar->fleetRole(), Fleet::Booster::No))
674  return PyStatic.NewFalse();
675  }
676  } break;
677  case Fleet::Booster::Squad: {
678  SquadData sData = SquadData();
679  sFltSvc.GetSquadData(pChar->squadID(), sData);
680  if ((sData.booster != nullptr) and ((pOldChar = sData.booster->GetChar().get()) != nullptr)) {
681  if (!sFltSvc.UpdateMember(pOldChar->itemID(), m_fleetID, pOldChar->wingID(), pOldChar->squadID(), pOldChar->fleetJob(), pOldChar->fleetRole(), Fleet::Booster::No))
682  return PyStatic.NewFalse();
683  }
684  } break;
685  }
686 
687  if (sFltSvc.UpdateMember(args.charID, m_fleetID, pChar->wingID(), pChar->squadID(), pChar->fleetJob(), pChar->fleetRole(), args.booster))
688  return PyStatic.NewTrue();
689 
690  // returns boolean
691  return PyStatic.NewFalse();
692 }
693 
694 PyResult FleetBound::Handle_MoveMember(PyCallArgs &call) {
695  /* self.fleet.MoveMember(charID, wingID, squadID, role, roleBooster):: */
696  sLog.Warning("FleetBound", "Handle_MoveMember() size=%u", call.tuple->size() );
697  call.Dump(FLEET__DUMP);
698 
699  MoveMemberCall args;
700  if (!args.Decode(&call.tuple)) {
701  codelog(SERVICE__ERROR, "%s: Failed to decode args.", call.client->GetChar()->name());
702  return PyStatic.NewFalse();
703  }
704 
705  Character* pChar = sEntityList.FindClientByCharID(args.charID)->GetChar().get();
706  if (pChar == nullptr)
707  return PyStatic.NewFalse();
708 
709  // if voice is enabled for this fleet, SendNotification OnFleetMove to enable changing channels (on client side)
710 
711  if (sFltSvc.UpdateMember(args.charID, m_fleetID, args.wingID, args.squadID, pChar->fleetJob(), args.role, args.booster))
712  return PyStatic.NewTrue();
713 
714  // returns boolean
715  return PyStatic.NewFalse();
716 }
717 
718 PyResult FleetBound::Handle_KickMember(PyCallArgs &call) {
719  /*
720  * if charID == eve.session.charid:
721  * self.LeaveFleet()
722  * else:
723  * self.fleet.KickMember(charID)
724  */
725  sLog.Warning("FleetBound", "Handle_KickMember() size=%u", call.tuple->size() );
726  call.Dump(FLEET__DUMP);
727 
728  Call_SingleIntegerArg arg;
729  if (!arg.Decode(&call.tuple)) {
730  codelog(SERVICE__ERROR, "%s: Failed to decode args.", call.client->GetChar()->name());
731  return PyStatic.NewFalse();
732  }
733 
734  sFltSvc.LeaveFleet(sEntityList.FindClientByCharID(arg.arg));
735 
736  // returns boolean
737  return PyStatic.NewTrue();
738 }
739 
740 PyResult FleetBound::Handle_CreateWing(PyCallArgs &call) {
741  /* wingID = self.fleet.CreateWing() */
742  sLog.Warning("FleetBound", "Handle_CreateWing() size=%u", call.tuple->size() );
743  call.Dump(FLEET__DUMP);
744 
745  return sFltSvc.CreateWing(m_fleetID);
746 }
747 
748 PyResult FleetBound::Handle_CreateSquad(PyCallArgs &call) {
749  /* self.fleet.CreateSquad(wingID) */
750  sLog.Warning("FleetBound", "Handle_CreateSquad() size=%u", call.tuple->size() );
751  call.Dump(FLEET__DUMP);
752 
753  Call_SingleIntegerArg arg;
754  if (!arg.Decode(&call.tuple)) {
755  codelog(SERVICE__ERROR, "%s: Failed to decode args.", call.client->GetChar()->name());
756  return nullptr;
757  }
758 
759  sFltSvc.CreateSquad(m_fleetID, arg.arg);
760 
761  // returns nothing
762  return nullptr;
763 }
764 
765 PyResult FleetBound::Handle_DeleteWing(PyCallArgs &call) {
766  /* self.fleet.DeleteWing(wingID) */
767  sLog.Warning("FleetBound", "Handle_DeleteWing() size=%u", call.tuple->size() );
768  call.Dump(FLEET__DUMP);
769 
770  Call_SingleIntegerArg arg;
771  if (!arg.Decode(&call.tuple)) {
772  codelog(SERVICE__ERROR, "%s: Failed to decode args.", call.client->GetChar()->name());
773  return nullptr;
774  }
775 
776  sFltSvc.DeleteWing(arg.arg);
777 
778  // returns nothing
779  return nullptr;
780 }
781 
782 PyResult FleetBound::Handle_DeleteSquad(PyCallArgs &call) {
783  /* self.fleet.DeleteSquad(squadID) */
784  sLog.Warning("FleetBound", "Handle_DeleteSquad() size=%u", call.tuple->size() );
785  call.Dump(FLEET__DUMP);
786 
787  Call_SingleIntegerArg arg;
788  if (!arg.Decode(&call.tuple)) {
789  codelog(SERVICE__ERROR, "%s: Failed to decode args.", call.client->GetChar()->name());
790  return nullptr;
791  }
792 
793  sFltSvc.DeleteSquad(arg.arg); //call.tuple->AsTuple()->GetItem(0)->AsInt()->value()
794 
795  // returns nothing
796  return nullptr;
797 }
798 
799 PyResult FleetBound::Handle_AddToVoiceChat(PyCallArgs &call) {
800  // self.fleet.AddToVoiceChat(channelName)
801  sLog.Warning("FleetBound", "Handle_AddToVoiceChat() size=%u", call.tuple->size() );
802  call.Dump(FLEET__DUMP);
803 
804  //sConfig.chat.EnableVoiceChat;
805 
806  // returns nothing
807  return nullptr;
808 }
809 
810 PyResult FleetBound::Handle_SetVoiceMuteStatus(PyCallArgs &call) {
811  // self.fleet.SetVoiceMuteStatus(status, channel)
812  sLog.Warning("FleetBound", "Handle_SetVoiceMuteStatus() size=%u", call.tuple->size() );
813  call.Dump(FLEET__DUMP);
814 
815  // returns nothing
816  return nullptr;
817 }
818 
819 PyResult FleetBound::Handle_ExcludeFromVoiceMute(PyCallArgs &call) {
820  // self.fleet.ExcludeFromVoiceMute(charid, channel)
821  sLog.Warning("FleetBound", "Handle_ExcludeFromVoiceMute()) size=%u", call.tuple->size() );
822  call.Dump(FLEET__DUMP);
823 
824  // returns nothing
825  return nullptr;
826 }
827 
828 PyResult FleetBound::Handle_Reconnect(PyCallArgs &call) {
829  // no args
830  sLog.Warning("FleetBound", "Handle_Reconnect()) size=%u", call.tuple->size() );
831 
832  // returns nothing
833  return nullptr;
834 }
Client * inviteBy
Definition: FleetData.h:140
#define sConfig
A macro for easier access to the singleton.
PyTuple * AsTuple()
Definition: PyRep.h:138
Dispatcher *const m_dispatch
int64 fleetJoinTime()
Definition: Character.h:317
void SendNotification(const PyAddress &dest, EVENotificationStream &noti, bool seq=true)
Definition: Client.cpp:2245
bool isRegistered
Definition: FleetData.h:101
static std::string StringContent(PyRep *pRep)
Definition: PyRep.cpp:103
uint32 GetSystemID() const
Definition: Client.h:152
#define _log(type, fmt,...)
Definition: logsys.h:124
int8 fleetRole() const
Definition: Character.h:321
PyRep * GetItem(size_t index) const
Returns Python object.
Definition: PyRep.h:602
Python string.
Definition: PyRep.h:430
PyRep * GetItemString(const char *key) const
Obtains database entry based on given key string.
Definition: PyRep.cpp:702
PyBool * AsBool()
Definition: PyRep.h:128
PyCallable_Make_InnerDispatcher(FleetBound) FleetBound
Definition: FleetBound.cpp:33
Python's dictionary.
Definition: PyRep.h:719
size_t size() const
Definition: PyRep.h:591
std::multimap< uint32, uint32 > isExcludedFromMuting
Definition: FleetData.h:112
Dispatcher *const m_dispatch
Definition: FleetBound.h:66
bool isVoiceEnabled
Definition: FleetData.h:102
std::string name
Definition: FleetData.h:109
void SendInfoModalMsg(const char *fmt,...)
Definition: Client.cpp:2756
int32 GetCharacterID() const
Definition: Client.h:113
bool isLootLogging
Definition: FleetData.h:103
bool value() const
Definition: PyRep.h:340
#define sEntityList
Definition: EntityList.h:208
PyObject * AsObject()
Definition: PyRep.h:152
int64 GetClientID() const
Definition: Client.h:119
bool isFreeMove
Definition: FleetData.h:100
const char * name()
void SendNotifyMsg(const char *fmt,...)
Definition: Client.cpp:2776
CharacterRef GetChar() const
Definition: Client.h:164
Python tuple.
Definition: PyRep.h:567
void Dump(FILE *into, const char *pfx) const
Dumps object to file.
Definition: PyRep.cpp:84
signed __int8 int8
Definition: eve-compat.h:45
PyRep * arguments() const
Definition: PyRep.h:845
void AddItem(PyRep *i)
Definition: PyRep.h:701
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
Python object.
Definition: PyRep.h:826
#define codelog(type, fmt,...)
Definition: logsys.h:128
void SetItem(size_t index, PyRep *object)
Stores Python object.
Definition: PyRep.h:610
int32 wingID() const
Definition: Character.h:319
std::string GetBindStr() const
int32 wingID
Definition: FleetData.h:137
Python integer.
Definition: PyRep.h:231
PyDict * AsDict()
Definition: PyRep.h:142
int8 role
Definition: FleetData.h:136
int8 fleetBooster() const
Definition: Character.h:322
Client * invited
Definition: FleetData.h:139
#define PyStatic
Definition: PyRep.h:1209
X * get() const
Definition: RefPtr.h:213
int32 squadID() const
Definition: Character.h:320
ShipItemRef GetShip() const
Definition: Client.h:167
const char * GetName() const
Definition: Client.h:94
std::string motd
Definition: FleetData.h:110
std::string name
Definition: FleetData.h:131
Client *const client
Definition: PyCallable.h:49
Client * booster
Definition: FleetData.h:130
#define PyCallable_REG_CALL(c, m)
Definition: PyServiceCD.h:78
Definition: Client.h:66
unsigned __int32 uint32
Definition: eve-compat.h:50
std::string GetCharName()
Definition: Client.h:165
double GetFileTimeNow()
Definition: utils_time.cpp:84
bool IsBool() const
Definition: PyRep.h:103
void Dump(LogType type) const
Definition: PyCallable.cpp:81
uint32 m_fleetID
Definition: FleetBound.h:71
std::multimap< uint32, uint32 > isMutedByLeader
Definition: FleetData.h:111
int8 GetSkillLevel(uint16 skillTypeID, bool zeroForNotInjected=true) const
Definition: Character.cpp:575
int8 fleetJob() const
Definition: Character.h:323
Client * booster
Definition: FleetData.h:120
int32 squadID
Definition: FleetData.h:138
#define PySafeDecRef(op)
Definition: PyRep.h:61
std::string name
Definition: FleetData.h:121
int32 fleetID() const
Definition: Character.h:318
Client * booster
Definition: FleetData.h:108
void SetItem(PyRep *key, PyRep *value)
SetItem adds or sets a database entry.
Definition: PyRep.cpp:713
uint16 typeID() const
Python list.
Definition: PyRep.h:639
uint32 itemID() const
Definition: InventoryItem.h:98
void SetItemString(const char *key, PyRep *value)
SetItemString adds or sets a database entry.
Definition: PyRep.h:812
bool HasSkill(uint16 skillTypeID) const
Definition: Character.cpp:538
Python long integer.
Definition: PyRep.h:261
PyTuple * tuple
Definition: PyCallable.h:50
virtual ~FleetBound()
Definition: FleetBound.cpp:79