EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Inventory.h
Go to the documentation of this file.
1 /*
2  ------------------------------------------------------------------------------------
3  LICENSE:
4  ------------------------------------------------------------------------------------
5  This file is part of EVEmu: EVE Online Server Emulator
6  Copyright 2006 - 2021 The EVEmu Team
7  For the latest information visit https://evemu.dev
8  ------------------------------------------------------------------------------------
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13 
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License along with
19  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20  Place - Suite 330, Boston, MA 02111-1307, USA, or go to
21  http://www.gnu.org/copyleft/lesser.txt.
22  ------------------------------------------------------------------------------------
23  Author: Bloody.Rabbit
24  Updates: Allan
25 */
26 
27 #ifndef __INVENTORY__H__INCL__
28 #define __INVENTORY__H__INCL__
29 
30 
31 #include "inventory/InventoryDB.h"
32 
33 
34 class CRowSet;
35 
36 /* this class is content management for items that can contain other items */
37 class Inventory
38 {
39  friend class InventoryItem;
40 public:
42  virtual ~Inventory() noexcept { /* do nothing here*/ }
43 
44  void Reset();
45  void Unload(); // used by stations and solar systems for item saving and unloading
46  void AddItem(InventoryItemRef iRef);
47  void RemoveItem(InventoryItemRef iRef);
48  void DeleteContents();
49  // returns map of mContents
50  void GetInventoryMap(std::map<uint32, InventoryItemRef> &invMap);
51  // this method also sorts in order - cargo, modules, charge, subsystems.
52  void GetInventoryVec(std::vector<InventoryItemRef> &itemVec);
54 
55  bool IsEmpty() { return mContents.empty(); }
56  bool LoadContents();
57  // this checks for available space for iRef by flag
58  bool ValidateAddItem(EVEItemFlags flag, InventoryItemRef iRef) const;// this will throw if it fails.
59  bool ValidateIHubUpgrade(InventoryItemRef iRef) const;
60  // this checks for available space for iRef by flag
61  bool HasAvailableSpace(EVEItemFlags flag, InventoryItemRef iRef) const; // this will not throw
62  bool ContentsLoaded() const { return mContentsLoaded; }
63  bool ContainsItem(uint32 itemID) const { return mContents.find( itemID ) != mContents.end(); }
64  // this checks all contents, not particular holds/hangars/items
65  bool ContainsTypeQty(uint16 typeID, uint32 qty=0) const;
68 
69  float GetCapacity(EVEItemFlags flag) const;
70  float GetStoredVolume(EVEItemFlags flag, bool combined=true) const;
71  float GetCorpHangerCapyUsed() const;
72  float GetRemainingCapacity(EVEItemFlags flag) const { return GetCapacity( flag ) - GetStoredVolume( flag ); }
73 
76 
77  /* Inventory-by-Flag methods */
79  bool IsEmptyByFlag(EVEItemFlags flag) const;
81  bool GetTypesByFlag(EVEItemFlags flag, std::map<uint16, InventoryItemRef> &items);
82  // for characters, ALL skills are flagSkill. we are not keeping flagSkillInTraining separate here
83  uint32 GetItemsByFlag(EVEItemFlags flag, std::vector<InventoryItemRef> &items) const;
84  uint32 GetItemsByFlagRange(EVEItemFlags low_flag, EVEItemFlags high_flag, std::vector<InventoryItemRef> &items) const;
85  uint32 GetItemsByFlagSet(std::set<EVEItemFlags> flags, std::vector<InventoryItemRef> &items) const;
86  // for characters, ALL skills are flagSkill. we are not keeping flagSkillInTraining separate here
89 
90  /* Primary packet builders */
92 
93  /* for station shit */
94  void GetInvForOwner(uint32 ownerID, std::vector<InventoryItemRef> &items);
95 
96  /* for debug command */
97  void GetCargoList(std::multimap<uint8, InventoryItemRef> &cargoMap); // returns map of cargoFlag:iRef from mContents
98 
99 protected:
100  bool GetItems(OwnerData od, std::vector< uint32 >& into);
101  void List(CRowSet* into, EVEItemFlags flag, uint32 ownerID=0) const;
102 
105 
106 private:
108 
110 
111  std::map<EVEItemFlags, double> m_itemsByFlag;
112 
113  std::vector<InventoryItemRef> SortVector(std::vector<InventoryItemRef> &itemVec);
114  std::map<uint32, InventoryItemRef> mContents; // itemID/ItemRef
115  std::multimap<uint8, InventoryItemRef> m_contentsByFlag; // flagID/ItemRef
116 };
117 
118 #endif /* !__INVENTORY__H__INCL__ */
119 
void GetInvForOwner(uint32 ownerID, std::vector< InventoryItemRef > &items)
Definition: Inventory.cpp:425
float GetRemainingCapacity(EVEItemFlags flag) const
Definition: Inventory.h:72
std::map< EVEItemFlags, double > m_itemsByFlag
Definition: Inventory.h:111
void GetInventoryVec(std::vector< InventoryItemRef > &itemVec)
Definition: Inventory.cpp:345
float GetCapacity(EVEItemFlags flag) const
Definition: Inventory.cpp:642
bool ContentsLoaded() const
Definition: Inventory.h:62
bool GetTypesByFlag(EVEItemFlags flag, std::map< uint16, InventoryItemRef > &items)
Definition: Inventory.cpp:465
void StackAll(EVEItemFlags flag, uint32 ownerID=0)
Definition: Inventory.cpp:575
InventoryItemRef FindFirstByFlag(EVEItemFlags flag) const
Definition: Inventory.cpp:436
bool ContainsTypeByFlag(uint16 typeID, EVEItemFlags flag=flagNone) const
Definition: Inventory.cpp:561
uint32 ownerID() const
Definition: InventoryItem.h:99
bool HasAvailableSpace(EVEItemFlags flag, InventoryItemRef iRef) const
Definition: Inventory.cpp:625
void AddItem(InventoryItemRef iRef)
Definition: Inventory.cpp:203
EVEItemFlags
Definition: EVE_Flags.h:13
std::multimap< uint8, InventoryItemRef > m_contentsByFlag
Definition: Inventory.h:115
float GetCorpHangerCapyUsed() const
Definition: Inventory.cpp:337
void DeleteContents()
Definition: Inventory.cpp:273
virtual ~Inventory() noexcept
Definition: Inventory.h:42
void RemoveItem(InventoryItemRef iRef)
Definition: Inventory.cpp:243
bool IsEmptyByFlag(EVEItemFlags flag) const
Definition: Inventory.cpp:498
bool ContainsItem(uint32 itemID) const
Definition: Inventory.h:63
uint32 GetItemsByFlag(EVEItemFlags flag, std::vector< InventoryItemRef > &items) const
Definition: Inventory.cpp:458
bool GetItems(OwnerData od, std::vector< uint32 > &into)
Definition: Inventory.cpp:109
void Unload()
Definition: Inventory.cpp:62
Inventory(InventoryItemRef iRef)
Definition: Inventory.cpp:49
std::map< uint32, InventoryItemRef > mContents
Definition: Inventory.h:114
Python object "dbutil.CRowset".
Definition: PyDatabase.h:124
void GetCargoList(std::multimap< uint8, InventoryItemRef > &cargoMap)
Definition: Inventory.cpp:332
bool ValidateIHubUpgrade(InventoryItemRef iRef) const
Definition: Inventory.cpp:706
unsigned __int32 uint32
Definition: eve-compat.h:50
uint32 GetItemsByFlagSet(std::set< EVEItemFlags > flags, std::vector< InventoryItemRef > &items) const
Definition: Inventory.cpp:514
EVEItemFlags flag() const
void GetInventoryMap(std::map< uint32, InventoryItemRef > &invMap)
Definition: Inventory.cpp:453
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
bool LoadContents()
Definition: Inventory.cpp:113
InventoryItemRef GetItemByTypeFlag(uint16 typeID, EVEItemFlags flag=flagNone)
Definition: Inventory.cpp:476
void Reset()
Definition: Inventory.cpp:56
bool IsEmpty()
Definition: Inventory.h:55
std::vector< InventoryItemRef > SortVector(std::vector< InventoryItemRef > &itemVec)
Definition: Inventory.cpp:356
bool ContainsTypeQtyByFlag(uint16 typeID, EVEItemFlags flag=flagNone, uint32 qty=0) const
Definition: Inventory.cpp:542
bool mContentsLoaded
Definition: Inventory.h:107
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
InventoryDB m_db
Definition: Inventory.h:103
InventoryItemRef GetByTypeFlag(uint32 typeID, EVEItemFlags flag) const
Definition: Inventory.cpp:444
CRowSet * List(EVEItemFlags flag, uint32 ownerID=0) const
Definition: Inventory.cpp:290
uint32 m_myID
Definition: Inventory.h:109
uint32 GetItemsByFlagRange(EVEItemFlags low_flag, EVEItemFlags high_flag, std::vector< InventoryItemRef > &items) const
Definition: Inventory.cpp:502
bool ValidateAddItem(EVEItemFlags flag, InventoryItemRef iRef) const
Definition: Inventory.cpp:747
uint16 typeID() const
bool ContainsTypeQty(uint16 typeID, uint32 qty=0) const
Definition: Inventory.cpp:526
InventoryItemRef GetByID(uint32 id) const
Definition: Inventory.cpp:415
float GetStoredVolume(EVEItemFlags flag, bool combined=true) const
Definition: Inventory.cpp:609
bool GetSingleItemByFlag(EVEItemFlags flag, InventoryItemRef &iRef) const
Definition: Inventory.cpp:489
Reference-counting-based smart pointer.
Definition: RefPtr.h:133
InventoryItemRef m_self
Definition: Inventory.h:104