[8250] Cleanup code and data for spell_threat

* Load table data to std::map instead SQLStorage and add check loaded spell existance.
* Drop from table not existed spells.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
nos4r2zod 2009-07-26 05:45:33 +04:00 committed by VladimirMangos
parent 13b709a10b
commit fd2eb3cfee
9 changed files with 64 additions and 33 deletions

View file

@ -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';
--
@ -18099,7 +18099,6 @@ INSERT INTO `spell_threat` VALUES
(284,39),
(285,59),
(770,108),
(778,108),
(1608,78),
(1672,180),
(1715,61),
@ -18119,10 +18118,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),
@ -18135,20 +18132,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),
@ -18168,9 +18157,7 @@ INSERT INTO `spell_threat` VALUES
(25286,175),
(25288,355),
(25289,60),
(26993,127),
(26996,176),
(27011,127),
(27179,54),
(29704,230),
(29707,196),

View file

@ -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);

View file

@ -254,6 +254,7 @@ pkgdata_DATA = \
8247_01_mangos_spell_bonus_data.sql \
8249_01_mangos_spell_proc_item_enchant.sql \
8249_02_mangos_spell_chain.sql \
8250_01_mangos_spell_threat.sql \
README
## Additional files to include when running 'make dist'
@ -488,4 +489,5 @@ EXTRA_DIST = \
8247_01_mangos_spell_bonus_data.sql \
8249_01_mangos_spell_proc_item_enchant.sql \
8249_02_mangos_spell_chain.sql \
8250_01_mangos_spell_threat.sql \
README

View file

@ -1426,13 +1426,6 @@ struct SpellFocusObjectEntry
// 16 string flags, unused
};
// stored in SQL table
struct SpellThreatEntry
{
uint32 spellId;
int32 threat;
};
struct SpellRadiusEntry
{
uint32 ID;

View file

@ -3566,13 +3566,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, float DamageMultiplier)

View file

@ -989,12 +989,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

View file

@ -36,8 +36,6 @@ class Player;
class Spell;
struct SpellModifier;
extern SQLStorage sSpellThreatStore;
// only used in code
enum SpellCategories
{
@ -450,6 +448,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 SpellTargetType
@ -663,6 +662,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
{
@ -927,6 +935,7 @@ class SpellMgr
SpellLearnSpellMap mSpellLearnSpells;
SpellTargetPositionMap mSpellTargetPositions;
SpellElixirMap mSpellElixirs;
SpellThreatMap mSpellThreatMap;
SpellProcEventMap mSpellProcEventMap;
SpellProcItemEnchantMap mSpellProcItemEnchantMap;
SpellBonusMap mSpellBonusMap;

View file

@ -36,7 +36,6 @@ const char GameObjectInfodstfmt[]="iiissssiifiiiiiiiiiiiiiiiiiiiiiiiiiiiii";
const char ItemPrototypesrcfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiisiiii";
const char ItemPrototypedstfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiiiiiii";
const char PageTextfmt[]="isi";
const char SpellThreatfmt[]="ii";
const char InstanceTemplatesrcfmt[]="iiiiiiiffffs";
const char InstanceTemplatedstfmt[]="iiiiiiiffffi";
@ -48,7 +47,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 ()

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "8249"
#define REVISION_NR "8250"
#endif // __REVISION_NR_H__