EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
InventoryBound Class Reference

#include "InventoryBound.h"

Inheritance diagram for InventoryBound:
Collaboration diagram for InventoryBound:

Public Member Functions

 InventoryBound (PyServiceMgr *mgr, InventoryItemRef item, EVEItemFlags flag, uint32 ownerID, bool passive)
 
virtual ~InventoryBound ()
 
virtual void Release ()
 
 PyCallable_DECL_CALL (List)
 
 PyCallable_DECL_CALL (Add)
 
 PyCallable_DECL_CALL (MultiAdd)
 
 PyCallable_DECL_CALL (GetItem)
 
 PyCallable_DECL_CALL (RemoveChargeToCargo)
 
 PyCallable_DECL_CALL (RemoveChargeToHangar)
 
 PyCallable_DECL_CALL (MultiMerge)
 
 PyCallable_DECL_CALL (StackAll)
 
 PyCallable_DECL_CALL (StripFitting)
 
 PyCallable_DECL_CALL (DestroyFitting)
 
 PyCallable_DECL_CALL (SetPassword)
 
 PyCallable_DECL_CALL (CreateBookmarkVouchers)
 
 PyCallable_DECL_CALL (RunRefiningProcess)
 
 PyCallable_DECL_CALL (ImportExportWithPlanet)
 
 PyCallable_DECL_CALL (TakeOutTrash)
 
 PyCallable_DECL_CALL (ListDroneBay)
 
- Public Member Functions inherited from PyBoundObject
 PyBoundObject (PyServiceMgr *mgr)
 
virtual ~PyBoundObject ()
 
uint32 nodeID () const
 
uint32 bindID () const
 
std::string GetBindStr () const
 
const char * GetName () const
 
virtual PyResult Call (const std::string &method, PyCallArgs &args)
 
- Public Member Functions inherited from PyCallable
 PyCallable ()
 
virtual ~PyCallable ()
 

Protected Member Functions

std::vector< int32CatSortItems (std::vector< InventoryItemRef > &itemVec)
 
PyRepMoveItems (Client *pClient, std::vector< int32 > &items, EVEItemFlags toFlag, int32 quantity, bool manyFlags, float capacity)
 
- Protected Member Functions inherited from PyBoundObject
void _SetNodeBindID (uint32 nodeID, uint32 bindID)
 
- Protected Member Functions inherited from PyCallable
void _SetCallDispatcher (CallDispatcher *d)
 

Protected Attributes

bool m_passive
 
EVEItemFlags m_flag
 
uint32 m_itemID
 
uint32 m_ownerID
 
Dispatcher *const m_dispatch
 
InventorypInventory
 
InventoryItemRef m_self
 
- Protected Attributes inherited from PyBoundObject
PyServiceMgr *const m_manager
 
std::string m_strBoundObjectName
 

Detailed Description

Definition at line 32 of file InventoryBound.h.

Constructor & Destructor Documentation

InventoryBound::InventoryBound ( PyServiceMgr mgr,
InventoryItemRef  item,
EVEItemFlags  flag,
uint32  ownerID,
bool  passive 
)
InventoryBound::~InventoryBound ( )
virtual

Definition at line 79 of file InventoryBound.cpp.

References m_dispatch.

80 {
81  delete m_dispatch;
82 }
Dispatcher *const m_dispatch

Member Function Documentation

std::vector< int32 > InventoryBound::CatSortItems ( std::vector< InventoryItemRef > &  itemVec)
protected

Definition at line 666 of file InventoryBound.cpp.

References InventoryItem::categoryID(), GetTimeUSeconds(), items, sConfig, and sLog.

667 {
668  /* sorts a vector of items by category, with loaded modules first (in slot order), then loaded charges (in slot order), then cargo
669  * if there is only one item, no sorting required...
670  * this is called on fitting a group of modules from MultiAdd
671  * -allan
672  */
673  std::vector<int32> items;
674  if (itemVec.size() < 2) {
675  items.push_back(itemVec.at(0)->itemID());
676  return items;
677  }
678 
679  uint16 count(0);
680  double start(0.0);
681  if (sConfig.debug.IsTestServer and sConfig.debug.UseProfiling)
682  start = GetTimeUSeconds();
683 
684  //begin basic sort
685  bool done(false);
686  InventoryItemRef tmp(nullptr);
687  while (!done) {
688  done = true; //assume sorted
689  //iterate though list
690  for (int i = 0, i2 = 1; (i < itemVec.size()) and (i2 < itemVec.size()); ++i, ++i2) {
691  //check if each pair is sorted by category. modules -> charges -> subsystems
692  if (itemVec[i]->categoryID() < itemVec[i2]->categoryID()) {
693  //it's not, so flip the values
694  tmp = itemVec[i];
695  itemVec[i] = itemVec[i2];
696  itemVec[i2] = tmp;
697  done = false; //we weren't sorted, so now go back and check if we are
698  }
699  ++count;
700  }
701  }
702 
703  for (auto cur : itemVec)
704  items.push_back(cur->itemID());
705 
706  if (sConfig.debug.IsTestServer and sConfig.debug.UseProfiling)
707  sLog.Warning("IB::CatSortItems", "%u items sorted in %.3fus with %u loops.", items.size(), (GetTimeUSeconds() - start), count);
708 
709  return items; //returns sorted list
710 }
#define sConfig
A macro for easier access to the singleton.
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
double GetTimeUSeconds()
Definition: utils_time.cpp:116
unsigned __int16 uint16
Definition: eve-compat.h:48
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 items

Here is the call graph for this function:

PyRep * InventoryBound::MoveItems ( Client pClient,
std::vector< int32 > &  items,
EVEItemFlags  toFlag,
int32  quantity,
bool  manyFlags,
float  capacity 
)
protected

Definition at line 410 of file InventoryBound.cpp.

References _log, InventoryItem::AddItem(), ShipItem::AddItemByFlag(), EVEDB::invGroups::Assembly_Array, EVEDB::invTypes::Bookmark, InventoryItem::categoryID(), EVEDB::invCategories::Celestial, EVEDB::invCategories::Charge, codelog, EVEDB::invGroups::Control_Tower, EVEDB::invGroups::Corporate_Hangar_Array, EVEDB::invGroups::Cynosural_Generator_Array, InventoryItem::Donate(), EVEDB::invGroups::Electronic_Warfare_Battery, EVEDB::invGroups::Energy_Neutralizing_Battery, ShipItem::FindAvailableModuleSlot(), InventoryItem::flag(), flagCargoHold, flagCorpMarket, flagDroneBay, flagIllegal, flagImpounded, flagLocked, flagNone, RefPtr< X >::get(), ShipItem::GetModule(), Client::GetShip(), InventoryItem::GetShipItem(), InventoryItem::groupID(), IsCargoHoldFlag, IsHangarFlag, IsModuleSlot, IsPlayerCorp, IsRigSlot, InventoryItem::itemID(), InventoryItem::locationID(), EVEDB::invGroups::Logistics_Array, m_flag, m_itemID, m_ownerID, m_self, EVEDB::invGroups::Mobile_Hybrid_Sentry, EVEDB::invGroups::Mobile_Laser_Sentry, EVEDB::invGroups::Mobile_Missile_Sentry, EVEDB::invGroups::Mobile_Projectile_Sentry, EVEDB::invCategories::Module, ShipItem::MoveModuleSlot(), InventoryItem::name(), EVEDB::invTypes::Office, EVEDB::invGroups::Orbital_Construction_Platform, EVEDB::invGroups::Orbital_Infrastructure, EVEDB::invCategories::Orbitals, pInventory, InventoryItem::quantity(), EVEDB::invGroups::Refining_Array, ShipItem::RemoveItem(), EVEDB::invGroups::Scanner_Array, sDataMgr, Client::SendNotifyMsg(), EVEDB::invGroups::Sensor_Dampening_Battery, EVEDB::invGroups::Shield_Hardening_Array, EVEDB::invCategories::Ship, ship, EVEDB::invGroups::Ship_Maintenance_Array, sItemFactory, InventoryItem::Split(), EVEDB::invGroups::Stasis_Webification_Battery, RefPtr< X >::StaticCast(), EVEDB::invCategories::Station, EVEDB::invGroups::Station, EVEDB::invGroups::Station_Services, EVEDB::invGroups::Stealth_Emitter_Array, EVEDB::invCategories::Structure, EVEDB::invGroups::Structure_Repair_Array, EVEDB::invGroups::Target_Painting_Battery, EvE::traceStack(), EVEDB::invCategories::Trading, ShipItem::TryModuleLimitChecks(), InventoryItem::typeID(), ShipItem::UnloadModule(), Inventory::ValidateAddItem(), ShipItem::VerifyHoldType(), and EVEDB::invGroups::Warp_Scrambling_Battery.

411 { // complete method rewrite -allan 21Dec17
412  ShipItem* pShip = pClient->GetShip().get();
413  bool donating = false, ship = false, customs = false;
414  int32 origQty = quantity;
415 
416  // we will need to check *this for specific item-moving rules
417  switch (m_self->categoryID()) {
418  // specific container-type categories that may move items in/out
420  // this shouldnt hit. trading is handled in separate system
421  codelog(INV__ERROR, "IB::MoveItems() - Trading Category called.");
422  EvE::traceStack();
423  } break;
425  // this is all POS groups. use corp donating checks
426  donating = true;
427  // may have to reset flags based on type
428  switch (m_self->groupID()) {
430  // flag 0 = fuel bay, flag = 122 strontium bay (2nd storage)
431  } break;
436  // flag 27 = hislot0 using ammo capy
437  } break;
444  } break;
455  } break;
456  default: {
457  } break;
458  }
459  } break;
461  switch (m_self->groupID()) {
463  // standard station hangar
464  if (toFlag == flagCorpMarket)
465  donating = true;
466  if (toFlag == flagImpounded)
467  donating = true;
468  //if (toFlag == flagDelivery)
469  // donating = true;
470  if (toFlag == flagLocked) {
471  ; // do tests here for moving locked items (corp role config and ??)
472  }
473  } break;
475  // station offices, office and factory folders.
476  if (m_self->typeID() == EVEDB::invTypes::Office) //office. use corp donating checks
477  donating = true;
478  } break;
479  }
480  } break;
482  switch (m_self->groupID()) {
484  ; // not sure what to do here yet
485  } break;
487  // orbital command centers and customs offices
488  // we dont change owners of xfered items
489  customs = true;
490  } break;
491  }
492  } break;
494  // containers, wrecks, construction platform, station improve/upgrade platform,
495  if (IsPlayerCorp(m_ownerID))
496  donating = true;
497  } break;
499  // do module checks and specific removeItem() for these items
500  ship = true;
501  // will need to add checks on from container to verify donating flag here.
502  //donating = true;
503  } break;
504  }
505 
506  EVEItemFlags fromFlag(flagNone);
507  EVEItemFlags origFlag(toFlag);
508  InventoryItemRef iRef(nullptr);
509  sItemFactory.SetUsingClient(pClient);
510 
511  std::vector<int32>::const_iterator itr = items.begin();
512  for (; itr != items.end(); ++itr) {
513  // reset vars for adding multiple items
514  toFlag = origFlag;
515  quantity = origQty;
516 
517  iRef = sItemFactory.GetItem(*itr);
518  if (iRef.get() == nullptr) {
519  _log(INV__ERROR, "IB::MoveItems() - item %i not found. continuing.", (*itr));
520  continue;
521  }
522 
523  if (iRef->typeID() == EVEDB::invTypes::Bookmark) {
524  // update this to keep owner/creator and other data
525  iRef->Donate(m_ownerID, m_itemID, toFlag);
526  continue;
527  }
528 
529  fromFlag = iRef->flag();
530 
531  if (moveStack)
532  quantity = iRef->quantity();
533 
534  // if client send capy, it is TOTAL space in this container, NOT current space.
535  if (capacity > 0) {
536  if (quantity < 1)
537  quantity = iRef->quantity(); // assume all.
538  } else if (quantity < 1) {
539  _log(INV__ERROR, "IB::MoveItems() - Quantity < 1. Setting quantity = 1.");
540  quantity = 1;
541  }
542 
543  // check for items that need specific handling
544  if (IsRigSlot(fromFlag)) // cant remove rigs like this. send error.
545  throw UserError ("CannotRemoveUpgradeManually");
546  else if (IsModuleSlot(fromFlag)) {
547  // can we remove modules from an inactive ship? not yet...
548  if (pShip == nullptr)
549  throw CustomError ("Ship not found. The %s wasnt moved. Ref: ServerError 63290", iRef->name());
550 
551  //if (sDataMgr.IsSolarSystem(pShip->locationID()))
552  // throw CustomError ("You cannot remove modules in space.");
553 
554  // verify module isnt active here (before we get too far in processing)
555  GenericModule* pMod = pShip->GetModule(fromFlag);
556  if (pMod == nullptr)
557  throw CustomError ("That module was not found. Chances are this is a server error, and either docking or reloging will correct it.");
558  if (pMod->IsActive())
559  throw CustomError ("Your %s is currently active. You must wait for the cycle to complete before it can be removed.", pMod->GetSelf()->name());
560 
561  if (IsModuleSlot(toFlag)) {
562  if (sDataMgr.IsSolarSystem(pShip->locationID()))
563  throw CustomError ("You cannot exchange module slots in space.");
564  //ModulesNotLoadableInSpace <-- this needs {device} but i dont know what module it is
565 
566  // we are wanting to change slots on a fitted module.
567  pShip->MoveModuleSlot(fromFlag, toFlag);
568  Call_SingleIntegerArg result;
569  result.arg = iRef->itemID();
570  return result.Encode();
571  } else {
572  // are we just unloading charges?
573  if (iRef->categoryID() == EVEDB::invCategories::Charge) {
574  pShip->UnloadModule(pMod);
575  return nullptr;
576  }
577  pShip->RemoveItem(iRef);
578  }
579  }
580 
581  if (!moveStack and (quantity < iRef->quantity())) {
582  InventoryItemRef newItem = iRef->Split(quantity);
583  if (newItem.get() == nullptr) {
584  _log(INV__ERROR, "IB::MoveItems() - Error splitting item %u. Skipping.", iRef->itemID());
585  continue;
586  }
587  iRef = newItem;
588  if (iRef.get() == nullptr) {
589  _log(INV__ERROR, "IB::MoveItems() - Error getting split item. Skipping.");
590  continue;
591  }
592  if (iRef->quantity() > quantity) {
593  _log(INV__ERROR, "IB::MoveItems() - Split item %u qty(%u) > requested qty of %u. Continuing.", \
594  iRef->itemID(), iRef->quantity(), quantity);
595  }
596  }
597 
598  if (donating) {
599  iRef->Donate(m_ownerID, m_itemID, toFlag);
600  continue;
601  }
602 
603  // move item to new location
604  if (ship) {
605  // are we adding module to ship using autoFit?
606  if (toFlag == flagNone) {
607  // assert(iRef->categoryID() != EVEDB::invCategories::Charge); // crash here...this should NOT happen.
608  if (iRef->categoryID() == EVEDB::invCategories::Module) {
609  toFlag = pShip->FindAvailableModuleSlot(iRef);
610  if (toFlag == flagIllegal) {
611  pClient->SendNotifyMsg("Your ship has no available slots to fit this module. Putting the %s in your CargoHold.", iRef->name());
612  toFlag = flagCargoHold;
613  }
614  } else {
615  // this needs work to verify mFlag is correct for application and that it is init'd correctly
616  toFlag = m_flag;
617  }
618  }
619 
620  // verify item is allowed in container first
621  m_self->GetShipItem()->VerifyHoldType(toFlag, iRef, pClient); // this will throw if it fails
622 
623  // then check for module limits
624  if (IsModuleSlot(toFlag)) {
625  m_self->GetShipItem()->TryModuleLimitChecks(toFlag, iRef); // this will throw if it fails
626  } else if (IsCargoHoldFlag(toFlag) or IsHangarFlag(toFlag) or (toFlag == flagDroneBay)) {
627  pInventory->ValidateAddItem(toFlag, iRef); // this will throw if it fails
628  }
629 
630  // check adding item to ship...if it fails, return to previous container
631  if (m_self->GetShipItem()->AddItemByFlag(toFlag, iRef, pClient) < 1) {
632  //ALL items *should* have a loaded container item.
633  InventoryItemRef contRef = sItemFactory.GetItemContainer(*itr);
634  if (contRef.get() != nullptr) {
635  contRef->AddItem(iRef);
636  } else {
637  _log(INV__ERROR, "IB::MoveItems() - previous container for item %i not found. continuing.", (*itr));
638  }
639  continue;
640  }
641  } else if (customs) {
642  pInventory->ValidateAddItem(toFlag, iRef); // this will throw if it fails
644  sRef->AddItem(iRef);// this will throw if it fails
645  } else {
646  pInventory->ValidateAddItem(toFlag, iRef); // this will throw if it fails
647  iRef->Donate(m_ownerID, m_itemID, toFlag);
648  }
649  }
650 
651  sItemFactory.UnsetUsingClient();
652 
653  if (iRef.get() == nullptr)
654  return nullptr;
655 
656  if (items.size() == 1) {
657  //call returns itemID for single-item adds...not sure about others
658  Call_SingleIntegerArg result;
659  result.arg = iRef->itemID();
660  return result.Encode();
661  }
662 
663  return nullptr;
664 }
virtual InventoryItemRef Split(int32 qty=0, bool notify=true, bool silent=false)
void UnloadModule(uint32 itemID)
Definition: Ship.h:130
#define _log(type, fmt,...)
Definition: logsys.h:124
EVEItemFlags m_flag
virtual void AddItem(InventoryItemRef iRef)
void VerifyHoldType(EVEItemFlags flag, InventoryItemRef iRef, Client *pClient=nullptr)
Definition: Ship.cpp:1972
EVEItemFlags
Definition: EVE_Flags.h:13
Inventory * pInventory
void SendNotifyMsg(const char *fmt,...)
Definition: Client.cpp:2776
Advanced version of UserError that allows to send a full custom message.
Definition: PyExceptions.h:453
uint16 groupID() const
signed __int32 int32
Definition: eve-compat.h:49
#define codelog(type, fmt,...)
Definition: logsys.h:128
uint32 locationID() const
X * get() const
Definition: RefPtr.h:213
ShipItemRef GetShip() const
Definition: Client.h:167
virtual ShipItem * GetShipItem()
Definition: InventoryItem.h:82
#define IsPlayerCorp(itemID)
Definition: EVE_Defines.h:241
Python object "ccp_exceptions.UserError".
Definition: PyExceptions.h:121
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.
Definition: RefPtr.h:238
void TryModuleLimitChecks(EVEItemFlags flag, InventoryItemRef iRef)
Definition: Ship.cpp:736
Definition: Ship.h:46
#define IsModuleSlot(flag)
Definition: EVE_Defines.h:350
GenericModule * GetModule(EVEItemFlags flag)
Definition: Ship.h:173
#define IsCargoHoldFlag(flag)
Definition: EVE_Defines.h:336
virtual void RemoveItem(InventoryItemRef iRef)
Definition: Ship.cpp:532
InventoryItemRef m_self
#define IsRigSlot(flag)
Definition: EVE_Defines.h:367
#define IsHangarFlag(flag)
Definition: EVE_Defines.h:344
void traceStack(void)
Definition: misc.cpp:169
uint32 AddItemByFlag(EVEItemFlags flag, InventoryItemRef iRef, Client *pClient=nullptr)
Definition: Ship.cpp:486
EVEItemFlags FindAvailableModuleSlot(InventoryItemRef iRef)
Definition: Ship.cpp:797
#define sItemFactory
Definition: ItemFactory.h:165
bool ValidateAddItem(EVEItemFlags flag, InventoryItemRef iRef) const
Definition: Inventory.cpp:747
uint16 typeID() const
uint8 categoryID() const
void MoveModuleSlot(EVEItemFlags slot1, EVEItemFlags slot2)
Definition: Ship.cpp:818
#define sDataMgr

Here is the call graph for this function:

InventoryBound::PyCallable_DECL_CALL ( List  )
InventoryBound::PyCallable_DECL_CALL ( Add  )
InventoryBound::PyCallable_DECL_CALL ( MultiAdd  )
InventoryBound::PyCallable_DECL_CALL ( GetItem  )
InventoryBound::PyCallable_DECL_CALL ( RemoveChargeToCargo  )
InventoryBound::PyCallable_DECL_CALL ( RemoveChargeToHangar  )
InventoryBound::PyCallable_DECL_CALL ( MultiMerge  )
InventoryBound::PyCallable_DECL_CALL ( StackAll  )
InventoryBound::PyCallable_DECL_CALL ( StripFitting  )
InventoryBound::PyCallable_DECL_CALL ( DestroyFitting  )
InventoryBound::PyCallable_DECL_CALL ( SetPassword  )
InventoryBound::PyCallable_DECL_CALL ( CreateBookmarkVouchers  )
InventoryBound::PyCallable_DECL_CALL ( RunRefiningProcess  )
InventoryBound::PyCallable_DECL_CALL ( ImportExportWithPlanet  )
InventoryBound::PyCallable_DECL_CALL ( TakeOutTrash  )
InventoryBound::PyCallable_DECL_CALL ( ListDroneBay  )
virtual void InventoryBound::Release ( )
inlinevirtual

Implements PyBoundObject.

Definition at line 39 of file InventoryBound.h.

39  {
40  //I hate this statement
41  delete this;
42  }

Member Data Documentation

Dispatcher* const InventoryBound::m_dispatch
protected

Definition at line 69 of file InventoryBound.h.

Referenced by ~InventoryBound().

EVEItemFlags InventoryBound::m_flag
protected

Definition at line 64 of file InventoryBound.h.

Referenced by MoveItems().

uint32 InventoryBound::m_itemID
protected

Definition at line 66 of file InventoryBound.h.

Referenced by MoveItems().

uint32 InventoryBound::m_ownerID
protected

Definition at line 67 of file InventoryBound.h.

Referenced by MoveItems().

bool InventoryBound::m_passive
protected

Definition at line 63 of file InventoryBound.h.

InventoryItemRef InventoryBound::m_self
protected

Definition at line 73 of file InventoryBound.h.

Referenced by MoveItems().

Inventory* InventoryBound::pInventory
protected

Definition at line 71 of file InventoryBound.h.

Referenced by MoveItems().


The documentation for this class was generated from the following files: