mirror of
https://github.com/mangosfour/server.git
synced 2025-12-20 16:37:04 +00:00
[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:
parent
13b709a10b
commit
fd2eb3cfee
9 changed files with 64 additions and 33 deletions
|
|
@ -1426,13 +1426,6 @@ struct SpellFocusObjectEntry
|
|||
// 16 string flags, unused
|
||||
};
|
||||
|
||||
// stored in SQL table
|
||||
struct SpellThreatEntry
|
||||
{
|
||||
uint32 spellId;
|
||||
int32 threat;
|
||||
};
|
||||
|
||||
struct SpellRadiusEntry
|
||||
{
|
||||
uint32 ID;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 ()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "8249"
|
||||
#define REVISION_NR "8250"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue