diff options
author | maximius <none@none> | 2009-10-17 15:35:07 -0700 |
---|---|---|
committer | maximius <none@none> | 2009-10-17 15:35:07 -0700 |
commit | 26b5e033ffde3d161382fc9addbfa99738379641 (patch) | |
tree | a344f369ca32945f787a02dee35c3dbe342bed7e /src/game/DBCStores.cpp | |
parent | f21f47005dcb6b76e1abc9f35fbcd03eed191bff (diff) |
*Massive cleanup (\n\n -> \n, *\n -> \n, cleanup for(...) to for (...), and some other cleanups by hand)
*Fix a possible crash in Spell::DoAllEffectOnTarget
--HG--
branch : trunk
Diffstat (limited to 'src/game/DBCStores.cpp')
-rw-r--r-- | src/game/DBCStores.cpp | 109 |
1 files changed, 0 insertions, 109 deletions
diff --git a/src/game/DBCStores.cpp b/src/game/DBCStores.cpp index 5dae4cb6e17..fa117a169c0 100644 --- a/src/game/DBCStores.cpp +++ b/src/game/DBCStores.cpp @@ -17,27 +17,21 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - #include "DBCStores.h" #include "Policies/SingletonImp.h" #include "Log.h" #include "ProgressBar.h" #include "SharedDefines.h" #include "SpellMgr.h" - #include "DBCfmt.h" - #include <map> - typedef std::map<uint16,uint32> AreaFlagByAreaID; typedef std::map<uint32,uint32> AreaFlagByMapID; - DBCStorage <AreaTableEntry> sAreaStore(AreaTableEntryfmt); DBCStorage <AreaGroupEntry> sAreaGroupStore(AreaGroupEntryfmt); DBCStorage <AreaPOIEntry> sAreaPOIStore(AreaPOIEntryfmt); static AreaFlagByAreaID sAreaFlagByAreaID; static AreaFlagByMapID sAreaFlagByMapID; // for instances without generated *.map files - DBCStorage <AchievementEntry> sAchievementStore(Achievementfmt); DBCStorage <AchievementCriteriaEntry> sAchievementCriteriaStore(AchievementCriteriafmt); DBCStorage <AreaTriggerEntry> sAreaTriggerStore(AreaTriggerEntryfmt); @@ -56,23 +50,18 @@ DBCStorage <CreatureFamilyEntry> sCreatureFamilyStore(CreatureFamilyfmt); DBCStorage <CreatureSpellDataEntry> sCreatureSpellDataStore(CreatureSpellDatafmt); DBCStorage <CreatureTypeEntry> sCreatureTypeStore(CreatureTypefmt); DBCStorage <CurrencyTypesEntry> sCurrencyTypesStore(CurrencyTypesfmt); - DBCStorage <DurabilityQualityEntry> sDurabilityQualityStore(DurabilityQualityfmt); DBCStorage <DurabilityCostsEntry> sDurabilityCostsStore(DurabilityCostsfmt); - DBCStorage <EmotesEntry> sEmotesStore(EmotesEntryfmt); DBCStorage <EmotesTextEntry> sEmotesTextStore(EmotesTextEntryfmt); - typedef std::map<uint32,SimpleFactionsList> FactionTeamMap; static FactionTeamMap sFactionTeamMap; DBCStorage <FactionEntry> sFactionStore(FactionEntryfmt); DBCStorage <FactionTemplateEntry> sFactionTemplateStore(FactionTemplateEntryfmt); - DBCStorage <GameObjectDisplayInfoEntry> sGameObjectDisplayInfoStore(GameObjectDisplayInfofmt); DBCStorage <GemPropertiesEntry> sGemPropertiesStore(GemPropertiesEntryfmt); DBCStorage <GlyphPropertiesEntry> sGlyphPropertiesStore(GlyphPropertiesfmt); DBCStorage <GlyphSlotEntry> sGlyphSlotStore(GlyphSlotfmt); - DBCStorage <GtBarberShopCostBaseEntry> sGtBarberShopCostBaseStore(GtBarberShopCostBasefmt); DBCStorage <GtCombatRatingsEntry> sGtCombatRatingsStore(GtCombatRatingsfmt); DBCStorage <GtChanceToMeleeCritBaseEntry> sGtChanceToMeleeCritBaseStore(GtChanceToMeleeCritBasefmt); @@ -83,9 +72,7 @@ DBCStorage <GtOCTRegenHPEntry> sGtOCTRegenHPStore(GtOCTRegenHPfmt); //DBCStorage <GtOCTRegenMPEntry> sGtOCTRegenMPStore(GtOCTRegenMPfmt); -- not used currently DBCStorage <GtRegenHPPerSptEntry> sGtRegenHPPerSptStore(GtRegenHPPerSptfmt); DBCStorage <GtRegenMPPerSptEntry> sGtRegenMPPerSptStore(GtRegenMPPerSptfmt); - DBCStorage <HolidaysEntry> sHolidaysStore(Holidaysfmt); - DBCStorage <ItemEntry> sItemStore(Itemfmt); DBCStorage <ItemBagFamilyEntry> sItemBagFamilyStore(ItemBagFamilyfmt); //DBCStorage <ItemCondExtCostsEntry> sItemCondExtCostsStore(ItemCondExtCostsEntryfmt); @@ -95,30 +82,22 @@ DBCStorage <ItemLimitCategoryEntry> sItemLimitCategoryStore(ItemLimitCategoryEnt DBCStorage <ItemRandomPropertiesEntry> sItemRandomPropertiesStore(ItemRandomPropertiesfmt); DBCStorage <ItemRandomSuffixEntry> sItemRandomSuffixStore(ItemRandomSuffixfmt); DBCStorage <ItemSetEntry> sItemSetStore(ItemSetEntryfmt); - DBCStorage <LockEntry> sLockStore(LockEntryfmt); - DBCStorage <MailTemplateEntry> sMailTemplateStore(MailTemplateEntryfmt); DBCStorage <MapEntry> sMapStore(MapEntryfmt); DBCStorage <MovieEntry> sMovieStore(MovieEntryfmt); - DBCStorage <QuestSortEntry> sQuestSortStore(QuestSortEntryfmt); - DBCStorage <RandomPropertiesPointsEntry> sRandomPropertiesPointsStore(RandomPropertiesPointsfmt); DBCStorage <ScalingStatDistributionEntry> sScalingStatDistributionStore(ScalingStatDistributionfmt); DBCStorage <ScalingStatValuesEntry> sScalingStatValuesStore(ScalingStatValuesfmt); - DBCStorage <SkillLineEntry> sSkillLineStore(SkillLinefmt); DBCStorage <SkillLineAbilityEntry> sSkillLineAbilityStore(SkillLineAbilityfmt); - DBCStorage <SoundEntriesEntry> sSoundEntriesStore(SoundEntriesfmt); - DBCStorage <SpellItemEnchantmentEntry> sSpellItemEnchantmentStore(SpellItemEnchantmentfmt); DBCStorage <SpellItemEnchantmentConditionEntry> sSpellItemEnchantmentConditionStore(SpellItemEnchantmentConditionfmt); DBCStorage <SpellEntry> sSpellStore(SpellEntryfmt); SpellCategoryStore sSpellCategoryStore; PetFamilySpellsStore sPetFamilySpellsStore; - DBCStorage <SpellCastTimesEntry> sSpellCastTimesStore(SpellCastTimefmt); DBCStorage <SpellDurationEntry> sSpellDurationStore(SpellDurationfmt); DBCStorage <SpellFocusObjectEntry> sSpellFocusObjectStore(SpellFocusObjectfmt); @@ -131,21 +110,16 @@ DBCStorage <SummonPropertiesEntry> sSummonPropertiesStore(SummonPropertiesfmt); DBCStorage <TalentEntry> sTalentStore(TalentEntryfmt); TalentSpellPosMap sTalentSpellPosMap; DBCStorage <TalentTabEntry> sTalentTabStore(TalentTabEntryfmt); - // store absolute bit position for first rank for talent inspect static uint32 sTalentTabPages[12/*MAX_CLASSES*/][3]; - DBCStorage <TaxiNodesEntry> sTaxiNodesStore(TaxiNodesEntryfmt); TaxiMask sTaxiNodesMask; TaxiMask sOldContinentsNodesMask; - // DBC used only for initialization sTaxiPathSetBySource at startup. TaxiPathSetBySource sTaxiPathSetBySource; DBCStorage <TaxiPathEntry> sTaxiPathStore(TaxiPathEntryfmt); - // DBC used only for initialization sTaxiPathSetBySource at startup. TaxiPathNodesByPath sTaxiPathNodesByPath; - static DBCStorage <TaxiPathNodeEntry> sTaxiPathNodeStore(TaxiPathNodeEntryfmt); DBCStorage <TotemCategoryEntry> sTotemCategoryStore(TotemCategoryEntryfmt); DBCStorage <VehicleEntry> sVehicleStore(VehicleEntryfmt); @@ -153,28 +127,22 @@ DBCStorage <VehicleSeatEntry> sVehicleSeatStore(VehicleSeatEntryfmt); DBCStorage <WorldMapAreaEntry> sWorldMapAreaStore(WorldMapAreaEntryfmt); DBCStorage <WorldMapOverlayEntry> sWorldMapOverlayStore(WorldMapOverlayEntryfmt); DBCStorage <WorldSafeLocsEntry> sWorldSafeLocsStore(WorldSafeLocsEntryfmt); - typedef std::list<std::string> StoreProblemList; - static bool LoadDBC_assert_print(uint32 fsize,uint32 rsize, const std::string& filename) { sLog.outError("ERROR: Size of '%s' setted by format string (%u) not equal size of C++ structure (%u).",filename.c_str(),fsize,rsize); - // assert must fail after function call return false; } - template<class T> 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) { // compatibility format and C++ structure sizes assert(DBCFileLoader::GetFormatRecordSize(storage.GetFormat()) == sizeof(T) || LoadDBC_assert_print(DBCFileLoader::GetFormatRecordSize(storage.GetFormat()),sizeof(T),filename)); - std::string dbc_filename = dbc_path + filename; SqlDbc * sql = NULL; if (custom_entries) sql = new SqlDbc(&filename,custom_entries, idname,storage.GetFormat()); - if(storage.Load(dbc_filename.c_str(), sql)) { bar.step(); @@ -182,7 +150,6 @@ inline void LoadDBC(uint32& availableDbcLocales,barGoLink& bar, StoreProblemList { if(!(availableDbcLocales & (1 << i))) continue; - std::string dbc_filename_loc = dbc_path + localeNames[i] + "/" + filename; if(!storage.LoadStringsFrom(dbc_filename_loc.c_str())) availableDbcLocales &= ~(1<<i); // mark as not available for speedup next checks @@ -205,20 +172,14 @@ inline void LoadDBC(uint32& availableDbcLocales,barGoLink& bar, StoreProblemList if (sql) delete sql; } - void LoadDBCStores(const std::string& dataPath) { std::string dbcPath = dataPath+"dbc/"; - const uint32 DBCFilesCount = 79; - barGoLink bar( DBCFilesCount ); - StoreProblemList bad_dbc_files; uint32 availableDbcLocales = 0xFFFFFFFF; - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sAreaStore, dbcPath,"AreaTable.dbc"); - // must be after sAreaStore loading for(uint32 i = 0; i < sAreaStore.GetNumRows(); ++i) // areaflag numbered from 0 { @@ -226,13 +187,11 @@ void LoadDBCStores(const std::string& dataPath) { // fill AreaId->DBC records sAreaFlagByAreaID.insert(AreaFlagByAreaID::value_type(uint16(area->ID),area->exploreFlag)); - // fill MapId->DBC records ( skip sub zones and continents ) if(area->zone==0 && area->mapid != 0 && area->mapid != 1 && area->mapid != 530 && area->mapid != 571 ) sAreaFlagByMapID.insert(AreaFlagByMapID::value_type(area->mapid,area->exploreFlag)); } } - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sAchievementStore, dbcPath,"Achievement.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sAchievementCriteriaStore, dbcPath,"Achievement_Criteria.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sAreaTriggerStore, dbcPath,"AreaTrigger.dbc"); @@ -243,7 +202,6 @@ void LoadDBCStores(const std::string& dataPath) LoadDBC(availableDbcLocales,bar,bad_dbc_files,sBattlemasterListStore, dbcPath,"BattlemasterList.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sBarberShopStyleStore, dbcPath,"BarberShopStyle.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCharStartOutfitStore, dbcPath,"CharStartOutfit.dbc"); - 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"); @@ -268,7 +226,6 @@ void LoadDBCStores(const std::string& dataPath) flist.push_back(i); } } - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sFactionTemplateStore, dbcPath,"FactionTemplate.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGameObjectDisplayInfoStore, dbcPath,"GameObjectDisplayInfo.dbc"); for(uint32 i = 0; i < sGameObjectDisplayInfoStore.GetNumRows(); ++i) @@ -283,20 +240,15 @@ void LoadDBCStores(const std::string& dataPath) std::swap(*(float*)(&info->maxZ), *(float*)(&info->minZ)); } } - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGemPropertiesStore, dbcPath,"GemProperties.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGlyphPropertiesStore, dbcPath,"GlyphProperties.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGlyphSlotStore, dbcPath,"GlyphSlot.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtBarberShopCostBaseStore,dbcPath,"gtBarberShopCostBase.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtCombatRatingsStore, dbcPath,"gtCombatRatings.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtChanceToMeleeCritBaseStore, dbcPath,"gtChanceToMeleeCritBase.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtChanceToMeleeCritStore, dbcPath,"gtChanceToMeleeCrit.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtChanceToSpellCritBaseStore, dbcPath,"gtChanceToSpellCritBase.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtChanceToSpellCritStore, dbcPath,"gtChanceToSpellCrit.dbc"); - 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"); @@ -329,16 +281,12 @@ void LoadDBCStores(const std::string& dataPath) if(spell && spell->Category) sSpellCategoryStore[spell->Category].insert(i); } - for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j) { SkillLineAbilityEntry const *skillLine = sSkillLineAbilityStore.LookupEntry(j); - if(!skillLine) continue; - SpellEntry const* spellInfo = sSpellStore.LookupEntry(skillLine->spellId); - if(spellInfo && IsPassiveSpell(spellInfo->Id)) { for (uint32 i = 1; i < sCreatureFamilyStore.GetNumRows(); ++i) @@ -346,20 +294,16 @@ void LoadDBCStores(const std::string& dataPath) CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(i); if(!cFamily) continue; - if(skillLine->skillId != cFamily->skillLine[0] && skillLine->skillId != cFamily->skillLine[1]) continue; if(spellInfo->spellLevel) continue; - if(skillLine->learnOnGetSkill != ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL) continue; - sPetFamilySpellsStore[i].insert(spellInfo->Id); } } } - 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"); @@ -372,7 +316,6 @@ void LoadDBCStores(const std::string& dataPath) LoadDBC(availableDbcLocales,bar,bad_dbc_files,sStableSlotPricesStore, dbcPath,"StableSlotPrices.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSummonPropertiesStore, dbcPath,"SummonProperties.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTalentStore, dbcPath,"Talent.dbc"); - // create talent spells set for (unsigned int i = 0; i < sTalentStore.GetNumRows(); ++i) { @@ -382,9 +325,7 @@ void LoadDBCStores(const std::string& dataPath) if(talentInfo->RankID[j]) sTalentSpellPosMap[talentInfo->RankID[j]] = TalentSpellPos(i,j); } - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTalentTabStore, dbcPath,"TalentTab.dbc"); - // prepare fast data access to bit pos of talent ranks for use at inspecting { // now have all max ranks (and then bit amount used for store talent ranks in inspect) @@ -393,27 +334,21 @@ void LoadDBCStores(const std::string& dataPath) TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentTabId ); if(!talentTabInfo) continue; - // prevent memory corruption; otherwise cls will become 12 below if ((talentTabInfo->ClassMask & CLASSMASK_ALL_PLAYABLE)==0) continue; - // store class talent tab pages uint32 cls = 1; for(uint32 m=1;!(m & talentTabInfo->ClassMask) && cls < MAX_CLASSES;m <<=1, ++cls) {} - sTalentTabPages[cls][talentTabInfo->tabpage]=talentTabId; } } - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTaxiNodesStore, dbcPath,"TaxiNodes.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTaxiPathStore, dbcPath,"TaxiPath.dbc"); for(uint32 i = 1; i < sTaxiPathStore.GetNumRows(); ++i) if(TaxiPathEntry const* entry = sTaxiPathStore.LookupEntry(i)) sTaxiPathSetBySource[entry->from][entry->to] = TaxiPathBySourceAndDestination(entry->ID,entry->price); uint32 pathCount = sTaxiPathStore.GetNumRows(); - //## TaxiPathNode.dbc ## Loaded only for initialization different structures LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTaxiPathNodeStore, dbcPath,"TaxiPathNode.dbc"); // Calculate path nodes count @@ -434,7 +369,6 @@ void LoadDBCStores(const std::string& dataPath) if(TaxiPathNodeEntry const* entry = sTaxiPathNodeStore.LookupEntry(i)) sTaxiPathNodesByPath[entry->path][entry->index] = TaxiPathNode(entry->mapid,entry->x,entry->y,entry->z,entry->actionFlag,entry->delay); sTaxiPathNodeStore.Clear(); - // Initialize global taxinodes mask // include existed nodes that have at least single not spell base (scripted) path { @@ -444,7 +378,6 @@ void LoadDBCStores(const std::string& dataPath) for(int j=0; j < 3; ++j) if(sInfo->Effect[j]==123 /*SPELL_EFFECT_SEND_TAXI*/) spellPaths.insert(sInfo->EffectMiscValue[j]); - memset(sTaxiNodesMask,0,sizeof(sTaxiNodesMask)); memset(sOldContinentsNodesMask,0,sizeof(sTaxiNodesMask)); for(uint32 i = 1; i < sTaxiNodesStore.GetNumRows(); ++i) @@ -452,7 +385,6 @@ void LoadDBCStores(const std::string& dataPath) TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(i); if(!node) continue; - TaxiPathSetBySource::const_iterator src_i = sTaxiPathSetBySource.find(i); if(src_i!=sTaxiPathSetBySource.end() && !src_i->second.empty()) { @@ -466,29 +398,24 @@ void LoadDBCStores(const std::string& dataPath) break; } } - if(!ok) continue; } - // valid taxi network node uint8 field = (uint8)((i - 1) / 32); uint32 submask = 1<<((i-1)%32); sTaxiNodesMask[field] |= submask; - // 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; } } - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTotemCategoryStore, dbcPath,"TotemCategory.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sVehicleStore, dbcPath,"Vehicle.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sVehicleSeatStore, dbcPath,"VehicleSeat.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWorldMapAreaStore, dbcPath,"WorldMapArea.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWorldMapOverlayStore, dbcPath,"WorldMapOverlay.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWorldSafeLocsStore, dbcPath,"WorldSafeLocs.dbc"); - // error checks if(bad_dbc_files.size() >= DBCFilesCount ) { @@ -500,11 +427,9 @@ void LoadDBCStores(const std::string& dataPath) std::string str; for(std::list<std::string>::iterator i = bad_dbc_files.begin(); i != bad_dbc_files.end(); ++i) str += *i + "\n"; - 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()); exit(1); } - // Check loaded DBC files proper version if( !sSpellStore.LookupEntry(66530) || // last added spell in 3.1.3 !sMapStore.LookupEntry(624) || // last map added in 3.1.3 @@ -517,11 +442,9 @@ void LoadDBCStores(const std::string& dataPath) sLog.outError("\nYou have _outdated_ DBC files. Please extract correct versions from current using client."); exit(1); } - sLog.outString(); sLog.outString( ">> Initialized %d data stores", DBCFilesCount ); } - SimpleFactionsList const* GetFactionTeamList(uint32 faction, bool &isTeamMember) { for(FactionTeamMap::const_iterator itr = sFactionTeamMap.begin(); itr != sFactionTeamMap.end(); ++itr) @@ -542,7 +465,6 @@ SimpleFactionsList const* GetFactionTeamList(uint32 faction, bool &isTeamMember) } return NULL; } - char* GetPetName(uint32 petfamily, uint32 dbclang) { if(!petfamily) @@ -552,53 +474,41 @@ char* GetPetName(uint32 petfamily, uint32 dbclang) return NULL; return pet_family->Name[dbclang]?pet_family->Name[dbclang]:NULL; } - TalentSpellPos const* GetTalentSpellPos(uint32 spellId) { TalentSpellPosMap::const_iterator itr = sTalentSpellPosMap.find(spellId); if(itr==sTalentSpellPosMap.end()) return NULL; - return &itr->second; } - uint32 GetTalentSpellCost(uint32 spellId) { if(TalentSpellPos const* pos = GetTalentSpellPos(spellId)) return pos->rank+1; - return 0; } - int32 GetAreaFlagByAreaID(uint32 area_id) { AreaFlagByAreaID::iterator i = sAreaFlagByAreaID.find(area_id); if(i == sAreaFlagByAreaID.end()) return -1; - return i->second; } - AreaTableEntry const* GetAreaEntryByAreaID(uint32 area_id) { int32 areaflag = GetAreaFlagByAreaID(area_id); if(areaflag < 0) return NULL; - return sAreaStore.LookupEntry(areaflag ); } - AreaTableEntry const* GetAreaEntryByAreaFlagAndMap(uint32 area_flag,uint32 map_id) { if(area_flag) return sAreaStore.LookupEntry(area_flag); - if(MapEntry const* mapEntry = sMapStore.LookupEntry(map_id)) return GetAreaEntryByAreaID(mapEntry->linked_zone); - return NULL; } - uint32 GetAreaFlagByMapId(uint32 mapid) { AreaFlagByMapID::iterator i = sAreaFlagByMapID.find(mapid); @@ -607,28 +517,22 @@ uint32 GetAreaFlagByMapId(uint32 mapid) else return i->second; } - uint32 GetVirtualMapForMapAndZone(uint32 mapid, uint32 zoneId) { if(mapid != 530 && mapid != 571) // speed for most cases return mapid; - if(WorldMapAreaEntry const* wma = sWorldMapAreaStore.LookupEntry(zoneId)) return wma->virtual_map_id >= 0 ? wma->virtual_map_id : wma->map_id; - return mapid; } - ContentLevels GetContentLevelsForMapAndZone(uint32 mapid, uint32 zoneId) { mapid = GetVirtualMapForMapAndZone(mapid,zoneId); if(mapid < 2) return CONTENT_1_60; - MapEntry const* mapEntry = sMapStore.LookupEntry(mapid); if(!mapEntry) return CONTENT_1_60; - switch(mapEntry->Expansion()) { default: return CONTENT_1_60; @@ -636,7 +540,6 @@ ContentLevels GetContentLevelsForMapAndZone(uint32 mapid, uint32 zoneId) case 2: return CONTENT_71_80; } } - ChatChannelsEntry const* GetChannelEntryFor(uint32 channel_id) { // not sorted, numbering index from 0 @@ -648,58 +551,46 @@ ChatChannelsEntry const* GetChannelEntryFor(uint32 channel_id) } return NULL; } - bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId, uint32 requiredTotemCategoryId) { if(requiredTotemCategoryId==0) return true; if(itemTotemCategoryId==0) return false; - TotemCategoryEntry const* itemEntry = sTotemCategoryStore.LookupEntry(itemTotemCategoryId); if(!itemEntry) return false; TotemCategoryEntry const* reqEntry = sTotemCategoryStore.LookupEntry(requiredTotemCategoryId); if(!reqEntry) return false; - if(itemEntry->categoryType!=reqEntry->categoryType) return false; - return (itemEntry->categoryMask & reqEntry->categoryMask)==reqEntry->categoryMask; } - void Zone2MapCoordinates(float& x,float& y,uint32 zone) { WorldMapAreaEntry const* maEntry = sWorldMapAreaStore.LookupEntry(zone); - // if not listed then map coordinates (instance) if(!maEntry) return; - 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 } - void Map2ZoneCoordinates(float& x,float& y,uint32 zone) { WorldMapAreaEntry const* maEntry = sWorldMapAreaStore.LookupEntry(zone); - // if not listed then map coordinates (instance) if(!maEntry) return; - 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 } - uint32 const* GetTalentTabPages(uint32 cls) { return sTalentTabPages[cls]; } - // script support functions TRINITY_DLL_SPEC DBCStorage <SoundEntriesEntry> const* GetSoundEntriesStore() { return &sSoundEntriesStore; } TRINITY_DLL_SPEC DBCStorage <SpellEntry> const* GetSpellStore() { return &sSpellStore; } |