diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game/DBCStructure.h | 7 | ||||
-rw-r--r-- | src/game/Spell.cpp | 9 | ||||
-rw-r--r-- | src/game/SpellMgr.cpp | 44 | ||||
-rw-r--r-- | src/game/SpellMgr.h | 13 | ||||
-rw-r--r-- | src/shared/Database/SQLStorage.cpp | 2 |
5 files changed, 57 insertions, 18 deletions
diff --git a/src/game/DBCStructure.h b/src/game/DBCStructure.h index ffc37e1ee9b..910316881a4 100644 --- a/src/game/DBCStructure.h +++ b/src/game/DBCStructure.h @@ -1463,13 +1463,6 @@ struct SpellFocusObjectEntry // 16 string flags, unused }; -// stored in SQL table -struct SpellThreatEntry -{ - uint32 spellId; - int32 threat; -}; - struct SpellRadiusEntry { uint32 ID; diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index f4e992b6a7b..5c1b2fc3687 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -4200,13 +4200,14 @@ void Spell::HandleThreatSpells(uint32 spellId) if(!m_targets.getUnitTarget()->CanHaveThreatList()) return; - SpellThreatEntry const *threatSpell = sSpellThreatStore.LookupEntry<SpellThreatEntry>(spellId); - if(!threatSpell) + uint16 threat = spellmgr.GetSpellThreat(spellId); + + if(!threat) return; - m_targets.getUnitTarget()->AddThreat(m_caster, float(threatSpell->threat)); + m_targets.getUnitTarget()->AddThreat(m_caster, float(threat)); - DEBUG_LOG("Spell %u, rank %u, added an additional %i threat", spellId, spellmgr.GetSpellRank(spellId), threatSpell->threat); + DEBUG_LOG("Spell %u, rank %u, added an additional %i threat", spellId, spellmgr.GetSpellRank(spellId), threat); } void Spell::HandleEffects(Unit *pUnitTarget,Item *pItemTarget,GameObject *pGOTarget,uint32 i) diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index 73aebc61490..942ab52e3da 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -1505,12 +1505,50 @@ void SpellMgr::LoadSpellElixirs() void SpellMgr::LoadSpellThreats() { - sSpellThreatStore.Free(); // for reload + mSpellThreatMap.clear(); // need for reload case - sSpellThreatStore.Load(); + uint32 count = 0; + + // 0 1 + QueryResult *result = WorldDatabase.Query("SELECT entry, Threat FROM spell_threat"); + if( !result ) + { + + barGoLink bar( 1 ); + + bar.step(); + + sLog.outString(); + sLog.outString( ">> Loaded %u aggro generating spells", count ); + return; + } + + barGoLink bar( result->GetRowCount() ); + + do + { + Field *fields = result->Fetch(); + + bar.step(); + + uint32 entry = fields[0].GetUInt32(); + uint16 Threat = fields[1].GetUInt16(); + + if (!sSpellStore.LookupEntry(entry)) + { + sLog.outErrorDb("Spell %u listed in `spell_threat` does not exist", entry); + continue; + } + + mSpellThreatMap[entry] = Threat; + + ++count; + } while( result->NextRow() ); + + delete result; - sLog.outString( ">> Loaded %u aggro generating spells", sSpellThreatStore.RecordCount ); sLog.outString(); + sLog.outString( ">> Loaded %u aggro generating spells", count ); } bool SpellMgr::IsRankSpellDueToSpell(SpellEntry const *spellInfo_1,uint32 spellId_2) const diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h index ca83be4a560..d71306e5b86 100644 --- a/src/game/SpellMgr.h +++ b/src/game/SpellMgr.h @@ -40,8 +40,6 @@ class Player; class Spell; struct SpellModifier; -extern SQLStorage sSpellThreatStore; - // only used in code enum SpellCategories { @@ -527,6 +525,7 @@ typedef UNORDERED_MAP<uint32, SpellBonusEntry> SpellBonusMap; typedef std::map<uint32, uint8> SpellElixirMap; typedef std::map<uint32, float> SpellProcItemEnchantMap; +typedef std::map<uint32, uint16> SpellThreatMap; // Spell script target related declarations (accessed using SpellMgr functions) enum SpellScriptTargetType @@ -764,6 +763,15 @@ class SpellMgr return SPELL_NORMAL; } + uint16 GetSpellThreat(uint32 spellid) const + { + SpellThreatMap::const_iterator itr = mSpellThreatMap.find(spellid); + if(itr==mSpellThreatMap.end()) + return 0; + + return itr->second; + } + // Spell proc events SpellProcEventEntry const* GetSpellProcEvent(uint32 spellId) const { @@ -1081,6 +1089,7 @@ class SpellMgr SpellLearnSpellMap mSpellLearnSpells; SpellTargetPositionMap mSpellTargetPositions; SpellElixirMap mSpellElixirs; + SpellThreatMap mSpellThreatMap; SpellProcEventMap mSpellProcEventMap; SpellProcItemEnchantMap mSpellProcItemEnchantMap; SpellBonusMap mSpellBonusMap; diff --git a/src/shared/Database/SQLStorage.cpp b/src/shared/Database/SQLStorage.cpp index 50fd484bff5..4113d35236d 100644 --- a/src/shared/Database/SQLStorage.cpp +++ b/src/shared/Database/SQLStorage.cpp @@ -38,7 +38,6 @@ const char GameObjectInfodstfmt[]="iiissssiifiiiiiiiiiiiiiiiiiiiiiiiiiiiii"; const char ItemPrototypesrcfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiisiiii"; const char ItemPrototypedstfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiiiiiii"; const char PageTextfmt[]="isi"; -const char SpellThreatfmt[]="ii"; const char InstanceTemplatesrcfmt[]="iiiiiiffffs"; const char InstanceTemplatedstfmt[]="iiiiiiffffi"; @@ -50,7 +49,6 @@ SQLStorage sEquipmentStorage(EquipmentInfofmt,"entry","creature_equip_template") SQLStorage sGOStorage(GameObjectInfosrcfmt, GameObjectInfodstfmt, "entry","gameobject_template"); SQLStorage sItemStorage(ItemPrototypesrcfmt, ItemPrototypedstfmt, "entry","item_template"); SQLStorage sPageTextStore(PageTextfmt,"entry","page_text"); -SQLStorage sSpellThreatStore(SpellThreatfmt,"entry","spell_threat"); SQLStorage sInstanceTemplate(InstanceTemplatesrcfmt, InstanceTemplatedstfmt, "map","instance_template"); void SQLStorage::Free () |