EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ItemType.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  Rewrite: Allan
25 */
26 
27 #ifndef __ITEM_TYPE__H__INCL__
28 #define __ITEM_TYPE__H__INCL__
29 
30 #include <unordered_map>
31 
32 #include "StaticDataMgr.h"
33 #include "effects/EffectsData.h"
34 #include "inventory/AttributeMap.h"
35 #include "inventory/ItemFactory.h"
36 
37 /*
38  * LOADING INVOKATION EXPLANATION:
39  * (written by original author (Bloody.Rabbit?)) [updated version by allan in InventoryItem.h]
40  * ItemType and InventoryItem classes and their children have special loading. Every such type has following methods:
41  *
42  * static Load(<identifier>):
43  * Merges static and virtual loading trees.
44  * First calls static _Load() to create desired object and
45  * then calls its virtual _Load() (if the type has any).
46  *
47  * static _Load(<identifier>[, <data-argument>, ...]):
48  * These functions gradually, one by one, load any data needed to create desired
49  * type and in the end they create the type object.
50  *
51  * virtual _Load() (optional):
52  * Performs any post-construction loading.
53  */
54 
55 /*
56  * Class which maintains type data.
57  */
58 class ItemType {
59 public:
60  virtual ~ItemType() { /* do nothing here */ }
61 
62  /* Helper methods */
63  uint16 id() const { return m_type.id; }
64  uint16 groupID() const { return m_group.id; }
65  const std::string &groupName() const { return m_group.name; }
66  uint8 categoryID() const { return m_group.catID; }
67 
68  float radius() const { return m_type.radius; }
69  float mass() const { return m_type.mass; }
70  float volume() const { return m_type.volume; }
71  float capacity() const { return m_type.capacity; }
72  uint8 race() const { return m_type.race; }
73 
74  const std::string &name() const { return m_type.name; }
75  const std::string &description() const { return m_type.description; }
76 
77  uint16 portionSize() const { return m_type.portionSize; }
78  double basePrice() const { return m_type.basePrice; }
81 
82  bool published() const { return m_type.published; }
83  bool refinable() const { return m_type.isRefinable; }
84  bool recyclable() const { return m_type.isRecyclable; }
85 
86  /* new attribute system */
87  const bool HasAttribute(const uint16 attributeID) const;
89  const void CopyAttributes(InventoryItem& itemRef) const;
90 
91  bool HasReqSkill(const uint16 skillID) const;
92 
93  /* new effects processing system */
94  void GetEffectMap(const int8 state, std::map<uint16, Effect>& effectMap) const;
96 
97  bool HasEffect(uint16 effectID) const;
98 
99  // load method
100  static ItemType* Load( uint16 typeID);
101 
102 protected:
103  ItemType(uint16 _id, const Inv::TypeData &_data);
104 
105  /*
106  * Member functions
107  */
108  // Template helper:
109  template<class _Ty>
110  static _Ty *Load( uint16 typeID)
111  {
112  // static load
113  _Ty *t = _Ty::template _Load<_Ty>(typeID);
114  if (t == nullptr)
115  return nullptr;
116 
117  // dynamic load
118  if (!t->_Load()) {
119  delete t;
120  return nullptr;
121  }
122 
123  return t;
124  }
125 
126  // Template loader:
127  template<class _Ty>
128  static _Ty *_Load(uint16 typeID)
129  {
130  // pull data
131  Inv::TypeData data = Inv::TypeData();
132  sDataMgr.GetType(typeID, data);
133  if (data.id == 0)
134  return nullptr;
136  if (data.groupID > 23) // gID < 23 are map items. will need to search for others
137  if (!data.published)
138  return nullptr;
139 
140  return _Ty::template _LoadType<_Ty>(typeID, data );
141  }
142 
143  // Actual loading stuff:
144  template<class _Ty>
145  static _Ty *_LoadType( uint16 typeID, const Inv::TypeData &data);
146 
147  virtual bool _Load();
148 
149  void LoadEffects();
150 
151 public:
152  // i dont like this......MUST fix later....
153  // UD: ive no clue what i didnt like about it
154  std::unordered_multimap<int8, Effect> m_stateFxMap; // k,v map of state, data -to search by state
155 
156 private:
159  uint16 m_defaultFxID; // default effectID
160 
161  std::map<uint16, uint8> m_reqSkillMap; // k,v map of required skill, level for this ItemType, if any.
162  std::map<uint16, EvilNumber> m_AttributeMap; // k,v map of attributeID, value
163 
164 };
165 
166 /*
167  * Simple container for raw item data.
168  */
169 class ItemData {
170 public:
171  // default constructor:
172  ItemData( const char *_name = "", uint16 _typeID = 0, uint32 _ownerID = ownerSystem, uint32 _locationID = locTemp,
173  EVEItemFlags _flag = flagNone, bool _contraband = false, bool _singleton = false, uint32 _quantity = 0,
174  const GPoint &_position = NULL_ORIGIN, const char *_customInfo = "");
175 
176  // non-singleton constructor:
177  ItemData( uint16 _typeID, uint32 _ownerID, uint32 _locationID, EVEItemFlags _flag, uint32 _quantity,
178  const char *_customInfo = "", bool _contraband = false);
179 
180  // Singleton constructor:
181  ItemData( uint16 _typeID, uint32 _ownerID, uint32 _locationID, EVEItemFlags _flag, const char *_name = "",
182  const GPoint &_position = NULL_ORIGIN, const char *_customInfo = "", bool _contraband = false);
183 
184  // Content:
185  bool contraband :1;
186  bool singleton :1; // singletonBlueprintCopy = 2
193  std::string name;
194  std::string customInfo;
195 };
196 
197 #endif /* __ITEM_TYPE__H__INCL__ */
198 
199 
200 
bool published() const
Definition: ItemType.h:82
unsigned __int8 uint8
Definition: eve-compat.h:46
bool recyclable() const
Definition: ItemType.h:84
void GetEffectMap(const int8 state, std::map< uint16, Effect > &effectMap) const
Definition: ItemType.cpp:217
uint16 id() const
Definition: ItemType.h:63
const bool HasAttribute(const uint16 attributeID) const
Definition: ItemType.cpp:160
uint32 locationID
Definition: ItemType.h:190
float chanceOfDuplicating() const
Definition: ItemType.h:80
bool HasReqSkill(const uint16 skillID) const
Definition: ItemType.cpp:176
uint16 groupID() const
Definition: ItemType.h:64
EVEItemFlags
Definition: EVE_Flags.h:13
std::string description
Definition: EVE_Inventory.h:90
const std::string & description() const
Definition: ItemType.h:75
GPoint position
Definition: ItemType.h:192
std::map< uint16, uint8 > m_reqSkillMap
Definition: ItemType.h:161
bool refinable() const
Definition: ItemType.h:83
EvilNumber GetAttribute(const uint16 attributeID) const
Definition: ItemType.cpp:168
uint16 GetDefaultEffect() const
Definition: ItemType.h:95
bool HasEffect(uint16 effectID) const
Definition: ItemType.cpp:208
this is a class that kinda mimics how python polymorph's numbers.
Definition: EvilNumber.h:59
std::unordered_multimap< int8, Effect > m_stateFxMap
Definition: ItemType.h:154
float capacity() const
Definition: ItemType.h:71
std::string name
Definition: EVE_Inventory.h:68
signed __int8 int8
Definition: eve-compat.h:45
uint8 categoryID() const
Definition: ItemType.h:66
std::string customInfo
Definition: ItemType.h:194
void LoadEffects()
Definition: ItemType.cpp:190
virtual bool _Load()
Definition: ItemType.cpp:114
uint32 marketGroupID
Definition: EVE_Inventory.h:82
uint16 portionSize
Definition: EVE_Inventory.h:81
typeID Spawn an NPC with the specified type text Search for items matching the specified query() type()() itemID() copy() materialLevel()()() itemID() itemID Fits selected item to active ship() skillID(level)-gives skillID to specified level." ) COMMAND( online
Definition: gpoint.h:33
typeID Spawn an NPC with the specified type text Search for items matching the specified query() type()() itemID() copy() materialLevel()()() itemID() attributeID(value)-Sets attributeID of itemID to value." ) COMMAND( fit
uint16 portionSize() const
Definition: ItemType.h:77
static const GPoint NULL_ORIGIN(0, 0, 0)
float chanceOfDuplicating
Definition: EVE_Inventory.h:83
float mass() const
Definition: ItemType.h:69
ItemType(uint16 _id, const Inv::TypeData &_data)
Definition: ItemType.cpp:39
ItemData(const char *_name="", uint16 _typeID=0, uint32 _ownerID=ownerSystem, uint32 _locationID=locTemp, EVEItemFlags _flag=flagNone, bool _contraband=false, bool _singleton=false, uint32 _quantity=0, const GPoint &_position=NULL_ORIGIN, const char *_customInfo="")
Definition: ItemType.cpp:228
uint32 marketGroupID() const
Definition: ItemType.h:79
uint32 quantity
Definition: ItemType.h:191
const std::string & name() const
Definition: ItemType.h:74
const void CopyAttributes(InventoryItem &itemRef) const
Definition: ItemType.cpp:153
virtual ~ItemType()
Definition: ItemType.h:60
static _Ty * Load(uint16 typeID)
Definition: ItemType.h:110
unsigned __int32 uint32
Definition: eve-compat.h:50
uint16 typeID
Definition: ItemType.h:188
EVEItemFlags flag
Definition: ItemType.h:187
static ItemType * Load(uint16 typeID)
Definition: ItemType.cpp:53
double basePrice() const
Definition: ItemType.h:78
Inv::TypeData m_type
Definition: ItemType.h:158
uint8 race() const
Definition: ItemType.h:72
uint16 m_defaultFxID
Definition: ItemType.h:159
double basePrice
Definition: EVE_Inventory.h:88
uint32 ownerID
Definition: ItemType.h:189
float radius() const
Definition: ItemType.h:68
Inv::GrpData m_group
Definition: ItemType.h:157
float volume() const
Definition: ItemType.h:70
static _Ty * _Load(uint16 typeID)
Definition: ItemType.h:128
bool contraband
Definition: ItemType.h:185
static _Ty * _LoadType(uint16 typeID, const Inv::TypeData &data)
Definition: ItemType.cpp:58
const std::string & groupName() const
Definition: ItemType.h:65
std::map< uint16, EvilNumber > m_AttributeMap
Definition: ItemType.h:162
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 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 their destiny state
std::string name
Definition: EVE_Inventory.h:89
std::string name
Definition: ItemType.h:193
bool singleton
Definition: ItemType.h:186
#define sDataMgr