TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
DB2Stores.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2 of the License, or (at your
7  * option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef TRINITY_DB2STORES_H
19 #define TRINITY_DB2STORES_H
20 
21 #include "DB2Store.h"
22 #include "DB2Structure.h"
23 #include "SharedDefines.h"
24 #include <boost/regex.hpp>
25 #include <array>
26 
110 
117 
119 {
123 };
124 
125 typedef std::vector<HotfixNotify> HotfixData;
126 
127 #define DEFINE_DB2_SET_COMPARATOR(structure) \
128  struct structure ## Comparator : public std::binary_function<structure const*, structure const*, bool> \
129  { \
130  bool operator()(structure const* left, structure const* right) const { return Compare(left, right); } \
131  static bool Compare(structure const* left, structure const* right); \
132  };
133 
135 {
136 public:
140 
141  typedef std::map<uint32 /*hash*/, DB2StorageBase*> StorageMap;
142  typedef std::unordered_map<uint32 /*areaGroupId*/, std::vector<uint32/*areaId*/>> AreaGroupMemberContainer;
143  typedef std::unordered_map<uint32, CharStartOutfitEntry const*> CharStartOutfitContainer;
144  typedef std::set<GlyphSlotEntry const*, GlyphSlotEntryComparator> GlyphSlotContainer;
145  typedef std::map<uint32 /*curveID*/, std::map<uint32/*index*/, CurvePointEntry const*, std::greater<uint32>>> HeirloomCurvesContainer;
146  typedef std::unordered_map<uint32, HeirloomEntry const*> HeirloomItemsContainer;
147  typedef std::vector<ItemBonusEntry const*> ItemBonusList;
148  typedef std::unordered_map<uint32 /*bonusListId*/, ItemBonusList> ItemBonusListContainer;
149  typedef std::unordered_multimap<uint32 /*itemId*/, uint32 /*bonusTreeId*/> ItemToBonusTreeContainer;
150  typedef std::unordered_map<uint32 /*itemId | appearanceMod << 24*/, uint32> ItemDisplayIdContainer;
151  typedef std::unordered_map<uint32, std::set<ItemBonusTreeNodeEntry const*>> ItemBonusTreeContainer;
152  typedef std::unordered_map<uint32, std::vector<ItemSpecOverrideEntry const*>> ItemSpecOverridesContainer;
153  typedef std::unordered_map<uint32, MountEntry const*> MountContainer;
154  typedef std::set<MountTypeXCapabilityEntry const*, MountTypeXCapabilityEntryComparator> MountTypeXCapabilitySet;
155  typedef std::unordered_map<uint32, MountTypeXCapabilitySet> MountCapabilitiesByTypeContainer;
156  typedef std::unordered_map<uint32, std::array<std::vector<NameGenEntry const*>, 2>> NameGenContainer;
157  typedef std::array<std::vector<boost::regex>, TOTAL_LOCALES + 1> NameValidationRegexContainer;
158  typedef std::unordered_map<uint32, std::set<uint32>> PhaseGroupContainer;
159  typedef std::unordered_map<uint32, std::vector<QuestPackageItemEntry const*>> QuestPackageItemContainer;
160  typedef std::unordered_map<uint32, std::vector<SpecializationSpellsEntry const*>> SpecializationSpellsContainer;
161  typedef std::unordered_map<uint32, std::vector<SpellPowerEntry const*>> SpellPowerContainer;
162  typedef std::unordered_map<uint32, std::unordered_map<uint32, std::vector<SpellPowerEntry const*>>> SpellPowerDifficultyContainer;
163  typedef std::unordered_set<uint32> ToyItemIdsContainer;
164 
165  static DB2Manager& Instance();
166 
167  void LoadStores(std::string const& dataPath, uint32 defaultLocale);
168  DB2StorageBase const* GetStorage(uint32 type) const;
169 
170  void LoadHotfixData();
171  HotfixData const* GetHotfixData() const { return &_hotfixData; }
172  time_t GetHotfixDate(uint32 entry, uint32 type) const;
173 
174  std::vector<uint32> GetAreasForGroup(uint32 areaGroupId) const;
175  static char const* GetBroadcastTextValue(BroadcastTextEntry const* broadcastText, LocaleConstant locale = DEFAULT_LOCALE, uint8 gender = GENDER_MALE, bool forceGender = false);
176  CharStartOutfitEntry const* GetCharStartOutfitEntry(uint8 race, uint8 class_, uint8 gender) const;
177  uint32 GetPowerIndexByClass(uint32 powerType, uint32 classId) const;
178  GlyphSlotContainer const& GetGlyphSlots() const { return _glyphSlots; }
179  uint32 GetHeirloomItemLevel(uint32 curveId, uint32 level) const;
180  HeirloomEntry const* GetHeirloomByItemId(uint32 itemId) const;
181  ItemBonusList const* GetItemBonusList(uint32 bonusListId) const;
182  std::set<uint32> GetItemBonusTree(uint32 itemId, uint32 itemBonusTreeMod) const;
183  uint32 GetItemDisplayId(uint32 itemId, uint32 appearanceModId) const;
184  std::vector<ItemSpecOverrideEntry const*> const* GetItemSpecOverrides(uint32 itemId) const;
185  std::string GetNameGenEntry(uint8 race, uint8 gender, LocaleConstant locale) const;
186  MountEntry const* GetMount(uint32 spellId) const;
187  MountEntry const* GetMountById(uint32 id) const;
188  MountTypeXCapabilitySet const* GetMountCapabilities(uint32 mountType) const;
189  ResponseCodes ValidateName(std::string const& name, LocaleConstant locale) const;
190  std::vector<QuestPackageItemEntry const*> const* GetQuestPackageItems(uint32 questPackageID) const;
191  uint32 GetQuestUniqueBitFlag(uint32 questId);
192  std::set<uint32> GetPhasesForGroup(uint32 group) const;
193  std::vector<SpecializationSpellsEntry const*> const* GetSpecializationSpells(uint32 specId) const;
194  std::vector<SpellPowerEntry const*> GetSpellPowers(uint32 spellId, Difficulty difficulty = DIFFICULTY_NONE, bool* hasDifficultyPowers = nullptr) const;
195  bool IsToyItem(uint32 toy) const;
196 
197 private:
198  StorageMap _stores;
200 
201  AreaGroupMemberContainer _areaGroupMembers;
202  CharStartOutfitContainer _charStartOutfits;
203  uint32 _powersByClass[MAX_CLASSES][MAX_POWERS];
204  GlyphSlotContainer _glyphSlots;
205  HeirloomItemsContainer _heirlooms;
206  HeirloomCurvesContainer _heirloomCurvePoints;
207  ItemBonusListContainer _itemBonusLists;
208  ItemBonusTreeContainer _itemBonusTrees;
209  ItemDisplayIdContainer _itemDisplayIDs;
210  ItemToBonusTreeContainer _itemToBonusTree;
211  ItemSpecOverridesContainer _itemSpecOverrides;
212  MountContainer _mountsBySpellId;
213  MountCapabilitiesByTypeContainer _mountCapabilitiesByType;
214  NameGenContainer _nameGenData;
215  NameValidationRegexContainer _nameValidators;
216  PhaseGroupContainer _phasesByGroup;
217  QuestPackageItemContainer _questPackages;
218  SpecializationSpellsContainer _specializationSpellsBySpec;
219  SpellPowerContainer _spellPowers;
220  SpellPowerDifficultyContainer _spellPowerDifficulties;
221  ToyItemIdsContainer _toys;
222 };
223 
224 #define sDB2Manager DB2Manager::Instance()
225 
226 #endif
TC_GAME_API DB2Storage< ImportPriceArmorEntry > sImportPriceArmorStore
std::unordered_map< uint32, MountTypeXCapabilitySet > MountCapabilitiesByTypeContainer
Definition: DB2Stores.h:155
TC_GAME_API DB2Storage< ItemSparseEntry > sItemSparseStore
MountCapabilitiesByTypeContainer _mountCapabilitiesByType
Definition: DB2Stores.h:213
Definition: DBCEnums.h:404
TC_GAME_API DB2Storage< ModifierTreeEntry > sModifierTreeStore
HotfixData const * GetHotfixData() const
Definition: DB2Stores.h:171
AreaGroupMemberContainer _areaGroupMembers
Definition: DB2Stores.h:201
TC_GAME_API DB2Storage< ImportPriceShieldEntry > sImportPriceShieldStore
TC_GAME_API DB2Storage< GarrAbilityEntry > sGarrAbilityStore
Difficulty
Definition: DBCEnums.h:402
TC_GAME_API DB2Storage< CurrencyTypesEntry > sCurrencyTypesStore
TC_GAME_API DB2Storage< SoundEntriesEntry > sSoundEntriesStore
TC_GAME_API DB2Storage< SpellXSpellVisualEntry > sSpellXSpellVisualStore
Definition: DB2Stores.h:118
PhaseGroupContainer _phasesByGroup
Definition: DB2Stores.h:216
TC_GAME_API DB2Storage< ItemPriceBaseEntry > sItemPriceBaseStore
TC_GAME_API DB2Storage< PlayerConditionEntry > sPlayerConditionStore
NameGenContainer _nameGenData
Definition: DB2Stores.h:214
MountContainer _mountsBySpellId
Definition: DB2Stores.h:212
TC_GAME_API DB2Storage< GarrBuildingPlotInstEntry > sGarrBuildingPlotInstStore
std::vector< HotfixNotify > HotfixData
Definition: DB2Stores.h:125
std::unordered_map< uint32, std::array< std::vector< NameGenEntry const * >, 2 > > NameGenContainer
Definition: DB2Stores.h:156
uint32 Entry
Definition: DB2Stores.h:122
std::map< uint32, DB2StorageBase * > StorageMap
Definition: DB2Stores.h:141
ItemDisplayIdContainer _itemDisplayIDs
Definition: DB2Stores.h:209
std::vector< TaxiPathNodeList > TaxiPathNodesByPath
Definition: DB2Structure.h:1450
TC_GAME_API DB2Storage< QuestMoneyRewardEntry > sQuestMoneyRewardStore
TC_GAME_API DB2Storage< BattlePetSpeciesStateEntry > sBattlePetSpeciesStateStore
TC_GAME_API DB2Storage< SpellRadiusEntry > sSpellRadiusStore
std::set< GlyphSlotEntry const *, GlyphSlotEntryComparator > GlyphSlotContainer
Definition: DB2Stores.h:144
Definition: DB2Structure.h:127
TC_GAME_API DB2Storage< ItemClassEntry > sItemClassStore
Definition: DB2Stores.h:134
TC_GAME_API DB2Storage< GlyphSlotEntry > sGlyphSlotStore
TC_GAME_API DB2Storage< GarrFollowerXAbilityEntry > sGarrFollowerXAbilityStore
TC_GAME_API DB2Storage< GarrClassSpecEntry > sGarrClassSpecStore
TC_GAME_API DB2Storage< SpellCastingRequirementsEntry > sSpellCastingRequirementsStore
TC_GAME_API DB2Storage< SpellDurationEntry > sSpellDurationStore
TC_GAME_API DB2Storage< GarrSiteLevelPlotInstEntry > sGarrSiteLevelPlotInstStore
std::set< MountTypeXCapabilityEntry const *, MountTypeXCapabilityEntryComparator > MountTypeXCapabilitySet
Definition: DB2Stores.h:154
TC_GAME_API DB2Storage< SpellCastTimesEntry > sSpellCastTimesStore
Definition: DB2Structure.h:586
TC_GAME_API DB2Storage< ItemEntry > sItemStore
TC_GAME_API DB2Storage< ItemDisenchantLootEntry > sItemDisenchantLootStore
TC_GAME_API DB2Storage< GarrPlotBuildingEntry > sGarrPlotBuildingStore
TC_GAME_API DB2Storage< GuildPerkSpellsEntry > sGuildPerkSpellsStore
Definition: DB2Structure.h:112
Definition: DB2Structure.h:345
std::unordered_map< uint32, std::set< uint32 > > PhaseGroupContainer
Definition: DB2Stores.h:158
TC_GAME_API DB2Storage< DestructibleModelDataEntry > sDestructibleModelDataStore
#define DEFINE_DB2_SET_COMPARATOR(structure)
Definition: DB2Stores.h:127
std::vector< ItemBonusEntry const * > ItemBonusList
Definition: DB2Stores.h:147
HeirloomItemsContainer _heirlooms
Definition: DB2Stores.h:205
SpellPowerContainer _spellPowers
Definition: DB2Stores.h:219
uint32 Timestamp
Definition: DB2Stores.h:121
TC_GAME_API DB2Storage< BattlePetSpeciesEntry > sBattlePetSpeciesStore
std::unordered_map< uint32, CharStartOutfitEntry const * > CharStartOutfitContainer
Definition: DB2Stores.h:143
TC_GAME_API DB2Storage< GameObjectsEntry > sGameObjectsStore
TC_GAME_API DB2Storage< SpellRangeEntry > sSpellRangeStore
TC_GAME_API DB2Storage< OverrideSpellDataEntry > sOverrideSpellDataStore
Definition: DB2Structure.h:572
ItemToBonusTreeContainer _itemToBonusTree
Definition: DB2Stores.h:210
Definition: DB2Structure.h:139
TC_GAME_API DB2Storage< CinematicSequencesEntry > sCinematicSequencesStore
TC_GAME_API DB2Storage< CreatureTypeEntry > sCreatureTypeStore
TC_GAME_API TaxiMask sHordeTaxiNodesMask
Definition: DB2Stores.cpp:136
Definition: SharedDefines.h:93
TC_GAME_API DB2Storage< SpellItemEnchantmentConditionEntry > sSpellItemEnchantmentConditionStore
TC_GAME_API DB2Storage< SpellTotemsEntry > sSpellTotemsStore
std::unordered_set< uint32 > ToyItemIdsContainer
Definition: DB2Stores.h:163
TC_GAME_API DB2Storage< GarrPlotEntry > sGarrPlotStore
Interface class for common access.
Definition: DB2Store.h:27
TC_GAME_API DB2Storage< GameTablesEntry > sGameTablesStore
TC_GAME_API DB2Storage< MountCapabilityEntry > sMountCapabilityStore
TC_GAME_API DB2Storage< TaxiPathEntry > sTaxiPathStore
std::map< uint32, TaxiPathSetForSource > TaxiPathSetBySource
Definition: DB2Structure.h:1447
TC_GAME_API DB2Storage< SpellClassOptionsEntry > sSpellClassOptionsStore
TC_GAME_API DB2Storage< HeirloomEntry > sHeirloomStore
SpecializationSpellsContainer _specializationSpellsBySpec
Definition: DB2Stores.h:218
GlyphSlotContainer const & GetGlyphSlots() const
Definition: DB2Stores.h:178
TC_GAME_API DB2Storage< ItemLimitCategoryEntry > sItemLimitCategoryStore
TC_GAME_API DB2Storage< ScalingStatDistributionEntry > sScalingStatDistributionStore
LocaleConstant
Definition: Common.h:115
TC_GAME_API DB2Storage< SpellReagentsEntry > sSpellReagentsStore
StorageMap _stores
Definition: DB2Stores.h:198
CharStartOutfitContainer _charStartOutfits
Definition: DB2Stores.h:202
TC_GAME_API DB2Storage< SpellLearnSpellEntry > sSpellLearnSpellStore
TC_GAME_API TaxiPathNodesByPath sTaxiPathNodesByPath
Definition: DB2Stores.cpp:139
TC_GAME_API DB2Storage< CriteriaEntry > sCriteriaStore
TC_GAME_API DB2Storage< GarrBuildingEntry > sGarrBuildingStore
TC_GAME_API DB2Storage< ImportPriceWeaponEntry > sImportPriceWeaponStore
TC_GAME_API DB2Storage< GarrPlotInstanceEntry > sGarrPlotInstanceStore
std::unordered_map< uint32, std::unordered_map< uint32, std::vector< SpellPowerEntry const * > > > SpellPowerDifficultyContainer
Definition: DB2Stores.h:162
std::unordered_map< uint32, std::vector< SpellPowerEntry const * > > SpellPowerContainer
Definition: DB2Stores.h:161
ResponseCodes
Definition: SharedDefines.h:4422
TC_GAME_API DB2Storage< SpellAuraRestrictionsEntry > sSpellAuraRestrictionsStore
ItemSpecOverridesContainer _itemSpecOverrides
Definition: DB2Stores.h:211
GlyphSlotContainer _glyphSlots
Definition: DB2Stores.h:204
TC_GAME_API DB2Storage< ItemSpecOverrideEntry > sItemSpecOverrideStore
TC_GAME_API DB2Storage< BattlePetBreedStateEntry > sBattlePetBreedStateStore
NameValidationRegexContainer _nameValidators
Definition: DB2Stores.h:215
uint32_t uint32
Definition: Define.h:150
std::unordered_multimap< uint32, uint32 > ItemToBonusTreeContainer
Definition: DB2Stores.h:149
std::unordered_map< uint32, std::vector< uint32 > > AreaGroupMemberContainer
Definition: DB2Stores.h:142
TC_GAME_API DB2Storage< TaxiNodesEntry > sTaxiNodesStore
std::unordered_map< uint32, std::vector< ItemSpecOverrideEntry const * > > ItemSpecOverridesContainer
Definition: DB2Stores.h:152
TC_GAME_API DB2Storage< ItemCurrencyCostEntry > sItemCurrencyCostStore
TC_GAME_API DB2Storage< SpellMiscEntry > sSpellMiscStore
TC_GAME_API DB2Storage< SpellRuneCostEntry > sSpellRuneCostStore
TC_GAME_API DB2Storage< HolidaysEntry > sHolidaysStore
TC_GAME_API DB2Storage< BarberShopStyleEntry > sBarberShopStyleStore
#define MAX_CLASSES
Definition: SharedDefines.h:181
std::array< uint8, TaxiMaskSize > TaxiMask
Definition: DB2Structure.h:1453
TC_GAME_API DB2Storage< AuctionHouseEntry > sAuctionHouseStore
QuestPackageItemContainer _questPackages
Definition: DB2Stores.h:217
TC_GAME_API DB2Storage< ItemEffectEntry > sItemEffectStore
TC_GAME_API TaxiPathSetBySource sTaxiPathSetBySource
Definition: DB2Stores.cpp:138
TC_GAME_API DB2Storage< ItemExtendedCostEntry > sItemExtendedCostStore
TC_GAME_API DB2Storage< QuestSortEntry > sQuestSortStore
ToyItemIdsContainer _toys
Definition: DB2Stores.h:221
TC_GAME_API DB2Storage< MailTemplateEntry > sMailTemplateStore
std::unordered_map< uint32, std::vector< SpecializationSpellsEntry const * > > SpecializationSpellsContainer
Definition: DB2Stores.h:160
TC_GAME_API DB2Storage< BattlePetBreedQualityEntry > sBattlePetBreedQualityStore
Definition: DB2Store.h:45
TC_GAME_API DB2Storage< TotemCategoryEntry > sTotemCategoryStore
std::unordered_map< uint32, HeirloomEntry const * > HeirloomItemsContainer
Definition: DB2Stores.h:146
TC_GAME_API DB2Storage< DurabilityQualityEntry > sDurabilityQualityStore
HeirloomCurvesContainer _heirloomCurvePoints
Definition: DB2Stores.h:206
TC_GAME_API DB2Storage< ImportPriceQualityEntry > sImportPriceQualityStore
ItemBonusTreeContainer _itemBonusTrees
Definition: DB2Stores.h:208
std::unordered_map< uint32, ItemBonusList > ItemBonusListContainer
Definition: DB2Stores.h:148
#define TC_GAME_API
Definition: Define.h:134
uint32 TableHash
Definition: DB2Stores.h:120
TC_GAME_API DB2Storage< CriteriaTreeEntry > sCriteriaTreeStore
uint8_t uint8
Definition: Define.h:152
Definition: SharedDefines.h:265
TC_GAME_API DB2Storage< ItemRandomSuffixEntry > sItemRandomSuffixStore
std::unordered_map< uint32, std::set< ItemBonusTreeNodeEntry const * > > ItemBonusTreeContainer
Definition: DB2Stores.h:151
TC_GAME_API DB2Storage< BroadcastTextEntry > sBroadcastTextStore
Definition: DB2Structure.h:939
TC_GAME_API DB2Storage< QuestXPEntry > sQuestXPStore
TC_GAME_API DB2Storage< GarrSiteLevelEntry > sGarrSiteLevelStore
HotfixData _hotfixData
Definition: DB2Stores.h:199
std::map< uint32, std::map< uint32, CurvePointEntry const *, std::greater< uint32 > > > HeirloomCurvesContainer
Definition: DB2Stores.h:145
TC_GAME_API DB2Storage< UnitPowerBarEntry > sUnitPowerBarStore
TC_GAME_API DB2Storage< CreatureDisplayInfoEntry > sCreatureDisplayInfoStore
TC_GAME_API TaxiMask sTaxiNodesMask
Definition: DB2Stores.cpp:134
TC_GAME_API TaxiMask sOldContinentsNodesMask
Definition: DB2Stores.cpp:135
TC_GAME_API DB2Storage< SpellPowerEntry > sSpellPowerStore
TC_GAME_API DB2Storage< WorldMapOverlayEntry > sWorldMapOverlayStore
TC_GAME_API DB2Storage< ItemSpecEntry > sItemSpecStore
std::unordered_map< uint32, std::vector< QuestPackageItemEntry const * > > QuestPackageItemContainer
Definition: DB2Stores.h:159
#define DEFAULT_LOCALE
Definition: Common.h:134
TC_GAME_API DB2Storage< ItemRandomPropertiesEntry > sItemRandomPropertiesStore
Definition: DB2Structure.h:913
TC_GAME_API DB2Storage< CharStartOutfitEntry > sCharStartOutfitStore
std::unordered_map< uint32, uint32 > ItemDisplayIdContainer
Definition: DB2Stores.h:150
SpellPowerDifficultyContainer _spellPowerDifficulties
Definition: DB2Stores.h:220
TC_GAME_API DB2Storage< GarrFollowerEntry > sGarrFollowerStore
std::array< std::vector< boost::regex >, TOTAL_LOCALES+1 > NameValidationRegexContainer
Definition: DB2Stores.h:157
std::unordered_map< uint32, MountEntry const * > MountContainer
Definition: DB2Stores.h:153
Definition: Common.h:130
TC_GAME_API DB2Storage< ItemToBattlePetSpeciesEntry > sItemToBattlePetSpeciesStore
TC_GAME_API DB2Storage< AchievementEntry > sAchievementStore
TC_GAME_API TaxiMask sAllianceTaxiNodesMask
Definition: DB2Stores.cpp:137
TC_GAME_API DB2Storage< ToyEntry > sToyStore
ItemBonusListContainer _itemBonusLists
Definition: DB2Stores.h:207