EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SystemCommands.cpp File Reference
Include dependency graph for SystemCommands.cpp:

Go to the source code of this file.

Macros

#define DEFAULT_RANGE   500000
 

Functions

PyResult Command_goto (Client *pClient, CommandDB *db, PyServiceMgr *services, const Seperator &args)
 
PyResult Command_translocate (Client *pClient, CommandDB *db, PyServiceMgr *services, const Seperator &args)
 
PyResult Command_tr (Client *pClient, CommandDB *db, PyServiceMgr *services, const Seperator &args)
 
static PyResult generic_createitem (Client *pClient, CommandDB *db, PyServiceMgr *services, const Seperator &args)
 
PyResult Command_create (Client *pClient, CommandDB *db, PyServiceMgr *services, const Seperator &args)
 
PyResult Command_createitem (Client *pClient, CommandDB *db, PyServiceMgr *services, const Seperator &args)
 
PyResult Command_kill (Client *pClient, CommandDB *db, PyServiceMgr *services, const Seperator &args)
 
PyResult Command_killallnpcs (Client *pClient, CommandDB *db, PyServiceMgr *services, const Seperator &args)
 
PyResult Command_unspawn (Client *pClient, CommandDB *db, PyServiceMgr *services, const Seperator &args)
 
PyResult Command_location (Client *pClient, CommandDB *db, PyServiceMgr *services, const Seperator &args)
 
PyResult Command_syncloc (Client *pClient, CommandDB *db, PyServiceMgr *services, const Seperator &args)
 
PyResult Command_syncpos (Client *pClient, CommandDB *db, PyServiceMgr *services, const Seperator &args)
 
PyResult Command_update (Client *pClient, CommandDB *db, PyServiceMgr *services, const Seperator &args)
 
PyResult Command_sendstate (Client *pClient, CommandDB *db, PyServiceMgr *services, const Seperator &args)
 
PyResult Command_addball (Client *pClient, CommandDB *db, PyServiceMgr *services, const Seperator &args)
 
PyResult Command_addball2 (Client *pClient, CommandDB *db, PyServiceMgr *services, const Seperator &args)
 
PyResult Command_cloak (Client *pClient, CommandDB *db, PyServiceMgr *services, const Seperator &args)
 
PyResult Command_hop (Client *pClient, CommandDB *db, PyServiceMgr *services, const Seperator &args)
 
PyResult Command_sov (Client *pClient, CommandDB *db, PyServiceMgr *services, const Seperator &args)
 
PyResult Command_pos (Client *pClient, CommandDB *db, PyServiceMgr *services, const Seperator &args)
 

Macro Definition Documentation

#define DEFAULT_RANGE   500000

Referenced by Command_unspawn().

Function Documentation

PyResult Command_addball ( Client pClient,
CommandDB db,
PyServiceMgr services,
const Seperator args 
)

Definition at line 805 of file SystemCommands.cpp.

References SystemEntity::DestinyMgr(), Client::EnterSystem(), Client::GetShipSE(), Client::GetSystemID(), Client::IsInSpace(), NULL_ORIGIN(), sBubbleMgr, SystemBubble::SendAddBalls(), Client::SetDestiny(), and SystemEntity::SysBubble().

805  {
806  if (!pClient->IsInSpace())
807  throw CustomError ("You're not in space.");
808  if (pClient->GetShipSE()->DestinyMgr() == nullptr)
809  pClient->SetDestiny(NULL_ORIGIN);
810  if (pClient->GetShipSE()->SysBubble() == nullptr)
811  pClient->EnterSystem(pClient->GetSystemID());
812 
813  SystemBubble *pBubble = pClient->GetShipSE()->SysBubble();
814  if (pBubble == nullptr) {
815  sBubbleMgr.Add(pClient->GetShipSE());
816  pBubble = pClient->GetShipSE()->SysBubble();
817  }
818  pBubble->SendAddBalls(pClient->GetShipSE());
819 
820  return new PyString("Update sent.");
821 }
uint32 GetSystemID() const
Definition: Client.h:152
void SendAddBalls(SystemEntity *to_who)
Python string.
Definition: PyRep.h:430
SystemBubble * SysBubble()
Definition: SystemEntity.h:195
bool IsInSpace()
Definition: Client.h:228
Advanced version of UserError that allows to send a full custom message.
Definition: PyExceptions.h:453
DestinyManager * DestinyMgr()
Definition: SystemEntity.h:198
static const GPoint NULL_ORIGIN(0, 0, 0)
ShipSE * GetShipSE()
Definition: Client.h:168
void SetDestiny(const GPoint &pt, bool update=false)
Definition: Client.cpp:847
void EnterSystem(uint32 systemID)
Definition: Client.cpp:679
#define sBubbleMgr

Here is the call graph for this function:

PyResult Command_addball2 ( Client pClient,
CommandDB db,
PyServiceMgr services,
const Seperator args 
)

Definition at line 823 of file SystemCommands.cpp.

References SystemEntity::DestinyMgr(), Client::EnterSystem(), Client::GetShipSE(), Client::GetSystemID(), Client::IsInSpace(), NULL_ORIGIN(), sBubbleMgr, SystemBubble::SendAddBalls2(), Client::SetDestiny(), and SystemEntity::SysBubble().

823  {
824  if (!pClient->IsInSpace())
825  throw CustomError ("You're not in space.");
826  if (pClient->GetShipSE()->DestinyMgr() == nullptr)
827  pClient->SetDestiny(NULL_ORIGIN);
828  if (pClient->GetShipSE()->SysBubble() == nullptr)
829  pClient->EnterSystem(pClient->GetSystemID());
830 
831  SystemBubble *pBubble = pClient->GetShipSE()->SysBubble();
832  if (pBubble == nullptr) {
833  sBubbleMgr.Add(pClient->GetShipSE());
834  pBubble = pClient->GetShipSE()->SysBubble();
835  }
836  pBubble->SendAddBalls2(pClient->GetShipSE());
837 
838  return new PyString("Update sent.");
839 }
uint32 GetSystemID() const
Definition: Client.h:152
Python string.
Definition: PyRep.h:430
SystemBubble * SysBubble()
Definition: SystemEntity.h:195
void SendAddBalls2(SystemEntity *to_who)
bool IsInSpace()
Definition: Client.h:228
Advanced version of UserError that allows to send a full custom message.
Definition: PyExceptions.h:453
DestinyManager * DestinyMgr()
Definition: SystemEntity.h:198
static const GPoint NULL_ORIGIN(0, 0, 0)
ShipSE * GetShipSE()
Definition: Client.h:168
void SetDestiny(const GPoint &pt, bool update=false)
Definition: Client.cpp:847
void EnterSystem(uint32 systemID)
Definition: Client.cpp:679
#define sBubbleMgr

Here is the call graph for this function:

PyResult Command_cloak ( Client pClient,
CommandDB db,
PyServiceMgr services,
const Seperator args 
)

Definition at line 841 of file SystemCommands.cpp.

References Seperator::argCount(), DestinyManager::Cloak(), SystemEntity::DestinyMgr(), Client::GetShipSE(), DestinyManager::IsCloaked(), Client::IsInSpace(), and DestinyManager::UnCloak().

842 {
843  if (args.argCount() == 1) {
844  if (pClient->IsInSpace()) {
845  if (pClient->GetShipSE()->DestinyMgr()->IsCloaked())
846  pClient->GetShipSE()->DestinyMgr()->UnCloak();
847  else
848  pClient->GetShipSE()->DestinyMgr()->Cloak();
849  } else
850  throw CustomError ("ERROR! You MUST be in space to cloak!");
851  } else
852  throw CustomError ("Correct Usage: /cloak");
853 
854  return nullptr;
855 }
bool IsInSpace()
Definition: Client.h:228
Advanced version of UserError that allows to send a full custom message.
Definition: PyExceptions.h:453
size_t argCount() const
Definition: Seperator.h:44
DestinyManager * DestinyMgr()
Definition: SystemEntity.h:198
ShipSE * GetShipSE()
Definition: Client.h:168

Here is the call graph for this function:

PyResult Command_create ( Client pClient,
CommandDB db,
PyServiceMgr services,
const Seperator args 
)

Definition at line 503 of file SystemCommands.cpp.

References Seperator::argCount(), and generic_createitem().

503  {
504  if (args.argCount() < 2) {
505  throw CustomError ("Correct Usage: /create [typeID|\"Type Name\"] [qty] [where]");
506  }
507  return generic_createitem(pClient, db, services, args);
508 }
static PyResult generic_createitem(Client *pClient, CommandDB *db, PyServiceMgr *services, const Seperator &args)
Advanced version of UserError that allows to send a full custom message.
Definition: PyExceptions.h:453
size_t argCount() const
Definition: Seperator.h:44

Here is the call graph for this function:

PyResult Command_createitem ( Client pClient,
CommandDB db,
PyServiceMgr services,
const Seperator args 
)

Definition at line 510 of file SystemCommands.cpp.

References Seperator::argCount(), and generic_createitem().

510  {
511  if (args.argCount() < 2) {
512  throw CustomError ("Correct Usage: /createitem [typeID|\"Type Name\"] [qty] [where]");
513  }
514  return generic_createitem(pClient, db, services, args);
515 }
static PyResult generic_createitem(Client *pClient, CommandDB *db, PyServiceMgr *services, const Seperator &args)
Advanced version of UserError that allows to send a full custom message.
Definition: PyExceptions.h:453
size_t argCount() const
Definition: Seperator.h:44

Here is the call graph for this function:

PyResult Command_goto ( Client pClient,
CommandDB db,
PyServiceMgr services,
const Seperator args 
)

Definition at line 30 of file SystemCommands.cpp.

References Seperator::arg(), Seperator::argCount(), Seperator::isNumber(), and Client::MoveToPosition().

31 {
32  if (args.argCount() != 4
33  || !args.isNumber(1)
34  || !args.isNumber(2)
35  || !args.isNumber(3))
36  {
37  throw CustomError ("Correct Usage: /goto [x coord] [y coor] [z coord]");
38  }
39 
40  GPoint p(atoll(args.arg(1).c_str()),
41  atoll(args.arg(2).c_str()),
42  atoll(args.arg(3).c_str()));
43 
44  pClient->MoveToPosition(p);
45  return new PyString("Goto successful.");
46 }
const std::string & arg(size_t index) const
Definition: Seperator.h:43
Python string.
Definition: PyRep.h:430
Advanced version of UserError that allows to send a full custom message.
Definition: PyExceptions.h:453
void MoveToPosition(const GPoint &pt)
Definition: Client.cpp:928
size_t argCount() const
Definition: Seperator.h:44
Definition: gpoint.h:33
bool isNumber(size_t index) const
Definition: Seperator.h:46

Here is the call graph for this function:

PyResult Command_hop ( Client pClient,
CommandDB db,
PyServiceMgr services,
const Seperator args 
)

Definition at line 857 of file SystemCommands.cpp.

857  {
858  /*22:49:01 W GMCommands: Command_hop(): This command passes args.argCount() = 1.
859  * sm.RemoteSvc('slash').SlashCmd('/hop %s' % distance)
860  */
861  return nullptr;
862 }
PyResult Command_kill ( Client pClient,
CommandDB db,
PyServiceMgr services,
const Seperator args 
)

Definition at line 518 of file SystemCommands.cpp.

References Seperator::arg(), Seperator::argCount(), SystemEntity::GetNPCSE(), SystemManager::GetSE(), Client::GetShipSE(), SystemEntity::IsNPCSE(), Seperator::isNumber(), NPC::Killed(), SystemEntity::Killed(), SystemManager::RemoveEntity(), sItemFactory, sLog, and Client::SystemMgr().

519 {
520  if (args.argCount() == 2) {
521  if (!args.isNumber(1)) {
522  throw CustomError ("Argument 1 should be a character ID");
523  }
524  int entity = atoi(args.arg(1).c_str());
525 
526  InventoryItemRef itemRef = sItemFactory.GetShip(entity);
527  if (itemRef.get() == NULL)
528  throw CustomError ("/kill NOT supported on non-ship types at this time");
529 
530  SystemEntity* shipEntity = pClient->SystemMgr()->GetSE(entity);
531  if (shipEntity == nullptr) {
532  throw CustomError ("/kill cannot process this object");
533  sLog.Error("GMCommands - Command_kill()", "Cannot process this object, aborting kill: %s [%u]", itemRef->name(), itemRef->itemID());
534  } else {
535  pClient->SystemMgr()->RemoveEntity(shipEntity);
536  if (shipEntity->IsNPCSE()) {
537  NPC* npcEntity = shipEntity->GetNPCSE();
538  Damage fatal_blow(pClient->GetShipSE(),true);
539  npcEntity->Killed(fatal_blow);
540  delete npcEntity;
541  } else {
542  Damage fatal_blow(pClient->GetShipSE(),true);
543  shipEntity->Killed(fatal_blow);
544  itemRef->Delete();
545  }
546  }
547  } else
548  throw CustomError ("Correct Usage: /kill <entityID>");
549 
550  return nullptr;
551 }
SystemEntity * GetSE(uint32 entityID) const
const std::string & arg(size_t index) const
Definition: Seperator.h:43
virtual bool IsNPCSE()
Definition: SystemEntity.h:186
virtual void Killed(Damage &fatal_blow)
virtual NPC * GetNPCSE()
Definition: SystemEntity.h:134
Advanced version of UserError that allows to send a full custom message.
Definition: PyExceptions.h:453
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
size_t argCount() const
Definition: Seperator.h:44
SystemManager * SystemMgr() const
Definition: Client.h:92
void RemoveEntity(SystemEntity *pSE)
Definition: Damage.h:33
Definition: NPC.h:41
ShipSE * GetShipSE()
Definition: Client.h:168
bool isNumber(size_t index) const
Definition: Seperator.h:46
#define sItemFactory
Definition: ItemFactory.h:165
virtual void Killed(Damage &fatal_blow)
Definition: NPC.cpp:304

Here is the call graph for this function:

PyResult Command_killallnpcs ( Client pClient,
CommandDB db,
PyServiceMgr services,
const Seperator args 
)

Definition at line 553 of file SystemCommands.cpp.

References Seperator::argCount(), SystemBubble::GetEntities(), Client::GetShipSE(), Client::IsInSpace(), and SystemEntity::SysBubble().

554 {
555  if (!pClient->IsInSpace())
556  throw CustomError ("You're not in space.");
557  if (args.argCount() != 1)
558  throw CustomError ("Correct Usage: /killallnpcs");
559  if (pClient->GetShipSE() == nullptr)
560  throw CustomError ("ShipSE invalid.");
561  if (pClient->GetShipSE()->SysBubble() == nullptr)
562  throw CustomError ("SysBubble invalid.");
563 
564  std::map< uint32, SystemEntity* > entityVec;
565  pClient->GetShipSE()->SysBubble()->GetEntities(entityVec);
566  for (auto cur : entityVec) {
567  if (cur.second == nullptr)
568  continue;
569  if (cur.second->IsNPCSE()) {
570  Damage fatal_blow(pClient->GetShipSE(),true);
571  cur.second->GetNPCSE()->Killed(fatal_blow);
572  }
573  }
574 
575  return nullptr;
576 }
SystemBubble * SysBubble()
Definition: SystemEntity.h:195
void GetEntities(std::map< uint32, SystemEntity * > &into) const
bool IsInSpace()
Definition: Client.h:228
Advanced version of UserError that allows to send a full custom message.
Definition: PyExceptions.h:453
size_t argCount() const
Definition: Seperator.h:44
Definition: Damage.h:33
ShipSE * GetShipSE()
Definition: Client.h:168

Here is the call graph for this function:

PyResult Command_location ( Client pClient,
CommandDB db,
PyServiceMgr services,
const Seperator args 
)

Definition at line 681 of file SystemCommands.cpp.

References bubble, SystemEntity::DestinyMgr(), Client::EnterSystem(), SystemBubble::GetID(), DestinyManager::GetPosition(), Client::GetShipSE(), Client::GetSystemID(), DestinyManager::GetVelocity(), Client::IsInSpace(), Ga::GaVec3::length(), NULL_ORIGIN(), sBubbleMgr, Client::SendInfoModalMsg(), Client::SetDestiny(), snprintf, SystemEntity::SysBubble(), Ga::GaVec3::x, Ga::GaVec3::y, and Ga::GaVec3::z.

682 {
683  if (!pClient->IsInSpace())
684  throw CustomError ("You're not in space.");
685  if (pClient->GetShipSE()->DestinyMgr() == nullptr)
686  pClient->SetDestiny(NULL_ORIGIN);
687  if (pClient->GetShipSE()->SysBubble() == nullptr)
688  pClient->EnterSystem(pClient->GetSystemID());
689 
690  DestinyManager *dm = pClient->GetShipSE()->DestinyMgr();
691  SystemBubble *pBubble = pClient->GetShipSE()->SysBubble();
692  if (pBubble == nullptr) {
693  sBubbleMgr.Add(pClient->GetShipSE());
694  pBubble = pClient->GetShipSE()->SysBubble();
695  }
696  uint16 bubble = pBubble->GetID();
697 
698  const GPoint &loc = dm->GetPosition();
699  const GVector &vel = dm->GetVelocity();
700 
701  char reply[140];
702  snprintf(reply, 140,
703  "SystemID: %u BubbleID: %u<br>"
704  "x: %.2f<br>"
705  "y: %.2f<br>"
706  "z: %.2f<br>"
707  "speed: %.1f",
708  pClient->GetSystemID(), bubble,
709  loc.x, loc.y, loc.z,
710  vel.length()
711  );
712 
713  pClient->SendInfoModalMsg(reply);
714 
715  return new PyString(reply);
716 }
GaExpInl GaFloat length() const
Definition: GaTypes.h:156
uint32 GetSystemID() const
Definition: Client.h:152
Python string.
Definition: PyRep.h:430
SystemBubble * SysBubble()
Definition: SystemEntity.h:195
void SendInfoModalMsg(const char *fmt,...)
Definition: Client.cpp:2756
const GVector & GetVelocity() const
bool IsInSpace()
Definition: Client.h:228
GaFloat x
Definition: GaTypes.h:207
Advanced version of UserError that allows to send a full custom message.
Definition: PyExceptions.h:453
entityID heal the character with the entityID note giving you detailed ship status information gives a list of all dynamic entities and players and their destinyState in this bubble shows some current destiny variables save all kick all and halt server immediate command list all items in current location s gives list of cargo contents and volumes in all holds list current session values show current ship DNA show current objects in bubble
Definition: gpoint.h:33
DestinyManager * DestinyMgr()
Definition: SystemEntity.h:198
uint16 GetID()
Definition: SystemBubble.h:91
static const GPoint NULL_ORIGIN(0, 0, 0)
#define snprintf
Definition: eve-compat.h:184
GaFloat y
Definition: GaTypes.h:207
ShipSE * GetShipSE()
Definition: Client.h:168
void SetDestiny(const GPoint &pt, bool update=false)
Definition: Client.cpp:847
const GPoint & GetPosition() const
void EnterSystem(uint32 systemID)
Definition: Client.cpp:679
Definition: gpoint.h:70
#define sBubbleMgr
unsigned __int16 uint16
Definition: eve-compat.h:48
GaFloat z
Definition: GaTypes.h:207

Here is the call graph for this function:

PyResult Command_pos ( Client pClient,
CommandDB db,
PyServiceMgr services,
const Seperator args 
)

Definition at line 879 of file SystemCommands.cpp.

879  {
880 // sLog.Warning("SystemCommands: Command_pos()", "This command passes args.argCount() = %u.", args.argCount());
881 
882  /*
883  * ' /pos online ' + str(itemID)
884  * ' /pos unanchor ' + str(itemID)
885  * ' /pos anchor ' + str(itemID)
886  * ' /pos offline ' + str(itemID)
887  * ' /pos fuel [itemID]
888  */
889 
890  /*
891  * 16:39:26 [CmdDump] Call Arguments:
892  * 16:39:26 [CmdDump] Tuple: 1 elements
893  * 16:39:26 [CmdDump] [ 0] String: '/pos offline 140035963'
894  */
895  return nullptr;
896 }
PyResult Command_sendstate ( Client pClient,
CommandDB db,
PyServiceMgr services,
const Seperator args 
)

Definition at line 786 of file SystemCommands.cpp.

References SystemEntity::DestinyMgr(), Client::EnterSystem(), Client::GetSessionChangeTime(), Client::GetShipSE(), Client::GetSystemID(), Client::IsInSpace(), Client::IsSessionChange(), NULL_ORIGIN(), Client::SendInfoModalMsg(), DestinyManager::SendSetState(), Client::SetDestiny(), Client::SetSessionTimer(), Client::SetStateSent(), and SystemEntity::SysBubble().

786  {
787  if (!pClient->IsInSpace())
788  throw CustomError ("You're not in space.");
789  if (pClient->GetShipSE()->DestinyMgr() == nullptr)
790  pClient->SetDestiny(NULL_ORIGIN);
791  if (pClient->GetShipSE()->SysBubble() == nullptr)
792  pClient->EnterSystem(pClient->GetSystemID());
793  if (pClient->IsSessionChange()) {
794  pClient->SendInfoModalMsg("Session Change Active. Wait %u seconds before issuing another command.",
795  pClient->GetSessionChangeTime());
796  return new PyString("SessionChange Active. Request Denied.");
797  }
798 
799  pClient->SetStateSent(false);
800  pClient->GetShipSE()->DestinyMgr()->SendSetState();
801  pClient->SetSessionTimer();
802  return new PyString("Update sent.");
803 }
bool IsSessionChange()
Definition: Client.h:241
uint32 GetSystemID() const
Definition: Client.h:152
Python string.
Definition: PyRep.h:430
SystemBubble * SysBubble()
Definition: SystemEntity.h:195
void SendInfoModalMsg(const char *fmt,...)
Definition: Client.cpp:2756
uint32 GetSessionChangeTime()
Definition: Client.h:242
bool IsInSpace()
Definition: Client.h:228
Advanced version of UserError that allows to send a full custom message.
Definition: PyExceptions.h:453
void SendSetState() const
DestinyManager * DestinyMgr()
Definition: SystemEntity.h:198
static const GPoint NULL_ORIGIN(0, 0, 0)
void SetStateSent(bool set=false)
Definition: Client.h:249
ShipSE * GetShipSE()
Definition: Client.h:168
void SetDestiny(const GPoint &pt, bool update=false)
Definition: Client.cpp:847
void EnterSystem(uint32 systemID)
Definition: Client.cpp:679
void SetSessionTimer()
Definition: Client.h:250

Here is the call graph for this function:

PyResult Command_sov ( Client pClient,
CommandDB db,
PyServiceMgr services,
const Seperator args 
)

Definition at line 865 of file SystemCommands.cpp.

References Seperator::argCount(), and sLog.

865  {
866  sLog.Warning("GMCommands: Command_sov()", "This command passes args.argCount() = %u.", args.argCount());
867  /*
868  * ' /sov complete ' + str(itemID)
869  */
870  /*
871  * 16:40:32 [CmdDump] Call Arguments:
872  * 16:40:32 [CmdDump] Tuple: 1 elements
873  * 16:40:32 [CmdDump] [ 0] String: '/sov complete 140035963'
874  */
875  return nullptr;
876 }
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
size_t argCount() const
Definition: Seperator.h:44

Here is the call graph for this function:

PyResult Command_syncloc ( Client pClient,
CommandDB db,
PyServiceMgr services,
const Seperator args 
)

Definition at line 718 of file SystemCommands.cpp.

References SystemEntity::DestinyMgr(), Client::EnterSystem(), SystemEntity::GetPosition(), Client::GetSessionChangeTime(), Client::GetShipSE(), Client::GetSystemID(), Client::IsInSpace(), Client::IsSessionChange(), NULL_ORIGIN(), Client::SendInfoModalMsg(), Client::SetDestiny(), DestinyManager::SetPosition(), Client::SetSessionTimer(), and SystemEntity::SysBubble().

719 {
720  if (!pClient->IsInSpace())
721  throw CustomError ("You're not in space.");
722  if (pClient->GetShipSE()->DestinyMgr() == nullptr)
723  pClient->SetDestiny(NULL_ORIGIN);
724  if (pClient->GetShipSE()->SysBubble() == nullptr)
725  pClient->EnterSystem(pClient->GetSystemID());
726  if (pClient->IsSessionChange()) {
727  pClient->SendInfoModalMsg("Session Change Active. Wait %u seconds before issuing another command.",
728  pClient->GetSessionChangeTime());
729  return new PyString("SessionChange Active. Request Denied.");
730  }
731 
732  pClient->GetShipSE()->DestinyMgr()->SetPosition(pClient->GetShipSE()->GetPosition(), true);
733  pClient->SetSessionTimer();
734 
735  return new PyString("Position synchronized.");
736 }
bool IsSessionChange()
Definition: Client.h:241
uint32 GetSystemID() const
Definition: Client.h:152
Python string.
Definition: PyRep.h:430
SystemBubble * SysBubble()
Definition: SystemEntity.h:195
void SendInfoModalMsg(const char *fmt,...)
Definition: Client.cpp:2756
uint32 GetSessionChangeTime()
Definition: Client.h:242
bool IsInSpace()
Definition: Client.h:228
Advanced version of UserError that allows to send a full custom message.
Definition: PyExceptions.h:453
const GPoint & GetPosition() const
Definition: SystemEntity.h:211
DestinyManager * DestinyMgr()
Definition: SystemEntity.h:198
static const GPoint NULL_ORIGIN(0, 0, 0)
void SetPosition(const GPoint &pt, bool update=false)
ShipSE * GetShipSE()
Definition: Client.h:168
void SetDestiny(const GPoint &pt, bool update=false)
Definition: Client.cpp:847
void EnterSystem(uint32 systemID)
Definition: Client.cpp:679
void SetSessionTimer()
Definition: Client.h:250

Here is the call graph for this function:

PyResult Command_syncpos ( Client pClient,
CommandDB db,
PyServiceMgr services,
const Seperator args 
)

Definition at line 738 of file SystemCommands.cpp.

References SystemEntity::DestinyMgr(), Client::EnterSystem(), Client::GetSessionChangeTime(), Client::GetShipSE(), Client::GetSystemID(), Client::IsInSpace(), Client::IsSessionChange(), NULL_ORIGIN(), Client::SendInfoModalMsg(), Client::SetDestiny(), Client::SetSessionTimer(), SystemBubble::SyncPos(), and SystemEntity::SysBubble().

739 {
740  if (!pClient->IsInSpace())
741  throw CustomError ("You're not in space.");
742  if (pClient->GetShipSE()->DestinyMgr() == nullptr)
743  pClient->SetDestiny(NULL_ORIGIN);
744  if (pClient->GetShipSE()->SysBubble() == nullptr)
745  pClient->EnterSystem(pClient->GetSystemID());
746  if (pClient->IsSessionChange()) {
747  pClient->SendInfoModalMsg("Session Change Active. Wait %u seconds before issuing another command.",
748  pClient->GetSessionChangeTime());
749  return new PyString("SessionChange Active. Request Denied.");
750  }
751 
752  pClient->GetShipSE()->SysBubble()->SyncPos();
753  pClient->SetSessionTimer();
754 
755  return new PyString("All Positions synchronized.");
756 }
bool IsSessionChange()
Definition: Client.h:241
uint32 GetSystemID() const
Definition: Client.h:152
Python string.
Definition: PyRep.h:430
SystemBubble * SysBubble()
Definition: SystemEntity.h:195
void SendInfoModalMsg(const char *fmt,...)
Definition: Client.cpp:2756
uint32 GetSessionChangeTime()
Definition: Client.h:242
bool IsInSpace()
Definition: Client.h:228
Advanced version of UserError that allows to send a full custom message.
Definition: PyExceptions.h:453
DestinyManager * DestinyMgr()
Definition: SystemEntity.h:198
static const GPoint NULL_ORIGIN(0, 0, 0)
ShipSE * GetShipSE()
Definition: Client.h:168
void SetDestiny(const GPoint &pt, bool update=false)
Definition: Client.cpp:847
void EnterSystem(uint32 systemID)
Definition: Client.cpp:679
void SetSessionTimer()
Definition: Client.h:250

Here is the call graph for this function:

PyResult Command_tr ( Client pClient,
CommandDB db,
PyServiceMgr services,
const Seperator args 
)
Todo:
this is a good start, but will need a bit more logic to idiot-proof and finish

Definition at line 77 of file SystemCommands.cpp.

References Seperator::arg(), Seperator::argCount(), badCharsSearch, LSC::fleet, RefPtr< X >::get(), Client::GetCloneStationID(), Client::GetDockStationID(), Client::GetLocationID(), SystemEntity::GetPosition(), SystemEntity::GetRadius(), SystemGPoint::GetRandPointOnMoon(), SystemGPoint::GetRandPointOnPlanet(), Client::GetShipSE(), CommandDB::GetSolarSystem(), CommandDB::GetStation(), Client::GetSystemID(), EvE::icontains(), Client::InFleet(), IsCharacterID, Client::IsDocked(), IsNPC, Seperator::isNumber(), IsPlayerItem, item(), Client::JumpInEffect(), Client::JumpOutEffect(), InventoryItem::locationID(), GPoint::MakeRandomPointOnSphere(), Client::MoveToLocation(), NULL_ORIGIN(), InventoryItem::ownerID(), InventoryItem::position(), sDataMgr, Client::SendInfoModalMsg(), sEntityList, sItemFactory, and snprintf.

Referenced by Command_translocate().

77  {
78  // i dont expect this to be used very often, so a bit of bloat is acceptable
79 
80  if (pClient == nullptr) // should never hit,
81  throw CustomError ("Translocate: Invalid Caller - Client sent NULL.");
82 
83  if (args.argCount() < 2)
84  throw CustomError ("Translocate: Missing Arguments (use '.tr help' for usage)");
85 
86  Client* pOtherClient(nullptr);
87  const char* Help = "help"; // many uses. avoid creating temp objects for every test
88  bool me = false, item = false, player = false, fleet = false;
89  GPoint pt(NULL_ORIGIN);
90  int locationID = 0, myLocationID = pClient->GetLocationID();
91 
92  if (args.argCount() == 2) { // single arg - help, locationID, {invalid}
93  if (args.isNumber(1)) {
94  // tr <me> to locationID
95  locationID = atoi(args.arg(1).c_str());
96  } else if (strcmp(args.arg(1).c_str(), Help) == 0) {
97  // {.tr help} will display the following list of options in notification window
98  std::ostringstream str; // for 'help' printing
99  str << ".tr [required first arg] [optional second arg] [optional third arg] [optional fourth arg]<br>"; //120
100  str << "1st arg = help|me|fleet|player name|shipID|itemID|locationID<br>"; //45
101  str << "2nd arg = help|me|fleet|home|last|shipID|itemID|locationID|x coord|moon|planet<br>"; //85
102  str << "3ed arg = me|fleet|home|last|shipID|itemID|locationID|y coords|moon|planet <br>"; //80
103  str << "4th arg = fleet|home|last|shipID|itemID|locationID|z coords|moon|planet <br>"; //77
104  str << "typical use is .tr locationID<br>"; //35
105  str << "<br>As there are too many options to explain in this msg, a full usage list can be found on our forums.<br>"; //105
106  int size = 500;
107  char reply[size];
108  snprintf(reply, size, str.str().c_str());
109  pClient->SendInfoModalMsg(reply);
110  return nullptr;
111  } else {
112  // tr <me> to <locationName>?
113  // this hits db directly, so test for possible sql injection code
114  for (const auto cur : badCharsSearch)
115  if (EvE::icontains(args.arg(1), cur))
116  throw CustomError ("Location contains invalid characters");
117  locationID = db->GetSolarSystem(args.arg(1).c_str());
118  if (!sDataMgr.IsSolarSystem(locationID)) {
119  locationID = db->GetStation(args.arg(1).c_str());
120  if (!sDataMgr.IsStation(locationID))
121  throw CustomError ("Translocate: Name Argument is neither SolarSystem nor StationName");
122  }
123  }
124  } else if (args.argCount() == 3) { // 2 args - me, player, ship, item, fleet, {invalid} : help, home, last, ship, location, moon, planet, {invalid}
125  // test for 'help' command
126  if ((strcmp(args.arg(1).c_str(), Help) == 0)
127  or (strcmp(args.arg(2).c_str(), Help) == 0))
128  throw CustomError ("Translocate: Invalid Arguments - 'help' not avalible for this command.");
129 
130  // decode first arg -- me, shipID, charID, playerName, itemID {invalid}
131  if (args.isNumber(1)) { // charID, shipID, {invalid}
132  int objectID = atoi(args.arg(1).c_str());
133  if (IsCharacterID(objectID)) {
134  pOtherClient = sEntityList.FindClientByCharID(objectID);
135  } else if (IsPlayerItem(objectID)) {
136  // get object's ownerID...this is rather powerful.
137  InventoryItemRef iRef = sItemFactory.GetItem(objectID);
138  if (iRef.get() == nullptr)
139  throw CustomError ("Translocate: Invalid Arguments - target object was not found.");
140  pOtherClient = sEntityList.FindClientByCharID(iRef->ownerID());
141  } else if (IsNPC(objectID)) {
142  throw CustomError ("Translocate: Invalid Object - You really wanna relocate an NPC?");
143  } else
144  throw CustomError ("Translocate: Invalid Object - %i is neither a character nor a ship", objectID);
145  } else if (strcmp(args.arg(1).c_str(), "me") == 0) {
146  // tr <me> to ?
147  // pClient doesnt change. do nothing here
148  me = true;
149  } else if (strcmp(args.arg(1).c_str(), "ship") == 0) {
150  // tr <ship|ship owner> to ?
151  item = true;
152  } else if (strcmp(args.arg(1).c_str(), "item") == 0) {
153  // tr me to item
154  item = true;
155  } else if (strcmp(args.arg(1).c_str(), "fleet") == 0) {
156  // tr <my fleet> to ?
157  fleet = true;
158  // not sure how im gonna do this one yet....
159  if (!pClient->InFleet())
160  throw CustomError ("Translocate: Fleet Move - You are not in a fleet.");
161  throw CustomError ("Translocate: Fleet Move - This command is currently incomplete.");
162  } else {
163  // check for player name
164  pOtherClient = sEntityList.FindClientByName(args.arg(1).c_str());
165  if (pOtherClient == nullptr)
166  throw CustomError ("Translocate: Bad Name - %s is not online or is not a valid player name", args.arg(1).c_str());
167  }
168  // decode second arg -- me, fleet, home, last, location, moon, planet, {invalid}
169  if (args.isNumber(2)) {
170  // tr <me|ship|player|fleet> to <locationID>
171  locationID = atoi(args.arg(2).c_str());
172  } else if (strcmp(args.arg(2).c_str(), "me") == 0) {
173  // tr <me|ship|player|fleet> to me
174  // pClient doesnt change. do nothing here
175  me = true;
176  locationID = myLocationID; // this wont do anything if used as ".tr me me"
177  } else if (strcmp(args.arg(2).c_str(), "home") == 0) {
178  if (fleet)
179  throw CustomError ("Translocate: Fleet Move - You cannot tr a fleet 'home'...yet.");
180  locationID = pClient->GetCloneStationID();
181  } else if (strcmp(args.arg(2).c_str(), "ship") == 0) {
182  // tr <me|ship|player|fleet> to <ship|ship owner>
183  if (item)
184  throw CustomError ("Translocate: Ship Move - You cannot tr one ship to another ship...yet.");
185  item = true;
186  } else if (strcmp(args.arg(2).c_str(), "last") == 0) {
187  // last station <me|player> was docked in
188  if (fleet)
189  throw CustomError ("Translocate: Fleet Move - You cannot tr a fleet to last docked station...yet.");
190  // if called with <player name>, <charID>, or <shipID>, then uses that char's (or owner's) last docked station
191  if (pOtherClient != nullptr)
192  locationID = pOtherClient->GetDockStationID();
193  else
194  locationID = pClient->GetDockStationID();
195  } else if (strcmp(args.arg(2).c_str(), "moon") == 0) {
196  // random moon in <me|player> current system
197  SystemGPoint sGP;
198  pt = sGP.GetRandPointOnMoon(pOtherClient == nullptr ? pClient->GetSystemID() : pOtherClient->GetSystemID());
199  //throw CustomError ("Translocate: This option is Incomplete");
200  } else if (strcmp(args.arg(2).c_str(), "planet") == 0) {
201  // random planet in <me|player> current system
202  SystemGPoint sGP;
203  pt = sGP.GetRandPointOnPlanet(pOtherClient == nullptr ? pClient->GetSystemID() : pOtherClient->GetSystemID());
204  //throw CustomError ("Translocate: This option is Incomplete");
205  } else {
206  if (me) {
207  // tr me to <locationName>?
208  // this hits db directly, so test for possible sql injection code
209  for (const auto cur : badCharsSearch)
210  if (EvE::icontains(args.arg(1), cur))
211  throw CustomError ("Location contains invalid characters");
212  locationID = db->GetSolarSystem(args.arg(1).c_str());
213  if (!sDataMgr.IsSolarSystem(locationID)) {
214  locationID = db->GetStation(args.arg(1).c_str());
215  if (!sDataMgr.IsStation(locationID))
216  throw CustomError ("Translocate: Name Argument is neither SolarSystem nor StationName");
217  }
218  } else {
219  // what are we missing?
220  throw CustomError ("Translocate: Missing Arguments");
221  }
222  }
223  } else if (args.argCount() == 4) { // 3 args - me, player, ship, coords, {invalid} : me, home, last, location, {invalid} : last, moon, planet, {invalid}
224  // test for 'help' command
225  if ((strcmp(args.arg(1).c_str(), Help) == 0)
226  or (strcmp(args.arg(2).c_str(), Help) == 0)
227  or (strcmp(args.arg(3).c_str(), Help) == 0))
228  throw CustomError ("Translocate: Invalid Arguments - 'help' not avalible for this command.");
229 
230  // check for coords
231  if ((args.isNumber(1))
232  and (args.isNumber(2))
233  and (args.isNumber(3)))
234  throw CustomError ("Translocate: Coords in current system - Use '.goto {x,y,z}' instead of this.");
235 
236  // decode first arg -- me, shipID, charID, playerName, {invalid}
237  if (args.isNumber(1)) {
238  int objectID = atoi(args.arg(1).c_str());
239  if (IsCharacterID(objectID)) {
240  pOtherClient = sEntityList.FindClientByCharID(objectID);
241  } else if (IsPlayerItem(objectID)) {
242  // get object's ownerID
243  pOtherClient = sEntityList.FindClientByCharID(objectID);
244  } else
245  throw CustomError ("Translocate: Invalid Object - %i is neither a character nor a ship", objectID);
246  } else if (strcmp(args.arg(1).c_str(), "me") == 0) {
247  // tr <me> to ?
248  // pClient doesnt change. do nothing here
249  me = true;
250  } else if (strcmp(args.arg(1).c_str(), "fleet") == 0) {
251  // tr <my fleet> to ?
252  fleet = true;
253  } else {
254  // this is either player name or invalid arg
255  throw CustomError ("Translocate: Invalid Arguments - searching by player name is incomplete at this time.");
256  }
257 
258  // decode second arg -- me, fleet, home, last, location, moon, planet, {invalid}
259  if (args.isNumber(2)) {
260  locationID = atoi(args.arg(2).c_str());
261  } else if (strcmp(args.arg(2).c_str(), "fleet") == 0) {
262  if (fleet)
263  throw CustomError ("Translocate: Fleet Move - You cannot tr a fleet to 'fleet'.");
264  // tr <my|player> fleet to last, moon, planet, {invalid}
265  fleet = true;
266  } else if (strcmp(args.arg(2).c_str(), "me") == 0) {
267  // tr <player|fleet> to me
268  me = true;
269  locationID = myLocationID;
270  } else if (strcmp(args.arg(2).c_str(), "ship") == 0) {
271  // tr <me|ship|player|fleet> to <ship|ship owner>
272  if (item)
273  throw CustomError ("Translocate: Ship Move - You cannot tr one ship to another ship...yet.");
274  item = true;
275  } else if (strcmp(args.arg(2).c_str(), "home") == 0) {
276  // tr <player|fleet> to <my|players> home
277  if (fleet)
278  throw CustomError ("Translocate: Fleet Move - You cannot tr a fleet 'home'...yet.");
279  locationID = pClient->GetCloneStationID();
280  } else if (strcmp(args.arg(2).c_str(), "last") == 0) {
281  if (fleet)
282  throw CustomError ("Translocate: Fleet Move - You cannot tr a fleet to last docked station...yet.");
283  // tr <player> me last -- tr <player> to my last docked station
284  // last station client was docked in
285  // if called with <player name> then uses that char's last station
286  if (pOtherClient != nullptr)
287  locationID = pOtherClient->GetDockStationID();
288  else
289  locationID = pClient->GetDockStationID();
290  } else if (strcmp(args.arg(2).c_str(), "moon") == 0) {
291  // random moon in client current system
292  SystemGPoint sGP;
293  pt = sGP.GetRandPointOnMoon(pOtherClient == nullptr ? pClient->GetSystemID() : pOtherClient->GetSystemID());
294  //throw CustomError ("Translocate: This option is Incomplete");
295  } else if (strcmp(args.arg(2).c_str(), "planet") == 0) {
296  // random planet in client current system
297  SystemGPoint sGP;
298  pt = sGP.GetRandPointOnPlanet(pOtherClient == nullptr ? pClient->GetSystemID() : pOtherClient->GetSystemID());
299  //throw CustomError ("Translocate: This option is Incomplete");
300  } else {
301  // what are we missing?
302  throw CustomError ("Translocate: Invalid Arguments");
303  }
304 
305  // decode third arg - last, moon, planet, {invalid}
306  if (args.isNumber(3)) {
307  // sending destination as itemID?
308  locationID = atoi(args.arg(2).c_str());
309  } else if (strcmp(args.arg(3).c_str(), "last") == 0) {
310  if (fleet)
311  throw CustomError ("Translocate: Fleet Move - You cannot tr a fleet to last docked station...yet.");
312  // tr <player> me last -- tr <player> to my last docked station
313  // last station client was docked in
314  // if called with <player name> then uses that char's last station
315  if (pOtherClient != nullptr)
316  locationID = pOtherClient->GetDockStationID();
317  else
318  locationID = pClient->GetDockStationID();
319  } else if (strcmp(args.arg(3).c_str(), "moon") == 0) {
320  // random moon in client current system
321  SystemGPoint sGP;
322  pt = sGP.GetRandPointOnMoon(pOtherClient == nullptr ? pClient->GetSystemID() : pOtherClient->GetSystemID());
323  //throw CustomError ("Translocate: This option is Incomplete");
324  } else if (strcmp(args.arg(3).c_str(), "planet") == 0) {
325  // random planet in client current system
326  SystemGPoint sGP;
327  pt = sGP.GetRandPointOnPlanet(pOtherClient == nullptr ? pClient->GetSystemID() : pOtherClient->GetSystemID());
328  //throw CustomError ("Translocate: This option is Incomplete");
329  } else {
330  // what are we missing?
331  throw CustomError ("Translocate: Invalid Arguments");
332  }
333 
334  } else if (args.argCount() == 5) { // 4 args - me, player, ship, coords, {invalid} : me, home, last, location, {invalid} : moon, planet, {invalid}
335  // test for 'help' command
336  if ((strcmp(args.arg(1).c_str(), Help) == 0)
337  or (strcmp(args.arg(2).c_str(), Help) == 0)
338  or (strcmp(args.arg(3).c_str(), Help) == 0)
339  or (strcmp(args.arg(4).c_str(), Help) == 0))
340  throw CustomError ("Translocate: Invalid Arguments - 'help' not avalible for this command.");
341 
342  // check for coords
343  if ((args.isNumber(1))
344  and (args.isNumber(2))
345  and (args.isNumber(3))
346  and (args.isNumber(4))) {
347  // pClient is caller, args are systemID and coords (assumed)
348  locationID = atoi(args.arg(1).c_str());
349  if (!sDataMgr.IsSolarSystem(locationID))
350  throw CustomError ("Translocate: Invalid Arguments - locationID %u is not a SolarSystemID.", locationID);
351  pt = GPoint(atoi(args.arg(2).c_str()), atoi(args.arg(3).c_str()), atoi(args.arg(4).c_str()));
352 
353  pClient->JumpOutEffect(locationID);
354  pClient->MoveToLocation(locationID, pt);
355  pClient->JumpInEffect();
356 
357  return nullptr;
358  }
359 
360  throw CustomError ("Translocate: 4 args - This command is currently incomplete.");
361  } else if (args.argCount() == 6) { // 5 args - me, player, ship, {invalid} : me, home, last, location, coords, {invalid} : moon, planet, {invalid}
362  // test for 'help' command
363  if ((strcmp(args.arg(1).c_str(), Help) == 0)
364  or (strcmp(args.arg(2).c_str(), Help) == 0)
365  or (strcmp(args.arg(3).c_str(), Help) == 0)
366  or (strcmp(args.arg(4).c_str(), Help) == 0)
367  or (strcmp(args.arg(5).c_str(), Help) == 0))
368  throw CustomError ("Translocate: Invalid Arguments - 'help' not avalible for this command.");
369 
370  throw CustomError ("Translocate: 5 args - This command is currently incomplete.");
371  } else {
372  throw CustomError ("Translocate: Too Many Arguments");
373  }
374 
375  if (fleet) {
376  // this will take a lil bit of doing....
377  throw CustomError ("Translocate: Fleet Move - This command is currently incomplete.");
378  }
379 
380  if (IsPlayerItem(locationID)) {
381  // locationID is sent as player item. this can be any celestial object, ship, pos, jetcan, wreck, etc.
382  // this will take a lil bit of doing to get booleans right.
383  InventoryItemRef iRef = sItemFactory.GetItem(locationID);
384  if (item) { // tr to ship/item location
385  pt = iRef->position();
386  locationID = iRef->locationID();
387  } else { // tr to ship/item owner location
388  Client* pClient2(sEntityList.FindClientByCharID(iRef->ownerID()));
389  if (pClient2 == nullptr) {
390  pt = iRef->position();
391  locationID = iRef->locationID();
392  } else if (pClient2->IsDocked()) {
393  pt = NULL_ORIGIN;
394  locationID = pClient2->GetLocationID();
395  } else {
396  pt = pClient2->GetShipSE()->GetPosition();
397  pt.MakeRandomPointOnSphere(100 + pClient->GetShipSE()->GetRadius() + pClient2->GetShipSE()->GetRadius());
398  locationID = pClient2->GetSystemID();
399  }
400  }
401  }
402  // connect to dataMgrs for location verification
403  else if (!sDataMgr.IsStation(locationID) and !sDataMgr.IsSolarSystem(locationID)) {
404  throw CustomError ("Translocate: Invalid Location %i", locationID);
405  }
406 
407  if (pOtherClient != nullptr) {
408  pOtherClient->JumpOutEffect(pOtherClient->GetLocationID());
409  pOtherClient->MoveToLocation(locationID, pt);
410  pOtherClient->JumpInEffect();
411  } else {
412  pClient->JumpOutEffect(myLocationID);
413  pClient->MoveToLocation(locationID, pt);
414  pClient->JumpInEffect();
415  }
416  return nullptr;
417 }
uint32 GetLocationID() const
Definition: Client.h:151
uint32 GetSystemID() const
Definition: Client.h:152
itemID[count] Create count or of the specified() x() y(z)-Jump to the specified position in space.Stopped." ) COMMAND( translocate
const std::string & arg(size_t index) const
Definition: Seperator.h:43
const GPoint GetRandPointOnMoon(uint32 systemID)
uint32_t GetSolarSystem(const char *name)
Definition: CommandDB.cpp:32
double GetRadius()
Definition: SystemEntity.h:208
void JumpOutEffect(uint32 locationID)
Definition: Client.cpp:1628
void JumpInEffect()
Definition: Client.cpp:1620
uint32 ownerID() const
Definition: InventoryItem.h:99
void MoveToLocation(uint32 location, const GPoint &pt)
Definition: Client.cpp:684
const GPoint & position() const
void SendInfoModalMsg(const char *fmt,...)
Definition: Client.cpp:2756
#define sEntityList
Definition: EntityList.h:208
Advanced version of UserError that allows to send a full custom message.
Definition: PyExceptions.h:453
itemID[count] Create count or of the specified item(from Insider)" ) COMMAND( goto
const GPoint GetRandPointOnPlanet(uint32 systemID)
size_t argCount() const
Definition: Seperator.h:44
Definition: gpoint.h:33
bool InFleet()
Definition: Client.h:142
#define IsPlayerItem(itemID)
Definition: EVE_Defines.h:256
static const GPoint NULL_ORIGIN(0, 0, 0)
#define snprintf
Definition: eve-compat.h:184
uint32 locationID() const
X * get() const
Definition: RefPtr.h:213
#define IsCharacterID(itemID)
Definition: EVE_Defines.h:206
Definition: Client.h:66
if(sConfig.world.saveOnMove)
int32 GetCloneStationID() const
Definition: Client.h:116
uint32 GetDockStationID()
Definition: Client.h:225
ShipSE * GetShipSE()
Definition: Client.h:168
static const std::array< std::string, 16 > badCharsSearch
Definition: EVE_Consts.h:108
bool isNumber(size_t index) const
Definition: Seperator.h:46
else
#define sItemFactory
Definition: ItemFactory.h:165
void MakeRandomPointOnSphere(double radius)
Definition: gpoint.h:46
#define IsNPC(itemID)
Definition: EVE_Defines.h:300
uint32_t GetStation(const char *name)
Definition: CommandDB.cpp:60
bool icontains(std::string data, std::string toSearch, size_t pos=0)
Definition: misc.cpp:194
#define sDataMgr

Here is the call graph for this function:

Here is the caller graph for this function:

PyResult Command_translocate ( Client pClient,
CommandDB db,
PyServiceMgr services,
const Seperator args 
)

Definition at line 48 of file SystemCommands.cpp.

References Command_tr().

48  {
49  return Command_tr(pClient,db,services,args);
50 }
PyResult Command_tr(Client *pClient, CommandDB *db, PyServiceMgr *services, const Seperator &args)

Here is the call graph for this function:

PyResult Command_unspawn ( Client pClient,
CommandDB db,
PyServiceMgr services,
const Seperator args 
)

Definition at line 578 of file SystemCommands.cpp.

References Seperator::arg(), cmd_find_nth_noneq(), cmd_parse_eq_arg(), codelog, DEFAULT_RANGE, InventoryItem::Delete(), Ga::GaVec3::distance(), EVEDB::invCategories::Drone, SystemBubble::GetEntities(), SystemEntity::GetPosition(), SystemManager::GetSE(), Client::GetShipSE(), Client::IsInSpace(), IsNumber(), Seperator::isNumber(), SystemManager::RemoveEntity(), sItemFactory, SystemEntity::SysBubble(), Client::SystemMgr(), and EVEDB::invGroups::Wreck.

579 {
580 #define DEFAULT_RANGE 500000
581  if (!pClient->IsInSpace()) {
582  throw CustomError ("You must be in space to unspawn things.");
583  }
584 
585  if (pClient->GetShipSE() == nullptr) {
586  throw CustomError ("/unspawn failed. You don't appear to have a ship?");
587  }
588  int target_index = cmd_find_nth_noneq(args, 1);
589  uint32 target = 0;
590  if (target_index > 0) {
591  if (!args.isNumber(target_index)) {
592  throw CustomError ("/unspawn called with non number");
593  }
594  target = atoi(args.arg(target_index).c_str());
595  }
596 
597  std::string range_str = cmd_parse_eq_arg(args, "range=");
598  std::string only_str = cmd_parse_eq_arg(args, "only=");
599 
600  codelog(COMMAND__ERROR, "unspawn got: %s %s %u",
601  range_str.c_str(), only_str.c_str(), target);
602 
603  uint32 range = DEFAULT_RANGE;
604 
605  if (range_str.size() > 0) {
606  if (!IsNumber(range_str)) {
607  throw CustomError ("/unspawn with range=x must be a number");
608  }
609  range = atoi(range_str.c_str());
610  }
611 
612  if ((range != DEFAULT_RANGE or
613  only_str.size() > 0) and
614  target != 0) {
615  throw CustomError ("/unspawn cannot be called with an explcit target and either range= or only=");
616  }
617 
618  if (target != 0) {
619  InventoryItemRef item_ref = sItemFactory.GetItem(target);
620  SystemEntity *sys_entity = pClient->SystemMgr()->GetSE(target);
621  if (sys_entity == nullptr) {
622  throw CustomError ("/unspawn failed. Item %u not found.", target);
623  }
624 
625  pClient->SystemMgr()->RemoveEntity(sys_entity);
626  item_ref->Delete();
627  codelog(COMMAND__MESSAGE, "/unspawn called with single target successful");
628  return new PyBool(true);
629  }
630 
631  if (only_str.size() == 0) {
632  throw CustomError ("/unspawn usage:<br> /unspawn [itemID]<br>/unspawn only=category|group<br>If using only the default range is 10k. You can set this by adding range=x in meters");
633  }
634 
635  bool is_category_match = false;
636  bool is_group_match = false;
637  uint16 match_id = 0;
638 
639  if (strcmp(only_str.c_str(), "categoryDrone") == 0) {
640  match_id = EVEDB::invCategories::Drone;
641  is_category_match = true;
642  } else if (strcmp(only_str.c_str(), "groupWreck") == 0) {
643  match_id = EVEDB::invGroups::Wreck;
644  is_group_match = true;
645  } else {
646  throw CustomError ("only='%s' not a supported group or category", only_str.c_str());
647  }
648 
649  SystemBubble *pBubble = pClient->GetShipSE()->SysBubble();
650  if (pBubble == nullptr) {
651  throw CustomError ("/unspawn failed. You don't appear to be in a bubble. Try /update");
652  }
653 
654  GPoint player_pos = pClient->GetShipSE()->GetPosition();
655 
656  std::map< uint32, SystemEntity* > entMap;
657  pBubble->GetEntities(entMap);
658  for (auto cur : entMap) {
659  if (is_group_match and match_id != cur.second->GetGroupID()) {
660  codelog(COMMAND__ERROR, "m: g%d c%d skipping match_id %u groupID %u",
661  is_group_match, is_category_match, match_id, cur.second->GetGroupID());
662  continue;
663  }
664  if (is_category_match and match_id != cur.second->GetCategoryID()) {
665  codelog(COMMAND__ERROR, "m: g%d c%d skipping match_id %u categoryID %u",
666  is_group_match, is_category_match, match_id, cur.second->GetGroupID());
667  continue;
668  }
669 
670  if (player_pos.distance(cur.second->GetPosition()) > range)
671  continue;
672 
673  cur.second->Delete();
674  }
675 
676 #undef DEFAULT_RANGE
677 
678  return new PyBool(true);
679 }
SystemEntity * GetSE(uint32 entityID) const
const std::string & arg(size_t index) const
Definition: Seperator.h:43
#define DEFAULT_RANGE
SystemBubble * SysBubble()
Definition: SystemEntity.h:195
void GetEntities(std::map< uint32, SystemEntity * > &into) const
std::string cmd_parse_eq_arg(const Seperator &args, const char *name)
bool IsInSpace()
Definition: Client.h:228
Advanced version of UserError that allows to send a full custom message.
Definition: PyExceptions.h:453
const GPoint & GetPosition() const
Definition: SystemEntity.h:211
Python boolean.
Definition: PyRep.h:323
Definition: gpoint.h:33
#define codelog(type, fmt,...)
Definition: logsys.h:128
SystemManager * SystemMgr() const
Definition: Client.h:92
void RemoveEntity(SystemEntity *pSE)
int cmd_find_nth_noneq(const Seperator &args, int n)
bool IsNumber(char c)
Checks whether character is a number.
unsigned __int32 uint32
Definition: eve-compat.h:50
ShipSE * GetShipSE()
Definition: Client.h:168
bool isNumber(size_t index) const
Definition: Seperator.h:46
virtual void Delete()
#define sItemFactory
Definition: ItemFactory.h:165
GaExpInl GaFloat distance(const GaVec3 &oth) const
Definition: GaTypes.h:158
unsigned __int16 uint16
Definition: eve-compat.h:48

Here is the call graph for this function:

PyResult Command_update ( Client pClient,
CommandDB db,
PyServiceMgr services,
const Seperator args 
)

Definition at line 758 of file SystemCommands.cpp.

References SystemEntity::DestinyMgr(), Client::EnterSystem(), SystemEntity::GetPosition(), Client::GetSessionChangeTime(), Client::GetShipSE(), Client::GetSystemID(), Client::IsInSpace(), Client::IsSessionChange(), NULL_ORIGIN(), sBubbleMgr, SystemBubble::SendAddBalls(), Client::SendInfoModalMsg(), DestinyManager::SendSetState(), Client::SetDestiny(), DestinyManager::SetPosition(), Client::SetSessionTimer(), Client::SetStateSent(), and SystemEntity::SysBubble().

758  {
759  if (!pClient->IsInSpace())
760  throw CustomError ("You're not in space.");
761  if (pClient->GetShipSE()->DestinyMgr() == nullptr)
762  pClient->SetDestiny(NULL_ORIGIN);
763  if (pClient->GetShipSE()->SysBubble() == nullptr)
764  pClient->EnterSystem(pClient->GetSystemID());
765  if (pClient->IsSessionChange()) {
766  pClient->SendInfoModalMsg("Session Change Active. Wait %u seconds before issuing another command.",
767  pClient->GetSessionChangeTime());
768  return new PyString("SessionChange Active. Request Denied.");
769  }
770 
771  pClient->GetShipSE()->DestinyMgr()->SetPosition(pClient->GetShipSE()->GetPosition(), true);
772 
773  SystemBubble *pBubble = pClient->GetShipSE()->SysBubble();
774  if (pBubble == nullptr) {
775  sBubbleMgr.Add(pClient->GetShipSE());
776  pBubble = pClient->GetShipSE()->SysBubble();
777  }
778  pBubble->SendAddBalls(pClient->GetShipSE());
779 
780  pClient->SetStateSent(false);
781  pClient->GetShipSE()->DestinyMgr()->SendSetState();
782  pClient->SetSessionTimer();
783  return new PyString("Update sent.");
784 }
bool IsSessionChange()
Definition: Client.h:241
uint32 GetSystemID() const
Definition: Client.h:152
void SendAddBalls(SystemEntity *to_who)
Python string.
Definition: PyRep.h:430
SystemBubble * SysBubble()
Definition: SystemEntity.h:195
void SendInfoModalMsg(const char *fmt,...)
Definition: Client.cpp:2756
uint32 GetSessionChangeTime()
Definition: Client.h:242
bool IsInSpace()
Definition: Client.h:228
Advanced version of UserError that allows to send a full custom message.
Definition: PyExceptions.h:453
void SendSetState() const
const GPoint & GetPosition() const
Definition: SystemEntity.h:211
DestinyManager * DestinyMgr()
Definition: SystemEntity.h:198
static const GPoint NULL_ORIGIN(0, 0, 0)
void SetStateSent(bool set=false)
Definition: Client.h:249
void SetPosition(const GPoint &pt, bool update=false)
ShipSE * GetShipSE()
Definition: Client.h:168
void SetDestiny(const GPoint &pt, bool update=false)
Definition: Client.cpp:847
void EnterSystem(uint32 systemID)
Definition: Client.cpp:679
void SetSessionTimer()
Definition: Client.h:250
#define sBubbleMgr

Here is the call graph for this function:

static PyResult generic_createitem ( Client pClient,
CommandDB db,
PyServiceMgr services,
const Seperator args 
)
static

Definition at line 419 of file SystemCommands.cpp.

References _log, ShipItem::AddItemByFlag(), Seperator::arg(), Seperator::argCount(), badCharsSearch, flagCargoHold, flagHangar, Client::GetCharacterID(), Client::GetShip(), Client::GetShipID(), Client::GetStationID(), EvE::icontains(), Client::IsInSpace(), Seperator::isNumber(), CommandDB::ItemSearch(), locTemp, sItemFactory, and strcasecmp.

Referenced by Command_create(), and Command_createitem().

419  {
420 
421  int typeID = -1;
422  if (args.isNumber(1)) {
423  typeID = atoi(args.arg(1).c_str());
424  } else {
425  // this hits db directly, so test for possible sql injection code
426  for (const auto cur : badCharsSearch)
427  if (EvE::icontains(args.arg(1), cur))
428  throw CustomError ("Name contains invalid characters");
429  std::map<uint32_t, std::string> matches;
430  if (!db->ItemSearch(args.arg(1).c_str(), matches))
431  throw CustomError ("Item not found");
432 
433  if (matches.size() > 1) {
434  auto c = matches.begin();
435  auto e = matches.end();
436  for (; c != e; c++) {
437  _log(COMMAND__MESSAGE, "Got match: %s\n", c->second.c_str());
438 
439  // POSIX standard btw
440  if (strcasecmp(c->second.c_str(), args.arg(1).c_str()) == 0)
441  typeID = c->first;
442  }
443  if (typeID == -1)
444  throw CustomError ("Item name is ambiguous. Please use a full item name");
445 
446  } else if (matches.size() == 1) {
447  auto cur = matches.begin();
448  _log(COMMAND__MESSAGE,
449  "ItemSearch returned type: \"%s\" given \"%s\"\n",
450  cur->second.c_str(), args.arg(1).c_str());
451  typeID = cur->first;
452  }
453  }
454  if (typeID == -1)
455  throw CustomError ("Unable to find valid type to create");
456 
457  if (typeID < 34)
458  throw CustomError ("Invalid Type ID.");
459 
460  int qty = 1;
461  if (2 < args.argCount()) {
462  if (args.isNumber(2))
463  qty = atoi(args.arg(2).c_str());
464  }
465 
466  _log(COMMAND__MESSAGE, "Create %s %u times", args.arg(1).c_str(), qty);
467 
468  //create into their cargo hold unless they are docked in a station,
469  //then stick it in their hangar instead.
470  uint32 locationID = 0;
471  EVEItemFlags flag;
472  if (pClient->IsInSpace()) {
473  locationID = pClient->GetShipID();
474  flag = flagCargoHold;
475  } else {
476  locationID = pClient->GetStationID();
477  flag = flagHangar;
478  }
479 
480  ItemData idata(
481  typeID,
482  pClient->GetCharacterID(),
483  locTemp, //temp location
484  flag,
485  qty
486  );
487 
488  InventoryItemRef iRef = sItemFactory.SpawnItem(idata);
489  if (iRef.get() == nullptr)
490  throw CustomError ("Unable to create item of type %s.", args.arg(1).c_str());
491 
492  //Move to location
493  if (pClient->IsInSpace())
494  pClient->GetShip()->AddItemByFlag(flag, iRef);
495  else
496  iRef->Move(locationID, flag, true);
497 
498  iRef->SaveItem();
499 
500  return new PyInt(iRef.get()->itemID());
501 }
uint32 GetShipID() const
Definition: Client.h:150
#define _log(type, fmt,...)
Definition: logsys.h:124
bool ItemSearch(const char *query, std::map< uint32, std::string > &into)
Definition: CommandDB.cpp:89
const std::string & arg(size_t index) const
Definition: Seperator.h:43
EVEItemFlags
Definition: EVE_Flags.h:13
int32 GetCharacterID() const
Definition: Client.h:113
bool IsInSpace()
Definition: Client.h:228
Advanced version of UserError that allows to send a full custom message.
Definition: PyExceptions.h:453
size_t argCount() const
Definition: Seperator.h:44
Python integer.
Definition: PyRep.h:231
ShipItemRef GetShip() const
Definition: Client.h:167
unsigned __int32 uint32
Definition: eve-compat.h:50
static const std::array< std::string, 16 > badCharsSearch
Definition: EVE_Consts.h:108
bool isNumber(size_t index) const
Definition: Seperator.h:46
uint32 AddItemByFlag(EVEItemFlags flag, InventoryItemRef iRef, Client *pClient=nullptr)
Definition: Ship.cpp:486
#define sItemFactory
Definition: ItemFactory.h:165
int32 GetStationID() const
Definition: Client.h:114
#define strcasecmp
Definition: eve-compat.h:262
bool icontains(std::string data, std::string toSearch, size_t pos=0)
Definition: misc.cpp:194

Here is the call graph for this function:

Here is the caller graph for this function: