2 * Copyright (C) 2005-2010 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
19 #include "DBCStores.h"
20 #include "Policies/SingletonImp.h"
22 #include "ProgressBar.h"
23 #include "SharedDefines.h"
24 #include "ObjectDefines.h"
30 typedef std::map
<uint16
,uint32
> AreaFlagByAreaID
;
31 typedef std::map
<uint32
,uint32
> AreaFlagByMapID
;
33 DBCStorage
<AreaTableEntry
> sAreaStore(AreaTableEntryfmt
);
34 DBCStorage
<AreaGroupEntry
> sAreaGroupStore(AreaGroupEntryfmt
);
35 static AreaFlagByAreaID sAreaFlagByAreaID
;
36 static AreaFlagByMapID sAreaFlagByMapID
; // for instances without generated *.map files
38 DBCStorage
<AchievementEntry
> sAchievementStore(Achievementfmt
);
39 DBCStorage
<AchievementCriteriaEntry
> sAchievementCriteriaStore(AchievementCriteriafmt
);
40 DBCStorage
<AreaTriggerEntry
> sAreaTriggerStore(AreaTriggerEntryfmt
);
41 DBCStorage
<AuctionHouseEntry
> sAuctionHouseStore(AuctionHouseEntryfmt
);
42 DBCStorage
<BankBagSlotPricesEntry
> sBankBagSlotPricesStore(BankBagSlotPricesEntryfmt
);
43 DBCStorage
<BattlemasterListEntry
> sBattlemasterListStore(BattlemasterListEntryfmt
);
44 DBCStorage
<BarberShopStyleEntry
> sBarberShopStyleStore(BarberShopStyleEntryfmt
);
45 DBCStorage
<CharStartOutfitEntry
> sCharStartOutfitStore(CharStartOutfitEntryfmt
);
46 DBCStorage
<CharTitlesEntry
> sCharTitlesStore(CharTitlesEntryfmt
);
47 DBCStorage
<ChatChannelsEntry
> sChatChannelsStore(ChatChannelsEntryfmt
);
48 DBCStorage
<ChrClassesEntry
> sChrClassesStore(ChrClassesEntryfmt
);
49 DBCStorage
<ChrRacesEntry
> sChrRacesStore(ChrRacesEntryfmt
);
50 DBCStorage
<CinematicSequencesEntry
> sCinematicSequencesStore(CinematicSequencesEntryfmt
);
51 DBCStorage
<CreatureDisplayInfoEntry
> sCreatureDisplayInfoStore(CreatureDisplayInfofmt
);
52 DBCStorage
<CreatureFamilyEntry
> sCreatureFamilyStore(CreatureFamilyfmt
);
53 DBCStorage
<CreatureSpellDataEntry
> sCreatureSpellDataStore(CreatureSpellDatafmt
);
54 DBCStorage
<CreatureTypeEntry
> sCreatureTypeStore(CreatureTypefmt
);
55 DBCStorage
<CurrencyTypesEntry
> sCurrencyTypesStore(CurrencyTypesfmt
);
57 DBCStorage
<DurabilityQualityEntry
> sDurabilityQualityStore(DurabilityQualityfmt
);
58 DBCStorage
<DurabilityCostsEntry
> sDurabilityCostsStore(DurabilityCostsfmt
);
60 DBCStorage
<EmotesEntry
> sEmotesStore(EmotesEntryfmt
);
61 DBCStorage
<EmotesTextEntry
> sEmotesTextStore(EmotesTextEntryfmt
);
63 typedef std::map
<uint32
,SimpleFactionsList
> FactionTeamMap
;
64 static FactionTeamMap sFactionTeamMap
;
65 DBCStorage
<FactionEntry
> sFactionStore(FactionEntryfmt
);
66 DBCStorage
<FactionTemplateEntry
> sFactionTemplateStore(FactionTemplateEntryfmt
);
68 DBCStorage
<GameObjectDisplayInfoEntry
> sGameObjectDisplayInfoStore(GameObjectDisplayInfofmt
);
69 DBCStorage
<GemPropertiesEntry
> sGemPropertiesStore(GemPropertiesEntryfmt
);
70 DBCStorage
<GlyphPropertiesEntry
> sGlyphPropertiesStore(GlyphPropertiesfmt
);
71 DBCStorage
<GlyphSlotEntry
> sGlyphSlotStore(GlyphSlotfmt
);
73 DBCStorage
<GtBarberShopCostBaseEntry
> sGtBarberShopCostBaseStore(GtBarberShopCostBasefmt
);
74 DBCStorage
<GtCombatRatingsEntry
> sGtCombatRatingsStore(GtCombatRatingsfmt
);
75 DBCStorage
<GtChanceToMeleeCritBaseEntry
> sGtChanceToMeleeCritBaseStore(GtChanceToMeleeCritBasefmt
);
76 DBCStorage
<GtChanceToMeleeCritEntry
> sGtChanceToMeleeCritStore(GtChanceToMeleeCritfmt
);
77 DBCStorage
<GtChanceToSpellCritBaseEntry
> sGtChanceToSpellCritBaseStore(GtChanceToSpellCritBasefmt
);
78 DBCStorage
<GtChanceToSpellCritEntry
> sGtChanceToSpellCritStore(GtChanceToSpellCritfmt
);
79 DBCStorage
<GtOCTRegenHPEntry
> sGtOCTRegenHPStore(GtOCTRegenHPfmt
);
80 //DBCStorage <GtOCTRegenMPEntry> sGtOCTRegenMPStore(GtOCTRegenMPfmt); -- not used currently
81 DBCStorage
<GtRegenHPPerSptEntry
> sGtRegenHPPerSptStore(GtRegenHPPerSptfmt
);
82 DBCStorage
<GtRegenMPPerSptEntry
> sGtRegenMPPerSptStore(GtRegenMPPerSptfmt
);
84 DBCStorage
<HolidaysEntry
> sHolidaysStore(Holidaysfmt
);
86 DBCStorage
<ItemEntry
> sItemStore(Itemfmt
);
87 DBCStorage
<ItemBagFamilyEntry
> sItemBagFamilyStore(ItemBagFamilyfmt
);
88 //DBCStorage <ItemCondExtCostsEntry> sItemCondExtCostsStore(ItemCondExtCostsEntryfmt);
89 //DBCStorage <ItemDisplayInfoEntry> sItemDisplayInfoStore(ItemDisplayTemplateEntryfmt); -- not used currently
90 DBCStorage
<ItemExtendedCostEntry
> sItemExtendedCostStore(ItemExtendedCostEntryfmt
);
91 DBCStorage
<ItemLimitCategoryEntry
> sItemLimitCategoryStore(ItemLimitCategoryEntryfmt
);
92 DBCStorage
<ItemRandomPropertiesEntry
> sItemRandomPropertiesStore(ItemRandomPropertiesfmt
);
93 DBCStorage
<ItemRandomSuffixEntry
> sItemRandomSuffixStore(ItemRandomSuffixfmt
);
94 DBCStorage
<ItemSetEntry
> sItemSetStore(ItemSetEntryfmt
);
96 DBCStorage
<LockEntry
> sLockStore(LockEntryfmt
);
98 DBCStorage
<MailTemplateEntry
> sMailTemplateStore(MailTemplateEntryfmt
);
99 DBCStorage
<MapEntry
> sMapStore(MapEntryfmt
);
101 // DBC used only for initialization sMapDifficultyMap at startup.
102 DBCStorage
<MapDifficultyEntry
> sMapDifficultyStore(MapDifficultyEntryfmt
); // only for loading
103 MapDifficultyMap sMapDifficultyMap
;
105 DBCStorage
<MovieEntry
> sMovieStore(MovieEntryfmt
);
107 DBCStorage
<QuestSortEntry
> sQuestSortStore(QuestSortEntryfmt
);
108 DBCStorage
<PvPDifficultyEntry
> sPvPDifficultyStore(PvPDifficultyfmt
);
110 DBCStorage
<RandomPropertiesPointsEntry
> sRandomPropertiesPointsStore(RandomPropertiesPointsfmt
);
111 DBCStorage
<ScalingStatDistributionEntry
> sScalingStatDistributionStore(ScalingStatDistributionfmt
);
112 DBCStorage
<ScalingStatValuesEntry
> sScalingStatValuesStore(ScalingStatValuesfmt
);
114 DBCStorage
<SkillLineEntry
> sSkillLineStore(SkillLinefmt
);
115 DBCStorage
<SkillLineAbilityEntry
> sSkillLineAbilityStore(SkillLineAbilityfmt
);
117 DBCStorage
<SoundEntriesEntry
> sSoundEntriesStore(SoundEntriesfmt
);
119 DBCStorage
<SpellItemEnchantmentEntry
> sSpellItemEnchantmentStore(SpellItemEnchantmentfmt
);
120 DBCStorage
<SpellItemEnchantmentConditionEntry
> sSpellItemEnchantmentConditionStore(SpellItemEnchantmentConditionfmt
);
121 DBCStorage
<SpellEntry
> sSpellStore(SpellEntryfmt
);
122 SpellCategoryStore sSpellCategoryStore
;
123 PetFamilySpellsStore sPetFamilySpellsStore
;
125 DBCStorage
<SpellCastTimesEntry
> sSpellCastTimesStore(SpellCastTimefmt
);
126 DBCStorage
<SpellDurationEntry
> sSpellDurationStore(SpellDurationfmt
);
127 DBCStorage
<SpellFocusObjectEntry
> sSpellFocusObjectStore(SpellFocusObjectfmt
);
128 DBCStorage
<SpellRadiusEntry
> sSpellRadiusStore(SpellRadiusfmt
);
129 DBCStorage
<SpellRangeEntry
> sSpellRangeStore(SpellRangefmt
);
130 DBCStorage
<SpellRuneCostEntry
> sSpellRuneCostStore(SpellRuneCostfmt
);
131 DBCStorage
<SpellShapeshiftEntry
> sSpellShapeshiftStore(SpellShapeshiftfmt
);
132 DBCStorage
<StableSlotPricesEntry
> sStableSlotPricesStore(StableSlotPricesfmt
);
133 DBCStorage
<SummonPropertiesEntry
> sSummonPropertiesStore(SummonPropertiesfmt
);
134 DBCStorage
<TalentEntry
> sTalentStore(TalentEntryfmt
);
135 TalentSpellPosMap sTalentSpellPosMap
;
136 DBCStorage
<TalentTabEntry
> sTalentTabStore(TalentTabEntryfmt
);
138 // store absolute bit position for first rank for talent inspect
139 static uint32 sTalentTabPages
[MAX_CLASSES
][3];
141 DBCStorage
<TaxiNodesEntry
> sTaxiNodesStore(TaxiNodesEntryfmt
);
142 TaxiMask sTaxiNodesMask
;
143 TaxiMask sOldContinentsNodesMask
;
145 // DBC used only for initialization sTaxiPathSetBySource at startup.
146 TaxiPathSetBySource sTaxiPathSetBySource
;
147 DBCStorage
<TaxiPathEntry
> sTaxiPathStore(TaxiPathEntryfmt
);
149 // DBC used only for initialization sTaxiPathNodeStore at startup.
150 TaxiPathNodesByPath sTaxiPathNodesByPath
;
151 static DBCStorage
<TaxiPathNodeEntry
> sTaxiPathNodeStore(TaxiPathNodeEntryfmt
);
153 DBCStorage
<TotemCategoryEntry
> sTotemCategoryStore(TotemCategoryEntryfmt
);
154 DBCStorage
<VehicleEntry
> sVehicleStore(VehicleEntryfmt
);
155 DBCStorage
<VehicleSeatEntry
> sVehicleSeatStore(VehicleSeatEntryfmt
);
156 DBCStorage
<WorldMapAreaEntry
> sWorldMapAreaStore(WorldMapAreaEntryfmt
);
157 DBCStorage
<WorldMapOverlayEntry
> sWorldMapOverlayStore(WorldMapOverlayEntryfmt
);
158 DBCStorage
<WorldSafeLocsEntry
> sWorldSafeLocsStore(WorldSafeLocsEntryfmt
);
160 typedef std::list
<std::string
> StoreProblemList
;
162 static bool LoadDBC_assert_print(uint32 fsize
,uint32 rsize
, const std::string
& filename
)
164 sLog
.outError("ERROR: Size of '%s' setted by format string (%u) not equal size of C++ structure (%u).",filename
.c_str(),fsize
,rsize
);
166 // assert must fail after function call
171 inline void LoadDBC(uint32
& availableDbcLocales
,barGoLink
& bar
, StoreProblemList
& errlist
, DBCStorage
<T
>& storage
, const std::string
& dbc_path
, const std::string
& filename
)
173 // compatibility format and C++ structure sizes
174 assert(DBCFileLoader::GetFormatRecordSize(storage
.GetFormat()) == sizeof(T
) || LoadDBC_assert_print(DBCFileLoader::GetFormatRecordSize(storage
.GetFormat()),sizeof(T
),filename
));
176 std::string dbc_filename
= dbc_path
+ filename
;
177 if(storage
.Load(dbc_filename
.c_str()))
180 for(uint8 i
= 0; i
< MAX_LOCALE
; ++i
)
182 if(!(availableDbcLocales
& (1 << i
)))
185 std::string dbc_filename_loc
= dbc_path
+ localeNames
[i
] + "/" + filename
;
186 if(!storage
.LoadStringsFrom(dbc_filename_loc
.c_str()))
187 availableDbcLocales
&= ~(1<<i
); // mark as not available for speedup next checks
192 // sort problematic dbc to (1) non compatible and (2) non-existed
193 FILE * f
=fopen(dbc_filename
.c_str(),"rb");
197 snprintf(buf
,100," (exist, but have %d fields instead " SIZEFMTD
") Wrong client version DBC file?",storage
.GetFieldCount(),strlen(storage
.GetFormat()));
198 errlist
.push_back(dbc_filename
+ buf
);
202 errlist
.push_back(dbc_filename
);
206 void LoadDBCStores(const std::string
& dataPath
)
208 std::string dbcPath
= dataPath
+"dbc/";
210 const uint32 DBCFilesCount
= 82;
212 barGoLink
bar( DBCFilesCount
);
214 StoreProblemList bad_dbc_files
;
215 uint32 availableDbcLocales
= 0xFFFFFFFF;
217 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sAreaStore
, dbcPath
,"AreaTable.dbc");
219 // must be after sAreaStore loading
220 for(uint32 i
= 0; i
< sAreaStore
.GetNumRows(); ++i
) // areaflag numbered from 0
222 if(AreaTableEntry
const* area
= sAreaStore
.LookupEntry(i
))
224 // fill AreaId->DBC records
225 sAreaFlagByAreaID
.insert(AreaFlagByAreaID::value_type(uint16(area
->ID
),area
->exploreFlag
));
227 // fill MapId->DBC records ( skip sub zones and continents )
228 if(area
->zone
==0 && area
->mapid
!= 0 && area
->mapid
!= 1 && area
->mapid
!= 530 && area
->mapid
!= 571 )
229 sAreaFlagByMapID
.insert(AreaFlagByMapID::value_type(area
->mapid
,area
->exploreFlag
));
233 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sAchievementStore
, dbcPath
,"Achievement.dbc");
234 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sAchievementCriteriaStore
, dbcPath
,"Achievement_Criteria.dbc");
235 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sAreaTriggerStore
, dbcPath
,"AreaTrigger.dbc");
236 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sAreaGroupStore
, dbcPath
,"AreaGroup.dbc");
237 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sAuctionHouseStore
, dbcPath
,"AuctionHouse.dbc");
238 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sBankBagSlotPricesStore
, dbcPath
,"BankBagSlotPrices.dbc");
239 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sBattlemasterListStore
, dbcPath
,"BattlemasterList.dbc");
240 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sBarberShopStyleStore
, dbcPath
,"BarberShopStyle.dbc");
241 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sCharStartOutfitStore
, dbcPath
,"CharStartOutfit.dbc");
242 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sCharTitlesStore
, dbcPath
,"CharTitles.dbc");
243 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sChatChannelsStore
, dbcPath
,"ChatChannels.dbc");
244 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sChrClassesStore
, dbcPath
,"ChrClasses.dbc");
245 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sChrRacesStore
, dbcPath
,"ChrRaces.dbc");
246 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sCinematicSequencesStore
, dbcPath
,"CinematicSequences.dbc");
247 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sCreatureDisplayInfoStore
, dbcPath
,"CreatureDisplayInfo.dbc");
248 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sCreatureFamilyStore
, dbcPath
,"CreatureFamily.dbc");
249 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sCreatureSpellDataStore
, dbcPath
,"CreatureSpellData.dbc");
250 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sCreatureTypeStore
, dbcPath
,"CreatureType.dbc");
251 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sCurrencyTypesStore
, dbcPath
,"CurrencyTypes.dbc");
252 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sDurabilityCostsStore
, dbcPath
,"DurabilityCosts.dbc");
253 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sDurabilityQualityStore
, dbcPath
,"DurabilityQuality.dbc");
254 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sEmotesStore
, dbcPath
,"Emotes.dbc");
255 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sEmotesTextStore
, dbcPath
,"EmotesText.dbc");
256 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sFactionStore
, dbcPath
,"Faction.dbc");
257 for (uint32 i
=0;i
<sFactionStore
.GetNumRows(); ++i
)
259 FactionEntry
const * faction
= sFactionStore
.LookupEntry(i
);
260 if (faction
&& faction
->team
)
262 SimpleFactionsList
&flist
= sFactionTeamMap
[faction
->team
];
267 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sFactionTemplateStore
, dbcPath
,"FactionTemplate.dbc");
268 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sGameObjectDisplayInfoStore
,dbcPath
,"GameObjectDisplayInfo.dbc");
269 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sGemPropertiesStore
, dbcPath
,"GemProperties.dbc");
270 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sGlyphPropertiesStore
, dbcPath
,"GlyphProperties.dbc");
271 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sGlyphSlotStore
, dbcPath
,"GlyphSlot.dbc");
273 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sGtBarberShopCostBaseStore
,dbcPath
,"gtBarberShopCostBase.dbc");
274 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sGtCombatRatingsStore
, dbcPath
,"gtCombatRatings.dbc");
276 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sGtChanceToMeleeCritBaseStore
, dbcPath
,"gtChanceToMeleeCritBase.dbc");
277 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sGtChanceToMeleeCritStore
, dbcPath
,"gtChanceToMeleeCrit.dbc");
279 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sGtChanceToSpellCritBaseStore
, dbcPath
,"gtChanceToSpellCritBase.dbc");
280 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sGtChanceToSpellCritStore
, dbcPath
,"gtChanceToSpellCrit.dbc");
282 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sGtOCTRegenHPStore
, dbcPath
,"gtOCTRegenHP.dbc");
283 //LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtOCTRegenMPStore, dbcPath,"gtOCTRegenMP.dbc"); -- not used currently
284 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sGtRegenHPPerSptStore
, dbcPath
,"gtRegenHPPerSpt.dbc");
285 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sGtRegenMPPerSptStore
, dbcPath
,"gtRegenMPPerSpt.dbc");
286 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sHolidaysStore
, dbcPath
,"Holidays.dbc");
287 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sItemStore
, dbcPath
,"Item.dbc");
288 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sItemBagFamilyStore
, dbcPath
,"ItemBagFamily.dbc");
289 //LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemDisplayInfoStore, dbcPath,"ItemDisplayInfo.dbc"); -- not used currently
290 //LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemCondExtCostsStore, dbcPath,"ItemCondExtCosts.dbc");
291 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sItemExtendedCostStore
, dbcPath
,"ItemExtendedCost.dbc");
292 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sItemLimitCategoryStore
, dbcPath
,"ItemLimitCategory.dbc");
293 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sItemRandomPropertiesStore
,dbcPath
,"ItemRandomProperties.dbc");
294 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sItemRandomSuffixStore
, dbcPath
,"ItemRandomSuffix.dbc");
295 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sItemSetStore
, dbcPath
,"ItemSet.dbc");
296 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sLockStore
, dbcPath
,"Lock.dbc");
297 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sMailTemplateStore
, dbcPath
,"MailTemplate.dbc");
298 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sMapStore
, dbcPath
,"Map.dbc");
300 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sMapDifficultyStore
, dbcPath
,"MapDifficulty.dbc");
302 for(uint32 i
= 1; i
< sMapDifficultyStore
.GetNumRows(); ++i
)
303 if(MapDifficultyEntry
const* entry
= sMapDifficultyStore
.LookupEntry(i
))
304 sMapDifficultyMap
[MAKE_PAIR32(entry
->MapId
,entry
->Difficulty
)] = MapDifficulty(entry
->resetTime
,entry
->maxPlayers
);
305 sMapDifficultyStore
.Clear();
307 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sMovieStore
, dbcPath
,"Movie.dbc");
308 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sQuestSortStore
, dbcPath
,"QuestSort.dbc");
309 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sPvPDifficultyStore
, dbcPath
,"PvpDifficulty.dbc");
310 for(uint32 i
= 0; i
< sPvPDifficultyStore
.GetNumRows(); ++i
)
311 if (PvPDifficultyEntry
const* entry
= sPvPDifficultyStore
.LookupEntry(i
))
312 if (entry
->bracketId
> MAX_BATTLEGROUND_BRACKETS
)
313 assert(false && "Need update MAX_BATTLEGROUND_BRACKETS by DBC data");
315 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sRandomPropertiesPointsStore
, dbcPath
,"RandPropPoints.dbc");
316 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sScalingStatDistributionStore
, dbcPath
,"ScalingStatDistribution.dbc");
317 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sScalingStatValuesStore
, dbcPath
,"ScalingStatValues.dbc");
318 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sSkillLineStore
, dbcPath
,"SkillLine.dbc");
319 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sSkillLineAbilityStore
, dbcPath
,"SkillLineAbility.dbc");
320 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sSoundEntriesStore
, dbcPath
,"SoundEntries.dbc");
321 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sSpellStore
, dbcPath
,"Spell.dbc");
322 for(uint32 i
= 1; i
< sSpellStore
.GetNumRows(); ++i
)
324 SpellEntry
const * spell
= sSpellStore
.LookupEntry(i
);
325 if(spell
&& spell
->Category
)
326 sSpellCategoryStore
[spell
->Category
].insert(i
);
328 // DBC not support uint64 fields but SpellEntry have SpellFamilyFlags mapped at 2 uint32 fields
329 // uint32 field already converted to bigendian if need, but must be swapped for correct uint64 bigendian view
330 #if MANGOS_ENDIAN == MANGOS_BIGENDIAN
331 std::swap(*((uint32
*)(&spell
->SpellFamilyFlags
)),*(((uint32
*)(&spell
->SpellFamilyFlags
))+1));
335 for (uint32 j
= 0; j
< sSkillLineAbilityStore
.GetNumRows(); ++j
)
337 SkillLineAbilityEntry
const *skillLine
= sSkillLineAbilityStore
.LookupEntry(j
);
342 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(skillLine
->spellId
);
344 if(spellInfo
&& (spellInfo
->Attributes
& 0x1D0) == 0x1D0)
346 for (unsigned int i
= 1; i
< sCreatureFamilyStore
.GetNumRows(); ++i
)
348 CreatureFamilyEntry
const* cFamily
= sCreatureFamilyStore
.LookupEntry(i
);
352 if(skillLine
->skillId
!= cFamily
->skillLine
[0] && skillLine
->skillId
!= cFamily
->skillLine
[1])
355 sPetFamilySpellsStore
[i
].insert(spellInfo
->Id
);
360 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sSpellCastTimesStore
, dbcPath
,"SpellCastTimes.dbc");
361 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sSpellDurationStore
, dbcPath
,"SpellDuration.dbc");
362 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sSpellFocusObjectStore
, dbcPath
,"SpellFocusObject.dbc");
363 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sSpellItemEnchantmentStore
,dbcPath
,"SpellItemEnchantment.dbc");
364 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sSpellItemEnchantmentConditionStore
,dbcPath
,"SpellItemEnchantmentCondition.dbc");
365 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sSpellRadiusStore
, dbcPath
,"SpellRadius.dbc");
366 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sSpellRangeStore
, dbcPath
,"SpellRange.dbc");
367 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sSpellRuneCostStore
, dbcPath
,"SpellRuneCost.dbc");
368 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sSpellShapeshiftStore
, dbcPath
,"SpellShapeshiftForm.dbc");
369 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sStableSlotPricesStore
, dbcPath
,"StableSlotPrices.dbc");
370 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sSummonPropertiesStore
, dbcPath
,"SummonProperties.dbc");
371 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sTalentStore
, dbcPath
,"Talent.dbc");
373 // create talent spells set
374 for (unsigned int i
= 0; i
< sTalentStore
.GetNumRows(); ++i
)
376 TalentEntry
const *talentInfo
= sTalentStore
.LookupEntry(i
);
377 if (!talentInfo
) continue;
378 for (int j
= 0; j
< MAX_TALENT_RANK
; j
++)
379 if(talentInfo
->RankID
[j
])
380 sTalentSpellPosMap
[talentInfo
->RankID
[j
]] = TalentSpellPos(i
,j
);
383 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sTalentTabStore
, dbcPath
,"TalentTab.dbc");
385 // prepare fast data access to bit pos of talent ranks for use at inspecting
387 // now have all max ranks (and then bit amount used for store talent ranks in inspect)
388 for(uint32 talentTabId
= 1; talentTabId
< sTalentTabStore
.GetNumRows(); ++talentTabId
)
390 TalentTabEntry
const *talentTabInfo
= sTalentTabStore
.LookupEntry( talentTabId
);
394 // prevent memory corruption; otherwise cls will become 12 below
395 if ((talentTabInfo
->ClassMask
& CLASSMASK_ALL_PLAYABLE
)==0)
398 // store class talent tab pages
400 for(uint32 m
=1;!(m
& talentTabInfo
->ClassMask
) && cls
< MAX_CLASSES
;m
<<=1, ++cls
) {}
402 sTalentTabPages
[cls
][talentTabInfo
->tabpage
]=talentTabId
;
406 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sTaxiNodesStore
, dbcPath
,"TaxiNodes.dbc");
408 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sTaxiPathStore
, dbcPath
,"TaxiPath.dbc");
409 for(uint32 i
= 1; i
< sTaxiPathStore
.GetNumRows(); ++i
)
410 if(TaxiPathEntry
const* entry
= sTaxiPathStore
.LookupEntry(i
))
411 sTaxiPathSetBySource
[entry
->from
][entry
->to
] = TaxiPathBySourceAndDestination(entry
->ID
,entry
->price
);
412 uint32 pathCount
= sTaxiPathStore
.GetNumRows();
414 //## TaxiPathNode.dbc ## Loaded only for initialization different structures
415 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sTaxiPathNodeStore
, dbcPath
,"TaxiPathNode.dbc");
416 // Calculate path nodes count
417 std::vector
<uint32
> pathLength
;
418 pathLength
.resize(pathCount
); // 0 and some other indexes not used
419 for(uint32 i
= 1; i
< sTaxiPathNodeStore
.GetNumRows(); ++i
)
420 if(TaxiPathNodeEntry
const* entry
= sTaxiPathNodeStore
.LookupEntry(i
))
422 if (pathLength
[entry
->path
] < entry
->index
+ 1)
423 pathLength
[entry
->path
] = entry
->index
+ 1;
426 sTaxiPathNodesByPath
.resize(pathCount
); // 0 and some other indexes not used
427 for(uint32 i
= 1; i
< sTaxiPathNodesByPath
.size(); ++i
)
428 sTaxiPathNodesByPath
[i
].resize(pathLength
[i
]);
430 for(uint32 i
= 1; i
< sTaxiPathNodeStore
.GetNumRows(); ++i
)
431 if(TaxiPathNodeEntry
const* entry
= sTaxiPathNodeStore
.LookupEntry(i
))
432 sTaxiPathNodesByPath
[entry
->path
][entry
->index
] = TaxiPathNode(entry
->mapid
,entry
->x
,entry
->y
,entry
->z
,entry
->actionFlag
,entry
->delay
);
433 sTaxiPathNodeStore
.Clear();
435 // Initialize global taxinodes mask
436 // include existed nodes that have at least single not spell base (scripted) path
438 std::set
<uint32
> spellPaths
;
439 for(uint32 i
= 1; i
< sSpellStore
.GetNumRows (); ++i
)
440 if(SpellEntry
const* sInfo
= sSpellStore
.LookupEntry (i
))
441 for(int j
=0; j
< 3; ++j
)
442 if(sInfo
->Effect
[j
]==123 /*SPELL_EFFECT_SEND_TAXI*/)
443 spellPaths
.insert(sInfo
->EffectMiscValue
[j
]);
445 memset(sTaxiNodesMask
,0,sizeof(sTaxiNodesMask
));
446 memset(sOldContinentsNodesMask
,0,sizeof(sTaxiNodesMask
));
447 for(uint32 i
= 1; i
< sTaxiNodesStore
.GetNumRows(); ++i
)
449 TaxiNodesEntry
const* node
= sTaxiNodesStore
.LookupEntry(i
);
453 TaxiPathSetBySource::const_iterator src_i
= sTaxiPathSetBySource
.find(i
);
454 if(src_i
!=sTaxiPathSetBySource
.end() && !src_i
->second
.empty())
457 for(TaxiPathSetForSource::const_iterator dest_i
= src_i
->second
.begin();dest_i
!= src_i
->second
.end(); ++dest_i
)
460 if(spellPaths
.find(dest_i
->second
.ID
)==spellPaths
.end())
471 // valid taxi network node
472 uint8 field
= (uint8
)((i
- 1) / 32);
473 uint32 submask
= 1<<((i
-1)%32);
474 sTaxiNodesMask
[field
] |= submask
;
476 // old continent node (+ nodes virtually at old continents, check explicitly to avoid loading map files for zone info)
477 if (node
->map_id
< 2 || i
== 82 || i
== 83 || i
== 93 || i
== 94)
478 sOldContinentsNodesMask
[field
] |= submask
;
482 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sTotemCategoryStore
, dbcPath
,"TotemCategory.dbc");
483 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sVehicleStore
, dbcPath
,"Vehicle.dbc");
484 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sVehicleSeatStore
, dbcPath
,"VehicleSeat.dbc");
485 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sWorldMapAreaStore
, dbcPath
,"WorldMapArea.dbc");
486 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sWorldMapOverlayStore
, dbcPath
,"WorldMapOverlay.dbc");
487 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sWorldSafeLocsStore
, dbcPath
,"WorldSafeLocs.dbc");
490 if(bad_dbc_files
.size() >= DBCFilesCount
)
492 sLog
.outError("\nIncorrect DataDir value in mangosd.conf or ALL required *.dbc files (%d) not found by path: %sdbc",DBCFilesCount
,dataPath
.c_str());
495 else if(!bad_dbc_files
.empty() )
498 for(std::list
<std::string
>::iterator i
= bad_dbc_files
.begin(); i
!= bad_dbc_files
.end(); ++i
)
501 sLog
.outError("\nSome required *.dbc files (%u from %d) not found or not compatible:\n%s",(uint32
)bad_dbc_files
.size(),DBCFilesCount
,str
.c_str());
505 // Check loaded DBC files proper version
506 if( !sSpellStore
.LookupEntry(66530) || // last added spell in 3.1.3
507 !sMapStore
.LookupEntry(624) || // last map added in 3.1.3
508 !sGemPropertiesStore
.LookupEntry(1609) || // last gem property added in 3.1.3
509 !sItemExtendedCostStore
.LookupEntry(2671) || // last item extended cost added in 3.1.3
510 !sCharTitlesStore
.LookupEntry(166) || // last char title added in 3.1.3
511 !sAreaStore
.LookupEntry(2905) || // last area (areaflag) added in 3.1.3
512 !sItemStore
.LookupEntry(46894) ) // last client known item added in 3.1.3
514 sLog
.outError("\nYou have _outdated_ DBC files. Please extract correct versions from current using client.");
519 sLog
.outString( ">> Initialized %d data stores", DBCFilesCount
);
522 SimpleFactionsList
const* GetFactionTeamList(uint32 faction
)
524 FactionTeamMap::const_iterator itr
= sFactionTeamMap
.find(faction
);
525 if(itr
==sFactionTeamMap
.end())
530 char* GetPetName(uint32 petfamily
, uint32 dbclang
)
534 CreatureFamilyEntry
const *pet_family
= sCreatureFamilyStore
.LookupEntry(petfamily
);
537 return pet_family
->Name
[dbclang
]?pet_family
->Name
[dbclang
]:NULL
;
540 TalentSpellPos
const* GetTalentSpellPos(uint32 spellId
)
542 TalentSpellPosMap::const_iterator itr
= sTalentSpellPosMap
.find(spellId
);
543 if(itr
==sTalentSpellPosMap
.end())
549 uint32
GetTalentSpellCost(uint32 spellId
)
551 if(TalentSpellPos
const* pos
= GetTalentSpellPos(spellId
))
557 int32
GetAreaFlagByAreaID(uint32 area_id
)
559 AreaFlagByAreaID::iterator i
= sAreaFlagByAreaID
.find(area_id
);
560 if(i
== sAreaFlagByAreaID
.end())
566 AreaTableEntry
const* GetAreaEntryByAreaID(uint32 area_id
)
568 int32 areaflag
= GetAreaFlagByAreaID(area_id
);
572 return sAreaStore
.LookupEntry(areaflag
);
575 AreaTableEntry
const* GetAreaEntryByAreaFlagAndMap(uint32 area_flag
,uint32 map_id
)
578 return sAreaStore
.LookupEntry(area_flag
);
580 if(MapEntry
const* mapEntry
= sMapStore
.LookupEntry(map_id
))
581 return GetAreaEntryByAreaID(mapEntry
->linked_zone
);
586 uint32
GetAreaFlagByMapId(uint32 mapid
)
588 AreaFlagByMapID::iterator i
= sAreaFlagByMapID
.find(mapid
);
589 if(i
== sAreaFlagByMapID
.end())
595 uint32
GetVirtualMapForMapAndZone(uint32 mapid
, uint32 zoneId
)
597 if(mapid
!= 530 && mapid
!= 571) // speed for most cases
600 if(WorldMapAreaEntry
const* wma
= sWorldMapAreaStore
.LookupEntry(zoneId
))
601 return wma
->virtual_map_id
>= 0 ? wma
->virtual_map_id
: wma
->map_id
;
606 ContentLevels
GetContentLevelsForMapAndZone(uint32 mapid
, uint32 zoneId
)
608 mapid
= GetVirtualMapForMapAndZone(mapid
,zoneId
);
612 MapEntry
const* mapEntry
= sMapStore
.LookupEntry(mapid
);
616 switch(mapEntry
->Expansion())
618 default: return CONTENT_1_60
;
619 case 1: return CONTENT_61_70
;
620 case 2: return CONTENT_71_80
;
624 ChatChannelsEntry
const* GetChannelEntryFor(uint32 channel_id
)
626 // not sorted, numbering index from 0
627 for(uint32 i
= 0; i
< sChatChannelsStore
.GetNumRows(); ++i
)
629 ChatChannelsEntry
const* ch
= sChatChannelsStore
.LookupEntry(i
);
630 if(ch
&& ch
->ChannelID
== channel_id
)
636 bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId
, uint32 requiredTotemCategoryId
)
638 if(requiredTotemCategoryId
==0)
640 if(itemTotemCategoryId
==0)
643 TotemCategoryEntry
const* itemEntry
= sTotemCategoryStore
.LookupEntry(itemTotemCategoryId
);
646 TotemCategoryEntry
const* reqEntry
= sTotemCategoryStore
.LookupEntry(requiredTotemCategoryId
);
650 if(itemEntry
->categoryType
!=reqEntry
->categoryType
)
653 return (itemEntry
->categoryMask
& reqEntry
->categoryMask
)==reqEntry
->categoryMask
;
656 void Zone2MapCoordinates(float& x
,float& y
,uint32 zone
)
658 WorldMapAreaEntry
const* maEntry
= sWorldMapAreaStore
.LookupEntry(zone
);
660 // if not listed then map coordinates (instance)
664 std::swap(x
,y
); // at client map coords swapped
665 x
= x
*((maEntry
->x2
-maEntry
->x1
)/100)+maEntry
->x1
;
666 y
= y
*((maEntry
->y2
-maEntry
->y1
)/100)+maEntry
->y1
; // client y coord from top to down
669 void Map2ZoneCoordinates(float& x
,float& y
,uint32 zone
)
671 WorldMapAreaEntry
const* maEntry
= sWorldMapAreaStore
.LookupEntry(zone
);
673 // if not listed then map coordinates (instance)
677 x
= (x
-maEntry
->x1
)/((maEntry
->x2
-maEntry
->x1
)/100);
678 y
= (y
-maEntry
->y1
)/((maEntry
->y2
-maEntry
->y1
)/100); // client y coord from top to down
679 std::swap(x
,y
); // client have map coords swapped
682 MapDifficulty
const* GetMapDifficultyData(uint32 mapId
, Difficulty difficulty
)
684 MapDifficultyMap::const_iterator itr
= sMapDifficultyMap
.find(MAKE_PAIR32(mapId
,difficulty
));
685 return itr
!= sMapDifficultyMap
.end() ? &itr
->second
: NULL
;
688 PvPDifficultyEntry
const* GetBattlegroundBracketByLevel( uint32 mapid
, uint32 level
)
690 // prevent out-of-range levels for dbc data
691 if (level
> DEFAULT_MAX_LEVEL
)
692 level
= DEFAULT_MAX_LEVEL
;
694 for(uint32 i
= 0; i
< sPvPDifficultyStore
.GetNumRows(); ++i
)
695 if (PvPDifficultyEntry
const* entry
= sPvPDifficultyStore
.LookupEntry(i
))
696 if (entry
->mapId
== mapid
&& entry
->minLevel
<= level
&& entry
->maxLevel
>= level
)
702 PvPDifficultyEntry
const* GetBattlegroundBracketById(uint32 mapid
, BattleGroundBracketId id
)
704 for(uint32 i
= 0; i
< sPvPDifficultyStore
.GetNumRows(); ++i
)
705 if (PvPDifficultyEntry
const* entry
= sPvPDifficultyStore
.LookupEntry(i
))
706 if (entry
->mapId
== mapid
&& entry
->GetBracketId() == id
)
712 uint32
const* GetTalentTabPages(uint32 cls
)
714 return sTalentTabPages
[cls
];
717 // script support functions
718 MANGOS_DLL_SPEC DBCStorage
<SoundEntriesEntry
> const* GetSoundEntriesStore() { return &sSoundEntriesStore
; }
719 MANGOS_DLL_SPEC DBCStorage
<SpellEntry
> const* GetSpellStore() { return &sSpellStore
; }
720 MANGOS_DLL_SPEC DBCStorage
<SpellRangeEntry
> const* GetSpellRangeStore() { return &sSpellRangeStore
; }
721 MANGOS_DLL_SPEC DBCStorage
<FactionEntry
> const* GetFactionStore() { return &sFactionStore
; }
722 MANGOS_DLL_SPEC DBCStorage
<ItemEntry
> const* GetItemDisplayStore() { return &sItemStore
; }
723 MANGOS_DLL_SPEC DBCStorage
<CreatureDisplayInfoEntry
> const* GetCreatureDisplayStore() { return &sCreatureDisplayInfoStore
; }
724 MANGOS_DLL_SPEC DBCStorage
<EmotesEntry
> const* GetEmotesStore() { return &sEmotesStore
; }
725 MANGOS_DLL_SPEC DBCStorage
<EmotesTextEntry
> const* GetEmotesTextStore() { return &sEmotesTextStore
; }