diff options
author | megamage <none@none> | 2009-07-30 11:37:08 +0800 |
---|---|---|
committer | megamage <none@none> | 2009-07-30 11:37:08 +0800 |
commit | af2d5e3fd4a57147280d265d1bc5ac1c2b70a3a3 (patch) | |
tree | eddb20436980a4ce6be2d5d623fa25d2a653d653 | |
parent | 7121d98480d58a4214abcc2e22f678bad76cdecf (diff) |
[8250] Cleanup code and data for `spell_threat` Author: nos4r2zod
* Load table data to std::map instead SQLStorage and add check loaded spell existance.
* Drop from table not existed spells.
--HG--
branch : trunk
-rw-r--r-- | sql/mangos.sql | 15 | ||||
-rw-r--r-- | sql/updates/4649_world_8250_spell_threat.sql | 3 | ||||
-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 |
7 files changed, 61 insertions, 32 deletions
diff --git a/sql/mangos.sql b/sql/mangos.sql index fa01abaa8e3..b3f451e44ed 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -23,7 +23,7 @@ DROP TABLE IF EXISTS `db_version`; CREATE TABLE `db_version` ( `version` varchar(120) default NULL, `creature_ai_version` varchar(120) default NULL, - `required_8249_02_mangos_spell_chain` bit(1) default NULL + `required_8250_01_mangos_spell_threat` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -18110,7 +18110,6 @@ INSERT INTO `spell_threat` VALUES (284,39), (285,59), (770,108), -(778,108), (1608,78), (1672,180), (1715,61), @@ -18130,10 +18129,8 @@ INSERT INTO `spell_threat` VALUES (8380,180), (8972,118), (9745,148), -(9749,108), (9880,178), (9881,207), -(9907,108), (11556,43), (11564,98), (11565,118), @@ -18146,20 +18143,12 @@ INSERT INTO `spell_threat` VALUES (11600,275), (11601,315), (11775,395), -(14274,200), (14921,415), -(15629,300), -(15630,400), -(15631,500), -(15632,600), (16857,108), (17735,200), (17750,300), (17751,450), (17752,600), -(17390,108), -(17391,108), -(17392,108), (20569,100), (20736,100), (20925,20), @@ -18179,9 +18168,7 @@ INSERT INTO `spell_threat` VALUES (25286,175), (25288,355), (25289,60), -(26993,127), (26996,176), -(27011,127), (27179,54), (29704,230), (29707,196), diff --git a/sql/updates/4649_world_8250_spell_threat.sql b/sql/updates/4649_world_8250_spell_threat.sql new file mode 100644 index 00000000000..a19513363bd --- /dev/null +++ b/sql/updates/4649_world_8250_spell_threat.sql @@ -0,0 +1,3 @@ +-- ALTER TABLE db_version CHANGE COLUMN required_8249_02_mangos_spell_chain required_8250_01_mangos_spell_threat bit; + +DELETE FROM `spell_threat` WHERE `entry` IN (778,9749,9907,14274,15629,15630,15631,15632,17390,17391,17392,26993,27011);
\ No newline at end of file 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 () |