138 _log(CLIENT__MESSAGE,
"ShipService bind request");
139 bind_args->
Dump(CLIENT__MESSAGE,
" ");
153 if (!args.Decode(&call.
tuple)) {
154 codelog(SERVICE__ERROR,
"%s: Failed to decode arguments.",
GetName());
161 if (pShipSE ==
nullptr)
162 throw CustomError (
"Invalid Ship. Ref: ServerError xxxxx");
166 throw CustomError (
"You cannot eject current ship with an active Cyno Field.");
171 throw CustomError (
"You cannot eject current ship while moving faster than 20m/s. Ref: ServerError 05139.");
174 if (pSystem ==
nullptr) {
182 if (pShipSE ==
nullptr) {
183 _log(SHIP__ERROR,
"Handle_Board() - Failed to get new ship %u for %s.", args.newShipID, pClient->
GetName());
184 throw CustomError (
"Something bad happened as you prepared to board the ship. Ref: ServerError 25107.");
188 codelog(ITEM__ERROR,
"Empty Pod %u in space. SystemID %u.", args.newShipID, pSystem->
GetID());
189 throw CustomError (
"You already have a pod. These cannot be boarded manally.");
196 throw CustomError (
"You cannot board the ship while it's moving faster than 20m/s. Ref: ServerError 05139.");
204 if (distance >
sConfig.world.shipBoardDistance)
205 throw CustomError (
"You are too far from %s to board it.<br>You must be within %u meters to board this ship.",\
208 pClient->
Board(pShipSE);
237 if (pShipSE ==
nullptr)
238 throw CustomError (
"Invalid Ship. Ref: ServerError xxxxx");
242 throw CustomError (
"You cannot eject with an active Cyno Field.");
247 throw CustomError (
"You cannot eject current ship while moving faster than 20m/s. Ref: ServerError 05139.");
268 Call_SingleIntegerArg arg;
269 if (!arg.Decode(&call.
tuple)) {
270 codelog(SERVICE__ERROR,
"%s: Failed to decode arguments.",
GetName());
278 if (podRef.
get() ==
nullptr)
287 return new PyInt(podID);
301 if (!args.Decode(&call.
tuple)) {
302 codelog(SERVICE__ERROR,
"%s: Failed to decode arguments.",
GetName());
308 if (newShipRef.
get() ==
nullptr) {
309 sLog.Error(
"ShipBound::Handle_ActivateShip()",
"%s: Failed to get new ship %u.", pClient->
GetName(), args.newShipID);
310 throw CustomError (
"Something bad happened as you prepared to board the ship. Ref: ServerError 15173+1");
322 rsp->
Dump(CLIENT__INFO,
" ");
338 Call_IntBoolArg
args;
339 if (!args.Decode(&call.
tuple)) {
340 codelog(SERVICE__ERROR,
"%s: Failed to decode arguments.",
GetName());
341 throw CustomError (
"Something bad happened as you prepared to board the ship. Ref: ServerError 15173");
346 if (pShip.
get() ==
nullptr) {
347 sLog.Error(
"ShipBound::Handle_ActivateShip()",
"%s: Failed to get ship item.", pClient->
GetName());
348 throw CustomError (
"Something bad happened as you prepared to board the ship. Ref: ServerError 15173");
352 bool ignoreContraband(args.arg2);
356 if (call.
byname.find(
"onlineModules") != call.
byname.end()) {
357 PyDict* onlineModules = call.
byname[
"onlineModules"]->AsDict();
359 _log(MODULE__INFO,
"Dumping 'onlineModules' List");
360 onlineModules->
Dump(MODULE__INFO,
" ");
363 for (; cur != end; ++cur)
378 _log(SHIP__INFO,
"ShipBound::Handle_Drop()");
379 call.
Dump(SHIP__INFO);
382 _log(SERVICE__ERROR,
"%s: Trying to drop items when not in space!", call.
client->
GetName());
387 if (!args.Decode(&call.
tuple)) {
388 codelog(SERVICE__ERROR,
"%s: Failed to decode arguments.",
GetName());
392 PyList* PyToDropList = args.toDrop;
393 uint32 ownerID = args.ownerID;
397 bool dropped =
false, shipDrop =
false;
401 if (pSystem ==
nullptr) {
408 double radius = pShip->
radius();
412 for (
uint32 i = 0; i < PyToDropList->
size(); ++i) {
417 qty = PyToDropList->
items.at(i)->AsTuple()->items.at(1)->AsInt()->value();
418 itemID = PyToDropList->
items.at(i)->AsTuple()->items.at(0)->AsInt()->value();
420 if (iRef.get() ==
nullptr) {
421 sLog.Error(
"ShipBound::Handle_Drop()",
"%s: Unable to find item %u to drop.", pClient->
GetName(),
itemID);
425 switch (iRef->categoryID()) {
427 if (!
sConfig.testing.EnableDrones) {
432 throw UserError (
"NoDroneManagementAbilities")
437 throw UserError (
"NoDroneManagementAbilitiesLeft")
444 throw UserError (
"DropItemNotInDroneBay")
451 for (
uint8 i = 0; i < qty; ++i) {
453 if (newItem.
get() ==
nullptr) {
454 _log(INV__ERROR,
"ShipBound::Handle_Drop() - Error splitting item %u. Skipping.", iRef->itemID());
458 _log(INV__ERROR,
"ShipBound::Handle_Drop() - Split item %u qty > 1 (%u). Continuing.", newItem->
itemID(), newItem->
quantity());
486 pClient->
SendErrorMsg(
"This Moon already has a Control Tower in orbit. Aborting Drop.");
491 pClient->
SendErrorMsg(
"You need an anchored Control Tower before launching modules. Aborting Drop.");
504 entity.
itemID = iRef->itemID();
506 entity.
typeID = iRef->typeID();
507 entity.
groupID = iRef->groupID();
512 iRef->SetPosition(location + iRef->radius() + radius);
513 iRef->ChangeOwner(entity.
ownerID);
521 if (pSE ==
nullptr) {
528 iRef->ChangeSingleton(
true);
537 pClient->
SendNotifyMsg(
"Launching Deployables isnt available yet.");
546 pClient->
SendErrorMsg(
"Launching sovereignty structures is forbidden in empire space.");
552 pClient->
SendErrorMsg(
"You must be part of an alliance to launch a sovereignty structure.");
556 switch (iRef->groupID()) {
559 std::vector<uint16> gateBubbles;
561 if (cur.second->IsGateSE())
563 gateBubbles.push_back(cur.second->SysBubble()->GetID());
566 if (!(std::find(gateBubbles.begin(), gateBubbles.end(),pClient->
GetShipSE()->
SysBubble()->
GetID())!=gateBubbles.end()))
568 pClient->
SendErrorMsg(
"Sovereignty blockade units must be deployed near a stargate.");
574 pClient->
SendErrorMsg(
"You cannot launch a Sovereignty Blockade Unit in an unclaimed system.");
580 pClient->
SendErrorMsg(
"You cannot launch a Sovereignty Blockade Unit in a system claimed by your alliance");
587 pClient->
SendErrorMsg(
"There is already a Sovereignty Blockade Unit on this stargate. Aborting Drop.");
593 if (cur.second->IsSBUSE())
597 pClient->
SendErrorMsg(
"There is already a Sovereignty Blockade Unit on this stargate. Aborting Drop.");
608 if (cur.second->IsTCUSE())
610 pClient->
SendErrorMsg(
"There is already a Territorial Claim Unit in this system. Aborting Drop.");
617 pClient->
SendErrorMsg(
"This system has already been claimed. ");
624 if (cur.second->IsIHubSE())
626 pClient->
SendErrorMsg(
"There is already an Infrastructure Hub this system. Aborting Drop.");
633 pClient->
SendErrorMsg(
"You cannot launch an Infrastructure Hub in a system not claimed by your alliance.");
644 entity.
itemID = iRef->itemID();
646 entity.
typeID = iRef->typeID();
647 entity.
groupID = iRef->groupID();
652 iRef->SetPosition(location + iRef->radius() + radius);
653 iRef->ChangeOwner(entity.
ownerID);
658 if (pSE ==
nullptr) {
665 iRef->ChangeSingleton(
true);
674 _log(INV__ERROR,
"ShipBound::Handle_Drop() - Item %s (cat %u) is neither drone, structure or deployable.", iRef->name(), iRef->categoryID());
702 Call_SingleIntegerArg arg;
703 if (!arg.Decode(&call.
tuple)) {
704 codelog(SERVICE__ERROR,
"%s: Failed to decode arguments.",
GetName());
711 if (pSysMgr ==
nullptr) {
712 codelog(CLIENT__ERROR,
"%s: Client has no system manager.", pClient->
GetName());
716 if (pSE ==
nullptr) {
717 _log(SERVICE__ERROR,
"%s: Unable to find object %u to scoop.", pClient->
GetName(), arg.arg);
731 throw CustomError (
"%s is under another pilot's control. Cannot scoop.", pSE->
GetName());
734 if (iRef.
get() ==
nullptr) {
735 codelog(CLIENT__ERROR,
"ItemRef for %s not found.", arg.arg);
752 pSysMgr->RemoveEntity(pSE);
761 Call_SingleIntList
args;
762 if (!args.Decode(&call.
tuple)) {
763 codelog(SERVICE__ERROR,
"%s: Failed to decode arguments.",
GetName());
772 std::vector<int32>::const_iterator cur = args.ints.begin();
773 for(; cur != args.ints.end(); ++cur) {
774 pDroneSE = pSysMgr->
GetSE(*cur);
775 if (pDroneSE ==
nullptr) {
776 _log(SERVICE__ERROR,
"%s: Unable to find droneSE %u to scoop.", pClient->
GetName(), *cur);
780 iRef = pDroneSE->GetSelf();
781 if (iRef.
get() ==
nullptr) {
782 _log(SERVICE__ERROR,
"%s: Unable to find droneItem %u to scoop.", pClient->
GetName(), *cur);
791 if (pDroneSE->GetDroneSE()->IsEnabled())
792 if (pDroneSE->GetDroneSE()->GetOwner() != pClient)
793 throw CustomError (
"The %s is under another pilot's control. Cannot scoop.", pDroneSE->GetName());
802 pSysMgr->RemoveEntity(pDroneSE);
813 Call_SingleIntList
args;
814 if (!args.Decode(&call.
tuple)) {
815 codelog(SERVICE__ERROR,
"%s: Failed to decode arguments.",
GetName());
822 _log(SERVICE__ERROR,
"%s: Trying to jettison items when not in space!", pClient->
GetName());
849 std::vector<int32>::iterator itr = args.ints.begin();
851 for (; itr != args.ints.end(); ++itr) {
854 if (iRef.
get() ==
nullptr)
861 if (sRef.get() ==
nullptr)
862 throw CustomError (
"Unable to spawn Structure item of type %u.", sRef->typeID());
866 location.MakeRandomPointOnSphere(1500.0 + sRef->type().radius());
869 pSysMgr->AddEntity(sSE);
871 itr = args.ints.erase(itr);
875 if (sRef.get() ==
nullptr)
876 throw CustomError (
"Unable to spawn Structure item of type %u.", sRef->typeID());
880 location.MakeRandomPointOnSphere(1500.0 + sRef->type().radius());
883 pSysMgr->AddEntity(sSE);
885 itr = args.ints.erase(itr);
889 if (cRef.get() ==
nullptr)
890 throw CustomError (
"Unable to spawn Deployable item of type %u.", cRef->typeID());
896 location.MakeRandomPointOnSphere(1500.0 + cRef->type().radius());
899 pSysMgr->AddEntity(dSE);
901 itr = args.ints.erase(itr);
915 if (ccRef.get() ==
nullptr)
916 throw CustomError (
"Unable to spawn item of type %u.", ccRef->typeID());
920 location.MakeRandomPointOnSphere(500.0);
923 pSysMgr->AddEntity(cSE);
927 args.ints.erase(itr);
928 itr = args.ints.end();
938 sLog.Warning(
"Ship::Jettison",
"%s: %s called to jettison.",pClient->
GetName(), iRef->
name());
942 sLog.Error(
"Ship::Jettison",
"%s: %s called to jettison.",pClient->
GetName(), iRef->
name());
950 for (
auto cur : args.ints) {
952 if (iRef.
get() ==
nullptr)
956 if ((ccRef.get() ==
nullptr) and (jcRef.get() ==
nullptr)) {
962 location.MakeRandomPointOnSphere(500.0);
968 "Jettisoned Cargo Container",
972 if (jcRef.get() ==
nullptr)
979 jcRef->SetAnchor(
true);
980 pSysMgr->AddEntity(cSE);
986 if (ccRef.get() !=
nullptr) {
987 if (ccRef->GetMyInventory()->HasAvailableSpace(
flagNone, iRef)) {
991 float remainingCapacity = jcRef->GetMyInventory ()->GetRemainingCapacity (
flagNone);
998 _log(ITEM__WARNING,
"%s: CargoContainer %u is full.", pClient->
GetName(), ccRef->itemID());
999 throw UserError (
"NotAllItemsWereMoved");
1001 }
else if (jcRef.get() !=
nullptr) {
1002 if (jcRef->GetMyInventory()->HasAvailableSpace(
flagNone, iRef)) {
1006 float remainingCapacity = jcRef->GetMyInventory ()->GetRemainingCapacity (
flagNone);
1014 _log(ITEM__WARNING,
"%s: Jetcan %u is full.", pClient->
GetName(), jcRef->itemID());
1015 throw UserError (
"NotAllItemsWereMoved");
1018 _log(ITEM__ERROR,
"Jettison call for %s - no CC or Jcan.", pClient->
GetName());
1019 throw CustomError (
"Item container not found.", cRef->typeID());
1056 call.
Dump(COLLECT__CALL_DUMP);
1060 bool t3Ship =
false;
1061 std::vector<int32> itemIDList;
1062 PyList* subSystemList(
nullptr);
1063 if (call.
byname.find(
"subSystems") != call.
byname.end()) {
1084 subSystemList = call.
byname.find(
"subSystems")->second->AsList();
1086 Call_AssembleShip
args;
1087 if (!args.Decode(&call.
tuple)) {
1088 codelog(SERVICE__ERROR,
"%s: Failed to decode arguments.",
GetName());
1091 itemIDList = args.items;
1104 sLog.Error(
"AssembleShip",
"tuple size == 2 and ([0] != int and [1] != string) or some shit like that.");
1107 sLog.Error(
"Handle_AssembleShip",
"end of conditional" );
1112 for (
auto cur : itemIDList) {
1115 if (
ship.get() ==
nullptr) {
1116 _log(ITEM__ERROR,
"Failed to load ship %u to assemble.", cur);
1121 if (
ship->quantity() > 1) {
1125 if (
ship.get() ==
nullptr) {
1126 _log(ITEM__ERROR,
"Failed to split stack to assemble ship %u.", cur);
1132 if (subSystemList ==
nullptr) {
1134 sLog.Error(
"AssembleShip",
"subSystemList == nullptr for %s", call.
client->
GetName());
1140 while (itr != end) {
1142 if (subSystemItem.get() !=
nullptr)
1148 ship->ChangeSingleton(
true,
true);
1190 _log(SERVICE__CALL_DUMP,
"ShipBound::Handle_LaunchFromContainer()");
1191 call.
Dump(SERVICE__CALL_DUMP);
1201 _log(SERVICE__CALL_DUMP,
"ShipBound::Handle_ScoopToSMA()");
1202 call.
Dump(SERVICE__CALL_DUMP);
1212 _log(SERVICE__CALL_DUMP,
"ShipBound::Handle_BoardStoredShip()");
1213 call.
Dump(SERVICE__CALL_DUMP);
1222 _log(SERVICE__CALL_DUMP,
"ShipBound::Handle_StoreVessel()");
1223 call.
Dump(SERVICE__CALL_DUMP);
#define sConfig
A macro for easier access to the singleton.
PyCallable_Make_InnerDispatcher(ShipService) ShipService
Dispatcher *const m_dispatch
Dispatcher *const m_dispatch
void SetPosition(const GPoint &pos)
virtual InventoryItemRef Split(int32 qty=0, bool notify=true, bool silent=false)
virtual DroneSE * GetDroneSE()
SystemEntity * GetSE(uint32 entityID) const
uint32 GetLocationID() const
void AddEntity(SystemEntity *pSE, bool addSignal=true)
UserError & AddTimeShort(const char *name, time_t time)
Shorthand method for adding the given time as a time string in the message (without minutes) ...
void SendErrorMsg(const char *fmt,...)
uint32 GetSystemID() const
#define _log(type, fmt,...)
PyRep * GetItem(size_t index) const
Returns Python object.
void ScoopDrone(SystemEntity *pSE)
PyRep * GetItemString(const char *key) const
Obtains database entry based on given key string.
virtual MoonSE * GetMoonSE()
void Drop(SystemBubble *pBubble)
std::map< std::string, PyRep * > byname
virtual void AddItem(InventoryItemRef iRef)
const GPoint & position() const
void SendJettisonPacket() const
void VerifyHoldType(EVEItemFlags flag, InventoryItemRef iRef, Client *pClient=nullptr)
SystemBubble * SysBubble()
virtual ShipSE * GetShipSE()
ShipItemRef GetShipItemRef()
void MoveItem(uint32 itemID, uint32 location, EVEItemFlags flag)
UserError & AddTypeName(const char *name, uint32 typeID)
Shorthand method for adding a type's name.
SystemEntity * GetClosestGateSE(const GPoint &myPos)
int32 GetCharacterID() const
int32 GetWarFactionID() const
int32 GetCorporationID() const
storage_type::const_iterator const_iterator
static uint32 IntegerValueU32(PyRep *pRep)
std::string m_strBoundObjectName
bool ValidateBoardShip(CharacterRef who)
UserError & AddFormatValue(const char *name, PyRep *value)
Fluent version of the protected AddKeyword, allows for adding a keyword to the exception.
void SendNotifyMsg(const char *fmt,...)
Dispatcher *const m_dispatch
CharacterRef GetChar() const
uint32 GetClosestPlanetID(const GPoint &myPos)
Advanced version of UserError that allows to send a full custom message.
void Dump(FILE *into, const char *pfx) const
Dumps object to file.
int32 GetAllianceID() const
const GPoint & GetPosition() const
void Move(uint32 new_location=locTemp, EVEItemFlags flag=flagNone, bool notify=false)
void SafeDelete(T *&p)
Deletes and nullifies a pointer.
PyCallable_Make_Dispatcher(ShipBound) ShipBound(PyServiceMgr *mgr
void _SetCallDispatcher(CallDispatcher *d)
void SetFleetSMBUsage(bool set=false)
#define is_log_enabled(type)
#define sLog
Evaluates to a NewLog instance.
ShipItemRef GetShipFromInventory(uint32 shipID)
DestinyManager * DestinyMgr()
PyRep * GetLinkedWeapons()
InventoryItemRef GetSelf()
PyCallable_DECL_CALL(Board)
#define codelog(type, fmt,...)
void SetItem(size_t index, PyRep *object)
Stores Python object.
static SystemEntity * BuildEntity(SystemManager &pSysMgr, const DBSystemDynamicEntity &entity)
SystemManager * SystemMgr() const
virtual bool IsContainerSE()
std::string GetBindStr() const
void MakeRandomPointOnSphereLayer(double radiusInner, double radiusOuter)
bool AlterQuantity(int32 qty, bool notify=false)
virtual SystemEntity * GetSE()
PyServiceMgr *const m_manager
ShipItemRef GetShip() const
const char * GetName() const
void ChangeOwner(uint32 new_owner, bool notify=false)
void Board(ShipSE *newShipSE)
const char * GetName() const
Python object "ccp_exceptions.UserError".
#define PyCallable_REG_CALL(c, m)
SystemEntity * GetClosestMoonSE(const GPoint &myPos)
void AddModuleToOnlineVec(uint32 modID)
itemID[count] Create count or of the specified() x() entityID Translocate to the specified entity Immediately stops ship
static RefPtr StaticCast(const RefPtr< Y > &oth)
Acts as static_cast from one RefPtr to another.
virtual StructureSE * GetPOSSE()
std::map< uint32, SystemEntity * > GetOperationalStatics()
const_iterator begin() const
bool LaunchDrone(InventoryItemRef dRef)
PyServiceMgr *const m_manager
void BoardShip(ShipItemRef newShipRef)
storage_type::const_iterator const_iterator
EvilNumber GetAttribute(const uint16 attrID) const
typeID Spawn an NPC with the specified type text Search for items matching the specified query() type()() itemID() copy() materialLevel()() itemID(attributeID)-Retrieves attribute value." ) COMMAND( setattr
void Dump(LogType type) const
PyDict * GetChargeState()
virtual PyBoundObject * CreateBoundObject(Client *pClient, const PyRep *bind_args)
const_iterator end() const
virtual ContainerSE * GetContSE()
virtual StargateSE * GetGateSE()
int32 GetStationID() const
GaExpInl GaFloat distance(const GaVec3 &oth) const
Inventory * GetMyInventory()
void SetItem(PyRep *key, PyRep *value)
SetItem adds or sets a database entry.
bool ValidateAddItem(EVEItemFlags flag, InventoryItemRef iRef) const
void SetItemString(const char *key, PyRep *value)
SetItemString adds or sets a database entry.
const char * GetName() const