2008-10-02 16:23:55 -05:00
/*
2009-02-04 12:42:26 +01:00
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
2008-10-14 11:57:03 -05:00
*
2010-01-16 20:19:18 +03:00
* Copyright (C) 2008-2010 Trinity <http://www.trinitycore.org/>
2008-10-02 16:23:55 -05:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
2008-11-20 16:16:57 -06:00
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2008-10-02 16:23:55 -05:00
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
2008-11-20 16:16:57 -06:00
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2008-10-02 16:23:55 -05:00
*/
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
#include "DBCStores.h"
#include "Policies/SingletonImp.h"
#include "Log.h"
#include "ProgressBar.h"
2009-03-29 17:19:47 -06:00
#include "SharedDefines.h"
2009-06-12 15:32:33 +02:00
#include "SpellMgr.h"
2009-10-17 15:51:44 -07:00
2009-03-27 10:00:42 -06:00
#include "DBCfmt.h"
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
#include <map>
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
typedef std :: map < uint16 , uint32 > AreaFlagByAreaID ;
typedef std :: map < uint32 , uint32 > AreaFlagByMapID ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
DBCStorage < AreaTableEntry > sAreaStore ( AreaTableEntryfmt );
2009-01-02 11:03:43 -06:00
DBCStorage < AreaGroupEntry > sAreaGroupStore ( AreaGroupEntryfmt );
2009-05-23 01:44:16 -05:00
DBCStorage < AreaPOIEntry > sAreaPOIStore ( AreaPOIEntryfmt );
2008-10-02 16:23:55 -05:00
static AreaFlagByAreaID sAreaFlagByAreaID ;
static AreaFlagByMapID sAreaFlagByMapID ; // for instances without generated *.map files
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
DBCStorage < AchievementEntry > sAchievementStore ( Achievementfmt );
DBCStorage < AchievementCriteriaEntry > sAchievementCriteriaStore ( AchievementCriteriafmt );
2008-10-02 16:23:55 -05:00
DBCStorage < AreaTriggerEntry > sAreaTriggerStore ( AreaTriggerEntryfmt );
2009-02-13 19:50:20 -06:00
DBCStorage < AuctionHouseEntry > sAuctionHouseStore ( AuctionHouseEntryfmt );
2008-10-02 16:23:55 -05:00
DBCStorage < BankBagSlotPricesEntry > sBankBagSlotPricesStore ( BankBagSlotPricesEntryfmt );
DBCStorage < BattlemasterListEntry > sBattlemasterListStore ( BattlemasterListEntryfmt );
2008-12-24 09:58:26 -06:00
DBCStorage < BarberShopStyleEntry > sBarberShopStyleStore ( BarberShopStyleEntryfmt );
2008-11-28 11:38:28 -06:00
DBCStorage < CharStartOutfitEntry > sCharStartOutfitStore ( CharStartOutfitEntryfmt );
2008-10-02 16:23:55 -05:00
DBCStorage < CharTitlesEntry > sCharTitlesStore ( CharTitlesEntryfmt );
DBCStorage < ChatChannelsEntry > sChatChannelsStore ( ChatChannelsEntryfmt );
DBCStorage < ChrClassesEntry > sChrClassesStore ( ChrClassesEntryfmt );
DBCStorage < ChrRacesEntry > sChrRacesStore ( ChrRacesEntryfmt );
2009-04-05 16:58:20 -05:00
DBCStorage < CinematicSequencesEntry > sCinematicSequencesStore ( CinematicSequencesEntryfmt );
2008-10-02 16:23:55 -05:00
DBCStorage < CreatureDisplayInfoEntry > sCreatureDisplayInfoStore ( CreatureDisplayInfofmt );
DBCStorage < CreatureFamilyEntry > sCreatureFamilyStore ( CreatureFamilyfmt );
DBCStorage < CreatureSpellDataEntry > sCreatureSpellDataStore ( CreatureSpellDatafmt );
2009-01-22 22:44:27 -06:00
DBCStorage < CreatureTypeEntry > sCreatureTypeStore ( CreatureTypefmt );
2009-03-21 22:44:59 -06:00
DBCStorage < CurrencyTypesEntry > sCurrencyTypesStore ( CurrencyTypesfmt );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
DBCStorage < DurabilityQualityEntry > sDurabilityQualityStore ( DurabilityQualityfmt );
DBCStorage < DurabilityCostsEntry > sDurabilityCostsStore ( DurabilityCostsfmt );
2009-10-17 15:51:44 -07:00
2009-04-18 20:54:43 -05:00
DBCStorage < EmotesEntry > sEmotesStore ( EmotesEntryfmt );
DBCStorage < EmotesTextEntry > sEmotesTextStore ( EmotesTextEntryfmt );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
typedef std :: map < uint32 , SimpleFactionsList > FactionTeamMap ;
static FactionTeamMap sFactionTeamMap ;
DBCStorage < FactionEntry > sFactionStore ( FactionEntryfmt );
DBCStorage < FactionTemplateEntry > sFactionTemplateStore ( FactionTemplateEntryfmt );
2009-10-17 15:51:44 -07:00
2009-05-21 10:00:44 -05:00
DBCStorage < GameObjectDisplayInfoEntry > sGameObjectDisplayInfoStore ( GameObjectDisplayInfofmt );
2008-10-02 16:23:55 -05:00
DBCStorage < GemPropertiesEntry > sGemPropertiesStore ( GemPropertiesEntryfmt );
2008-12-24 09:58:26 -06:00
DBCStorage < GlyphPropertiesEntry > sGlyphPropertiesStore ( GlyphPropertiesfmt );
DBCStorage < GlyphSlotEntry > sGlyphSlotStore ( GlyphSlotfmt );
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
DBCStorage < GtBarberShopCostBaseEntry > sGtBarberShopCostBaseStore ( GtBarberShopCostBasefmt );
2008-10-02 16:23:55 -05:00
DBCStorage < GtCombatRatingsEntry > sGtCombatRatingsStore ( GtCombatRatingsfmt );
DBCStorage < GtChanceToMeleeCritBaseEntry > sGtChanceToMeleeCritBaseStore ( GtChanceToMeleeCritBasefmt );
DBCStorage < GtChanceToMeleeCritEntry > sGtChanceToMeleeCritStore ( GtChanceToMeleeCritfmt );
DBCStorage < GtChanceToSpellCritBaseEntry > sGtChanceToSpellCritBaseStore ( GtChanceToSpellCritBasefmt );
DBCStorage < GtChanceToSpellCritEntry > sGtChanceToSpellCritStore ( GtChanceToSpellCritfmt );
DBCStorage < GtOCTRegenHPEntry > sGtOCTRegenHPStore ( GtOCTRegenHPfmt );
//DBCStorage <GtOCTRegenMPEntry> sGtOCTRegenMPStore(GtOCTRegenMPfmt); -- not used currently
DBCStorage < GtRegenHPPerSptEntry > sGtRegenHPPerSptStore ( GtRegenHPPerSptfmt );
DBCStorage < GtRegenMPPerSptEntry > sGtRegenMPPerSptStore ( GtRegenMPPerSptfmt );
2009-10-17 15:51:44 -07:00
2009-03-06 19:36:47 -06:00
DBCStorage < HolidaysEntry > sHolidaysStore ( Holidaysfmt );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
DBCStorage < ItemEntry > sItemStore ( Itemfmt );
2009-03-21 22:43:47 -06:00
DBCStorage < ItemBagFamilyEntry > sItemBagFamilyStore ( ItemBagFamilyfmt );
2008-10-02 16:23:55 -05:00
//DBCStorage <ItemCondExtCostsEntry> sItemCondExtCostsStore(ItemCondExtCostsEntryfmt);
//DBCStorage <ItemDisplayInfoEntry> sItemDisplayInfoStore(ItemDisplayTemplateEntryfmt); -- not used currently
DBCStorage < ItemExtendedCostEntry > sItemExtendedCostStore ( ItemExtendedCostEntryfmt );
2009-02-15 11:58:27 -06:00
DBCStorage < ItemLimitCategoryEntry > sItemLimitCategoryStore ( ItemLimitCategoryEntryfmt );
2008-10-02 16:23:55 -05:00
DBCStorage < ItemRandomPropertiesEntry > sItemRandomPropertiesStore ( ItemRandomPropertiesfmt );
DBCStorage < ItemRandomSuffixEntry > sItemRandomSuffixStore ( ItemRandomSuffixfmt );
DBCStorage < ItemSetEntry > sItemSetStore ( ItemSetEntryfmt );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
DBCStorage < LockEntry > sLockStore ( LockEntryfmt );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
DBCStorage < MailTemplateEntry > sMailTemplateStore ( MailTemplateEntryfmt );
DBCStorage < MapEntry > sMapStore ( MapEntryfmt );
2009-12-17 10:27:53 +01:00
// DBC used only for initialization sMapDifficultyMap at startup.
DBCStorage < MapDifficultyEntry > sMapDifficultyStore ( MapDifficultyEntryfmt ); // only for loading
MapDifficultyMap sMapDifficultyMap ;
2009-04-05 16:58:20 -05:00
DBCStorage < MovieEntry > sMovieStore ( MovieEntryfmt );
2009-10-17 15:51:44 -07:00
2010-02-15 15:31:27 +01:00
DBCStorage < PvPDifficultyEntry > sPvPDifficultyStore ( PvPDifficultyfmt );
2008-10-02 16:23:55 -05:00
DBCStorage < QuestSortEntry > sQuestSortStore ( QuestSortEntryfmt );
2010-02-14 19:13:14 -07:00
DBCStorage < QuestXPEntry > sQuestXPStore ( QuestXPfmt );
DBCStorage < QuestFactionRewEntry > sQuestFactionRewardStore ( QuestFactionRewardfmt );
2008-10-02 16:23:55 -05:00
DBCStorage < RandomPropertiesPointsEntry > sRandomPropertiesPointsStore ( RandomPropertiesPointsfmt );
2008-12-24 09:58:26 -06:00
DBCStorage < ScalingStatDistributionEntry > sScalingStatDistributionStore ( ScalingStatDistributionfmt );
DBCStorage < ScalingStatValuesEntry > sScalingStatValuesStore ( ScalingStatValuesfmt );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
DBCStorage < SkillLineEntry > sSkillLineStore ( SkillLinefmt );
DBCStorage < SkillLineAbilityEntry > sSkillLineAbilityStore ( SkillLineAbilityfmt );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
DBCStorage < SoundEntriesEntry > sSoundEntriesStore ( SoundEntriesfmt );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
DBCStorage < SpellItemEnchantmentEntry > sSpellItemEnchantmentStore ( SpellItemEnchantmentfmt );
DBCStorage < SpellItemEnchantmentConditionEntry > sSpellItemEnchantmentConditionStore ( SpellItemEnchantmentConditionfmt );
DBCStorage < SpellEntry > sSpellStore ( SpellEntryfmt );
SpellCategoryStore sSpellCategoryStore ;
PetFamilySpellsStore sPetFamilySpellsStore ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
DBCStorage < SpellCastTimesEntry > sSpellCastTimesStore ( SpellCastTimefmt );
DBCStorage < SpellDurationEntry > sSpellDurationStore ( SpellDurationfmt );
DBCStorage < SpellFocusObjectEntry > sSpellFocusObjectStore ( SpellFocusObjectfmt );
DBCStorage < SpellRadiusEntry > sSpellRadiusStore ( SpellRadiusfmt );
DBCStorage < SpellRangeEntry > sSpellRangeStore ( SpellRangefmt );
2008-12-24 09:58:26 -06:00
DBCStorage < SpellRuneCostEntry > sSpellRuneCostStore ( SpellRuneCostfmt );
2008-10-02 16:23:55 -05:00
DBCStorage < SpellShapeshiftEntry > sSpellShapeshiftStore ( SpellShapeshiftfmt );
DBCStorage < StableSlotPricesEntry > sStableSlotPricesStore ( StableSlotPricesfmt );
2009-03-18 20:54:39 -06:00
DBCStorage < SummonPropertiesEntry > sSummonPropertiesStore ( SummonPropertiesfmt );
2008-10-02 16:23:55 -05:00
DBCStorage < TalentEntry > sTalentStore ( TalentEntryfmt );
TalentSpellPosMap sTalentSpellPosMap ;
DBCStorage < TalentTabEntry > sTalentTabStore ( TalentTabEntryfmt );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
// store absolute bit position for first rank for talent inspect
2009-12-17 10:27:53 +01:00
static uint32 sTalentTabPages [ MAX_CLASSES ][ 3 ];
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
DBCStorage < TaxiNodesEntry > sTaxiNodesStore ( TaxiNodesEntryfmt );
TaxiMask sTaxiNodesMask ;
2009-03-28 17:50:36 -06:00
TaxiMask sOldContinentsNodesMask ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
// DBC used only for initialization sTaxiPathSetBySource at startup.
TaxiPathSetBySource sTaxiPathSetBySource ;
DBCStorage < TaxiPathEntry > sTaxiPathStore ( TaxiPathEntryfmt );
2009-10-17 15:51:44 -07:00
2009-12-17 10:27:53 +01:00
// DBC used only for initialization sTaxiPathNodeStore at startup.
2008-10-02 16:23:55 -05:00
TaxiPathNodesByPath sTaxiPathNodesByPath ;
2008-11-20 16:16:57 -06:00
static DBCStorage < TaxiPathNodeEntry > sTaxiPathNodeStore ( TaxiPathNodeEntryfmt );
2009-12-17 10:27:53 +01:00
2008-10-02 16:23:55 -05:00
DBCStorage < TotemCategoryEntry > sTotemCategoryStore ( TotemCategoryEntryfmt );
2008-12-24 09:58:26 -06:00
DBCStorage < VehicleEntry > sVehicleStore ( VehicleEntryfmt );
DBCStorage < VehicleSeatEntry > sVehicleSeatStore ( VehicleSeatEntryfmt );
2008-10-02 16:23:55 -05:00
DBCStorage < WorldMapAreaEntry > sWorldMapAreaStore ( WorldMapAreaEntryfmt );
2008-12-24 09:58:26 -06:00
DBCStorage < WorldMapOverlayEntry > sWorldMapOverlayStore ( WorldMapOverlayEntryfmt );
2009-04-27 18:45:41 -05:00
DBCStorage < WorldSafeLocsEntry > sWorldSafeLocsStore ( WorldSafeLocsEntryfmt );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
typedef std :: list < std :: string > StoreProblemList ;
2009-10-17 15:51:44 -07:00
2008-12-12 11:21:28 -06:00
static bool LoadDBC_assert_print ( uint32 fsize , uint32 rsize , const std :: string & filename )
2008-10-02 16:23:55 -05:00
{
sLog . outError ( "ERROR: Size of '%s' setted by format string (%u) not equal size of C++ structure (%u)." , filename . c_str (), fsize , rsize );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
// assert must fail after function call
return false ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
template < class T >
2009-08-27 17:44:30 +02:00
inline void LoadDBC ( uint32 & availableDbcLocales , barGoLink & bar , StoreProblemList & errlist , DBCStorage < T >& storage , const std :: string & dbc_path , const std :: string & filename , const std :: string * custom_entries = NULL , const std :: string * idname = NULL )
2008-10-02 16:23:55 -05:00
{
// compatibility format and C++ structure sizes
2009-03-27 10:00:42 -06:00
assert ( DBCFileLoader :: GetFormatRecordSize ( storage . GetFormat ()) == sizeof ( T ) || LoadDBC_assert_print ( DBCFileLoader :: GetFormatRecordSize ( storage . GetFormat ()), sizeof ( T ), filename ));
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
std :: string dbc_filename = dbc_path + filename ;
2009-08-27 17:44:30 +02:00
SqlDbc * sql = NULL ;
if ( custom_entries )
sql = new SqlDbc ( & filename , custom_entries , idname , storage . GetFormat ());
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( storage . Load ( dbc_filename . c_str (), sql ))
2008-10-02 16:23:55 -05:00
{
bar . step ();
2009-10-17 16:20:24 -07:00
for ( uint8 i = 0 ; i < MAX_LOCALE ; ++ i )
2008-10-02 16:23:55 -05:00
{
2010-04-07 19:14:10 +02:00
if ( ! ( availableDbcLocales & ( 1 << i )))
2008-10-02 16:23:55 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
std :: string dbc_filename_loc = dbc_path + localeNames [ i ] + "/" + filename ;
2010-04-07 19:14:10 +02:00
if ( ! storage . LoadStringsFrom ( dbc_filename_loc . c_str ()))
2008-10-02 16:23:55 -05:00
availableDbcLocales &= ~ ( 1 << i ); // mark as not available for speedup next checks
}
}
else
{
// sort problematic dbc to (1) non compatible and (2) non-existed
FILE * f = fopen ( dbc_filename . c_str (), "rb" );
2010-04-07 19:14:10 +02:00
if ( f )
2008-10-02 16:23:55 -05:00
{
char buf [ 100 ];
2009-07-12 17:52:27 +08:00
snprintf ( buf , 100 , " (exist, but have %d fields instead " SIZEFMTD ") Wrong client version DBC file?" , storage . GetFieldCount (), strlen ( storage . GetFormat ()));
2008-10-02 16:23:55 -05:00
errlist . push_back ( dbc_filename + buf );
fclose ( f );
}
else
errlist . push_back ( dbc_filename );
}
2009-08-27 17:44:30 +02:00
if ( sql )
delete sql ;
2008-10-02 16:23:55 -05:00
}
2009-10-17 15:51:44 -07:00
2008-12-12 11:21:28 -06:00
void LoadDBCStores ( const std :: string & dataPath )
2008-10-02 16:23:55 -05:00
{
std :: string dbcPath = dataPath + "dbc/" ;
2009-10-17 15:51:44 -07:00
2010-02-16 15:26:40 -07:00
const uint32 DBCFilesCount = 85 ;
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
barGoLink bar ( DBCFilesCount );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
StoreProblemList bad_dbc_files ;
uint32 availableDbcLocales = 0xFFFFFFFF ;
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sAreaStore , dbcPath , "AreaTable.dbc" );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
// must be after sAreaStore loading
2009-10-17 16:20:24 -07:00
for ( uint32 i = 0 ; i < sAreaStore . GetNumRows (); ++ i ) // areaflag numbered from 0
2008-10-02 16:23:55 -05:00
{
2010-04-07 19:14:10 +02:00
if ( AreaTableEntry const * area = sAreaStore . LookupEntry ( i ))
2008-10-02 16:23:55 -05:00
{
// fill AreaId->DBC records
sAreaFlagByAreaID . insert ( AreaFlagByAreaID :: value_type ( uint16 ( area -> ID ), area -> exploreFlag ));
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
// fill MapId->DBC records (skip sub zones and continents)
2010-04-07 23:25:02 +02:00
if ( area -> zone == 0 && area -> mapid != 0 && area -> mapid != 1 && area -> mapid != 530 && area -> mapid != 571 )
2008-10-02 16:23:55 -05:00
sAreaFlagByMapID . insert ( AreaFlagByMapID :: value_type ( area -> mapid , area -> exploreFlag ));
}
}
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sAchievementStore , dbcPath , "Achievement.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sAchievementCriteriaStore , dbcPath , "Achievement_Criteria.dbc" );
2008-10-02 16:23:55 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sAreaTriggerStore , dbcPath , "AreaTrigger.dbc" );
2009-01-02 11:03:43 -06:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sAreaGroupStore , dbcPath , "AreaGroup.dbc" );
2009-05-23 01:44:16 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sAreaPOIStore , dbcPath , "AreaPOI.dbc" );
2009-02-13 19:50:20 -06:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sAuctionHouseStore , dbcPath , "AuctionHouse.dbc" );
2008-10-02 16:23:55 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sBankBagSlotPricesStore , dbcPath , "BankBagSlotPrices.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sBattlemasterListStore , dbcPath , "BattlemasterList.dbc" );
2008-12-24 09:58:26 -06:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sBarberShopStyleStore , dbcPath , "BarberShopStyle.dbc" );
2008-11-28 11:38:28 -06:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sCharStartOutfitStore , dbcPath , "CharStartOutfit.dbc" );
2008-10-02 16:23:55 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sCharTitlesStore , dbcPath , "CharTitles.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sChatChannelsStore , dbcPath , "ChatChannels.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sChrClassesStore , dbcPath , "ChrClasses.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sChrRacesStore , dbcPath , "ChrRaces.dbc" );
2009-04-05 16:58:20 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sCinematicSequencesStore , dbcPath , "CinematicSequences.dbc" );
2008-10-02 16:23:55 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sCreatureDisplayInfoStore , dbcPath , "CreatureDisplayInfo.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sCreatureFamilyStore , dbcPath , "CreatureFamily.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sCreatureSpellDataStore , dbcPath , "CreatureSpellData.dbc" );
2009-01-22 22:44:27 -06:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sCreatureTypeStore , dbcPath , "CreatureType.dbc" );
2009-03-21 22:44:59 -06:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sCurrencyTypesStore , dbcPath , "CurrencyTypes.dbc" );
2008-10-02 16:23:55 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sDurabilityCostsStore , dbcPath , "DurabilityCosts.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sDurabilityQualityStore , dbcPath , "DurabilityQuality.dbc" );
2009-04-18 20:54:43 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sEmotesStore , dbcPath , "Emotes.dbc" );
2008-10-02 16:23:55 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sEmotesTextStore , dbcPath , "EmotesText.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sFactionStore , dbcPath , "Faction.dbc" );
2009-10-17 16:20:24 -07:00
for ( uint32 i = 0 ; i < sFactionStore . GetNumRows (); ++ i )
2008-10-02 16:23:55 -05:00
{
FactionEntry const * faction = sFactionStore . LookupEntry ( i );
if ( faction && faction -> team )
{
SimpleFactionsList & flist = sFactionTeamMap [ faction -> team ];
flist . push_back ( i );
}
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sFactionTemplateStore , dbcPath , "FactionTemplate.dbc" );
2009-05-21 10:00:44 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sGameObjectDisplayInfoStore , dbcPath , "GameObjectDisplayInfo.dbc" );
2009-10-17 16:20:24 -07:00
for ( uint32 i = 0 ; i < sGameObjectDisplayInfoStore . GetNumRows (); ++ i )
2009-05-21 10:00:44 -05:00
{
2010-04-07 19:14:10 +02:00
if ( GameObjectDisplayInfoEntry const * info = sGameObjectDisplayInfoStore . LookupEntry ( i ))
2009-05-21 10:00:44 -05:00
{
2010-04-07 19:14:10 +02:00
if ( info -> maxX < info -> minX )
2009-05-21 10:00:44 -05:00
std :: swap ( * ( float * )( & info -> maxX ), * ( float * )( & info -> minX ));
2010-04-07 19:14:10 +02:00
if ( info -> maxY < info -> minY )
2009-05-21 10:00:44 -05:00
std :: swap ( * ( float * )( & info -> maxY ), * ( float * )( & info -> minY ));
2010-04-07 19:14:10 +02:00
if ( info -> maxZ < info -> minZ )
2009-05-21 10:00:44 -05:00
std :: swap ( * ( float * )( & info -> maxZ ), * ( float * )( & info -> minZ ));
}
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sGemPropertiesStore , dbcPath , "GemProperties.dbc" );
2008-12-24 09:58:26 -06:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sGlyphPropertiesStore , dbcPath , "GlyphProperties.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sGlyphSlotStore , dbcPath , "GlyphSlot.dbc" );
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sGtBarberShopCostBaseStore , dbcPath , "gtBarberShopCostBase.dbc" );
2008-10-02 16:23:55 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sGtCombatRatingsStore , dbcPath , "gtCombatRatings.dbc" );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sGtChanceToMeleeCritBaseStore , dbcPath , "gtChanceToMeleeCritBase.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sGtChanceToMeleeCritStore , dbcPath , "gtChanceToMeleeCrit.dbc" );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sGtChanceToSpellCritBaseStore , dbcPath , "gtChanceToSpellCritBase.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sGtChanceToSpellCritStore , dbcPath , "gtChanceToSpellCrit.dbc" );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sGtOCTRegenHPStore , dbcPath , "gtOCTRegenHP.dbc" );
//LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtOCTRegenMPStore, dbcPath,"gtOCTRegenMP.dbc"); -- not used currently
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sGtRegenHPPerSptStore , dbcPath , "gtRegenHPPerSpt.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sGtRegenMPPerSptStore , dbcPath , "gtRegenMPPerSpt.dbc" );
2009-03-06 19:36:47 -06:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sHolidaysStore , dbcPath , "Holidays.dbc" );
2008-10-02 16:23:55 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sItemStore , dbcPath , "Item.dbc" );
2009-03-21 22:43:47 -06:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sItemBagFamilyStore , dbcPath , "ItemBagFamily.dbc" );
2008-10-02 16:23:55 -05:00
//LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemDisplayInfoStore, dbcPath,"ItemDisplayInfo.dbc"); -- not used currently
//LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemCondExtCostsStore, dbcPath,"ItemCondExtCosts.dbc");
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sItemExtendedCostStore , dbcPath , "ItemExtendedCost.dbc" );
2009-02-15 11:58:27 -06:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sItemLimitCategoryStore , dbcPath , "ItemLimitCategory.dbc" );
2008-10-02 16:23:55 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sItemRandomPropertiesStore , dbcPath , "ItemRandomProperties.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sItemRandomSuffixStore , dbcPath , "ItemRandomSuffix.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sItemSetStore , dbcPath , "ItemSet.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sLockStore , dbcPath , "Lock.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sMailTemplateStore , dbcPath , "MailTemplate.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sMapStore , dbcPath , "Map.dbc" );
2009-12-17 10:27:53 +01:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sMapDifficultyStore , dbcPath , "MapDifficulty.dbc" );
// fill data
2010-04-07 19:12:44 +02:00
for ( uint32 i = 1 ; i < sMapDifficultyStore . GetNumRows (); ++ i )
2010-04-07 19:14:10 +02:00
if ( MapDifficultyEntry const * entry = sMapDifficultyStore . LookupEntry ( i ))
2009-12-17 10:27:53 +01:00
sMapDifficultyMap [ MAKE_PAIR32 ( entry -> MapId , entry -> Difficulty )] = MapDifficulty ( entry -> resetTime , entry -> maxPlayers );
sMapDifficultyStore . Clear ();
2009-04-05 16:58:20 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sMovieStore , dbcPath , "Movie.dbc" );
2008-10-02 16:23:55 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sQuestSortStore , dbcPath , "QuestSort.dbc" );
2010-02-15 15:31:27 +01:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sPvPDifficultyStore , dbcPath , "PvpDifficulty.dbc" );
2010-04-07 19:12:44 +02:00
for ( uint32 i = 0 ; i < sPvPDifficultyStore . GetNumRows (); ++ i )
2010-02-15 15:31:27 +01:00
if ( PvPDifficultyEntry const * entry = sPvPDifficultyStore . LookupEntry ( i ))
if ( entry -> bracketId > MAX_BATTLEGROUND_BRACKETS )
assert ( false && "Need update MAX_BATTLEGROUND_BRACKETS by DBC data" );
2010-04-07 18:09:10 +02:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sQuestXPStore , dbcPath , "QuestXP.dbc" );
2010-02-14 19:13:14 -07:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sQuestFactionRewardStore , dbcPath , "QuestFactionReward.dbc" );
2008-10-02 16:23:55 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sRandomPropertiesPointsStore , dbcPath , "RandPropPoints.dbc" );
2008-12-24 09:58:26 -06:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sScalingStatDistributionStore , dbcPath , "ScalingStatDistribution.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sScalingStatValuesStore , dbcPath , "ScalingStatValues.dbc" );
2008-10-02 16:23:55 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sSkillLineStore , dbcPath , "SkillLine.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sSkillLineAbilityStore , dbcPath , "SkillLineAbility.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sSoundEntriesStore , dbcPath , "SoundEntries.dbc" );
2009-12-18 13:41:30 -08:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sSpellStore , dbcPath , "Spell.dbc" , & CustomSpellEntryfmt , & CustomSpellEntryIndex );
2009-10-17 16:20:24 -07:00
for ( uint32 i = 1 ; i < sSpellStore . GetNumRows (); ++ i )
2008-10-02 16:23:55 -05:00
{
SpellEntry const * spell = sSpellStore . LookupEntry ( i );
2010-04-07 19:14:10 +02:00
if ( spell && spell -> Category )
2008-10-02 16:23:55 -05:00
sSpellCategoryStore [ spell -> Category ]. insert ( i );
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
for ( uint32 j = 0 ; j < sSkillLineAbilityStore . GetNumRows (); ++ j )
{
SkillLineAbilityEntry const * skillLine = sSkillLineAbilityStore . LookupEntry ( j );
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( ! skillLine )
2008-10-02 16:23:55 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
SpellEntry const * spellInfo = sSpellStore . LookupEntry ( skillLine -> spellId );
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( spellInfo && IsPassiveSpell ( spellInfo -> Id ))
2008-11-20 16:16:57 -06:00
{
2009-04-19 17:23:03 +02:00
for ( uint32 i = 1 ; i < sCreatureFamilyStore . GetNumRows (); ++ i )
2008-10-02 16:23:55 -05:00
{
CreatureFamilyEntry const * cFamily = sCreatureFamilyStore . LookupEntry ( i );
2010-04-07 19:14:10 +02:00
if ( ! cFamily )
2008-10-02 16:23:55 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( skillLine -> skillId != cFamily -> skillLine [ 0 ] && skillLine -> skillId != cFamily -> skillLine [ 1 ])
2008-10-02 16:23:55 -05:00
continue ;
2010-04-07 19:14:10 +02:00
if ( spellInfo -> spellLevel )
2009-04-19 20:45:55 +02:00
continue ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( skillLine -> learnOnGetSkill != ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL )
2009-05-02 16:08:52 +02:00
continue ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
sPetFamilySpellsStore [ i ]. insert ( spellInfo -> Id );
}
}
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sSpellCastTimesStore , dbcPath , "SpellCastTimes.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sSpellDurationStore , dbcPath , "SpellDuration.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sSpellFocusObjectStore , dbcPath , "SpellFocusObject.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sSpellItemEnchantmentStore , dbcPath , "SpellItemEnchantment.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sSpellItemEnchantmentConditionStore , dbcPath , "SpellItemEnchantmentCondition.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sSpellRadiusStore , dbcPath , "SpellRadius.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sSpellRangeStore , dbcPath , "SpellRange.dbc" );
2008-12-24 09:58:26 -06:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sSpellRuneCostStore , dbcPath , "SpellRuneCost.dbc" );
2008-10-02 16:23:55 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sSpellShapeshiftStore , dbcPath , "SpellShapeshiftForm.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sStableSlotPricesStore , dbcPath , "StableSlotPrices.dbc" );
2009-03-19 14:41:30 -06:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sSummonPropertiesStore , dbcPath , "SummonProperties.dbc" );
2008-10-02 16:23:55 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sTalentStore , dbcPath , "Talent.dbc" );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
// create talent spells set
for ( unsigned int i = 0 ; i < sTalentStore . GetNumRows (); ++ i )
{
TalentEntry const * talentInfo = sTalentStore . LookupEntry ( i );
if ( ! talentInfo ) continue ;
2009-03-21 14:55:10 -06:00
for ( int j = 0 ; j < MAX_TALENT_RANK ; j ++ )
2010-04-07 19:14:10 +02:00
if ( talentInfo -> RankID [ j ])
2008-10-02 16:23:55 -05:00
sTalentSpellPosMap [ talentInfo -> RankID [ j ]] = TalentSpellPos ( i , j );
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sTalentTabStore , dbcPath , "TalentTab.dbc" );
2009-10-17 15:51:44 -07:00
2008-11-14 16:28:45 -06:00
// prepare fast data access to bit pos of talent ranks for use at inspecting
2008-10-02 16:23:55 -05:00
{
// now have all max ranks (and then bit amount used for store talent ranks in inspect)
2009-10-17 16:20:24 -07:00
for ( uint32 talentTabId = 1 ; talentTabId < sTalentTabStore . GetNumRows (); ++ talentTabId )
2008-10-02 16:23:55 -05:00
{
2010-04-07 22:59:46 +02:00
TalentTabEntry const * talentTabInfo = sTalentTabStore . LookupEntry ( talentTabId );
2010-04-07 19:14:10 +02:00
if ( ! talentTabInfo )
2008-10-02 16:23:55 -05:00
continue ;
2009-10-17 15:51:44 -07:00
2009-03-29 17:19:47 -06:00
// prevent memory corruption; otherwise cls will become 12 below
2010-04-07 23:25:02 +02:00
if (( talentTabInfo -> ClassMask & CLASSMASK_ALL_PLAYABLE ) == 0 )
2009-03-29 17:19:47 -06:00
continue ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
// store class talent tab pages
uint32 cls = 1 ;
2010-04-07 23:56:35 +02:00
for ( uint32 m = 1 ; ! ( m & talentTabInfo -> ClassMask ) && cls < MAX_CLASSES ; m <<= 1 , ++ cls ) {}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
sTalentTabPages [ cls ][ talentTabInfo -> tabpage ] = talentTabId ;
}
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sTaxiNodesStore , dbcPath , "TaxiNodes.dbc" );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sTaxiPathStore , dbcPath , "TaxiPath.dbc" );
2009-10-17 16:20:24 -07:00
for ( uint32 i = 1 ; i < sTaxiPathStore . GetNumRows (); ++ i )
2010-04-07 19:14:10 +02:00
if ( TaxiPathEntry const * entry = sTaxiPathStore . LookupEntry ( i ))
2008-10-02 16:23:55 -05:00
sTaxiPathSetBySource [ entry -> from ][ entry -> to ] = TaxiPathBySourceAndDestination ( entry -> ID , entry -> price );
uint32 pathCount = sTaxiPathStore . GetNumRows ();
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
//## TaxiPathNode.dbc ## Loaded only for initialization different structures
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sTaxiPathNodeStore , dbcPath , "TaxiPathNode.dbc" );
// Calculate path nodes count
std :: vector < uint32 > pathLength ;
pathLength . resize ( pathCount ); // 0 and some other indexes not used
2009-10-17 16:20:24 -07:00
for ( uint32 i = 1 ; i < sTaxiPathNodeStore . GetNumRows (); ++ i )
2010-04-07 19:14:10 +02:00
if ( TaxiPathNodeEntry const * entry = sTaxiPathNodeStore . LookupEntry ( i ))
2008-12-24 09:58:26 -06:00
{
if ( pathLength [ entry -> path ] < entry -> index + 1 )
pathLength [ entry -> path ] = entry -> index + 1 ;
}
2008-10-02 16:23:55 -05:00
// Set path length
sTaxiPathNodesByPath . resize ( pathCount ); // 0 and some other indexes not used
2009-10-17 16:20:24 -07:00
for ( uint32 i = 1 ; i < sTaxiPathNodesByPath . size (); ++ i )
2008-10-02 16:23:55 -05:00
sTaxiPathNodesByPath [ i ]. resize ( pathLength [ i ]);
// fill data
2009-10-17 16:20:24 -07:00
for ( uint32 i = 1 ; i < sTaxiPathNodeStore . GetNumRows (); ++ i )
2010-04-07 19:14:10 +02:00
if ( TaxiPathNodeEntry const * entry = sTaxiPathNodeStore . LookupEntry ( i ))
2008-10-02 16:23:55 -05:00
sTaxiPathNodesByPath [ entry -> path ][ entry -> index ] = TaxiPathNode ( entry -> mapid , entry -> x , entry -> y , entry -> z , entry -> actionFlag , entry -> delay );
sTaxiPathNodeStore . Clear ();
2009-10-17 15:51:44 -07:00
2009-01-22 22:44:27 -06:00
// Initialize global taxinodes mask
// include existed nodes that have at least single not spell base (scripted) path
{
std :: set < uint32 > spellPaths ;
2009-10-17 16:20:24 -07:00
for ( uint32 i = 1 ; i < sSpellStore . GetNumRows (); ++ i )
2010-04-07 19:14:10 +02:00
if ( SpellEntry const * sInfo = sSpellStore . LookupEntry ( i ))
2009-10-17 16:20:24 -07:00
for ( int j = 0 ; j < 3 ; ++ j )
2010-04-07 23:25:02 +02:00
if ( sInfo -> Effect [ j ] == 123 /*SPELL_EFFECT_SEND_TAXI*/ )
2009-01-22 22:44:27 -06:00
spellPaths . insert ( sInfo -> EffectMiscValue [ j ]);
2009-10-17 15:51:44 -07:00
2009-01-22 22:44:27 -06:00
memset ( sTaxiNodesMask , 0 , sizeof ( sTaxiNodesMask ));
2009-03-28 17:50:36 -06:00
memset ( sOldContinentsNodesMask , 0 , sizeof ( sTaxiNodesMask ));
2009-10-17 16:20:24 -07:00
for ( uint32 i = 1 ; i < sTaxiNodesStore . GetNumRows (); ++ i )
2009-01-22 22:44:27 -06:00
{
2009-03-28 17:50:36 -06:00
TaxiNodesEntry const * node = sTaxiNodesStore . LookupEntry ( i );
2010-04-07 19:14:10 +02:00
if ( ! node )
2009-01-22 22:44:27 -06:00
continue ;
2009-10-17 15:51:44 -07:00
2009-01-22 22:44:27 -06:00
TaxiPathSetBySource :: const_iterator src_i = sTaxiPathSetBySource . find ( i );
2010-04-07 19:14:10 +02:00
if ( src_i != sTaxiPathSetBySource . end () && ! src_i -> second . empty ())
2009-01-22 22:44:27 -06:00
{
bool ok = false ;
2009-10-17 16:20:24 -07:00
for ( TaxiPathSetForSource :: const_iterator dest_i = src_i -> second . begin (); dest_i != src_i -> second . end (); ++ dest_i )
2009-01-22 22:44:27 -06:00
{
// not spell path
2010-04-07 23:25:02 +02:00
if ( spellPaths . find ( dest_i -> second . ID ) == spellPaths . end ())
2009-01-22 22:44:27 -06:00
{
ok = true ;
break ;
}
}
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( ! ok )
2009-01-22 22:44:27 -06:00
continue ;
}
2009-10-17 15:51:44 -07:00
2009-03-28 17:50:36 -06:00
// valid taxi network node
2009-01-22 22:44:27 -06:00
uint8 field = ( uint8 )(( i - 1 ) / 32 );
uint32 submask = 1 << (( i - 1 ) % 32 );
sTaxiNodesMask [ field ] |= submask ;
2009-10-17 15:51:44 -07:00
2009-03-28 17:50:36 -06:00
// old continent node (+ nodes virtually at old continents, check explicitly to avoid loading map files for zone info)
if ( node -> map_id < 2 || i == 82 || i == 83 || i == 93 || i == 94 )
sOldContinentsNodesMask [ field ] |= submask ;
2010-01-01 07:02:42 +01:00
// fix DK node at Ebon Hold
if ( i == 315 ) {
(( TaxiNodesEntry * ) node ) -> MountCreatureID [ 1 ] = 32981 ;
}
2009-01-22 22:44:27 -06:00
}
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sTotemCategoryStore , dbcPath , "TotemCategory.dbc" );
2008-12-24 09:58:26 -06:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sVehicleStore , dbcPath , "Vehicle.dbc" );
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sVehicleSeatStore , dbcPath , "VehicleSeat.dbc" );
2008-10-02 16:23:55 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sWorldMapAreaStore , dbcPath , "WorldMapArea.dbc" );
2008-12-24 09:58:26 -06:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sWorldMapOverlayStore , dbcPath , "WorldMapOverlay.dbc" );
2009-04-27 18:45:41 -05:00
LoadDBC ( availableDbcLocales , bar , bad_dbc_files , sWorldSafeLocsStore , dbcPath , "WorldSafeLocs.dbc" );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
// error checks
2010-04-07 22:59:46 +02:00
if ( bad_dbc_files . size () >= DBCFilesCount )
2008-10-02 16:23:55 -05:00
{
2008-10-14 11:57:03 -05:00
sLog . outError ( " \n Incorrect DataDir value in Trinityd.conf or ALL required *.dbc files (%d) not found by path: %sdbc" , DBCFilesCount , dataPath . c_str ());
2008-10-02 16:23:55 -05:00
exit ( 1 );
}
2010-04-07 22:59:46 +02:00
else if ( ! bad_dbc_files . empty ())
2008-10-02 16:23:55 -05:00
{
std :: string str ;
2009-10-17 16:20:24 -07:00
for ( std :: list < std :: string >:: iterator i = bad_dbc_files . begin (); i != bad_dbc_files . end (); ++ i )
2008-10-02 16:23:55 -05:00
str += * i + " \n " ;
2009-10-17 15:51:44 -07:00
2009-03-24 17:38:14 -06:00
sLog . outError ( " \n Some required *.dbc files (%u from %d) not found or not compatible: \n %s" ,( uint32 ) bad_dbc_files . size (), DBCFilesCount , str . c_str ());
2008-10-02 16:23:55 -05:00
exit ( 1 );
}
2009-10-17 15:51:44 -07:00
2009-01-30 19:22:49 -06:00
// Check loaded DBC files proper version
2010-04-07 22:59:46 +02:00
if ( ! sSpellStore . LookupEntry ( 74445 ) || // last added spell in 3.3.2
2010-02-14 19:13:14 -07:00
! sMapStore . LookupEntry ( 718 ) || // last map added in 3.3.2
! sGemPropertiesStore . LookupEntry ( 1629 ) || // last gem property added in 3.3.2
! sItemExtendedCostStore . LookupEntry ( 2982 ) || // last item extended cost added in 3.3.2
! sCharTitlesStore . LookupEntry ( 177 ) || // last char title added in 3.3.2
! sAreaStore . LookupEntry ( 3461 ) || // last area (areaflag) added in 3.3.2
2010-04-07 22:59:46 +02:00
! sItemStore . LookupEntry ( 52686 )) // last client known item added in 3.3.2
2008-10-02 16:23:55 -05:00
{
sLog . outError ( " \n You have _outdated_ DBC files. Please extract correct versions from current using client." );
exit ( 1 );
}
2009-04-03 16:36:20 -06:00
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Initialized %d data stores" , DBCFilesCount );
2008-10-02 16:23:55 -05:00
}
2009-10-17 15:51:44 -07:00
2009-10-10 23:02:11 +02:00
SimpleFactionsList const * GetFactionTeamList ( uint32 faction , bool & isTeamMember )
2008-10-02 16:23:55 -05:00
{
2009-10-17 16:20:24 -07:00
for ( FactionTeamMap :: const_iterator itr = sFactionTeamMap . begin (); itr != sFactionTeamMap . end (); ++ itr )
2009-10-10 23:02:11 +02:00
{
2010-04-07 19:14:10 +02:00
if ( itr -> first == faction )
2009-10-10 23:02:11 +02:00
{
isTeamMember = false ;
return & itr -> second ;
}
2009-10-17 16:20:24 -07:00
for ( SimpleFactionsList :: const_iterator itr2 = itr -> second . begin (); itr2 != itr -> second . end (); ++ itr2 )
2009-10-10 23:02:11 +02:00
{
2010-04-07 19:14:10 +02:00
if (( * itr2 ) == faction )
2009-10-10 23:02:11 +02:00
{
isTeamMember = true ;
return & itr -> second ;
}
}
}
return NULL ;
2008-10-02 16:23:55 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
char * GetPetName ( uint32 petfamily , uint32 dbclang )
{
2010-04-07 19:14:10 +02:00
if ( ! petfamily )
2008-10-02 16:23:55 -05:00
return NULL ;
CreatureFamilyEntry const * pet_family = sCreatureFamilyStore . LookupEntry ( petfamily );
2010-04-07 19:14:10 +02:00
if ( ! pet_family )
2008-10-02 16:23:55 -05:00
return NULL ;
return pet_family -> Name [ dbclang ] ? pet_family -> Name [ dbclang ] : NULL ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
TalentSpellPos const * GetTalentSpellPos ( uint32 spellId )
{
TalentSpellPosMap :: const_iterator itr = sTalentSpellPosMap . find ( spellId );
2010-04-07 23:25:02 +02:00
if ( itr == sTalentSpellPosMap . end ())
2008-10-02 16:23:55 -05:00
return NULL ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
return & itr -> second ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
uint32 GetTalentSpellCost ( uint32 spellId )
{
2010-04-07 19:14:10 +02:00
if ( TalentSpellPos const * pos = GetTalentSpellPos ( spellId ))
2008-10-02 16:23:55 -05:00
return pos -> rank + 1 ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
return 0 ;
}
2009-10-17 15:51:44 -07:00
2008-11-30 12:47:26 -06:00
int32 GetAreaFlagByAreaID ( uint32 area_id )
2008-10-02 16:23:55 -05:00
{
AreaFlagByAreaID :: iterator i = sAreaFlagByAreaID . find ( area_id );
2010-04-07 19:14:10 +02:00
if ( i == sAreaFlagByAreaID . end ())
2008-11-30 12:47:26 -06:00
return - 1 ;
2009-10-17 15:51:44 -07:00
2008-11-30 12:47:26 -06:00
return i -> second ;
}
2009-10-17 15:51:44 -07:00
2008-11-30 12:47:26 -06:00
AreaTableEntry const * GetAreaEntryByAreaID ( uint32 area_id )
{
int32 areaflag = GetAreaFlagByAreaID ( area_id );
2010-04-07 19:14:10 +02:00
if ( areaflag < 0 )
2008-10-02 16:23:55 -05:00
return NULL ;
2009-10-17 15:51:44 -07:00
2009-11-19 03:53:49 -08:00
return sAreaStore . LookupEntry ( areaflag );
2008-10-02 16:23:55 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
AreaTableEntry const * GetAreaEntryByAreaFlagAndMap ( uint32 area_flag , uint32 map_id )
{
2010-04-07 19:14:10 +02:00
if ( area_flag )
2008-10-02 16:23:55 -05:00
return sAreaStore . LookupEntry ( area_flag );
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( MapEntry const * mapEntry = sMapStore . LookupEntry ( map_id ))
2008-10-02 16:23:55 -05:00
return GetAreaEntryByAreaID ( mapEntry -> linked_zone );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
return NULL ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
uint32 GetAreaFlagByMapId ( uint32 mapid )
{
AreaFlagByMapID :: iterator i = sAreaFlagByMapID . find ( mapid );
2010-04-07 19:14:10 +02:00
if ( i == sAreaFlagByMapID . end ())
2008-10-02 16:23:55 -05:00
return 0 ;
else
return i -> second ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
uint32 GetVirtualMapForMapAndZone ( uint32 mapid , uint32 zoneId )
{
2010-04-07 19:14:10 +02:00
if ( mapid != 530 && mapid != 571 ) // speed for most cases
2008-10-02 16:23:55 -05:00
return mapid ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( WorldMapAreaEntry const * wma = sWorldMapAreaStore . LookupEntry ( zoneId ))
2008-10-02 16:23:55 -05:00
return wma -> virtual_map_id >= 0 ? wma -> virtual_map_id : wma -> map_id ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
return mapid ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
ContentLevels GetContentLevelsForMapAndZone ( uint32 mapid , uint32 zoneId )
{
mapid = GetVirtualMapForMapAndZone ( mapid , zoneId );
2010-04-07 19:14:10 +02:00
if ( mapid < 2 )
2008-10-02 16:23:55 -05:00
return CONTENT_1_60 ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
MapEntry const * mapEntry = sMapStore . LookupEntry ( mapid );
2010-04-07 19:14:10 +02:00
if ( ! mapEntry )
2008-10-20 12:23:56 -05:00
return CONTENT_1_60 ;
2009-10-17 15:51:44 -07:00
2008-10-20 12:23:56 -05:00
switch ( mapEntry -> Expansion ())
{
default : return CONTENT_1_60 ;
case 1 : return CONTENT_61_70 ;
case 2 : return CONTENT_71_80 ;
}
2008-10-02 16:23:55 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
ChatChannelsEntry const * GetChannelEntryFor ( uint32 channel_id )
{
// not sorted, numbering index from 0
2009-10-17 16:20:24 -07:00
for ( uint32 i = 0 ; i < sChatChannelsStore . GetNumRows (); ++ i )
2008-10-02 16:23:55 -05:00
{
ChatChannelsEntry const * ch = sChatChannelsStore . LookupEntry ( i );
2010-04-07 19:14:10 +02:00
if ( ch && ch -> ChannelID == channel_id )
2008-10-02 16:23:55 -05:00
return ch ;
}
return NULL ;
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
bool IsTotemCategoryCompatiableWith ( uint32 itemTotemCategoryId , uint32 requiredTotemCategoryId )
{
2010-04-07 23:25:02 +02:00
if ( requiredTotemCategoryId == 0 )
2008-10-02 16:23:55 -05:00
return true ;
2010-04-07 23:25:02 +02:00
if ( itemTotemCategoryId == 0 )
2008-10-02 16:23:55 -05:00
return false ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
TotemCategoryEntry const * itemEntry = sTotemCategoryStore . LookupEntry ( itemTotemCategoryId );
2010-04-07 19:14:10 +02:00
if ( ! itemEntry )
2008-10-02 16:23:55 -05:00
return false ;
TotemCategoryEntry const * reqEntry = sTotemCategoryStore . LookupEntry ( requiredTotemCategoryId );
2010-04-07 19:14:10 +02:00
if ( ! reqEntry )
2008-10-02 16:23:55 -05:00
return false ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:14:10 +02:00
if ( itemEntry -> categoryType != reqEntry -> categoryType )
2008-10-02 16:23:55 -05:00
return false ;
2009-10-17 15:51:44 -07:00
2010-04-07 23:25:02 +02:00
return ( itemEntry -> categoryMask & reqEntry -> categoryMask ) == reqEntry -> categoryMask ;
2008-10-02 16:23:55 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
void Zone2MapCoordinates ( float & x , float & y , uint32 zone )
{
WorldMapAreaEntry const * maEntry = sWorldMapAreaStore . LookupEntry ( zone );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
// if not listed then map coordinates (instance)
2010-04-07 19:14:10 +02:00
if ( ! maEntry )
2008-10-02 16:23:55 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
std :: swap ( x , y ); // at client map coords swapped
x = x * (( maEntry -> x2 - maEntry -> x1 ) / 100 ) + maEntry -> x1 ;
y = y * (( maEntry -> y2 - maEntry -> y1 ) / 100 ) + maEntry -> y1 ; // client y coord from top to down
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
void Map2ZoneCoordinates ( float & x , float & y , uint32 zone )
{
WorldMapAreaEntry const * maEntry = sWorldMapAreaStore . LookupEntry ( zone );
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
// if not listed then map coordinates (instance)
2010-04-07 19:14:10 +02:00
if ( ! maEntry )
2008-10-02 16:23:55 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
x = ( x - maEntry -> x1 ) / (( maEntry -> x2 - maEntry -> x1 ) / 100 );
y = ( y - maEntry -> y1 ) / (( maEntry -> y2 - maEntry -> y1 ) / 100 ); // client y coord from top to down
std :: swap ( x , y ); // client have map coords swapped
}
2009-10-17 15:51:44 -07:00
2009-12-17 10:27:53 +01:00
MapDifficulty const * GetMapDifficultyData ( uint32 mapId , Difficulty difficulty )
{
MapDifficultyMap :: const_iterator itr = sMapDifficultyMap . find ( MAKE_PAIR32 ( mapId , difficulty ));
return itr != sMapDifficultyMap . end () ? & itr -> second : NULL ;
}
2010-04-07 22:59:46 +02:00
PvPDifficultyEntry const * GetBattlegroundBracketByLevel ( uint32 mapid , uint32 level )
2010-02-15 15:31:27 +01:00
{
// prevent out-of-range levels for dbc data
if ( level > DEFAULT_MAX_LEVEL )
level = DEFAULT_MAX_LEVEL ;
2010-04-07 19:12:44 +02:00
for ( uint32 i = 0 ; i < sPvPDifficultyStore . GetNumRows (); ++ i )
2010-02-15 15:31:27 +01:00
if ( PvPDifficultyEntry const * entry = sPvPDifficultyStore . LookupEntry ( i ))
if ( entry -> mapId == mapid && entry -> minLevel <= level && entry -> maxLevel >= level )
return entry ;
return NULL ;
}
PvPDifficultyEntry const * GetBattlegroundBracketById ( uint32 mapid , BattleGroundBracketId id )
{
2010-04-07 19:12:44 +02:00
for ( uint32 i = 0 ; i < sPvPDifficultyStore . GetNumRows (); ++ i )
2010-02-15 15:31:27 +01:00
if ( PvPDifficultyEntry const * entry = sPvPDifficultyStore . LookupEntry ( i ))
if ( entry -> mapId == mapid && entry -> GetBracketId () == id )
return entry ;
return NULL ;
}
2009-11-19 03:53:49 -08:00
uint32 const * GetTalentTabPages ( uint8 cls )
2008-10-02 16:23:55 -05:00
{
return sTalentTabPages [ cls ];
}
2009-10-17 15:51:44 -07:00
2008-10-02 16:23:55 -05:00
// script support functions
2010-02-05 00:31:28 +01:00
DBCStorage < SoundEntriesEntry > const * GetSoundEntriesStore () { return & sSoundEntriesStore ; }
DBCStorage < SpellEntry > const * GetSpellStore () { return & sSpellStore ; }
DBCStorage < SpellRangeEntry > const * GetSpellRangeStore () { return & sSpellRangeStore ; }
DBCStorage < FactionEntry > const * GetFactionStore () { return & sFactionStore ; }
DBCStorage < ItemEntry > const * GetItemDisplayStore () { return & sItemStore ; }
DBCStorage < CreatureDisplayInfoEntry > const * GetCreatureDisplayStore () { return & sCreatureDisplayInfoStore ; }
DBCStorage < EmotesEntry > const * GetEmotesStore () { return & sEmotesStore ; }
DBCStorage < EmotesTextEntry > const * GetEmotesTextStore () { return & sEmotesTextStore ; }
DBCStorage < AchievementEntry > const * GetAchievementStore () { return & sAchievementStore ; }