2 * Copyright (C) 2005-2008 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 //#include "DataStore.h"
25 #include "DBCStructure.h"
29 typedef std::list
<uint32
> SimpleFactionsList
;
31 SimpleFactionsList
const* GetFactionTeamList(uint32 faction
);
32 char* GetPetName(uint32 petfamily
, uint32 dbclang
);
33 uint32
GetTalentSpellCost(uint32 spellId
);
34 TalentSpellPos
const* GetTalentSpellPos(uint32 spellId
);
36 AreaTableEntry
const* GetAreaEntryByAreaID(uint32 area_id
);
37 AreaTableEntry
const* GetAreaEntryByAreaFlagAndMap(uint32 area_flag
,uint32 map_id
);
38 uint32
GetAreaFlagByMapId(uint32 mapid
);
40 uint32
GetVirtualMapForMapAndZone(uint32 mapid
, uint32 zoneId
);
48 ContentLevels
GetContentLevelsForMapAndZone(uint32 mapid
, uint32 zoneId
);
50 ChatChannelsEntry
const* GetChannelEntryFor(uint32 channel_id
);
52 bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId
, uint32 requiredTotemCategoryId
);
54 void Zone2MapCoordinates(float& x
,float& y
,uint32 zone
);
55 void Map2ZoneCoordinates(float& x
,float& y
,uint32 zone
);
57 uint32
GetTalentInspectBitPosInTab(uint32 talentId
);
58 uint32
GetTalentTabInspectBitSize(uint32 talentTabId
);
59 uint32
const* /*[3]*/ GetTalentTabPages(uint32 cls
);
64 typedef std::list
<char*> StringPoolList
;
66 explicit DBCStorage(const char *f
) : nCount(0), fieldCount(0), fmt(f
), indexTable(NULL
), m_dataTable(NULL
) { }
67 ~DBCStorage() { Clear(); }
69 T
const* LookupEntry(uint32 id
) const { return (id
>=nCount
)?NULL
:indexTable
[id
]; }
70 uint32
GetNumRows() const { return nCount
; }
71 char const* GetFormat() const { return fmt
; }
72 uint32
GetFieldCount() const { return fieldCount
; }
74 bool Load(char const* fn
)
77 // Check if load was sucessful, only then continue
78 if(!dbc
.Load(fn
, fmt
))
81 fieldCount
= dbc
.GetCols();
82 m_dataTable
= (T
*)dbc
.AutoProduceData(fmt
,nCount
,(char**&)indexTable
);
83 m_stringPoolList
.push_back(dbc
.AutoProduceStrings(fmt
,(char*)m_dataTable
));
85 // error in dbc file at loading if NULL
86 return indexTable
!=NULL
;
89 bool LoadStringsFrom(char const* fn
)
91 // DBC must be already loaded using Load
96 // Check if load was successful, only then continue
97 if(!dbc
.Load(fn
, fmt
))
100 m_stringPoolList
.push_back(dbc
.AutoProduceStrings(fmt
,(char*)m_dataTable
));
110 delete[] ((char*)indexTable
);
112 delete[] ((char*)m_dataTable
);
115 while(!m_stringPoolList
.empty())
117 delete[] m_stringPoolList
.front();
118 m_stringPoolList
.pop_front();
129 StringPoolList m_stringPoolList
;
132 extern DBCStorage
<AreaTableEntry
> sAreaStore
;// recommend access using functions
133 extern DBCStorage
<AreaTriggerEntry
> sAreaTriggerStore
;
134 extern DBCStorage
<BankBagSlotPricesEntry
> sBankBagSlotPricesStore
;
135 extern DBCStorage
<BattlemasterListEntry
> sBattlemasterListStore
;
136 //extern DBCStorage <ChatChannelsEntry> sChatChannelsStore; -- accessed using function, no usable index
137 extern DBCStorage
<CharTitlesEntry
> sCharTitlesStore
;
138 extern DBCStorage
<ChrClassesEntry
> sChrClassesStore
;
139 extern DBCStorage
<ChrRacesEntry
> sChrRacesStore
;
140 extern DBCStorage
<CreatureDisplayInfoEntry
> sCreatureDisplayInfoStore
;
141 extern DBCStorage
<CreatureFamilyEntry
> sCreatureFamilyStore
;
142 extern DBCStorage
<CreatureSpellDataEntry
> sCreatureSpellDataStore
;
143 extern DBCStorage
<DurabilityCostsEntry
> sDurabilityCostsStore
;
144 extern DBCStorage
<DurabilityQualityEntry
> sDurabilityQualityStore
;
145 extern DBCStorage
<EmotesTextEntry
> sEmotesTextStore
;
146 extern DBCStorage
<FactionEntry
> sFactionStore
;
147 extern DBCStorage
<FactionTemplateEntry
> sFactionTemplateStore
;
148 extern DBCStorage
<GemPropertiesEntry
> sGemPropertiesStore
;
150 extern DBCStorage
<GtCombatRatingsEntry
> sGtCombatRatingsStore
;
151 extern DBCStorage
<GtChanceToMeleeCritBaseEntry
> sGtChanceToMeleeCritBaseStore
;
152 extern DBCStorage
<GtChanceToMeleeCritEntry
> sGtChanceToMeleeCritStore
;
153 extern DBCStorage
<GtChanceToSpellCritBaseEntry
> sGtChanceToSpellCritBaseStore
;
154 extern DBCStorage
<GtChanceToSpellCritEntry
> sGtChanceToSpellCritStore
;
155 extern DBCStorage
<GtOCTRegenHPEntry
> sGtOCTRegenHPStore
;
156 //extern DBCStorage <GtOCTRegenMPEntry> sGtOCTRegenMPStore; -- not used currently
157 extern DBCStorage
<GtRegenHPPerSptEntry
> sGtRegenHPPerSptStore
;
158 extern DBCStorage
<GtRegenMPPerSptEntry
> sGtRegenMPPerSptStore
;
159 extern DBCStorage
<ItemEntry
> sItemStore
;
160 //extern DBCStorage <ItemDisplayInfoEntry> sItemDisplayInfoStore; -- not used currently
161 extern DBCStorage
<ItemExtendedCostEntry
> sItemExtendedCostStore
;
162 extern DBCStorage
<ItemRandomPropertiesEntry
> sItemRandomPropertiesStore
;
163 extern DBCStorage
<ItemRandomSuffixEntry
> sItemRandomSuffixStore
;
164 extern DBCStorage
<ItemSetEntry
> sItemSetStore
;
165 extern DBCStorage
<LockEntry
> sLockStore
;
166 extern DBCStorage
<MailTemplateEntry
> sMailTemplateStore
;
167 extern DBCStorage
<MapEntry
> sMapStore
;
168 extern DBCStorage
<QuestSortEntry
> sQuestSortStore
;
169 extern DBCStorage
<RandomPropertiesPointsEntry
> sRandomPropertiesPointsStore
;
170 extern DBCStorage
<SkillLineEntry
> sSkillLineStore
;
171 extern DBCStorage
<SkillLineAbilityEntry
> sSkillLineAbilityStore
;
172 extern DBCStorage
<SoundEntriesEntry
> sSoundEntriesStore
;
173 extern DBCStorage
<SpellCastTimesEntry
> sSpellCastTimesStore
;
174 extern DBCStorage
<SpellDurationEntry
> sSpellDurationStore
;
175 extern DBCStorage
<SpellFocusObjectEntry
> sSpellFocusObjectStore
;
176 extern DBCStorage
<SpellItemEnchantmentEntry
> sSpellItemEnchantmentStore
;
177 extern DBCStorage
<SpellItemEnchantmentConditionEntry
> sSpellItemEnchantmentConditionStore
;
178 extern SpellCategoryStore sSpellCategoryStore
;
179 extern PetFamilySpellsStore sPetFamilySpellsStore
;
180 extern DBCStorage
<SpellRadiusEntry
> sSpellRadiusStore
;
181 extern DBCStorage
<SpellRangeEntry
> sSpellRangeStore
;
182 extern DBCStorage
<SpellShapeshiftEntry
> sSpellShapeshiftStore
;
183 extern DBCStorage
<SpellEntry
> sSpellStore
;
184 extern DBCStorage
<StableSlotPricesEntry
> sStableSlotPricesStore
;
185 extern DBCStorage
<TalentEntry
> sTalentStore
;
186 extern DBCStorage
<TalentTabEntry
> sTalentTabStore
;
187 extern DBCStorage
<TaxiNodesEntry
> sTaxiNodesStore
;
188 extern DBCStorage
<TaxiPathEntry
> sTaxiPathStore
;
189 extern TaxiMask sTaxiNodesMask
;
190 extern TaxiPathSetBySource sTaxiPathSetBySource
;
191 extern TaxiPathNodesByPath sTaxiPathNodesByPath
;
192 extern DBCStorage
<TotemCategoryEntry
> sTotemCategoryStore
;
193 //extern DBCStorage <WorldMapAreaEntry> sWorldMapAreaStore; -- use Zone2MapCoordinates and Map2ZoneCoordinates
194 extern DBCStorage
<WorldSafeLocsEntry
> sWorldSafeLocsStore
;
196 void LoadDBCStores(std::string dataPath
);
198 // script support functions
199 MANGOS_DLL_SPEC DBCStorage
<SoundEntriesEntry
> const* GetSoundEntriesStore();
200 MANGOS_DLL_SPEC DBCStorage
<SpellEntry
> const* GetSpellStore();
201 MANGOS_DLL_SPEC DBCStorage
<SpellRangeEntry
> const* GetSpellRangeStore();