2 * Copyright (C) 2005-2009 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"
29 typedef std::map
<uint16
,uint32
> AreaFlagByAreaID
;
30 typedef std::map
<uint32
,uint32
> AreaFlagByMapID
;
32 DBCStorage
<AreaTableEntry
> sAreaStore(AreaTableEntryfmt
);
33 DBCStorage
<AreaGroupEntry
> sAreaGroupStore(AreaGroupEntryfmt
);
34 static AreaFlagByAreaID sAreaFlagByAreaID
;
35 static AreaFlagByMapID sAreaFlagByMapID
; // for instances without generated *.map files
37 DBCStorage
<AchievementEntry
> sAchievementStore(Achievementfmt
);
38 DBCStorage
<AchievementCriteriaEntry
> sAchievementCriteriaStore(AchievementCriteriafmt
);
39 DBCStorage
<AreaTriggerEntry
> sAreaTriggerStore(AreaTriggerEntryfmt
);
40 DBCStorage
<AuctionHouseEntry
> sAuctionHouseStore(AuctionHouseEntryfmt
);
41 DBCStorage
<BankBagSlotPricesEntry
> sBankBagSlotPricesStore(BankBagSlotPricesEntryfmt
);
42 DBCStorage
<BattlemasterListEntry
> sBattlemasterListStore(BattlemasterListEntryfmt
);
43 DBCStorage
<BarberShopStyleEntry
> sBarberShopStyleStore(BarberShopStyleEntryfmt
);
44 DBCStorage
<CharStartOutfitEntry
> sCharStartOutfitStore(CharStartOutfitEntryfmt
);
45 DBCStorage
<CharTitlesEntry
> sCharTitlesStore(CharTitlesEntryfmt
);
46 DBCStorage
<ChatChannelsEntry
> sChatChannelsStore(ChatChannelsEntryfmt
);
47 DBCStorage
<ChrClassesEntry
> sChrClassesStore(ChrClassesEntryfmt
);
48 DBCStorage
<ChrRacesEntry
> sChrRacesStore(ChrRacesEntryfmt
);
49 DBCStorage
<CinematicSequencesEntry
> sCinematicSequencesStore(CinematicSequencesEntryfmt
);
50 DBCStorage
<CreatureDisplayInfoEntry
> sCreatureDisplayInfoStore(CreatureDisplayInfofmt
);
51 DBCStorage
<CreatureFamilyEntry
> sCreatureFamilyStore(CreatureFamilyfmt
);
52 DBCStorage
<CreatureSpellDataEntry
> sCreatureSpellDataStore(CreatureSpellDatafmt
);
53 DBCStorage
<CreatureTypeEntry
> sCreatureTypeStore(CreatureTypefmt
);
54 DBCStorage
<CurrencyTypesEntry
> sCurrencyTypesStore(CurrencyTypesfmt
);
56 DBCStorage
<DurabilityQualityEntry
> sDurabilityQualityStore(DurabilityQualityfmt
);
57 DBCStorage
<DurabilityCostsEntry
> sDurabilityCostsStore(DurabilityCostsfmt
);
59 DBCStorage
<EmotesEntry
> sEmotesStore(EmotesEntryfmt
);
60 DBCStorage
<EmotesTextEntry
> sEmotesTextStore(EmotesTextEntryfmt
);
62 typedef std::map
<uint32
,SimpleFactionsList
> FactionTeamMap
;
63 static FactionTeamMap sFactionTeamMap
;
64 DBCStorage
<FactionEntry
> sFactionStore(FactionEntryfmt
);
65 DBCStorage
<FactionTemplateEntry
> sFactionTemplateStore(FactionTemplateEntryfmt
);
67 DBCStorage
<GemPropertiesEntry
> sGemPropertiesStore(GemPropertiesEntryfmt
);
68 DBCStorage
<GlyphPropertiesEntry
> sGlyphPropertiesStore(GlyphPropertiesfmt
);
69 DBCStorage
<GlyphSlotEntry
> sGlyphSlotStore(GlyphSlotfmt
);
71 DBCStorage
<GtBarberShopCostBaseEntry
> sGtBarberShopCostBaseStore(GtBarberShopCostBasefmt
);
72 DBCStorage
<GtCombatRatingsEntry
> sGtCombatRatingsStore(GtCombatRatingsfmt
);
73 DBCStorage
<GtChanceToMeleeCritBaseEntry
> sGtChanceToMeleeCritBaseStore(GtChanceToMeleeCritBasefmt
);
74 DBCStorage
<GtChanceToMeleeCritEntry
> sGtChanceToMeleeCritStore(GtChanceToMeleeCritfmt
);
75 DBCStorage
<GtChanceToSpellCritBaseEntry
> sGtChanceToSpellCritBaseStore(GtChanceToSpellCritBasefmt
);
76 DBCStorage
<GtChanceToSpellCritEntry
> sGtChanceToSpellCritStore(GtChanceToSpellCritfmt
);
77 DBCStorage
<GtOCTRegenHPEntry
> sGtOCTRegenHPStore(GtOCTRegenHPfmt
);
78 //DBCStorage <GtOCTRegenMPEntry> sGtOCTRegenMPStore(GtOCTRegenMPfmt); -- not used currently
79 DBCStorage
<GtRegenHPPerSptEntry
> sGtRegenHPPerSptStore(GtRegenHPPerSptfmt
);
80 DBCStorage
<GtRegenMPPerSptEntry
> sGtRegenMPPerSptStore(GtRegenMPPerSptfmt
);
82 DBCStorage
<HolidaysEntry
> sHolidaysStore(Holidaysfmt
);
84 DBCStorage
<ItemEntry
> sItemStore(Itemfmt
);
85 DBCStorage
<ItemBagFamilyEntry
> sItemBagFamilyStore(ItemBagFamilyfmt
);
86 //DBCStorage <ItemCondExtCostsEntry> sItemCondExtCostsStore(ItemCondExtCostsEntryfmt);
87 //DBCStorage <ItemDisplayInfoEntry> sItemDisplayInfoStore(ItemDisplayTemplateEntryfmt); -- not used currently
88 DBCStorage
<ItemExtendedCostEntry
> sItemExtendedCostStore(ItemExtendedCostEntryfmt
);
89 DBCStorage
<ItemLimitCategoryEntry
> sItemLimitCategoryStore(ItemLimitCategoryEntryfmt
);
90 DBCStorage
<ItemRandomPropertiesEntry
> sItemRandomPropertiesStore(ItemRandomPropertiesfmt
);
91 DBCStorage
<ItemRandomSuffixEntry
> sItemRandomSuffixStore(ItemRandomSuffixfmt
);
92 DBCStorage
<ItemSetEntry
> sItemSetStore(ItemSetEntryfmt
);
94 DBCStorage
<LockEntry
> sLockStore(LockEntryfmt
);
96 DBCStorage
<MailTemplateEntry
> sMailTemplateStore(MailTemplateEntryfmt
);
97 DBCStorage
<MapEntry
> sMapStore(MapEntryfmt
);
98 DBCStorage
<MovieEntry
> sMovieStore(MovieEntryfmt
);
100 DBCStorage
<QuestSortEntry
> sQuestSortStore(QuestSortEntryfmt
);
102 DBCStorage
<RandomPropertiesPointsEntry
> sRandomPropertiesPointsStore(RandomPropertiesPointsfmt
);
103 DBCStorage
<ScalingStatDistributionEntry
> sScalingStatDistributionStore(ScalingStatDistributionfmt
);
104 DBCStorage
<ScalingStatValuesEntry
> sScalingStatValuesStore(ScalingStatValuesfmt
);
106 DBCStorage
<SkillLineEntry
> sSkillLineStore(SkillLinefmt
);
107 DBCStorage
<SkillLineAbilityEntry
> sSkillLineAbilityStore(SkillLineAbilityfmt
);
109 DBCStorage
<SoundEntriesEntry
> sSoundEntriesStore(SoundEntriesfmt
);
111 DBCStorage
<SpellItemEnchantmentEntry
> sSpellItemEnchantmentStore(SpellItemEnchantmentfmt
);
112 DBCStorage
<SpellItemEnchantmentConditionEntry
> sSpellItemEnchantmentConditionStore(SpellItemEnchantmentConditionfmt
);
113 DBCStorage
<SpellEntry
> sSpellStore(SpellEntryfmt
);
114 SpellCategoryStore sSpellCategoryStore
;
115 PetFamilySpellsStore sPetFamilySpellsStore
;
117 DBCStorage
<SpellCastTimesEntry
> sSpellCastTimesStore(SpellCastTimefmt
);
118 DBCStorage
<SpellDurationEntry
> sSpellDurationStore(SpellDurationfmt
);
119 DBCStorage
<SpellFocusObjectEntry
> sSpellFocusObjectStore(SpellFocusObjectfmt
);
120 DBCStorage
<SpellRadiusEntry
> sSpellRadiusStore(SpellRadiusfmt
);
121 DBCStorage
<SpellRangeEntry
> sSpellRangeStore(SpellRangefmt
);
122 DBCStorage
<SpellRuneCostEntry
> sSpellRuneCostStore(SpellRuneCostfmt
);
123 DBCStorage
<SpellShapeshiftEntry
> sSpellShapeshiftStore(SpellShapeshiftfmt
);
124 DBCStorage
<StableSlotPricesEntry
> sStableSlotPricesStore(StableSlotPricesfmt
);
125 //DBCStorage <SummonPropertiesEntry> sSummonPropertiesStore(SummonPropertiesfmt);
126 DBCStorage
<TalentEntry
> sTalentStore(TalentEntryfmt
);
127 TalentSpellPosMap sTalentSpellPosMap
;
128 DBCStorage
<TalentTabEntry
> sTalentTabStore(TalentTabEntryfmt
);
130 // store absolute bit position for first rank for talent inspect
131 typedef std::map
<uint32
,uint32
> TalentInspectMap
;
132 static TalentInspectMap sTalentPosInInspect
;
133 static TalentInspectMap sTalentTabSizeInInspect
;
134 static uint32 sTalentTabPages
[12/*MAX_CLASSES*/][3];
136 DBCStorage
<TaxiNodesEntry
> sTaxiNodesStore(TaxiNodesEntryfmt
);
137 TaxiMask sTaxiNodesMask
;
138 TaxiMask sOldContinentsNodesMask
;
140 // DBC used only for initialization sTaxiPathSetBySource at startup.
141 TaxiPathSetBySource sTaxiPathSetBySource
;
142 DBCStorage
<TaxiPathEntry
> sTaxiPathStore(TaxiPathEntryfmt
);
144 // DBC used only for initialization sTaxiPathSetBySource at startup.
145 TaxiPathNodesByPath sTaxiPathNodesByPath
;
147 static DBCStorage
<TaxiPathNodeEntry
> sTaxiPathNodeStore(TaxiPathNodeEntryfmt
);
148 DBCStorage
<TotemCategoryEntry
> sTotemCategoryStore(TotemCategoryEntryfmt
);
149 DBCStorage
<VehicleEntry
> sVehicleStore(VehicleEntryfmt
);
150 DBCStorage
<VehicleSeatEntry
> sVehicleSeatStore(VehicleSeatEntryfmt
);
151 DBCStorage
<WorldMapAreaEntry
> sWorldMapAreaStore(WorldMapAreaEntryfmt
);
152 DBCStorage
<WorldMapOverlayEntry
> sWorldMapOverlayStore(WorldMapOverlayEntryfmt
);
153 DBCStorage
<WorldSafeLocsEntry
> sWorldSafeLocsStore(WorldSafeLocsEntryfmt
);
155 typedef std::list
<std::string
> StoreProblemList
;
157 static bool LoadDBC_assert_print(uint32 fsize
,uint32 rsize
, const std::string
& filename
)
159 sLog
.outError("ERROR: Size of '%s' setted by format string (%u) not equal size of C++ structure (%u).",filename
.c_str(),fsize
,rsize
);
161 // assert must fail after function call
166 inline void LoadDBC(uint32
& availableDbcLocales
,barGoLink
& bar
, StoreProblemList
& errlist
, DBCStorage
<T
>& storage
, const std::string
& dbc_path
, const std::string
& filename
)
168 // compatibility format and C++ structure sizes
169 assert(DBCFileLoader::GetFormatRecordSize(storage
.GetFormat()) == sizeof(T
) || LoadDBC_assert_print(DBCFileLoader::GetFormatRecordSize(storage
.GetFormat()),sizeof(T
),filename
));
171 std::string dbc_filename
= dbc_path
+ filename
;
172 if(storage
.Load(dbc_filename
.c_str()))
175 for(uint8 i
= 0; i
< MAX_LOCALE
; ++i
)
177 if(!(availableDbcLocales
& (1 << i
)))
180 std::string dbc_filename_loc
= dbc_path
+ localeNames
[i
] + "/" + filename
;
181 if(!storage
.LoadStringsFrom(dbc_filename_loc
.c_str()))
182 availableDbcLocales
&= ~(1<<i
); // mark as not available for speedup next checks
187 // sort problematic dbc to (1) non compatible and (2) non-existed
188 FILE * f
=fopen(dbc_filename
.c_str(),"rb");
192 snprintf(buf
,100," (exist, but have %d fields instead %d) Wrong client version DBC file?",storage
.GetFieldCount(),strlen(storage
.GetFormat()));
193 errlist
.push_back(dbc_filename
+ buf
);
197 errlist
.push_back(dbc_filename
);
201 void LoadDBCStores(const std::string
& dataPath
)
203 std::string dbcPath
= dataPath
+"dbc/";
205 const uint32 DBCFilesCount
= 78;
207 barGoLink
bar( DBCFilesCount
);
209 StoreProblemList bad_dbc_files
;
210 uint32 availableDbcLocales
= 0xFFFFFFFF;
212 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sAreaStore
, dbcPath
,"AreaTable.dbc");
214 // must be after sAreaStore loading
215 for(uint32 i
= 0; i
< sAreaStore
.GetNumRows(); ++i
) // areaflag numbered from 0
217 if(AreaTableEntry
const* area
= sAreaStore
.LookupEntry(i
))
219 // fill AreaId->DBC records
220 sAreaFlagByAreaID
.insert(AreaFlagByAreaID::value_type(uint16(area
->ID
),area
->exploreFlag
));
222 // fill MapId->DBC records ( skip sub zones and continents )
223 if(area
->zone
==0 && area
->mapid
!= 0 && area
->mapid
!= 1 && area
->mapid
!= 530 && area
->mapid
!= 571 )
224 sAreaFlagByMapID
.insert(AreaFlagByMapID::value_type(area
->mapid
,area
->exploreFlag
));
228 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sAchievementStore
, dbcPath
,"Achievement.dbc");
229 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sAchievementCriteriaStore
, dbcPath
,"Achievement_Criteria.dbc");
230 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sAreaTriggerStore
, dbcPath
,"AreaTrigger.dbc");
231 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sAreaGroupStore
, dbcPath
,"AreaGroup.dbc");
232 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sAuctionHouseStore
, dbcPath
,"AuctionHouse.dbc");
233 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sBankBagSlotPricesStore
, dbcPath
,"BankBagSlotPrices.dbc");
234 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sBattlemasterListStore
, dbcPath
,"BattlemasterList.dbc");
235 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sBarberShopStyleStore
, dbcPath
,"BarberShopStyle.dbc");
236 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sCharStartOutfitStore
, dbcPath
,"CharStartOutfit.dbc");
238 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sCharTitlesStore
, dbcPath
,"CharTitles.dbc");
239 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sChatChannelsStore
, dbcPath
,"ChatChannels.dbc");
240 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sChrClassesStore
, dbcPath
,"ChrClasses.dbc");
241 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sChrRacesStore
, dbcPath
,"ChrRaces.dbc");
242 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sCinematicSequencesStore
, dbcPath
,"CinematicSequences.dbc");
243 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sCreatureDisplayInfoStore
, dbcPath
,"CreatureDisplayInfo.dbc");
244 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sCreatureFamilyStore
, dbcPath
,"CreatureFamily.dbc");
245 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sCreatureSpellDataStore
, dbcPath
,"CreatureSpellData.dbc");
246 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sCreatureTypeStore
, dbcPath
,"CreatureType.dbc");
247 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sCurrencyTypesStore
, dbcPath
,"CurrencyTypes.dbc");
248 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sDurabilityCostsStore
, dbcPath
,"DurabilityCosts.dbc");
249 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sDurabilityQualityStore
, dbcPath
,"DurabilityQuality.dbc");
250 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sEmotesStore
, dbcPath
,"Emotes.dbc");
251 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sEmotesTextStore
, dbcPath
,"EmotesText.dbc");
252 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sFactionStore
, dbcPath
,"Faction.dbc");
253 for (uint32 i
=0;i
<sFactionStore
.GetNumRows(); ++i
)
255 FactionEntry
const * faction
= sFactionStore
.LookupEntry(i
);
256 if (faction
&& faction
->team
)
258 SimpleFactionsList
&flist
= sFactionTeamMap
[faction
->team
];
263 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sFactionTemplateStore
, dbcPath
,"FactionTemplate.dbc");
264 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sGemPropertiesStore
, dbcPath
,"GemProperties.dbc");
265 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sGlyphPropertiesStore
, dbcPath
,"GlyphProperties.dbc");
266 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sGlyphSlotStore
, dbcPath
,"GlyphSlot.dbc");
268 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sGtBarberShopCostBaseStore
,dbcPath
,"gtBarberShopCostBase.dbc");
269 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sGtCombatRatingsStore
, dbcPath
,"gtCombatRatings.dbc");
271 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sGtChanceToMeleeCritBaseStore
, dbcPath
,"gtChanceToMeleeCritBase.dbc");
272 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sGtChanceToMeleeCritStore
, dbcPath
,"gtChanceToMeleeCrit.dbc");
274 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sGtChanceToSpellCritBaseStore
, dbcPath
,"gtChanceToSpellCritBase.dbc");
275 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sGtChanceToSpellCritStore
, dbcPath
,"gtChanceToSpellCrit.dbc");
277 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sGtOCTRegenHPStore
, dbcPath
,"gtOCTRegenHP.dbc");
278 //LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtOCTRegenMPStore, dbcPath,"gtOCTRegenMP.dbc"); -- not used currently
279 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sGtRegenHPPerSptStore
, dbcPath
,"gtRegenHPPerSpt.dbc");
280 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sGtRegenMPPerSptStore
, dbcPath
,"gtRegenMPPerSpt.dbc");
281 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sHolidaysStore
, dbcPath
,"Holidays.dbc");
282 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sItemStore
, dbcPath
,"Item.dbc");
283 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sItemBagFamilyStore
, dbcPath
,"ItemBagFamily.dbc");
284 //LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemDisplayInfoStore, dbcPath,"ItemDisplayInfo.dbc"); -- not used currently
285 //LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemCondExtCostsStore, dbcPath,"ItemCondExtCosts.dbc");
286 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sItemExtendedCostStore
, dbcPath
,"ItemExtendedCost.dbc");
287 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sItemLimitCategoryStore
, dbcPath
,"ItemLimitCategory.dbc");
288 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sItemRandomPropertiesStore
,dbcPath
,"ItemRandomProperties.dbc");
289 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sItemRandomSuffixStore
, dbcPath
,"ItemRandomSuffix.dbc");
290 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sItemSetStore
, dbcPath
,"ItemSet.dbc");
291 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sLockStore
, dbcPath
,"Lock.dbc");
292 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sMailTemplateStore
, dbcPath
,"MailTemplate.dbc");
293 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sMapStore
, dbcPath
,"Map.dbc");
294 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sMovieStore
, dbcPath
,"Movie.dbc");
295 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sQuestSortStore
, dbcPath
,"QuestSort.dbc");
296 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sRandomPropertiesPointsStore
, dbcPath
,"RandPropPoints.dbc");
297 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sScalingStatDistributionStore
, dbcPath
,"ScalingStatDistribution.dbc");
298 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sScalingStatValuesStore
, dbcPath
,"ScalingStatValues.dbc");
299 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sSkillLineStore
, dbcPath
,"SkillLine.dbc");
300 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sSkillLineAbilityStore
, dbcPath
,"SkillLineAbility.dbc");
301 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sSoundEntriesStore
, dbcPath
,"SoundEntries.dbc");
302 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sSpellStore
, dbcPath
,"Spell.dbc");
303 for(uint32 i
= 1; i
< sSpellStore
.GetNumRows(); ++i
)
305 SpellEntry
const * spell
= sSpellStore
.LookupEntry(i
);
306 if(spell
&& spell
->Category
)
307 sSpellCategoryStore
[spell
->Category
].insert(i
);
309 // DBC not support uint64 fields but SpellEntry have SpellFamilyFlags mapped at 2 uint32 fields
310 // uint32 field already converted to bigendian if need, but must be swapped for correct uint64 bigendian view
311 #if MANGOS_ENDIAN == MANGOS_BIGENDIAN
312 std::swap(*((uint32
*)(&spell
->SpellFamilyFlags
)),*(((uint32
*)(&spell
->SpellFamilyFlags
))+1));
316 for (uint32 j
= 0; j
< sSkillLineAbilityStore
.GetNumRows(); ++j
)
318 SkillLineAbilityEntry
const *skillLine
= sSkillLineAbilityStore
.LookupEntry(j
);
323 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(skillLine
->spellId
);
325 if(spellInfo
&& (spellInfo
->Attributes
& 0x1D0) == 0x1D0)
327 for (unsigned int i
= 1; i
< sCreatureFamilyStore
.GetNumRows(); ++i
)
329 CreatureFamilyEntry
const* cFamily
= sCreatureFamilyStore
.LookupEntry(i
);
333 if(skillLine
->skillId
!= cFamily
->skillLine
[0] && skillLine
->skillId
!= cFamily
->skillLine
[1])
336 sPetFamilySpellsStore
[i
].insert(spellInfo
->Id
);
341 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sSpellCastTimesStore
, dbcPath
,"SpellCastTimes.dbc");
342 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sSpellDurationStore
, dbcPath
,"SpellDuration.dbc");
343 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sSpellFocusObjectStore
, dbcPath
,"SpellFocusObject.dbc");
344 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sSpellItemEnchantmentStore
,dbcPath
,"SpellItemEnchantment.dbc");
345 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sSpellItemEnchantmentConditionStore
,dbcPath
,"SpellItemEnchantmentCondition.dbc");
346 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sSpellRadiusStore
, dbcPath
,"SpellRadius.dbc");
347 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sSpellRangeStore
, dbcPath
,"SpellRange.dbc");
348 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sSpellRuneCostStore
, dbcPath
,"SpellRuneCost.dbc");
349 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sSpellShapeshiftStore
, dbcPath
,"SpellShapeshiftForm.dbc");
350 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sStableSlotPricesStore
, dbcPath
,"StableSlotPrices.dbc");
351 //LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSummonPropertiesStore, dbcPath,"SummonProperties.dbc");
352 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sTalentStore
, dbcPath
,"Talent.dbc");
354 // create talent spells set
355 for (unsigned int i
= 0; i
< sTalentStore
.GetNumRows(); ++i
)
357 TalentEntry
const *talentInfo
= sTalentStore
.LookupEntry(i
);
358 if (!talentInfo
) continue;
359 for (int j
= 0; j
< MAX_TALENT_RANK
; j
++)
360 if(talentInfo
->RankID
[j
])
361 sTalentSpellPosMap
[talentInfo
->RankID
[j
]] = TalentSpellPos(i
,j
);
364 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sTalentTabStore
, dbcPath
,"TalentTab.dbc");
366 // prepare fast data access to bit pos of talent ranks for use at inspecting
368 // fill table by amount of talent ranks and fill sTalentTabBitSizeInInspect
369 // store in with (row,col,talent)->size key for correct sorting by (row,col)
370 typedef std::map
<uint32
,uint32
> TalentBitSize
;
371 TalentBitSize sTalentBitSize
;
372 for(uint32 i
= 1; i
< sTalentStore
.GetNumRows(); ++i
)
374 TalentEntry
const *talentInfo
= sTalentStore
.LookupEntry(i
);
375 if (!talentInfo
) continue;
377 TalentTabEntry
const *talentTabInfo
= sTalentTabStore
.LookupEntry( talentInfo
->TalentTab
);
382 uint32 curtalent_maxrank
= 0;
383 for(uint32 k
= MAX_TALENT_RANK
; k
> 0; --k
)
385 if(talentInfo
->RankID
[k
-1])
387 curtalent_maxrank
= k
;
392 sTalentBitSize
[(talentInfo
->Row
<<24) + (talentInfo
->Col
<<16)+talentInfo
->TalentID
] = curtalent_maxrank
;
393 sTalentTabSizeInInspect
[talentInfo
->TalentTab
] += curtalent_maxrank
;
396 // now have all max ranks (and then bit amount used for store talent ranks in inspect)
397 for(uint32 talentTabId
= 1; talentTabId
< sTalentTabStore
.GetNumRows(); ++talentTabId
)
399 TalentTabEntry
const *talentTabInfo
= sTalentTabStore
.LookupEntry( talentTabId
);
403 // prevent memory corruption; otherwise cls will become 12 below
404 if ((talentTabInfo
->ClassMask
& CLASSMASK_ALL_PLAYABLE
)==0)
407 // store class talent tab pages
409 for(uint32 m
=1;!(m
& talentTabInfo
->ClassMask
) && cls
< MAX_CLASSES
;m
<<=1, ++cls
) {}
411 sTalentTabPages
[cls
][talentTabInfo
->tabpage
]=talentTabId
;
413 // add total amount bits for first rank starting from talent tab first talent rank pos.
415 for(TalentBitSize::iterator itr
= sTalentBitSize
.begin(); itr
!= sTalentBitSize
.end(); ++itr
)
417 uint32 talentId
= itr
->first
& 0xFFFF;
418 TalentEntry
const *talentInfo
= sTalentStore
.LookupEntry( talentId
);
422 if(talentInfo
->TalentTab
!= talentTabId
)
425 sTalentPosInInspect
[talentId
] = pos
;
431 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sTaxiNodesStore
, dbcPath
,"TaxiNodes.dbc");
433 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sTaxiPathStore
, dbcPath
,"TaxiPath.dbc");
434 for(uint32 i
= 1; i
< sTaxiPathStore
.GetNumRows(); ++i
)
435 if(TaxiPathEntry
const* entry
= sTaxiPathStore
.LookupEntry(i
))
436 sTaxiPathSetBySource
[entry
->from
][entry
->to
] = TaxiPathBySourceAndDestination(entry
->ID
,entry
->price
);
437 uint32 pathCount
= sTaxiPathStore
.GetNumRows();
439 //## TaxiPathNode.dbc ## Loaded only for initialization different structures
440 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sTaxiPathNodeStore
, dbcPath
,"TaxiPathNode.dbc");
441 // Calculate path nodes count
442 std::vector
<uint32
> pathLength
;
443 pathLength
.resize(pathCount
); // 0 and some other indexes not used
444 for(uint32 i
= 1; i
< sTaxiPathNodeStore
.GetNumRows(); ++i
)
445 if(TaxiPathNodeEntry
const* entry
= sTaxiPathNodeStore
.LookupEntry(i
))
447 if (pathLength
[entry
->path
] < entry
->index
+ 1)
448 pathLength
[entry
->path
] = entry
->index
+ 1;
451 sTaxiPathNodesByPath
.resize(pathCount
); // 0 and some other indexes not used
452 for(uint32 i
= 1; i
< sTaxiPathNodesByPath
.size(); ++i
)
453 sTaxiPathNodesByPath
[i
].resize(pathLength
[i
]);
455 for(uint32 i
= 1; i
< sTaxiPathNodeStore
.GetNumRows(); ++i
)
456 if(TaxiPathNodeEntry
const* entry
= sTaxiPathNodeStore
.LookupEntry(i
))
457 sTaxiPathNodesByPath
[entry
->path
][entry
->index
] = TaxiPathNode(entry
->mapid
,entry
->x
,entry
->y
,entry
->z
,entry
->actionFlag
,entry
->delay
);
458 sTaxiPathNodeStore
.Clear();
460 // Initialize global taxinodes mask
461 // include existed nodes that have at least single not spell base (scripted) path
463 std::set
<uint32
> spellPaths
;
464 for(uint32 i
= 1; i
< sSpellStore
.GetNumRows (); ++i
)
465 if(SpellEntry
const* sInfo
= sSpellStore
.LookupEntry (i
))
466 for(int j
=0; j
< 3; ++j
)
467 if(sInfo
->Effect
[j
]==123 /*SPELL_EFFECT_SEND_TAXI*/)
468 spellPaths
.insert(sInfo
->EffectMiscValue
[j
]);
470 memset(sTaxiNodesMask
,0,sizeof(sTaxiNodesMask
));
471 memset(sOldContinentsNodesMask
,0,sizeof(sTaxiNodesMask
));
472 for(uint32 i
= 1; i
< sTaxiNodesStore
.GetNumRows(); ++i
)
474 TaxiNodesEntry
const* node
= sTaxiNodesStore
.LookupEntry(i
);
478 TaxiPathSetBySource::const_iterator src_i
= sTaxiPathSetBySource
.find(i
);
479 if(src_i
!=sTaxiPathSetBySource
.end() && !src_i
->second
.empty())
482 for(TaxiPathSetForSource::const_iterator dest_i
= src_i
->second
.begin();dest_i
!= src_i
->second
.end(); ++dest_i
)
485 if(spellPaths
.find(dest_i
->second
.ID
)==spellPaths
.end())
496 // valid taxi network node
497 uint8 field
= (uint8
)((i
- 1) / 32);
498 uint32 submask
= 1<<((i
-1)%32);
499 sTaxiNodesMask
[field
] |= submask
;
501 // old continent node (+ nodes virtually at old continents, check explicitly to avoid loading map files for zone info)
502 if (node
->map_id
< 2 || i
== 82 || i
== 83 || i
== 93 || i
== 94)
503 sOldContinentsNodesMask
[field
] |= submask
;
507 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sTotemCategoryStore
, dbcPath
,"TotemCategory.dbc");
508 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sVehicleStore
, dbcPath
,"Vehicle.dbc");
509 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sVehicleSeatStore
, dbcPath
,"VehicleSeat.dbc");
510 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sWorldMapAreaStore
, dbcPath
,"WorldMapArea.dbc");
511 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sWorldMapOverlayStore
, dbcPath
,"WorldMapOverlay.dbc");
512 LoadDBC(availableDbcLocales
,bar
,bad_dbc_files
,sWorldSafeLocsStore
, dbcPath
,"WorldSafeLocs.dbc");
515 if(bad_dbc_files
.size() >= DBCFilesCount
)
517 sLog
.outError("\nIncorrect DataDir value in mangosd.conf or ALL required *.dbc files (%d) not found by path: %sdbc",DBCFilesCount
,dataPath
.c_str());
520 else if(!bad_dbc_files
.empty() )
523 for(std::list
<std::string
>::iterator i
= bad_dbc_files
.begin(); i
!= bad_dbc_files
.end(); ++i
)
526 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());
530 // Check loaded DBC files proper version
531 if( !sSpellStore
.LookupEntry(62735) || // last added spell in 3.0.9
532 !sMapStore
.LookupEntry(624) || // last map added in 3.0.8a/3.0.9
533 !sGemPropertiesStore
.LookupEntry(1557) || // last gem property added in 3.0.8a/3.0.9
534 !sItemExtendedCostStore
.LookupEntry(2589) || // last item extended cost added in 3.0.8a/3.0.9
535 !sCharTitlesStore
.LookupEntry(144) || // last char title added in 3.0.8a/3.0.9
536 !sAreaStore
.LookupEntry(2769) || // last area (areaflag) added in 3.0.8a/3.0.9
537 !sItemStore
.LookupEntry(45037) ) // last client known item added in 3.0.9
539 sLog
.outError("\nYou have _outdated_ DBC files. Please extract correct versions from current using client.");
544 sLog
.outString( ">> Initialized %d data stores", DBCFilesCount
);
547 SimpleFactionsList
const* GetFactionTeamList(uint32 faction
)
549 FactionTeamMap::const_iterator itr
= sFactionTeamMap
.find(faction
);
550 if(itr
==sFactionTeamMap
.end())
555 char* GetPetName(uint32 petfamily
, uint32 dbclang
)
559 CreatureFamilyEntry
const *pet_family
= sCreatureFamilyStore
.LookupEntry(petfamily
);
562 return pet_family
->Name
[dbclang
]?pet_family
->Name
[dbclang
]:NULL
;
565 TalentSpellPos
const* GetTalentSpellPos(uint32 spellId
)
567 TalentSpellPosMap::const_iterator itr
= sTalentSpellPosMap
.find(spellId
);
568 if(itr
==sTalentSpellPosMap
.end())
574 uint32
GetTalentSpellCost(uint32 spellId
)
576 if(TalentSpellPos
const* pos
= GetTalentSpellPos(spellId
))
582 int32
GetAreaFlagByAreaID(uint32 area_id
)
584 AreaFlagByAreaID::iterator i
= sAreaFlagByAreaID
.find(area_id
);
585 if(i
== sAreaFlagByAreaID
.end())
591 AreaTableEntry
const* GetAreaEntryByAreaID(uint32 area_id
)
593 int32 areaflag
= GetAreaFlagByAreaID(area_id
);
597 return sAreaStore
.LookupEntry(areaflag
);
600 AreaTableEntry
const* GetAreaEntryByAreaFlagAndMap(uint32 area_flag
,uint32 map_id
)
603 return sAreaStore
.LookupEntry(area_flag
);
605 if(MapEntry
const* mapEntry
= sMapStore
.LookupEntry(map_id
))
606 return GetAreaEntryByAreaID(mapEntry
->linked_zone
);
611 uint32
GetAreaFlagByMapId(uint32 mapid
)
613 AreaFlagByMapID::iterator i
= sAreaFlagByMapID
.find(mapid
);
614 if(i
== sAreaFlagByMapID
.end())
620 uint32
GetVirtualMapForMapAndZone(uint32 mapid
, uint32 zoneId
)
622 if(mapid
!= 530 && mapid
!= 571) // speed for most cases
625 if(WorldMapAreaEntry
const* wma
= sWorldMapAreaStore
.LookupEntry(zoneId
))
626 return wma
->virtual_map_id
>= 0 ? wma
->virtual_map_id
: wma
->map_id
;
631 ContentLevels
GetContentLevelsForMapAndZone(uint32 mapid
, uint32 zoneId
)
633 mapid
= GetVirtualMapForMapAndZone(mapid
,zoneId
);
637 MapEntry
const* mapEntry
= sMapStore
.LookupEntry(mapid
);
641 switch(mapEntry
->Expansion())
643 default: return CONTENT_1_60
;
644 case 1: return CONTENT_61_70
;
645 case 2: return CONTENT_71_80
;
649 ChatChannelsEntry
const* GetChannelEntryFor(uint32 channel_id
)
651 // not sorted, numbering index from 0
652 for(uint32 i
= 0; i
< sChatChannelsStore
.GetNumRows(); ++i
)
654 ChatChannelsEntry
const* ch
= sChatChannelsStore
.LookupEntry(i
);
655 if(ch
&& ch
->ChannelID
== channel_id
)
661 bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId
, uint32 requiredTotemCategoryId
)
663 if(requiredTotemCategoryId
==0)
665 if(itemTotemCategoryId
==0)
668 TotemCategoryEntry
const* itemEntry
= sTotemCategoryStore
.LookupEntry(itemTotemCategoryId
);
671 TotemCategoryEntry
const* reqEntry
= sTotemCategoryStore
.LookupEntry(requiredTotemCategoryId
);
675 if(itemEntry
->categoryType
!=reqEntry
->categoryType
)
678 return (itemEntry
->categoryMask
& reqEntry
->categoryMask
)==reqEntry
->categoryMask
;
681 void Zone2MapCoordinates(float& x
,float& y
,uint32 zone
)
683 WorldMapAreaEntry
const* maEntry
= sWorldMapAreaStore
.LookupEntry(zone
);
685 // if not listed then map coordinates (instance)
689 std::swap(x
,y
); // at client map coords swapped
690 x
= x
*((maEntry
->x2
-maEntry
->x1
)/100)+maEntry
->x1
;
691 y
= y
*((maEntry
->y2
-maEntry
->y1
)/100)+maEntry
->y1
; // client y coord from top to down
694 void Map2ZoneCoordinates(float& x
,float& y
,uint32 zone
)
696 WorldMapAreaEntry
const* maEntry
= sWorldMapAreaStore
.LookupEntry(zone
);
698 // if not listed then map coordinates (instance)
702 x
= (x
-maEntry
->x1
)/((maEntry
->x2
-maEntry
->x1
)/100);
703 y
= (y
-maEntry
->y1
)/((maEntry
->y2
-maEntry
->y1
)/100); // client y coord from top to down
704 std::swap(x
,y
); // client have map coords swapped
707 uint32
GetTalentInspectBitPosInTab(uint32 talentId
)
709 TalentInspectMap::const_iterator itr
= sTalentPosInInspect
.find(talentId
);
710 if(itr
== sTalentPosInInspect
.end())
716 uint32
GetTalentTabInspectBitSize(uint32 talentTabId
)
718 TalentInspectMap::const_iterator itr
= sTalentTabSizeInInspect
.find(talentTabId
);
719 if(itr
== sTalentTabSizeInInspect
.end())
725 uint32
const* GetTalentTabPages(uint32 cls
)
727 return sTalentTabPages
[cls
];
730 // script support functions
731 MANGOS_DLL_SPEC DBCStorage
<SoundEntriesEntry
> const* GetSoundEntriesStore() { return &sSoundEntriesStore
; }
732 MANGOS_DLL_SPEC DBCStorage
<SpellEntry
> const* GetSpellStore() { return &sSpellStore
; }
733 MANGOS_DLL_SPEC DBCStorage
<SpellRangeEntry
> const* GetSpellRangeStore() { return &sSpellRangeStore
; }
734 MANGOS_DLL_SPEC DBCStorage
<FactionEntry
> const* GetFactionStore() { return &sFactionStore
; }
735 MANGOS_DLL_SPEC DBCStorage
<ItemEntry
> const* GetItemDisplayStore() { return &sItemStore
; }
736 MANGOS_DLL_SPEC DBCStorage
<CreatureDisplayInfoEntry
> const* GetCreatureDisplayStore() { return &sCreatureDisplayInfoStore
; }
737 MANGOS_DLL_SPEC DBCStorage
<EmotesEntry
> const* GetEmotesStore() { return &sEmotesStore
; }
738 MANGOS_DLL_SPEC DBCStorage
<EmotesTextEntry
> const* GetEmotesTextStore() { return &sEmotesTextStore
; }