From 6002d7ea2c16c2e22cc28753253c53e16e1f46c1 Mon Sep 17 00:00:00 2001 From: ApoC Date: Tue, 7 Jul 2009 01:39:56 +0200 Subject: [PATCH] Implemented precast spell store as dynamicaly allocated list of precasts. Signed-off-by: ApoC --- src/game/Spell.cpp | 30 ++++++++++++++++++------------ src/game/Spell.h | 10 +++++++++- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 890d217f0..a0ce1f390 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -405,7 +405,7 @@ Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 origi focusObject = NULL; m_cast_count = 0; m_glyphIndex = 0; - m_preCastSpell = 0; + m_preCastSpells = NULL; m_triggeredByAuraSpell = NULL; //Auto Shot & Shoot (wand) @@ -445,6 +445,7 @@ Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 origi Spell::~Spell() { + delete m_preCastSpells; } template @@ -550,7 +551,7 @@ void Spell::FillTargetMap() if(m_targets.getUnitTarget()) tmpUnitMap.push_back(m_targets.getUnitTarget()); else - tmpUnitMap.push_back(m_caster); + tmpUnitMap.push_back(m_caster); break; case TARGET_AREAEFFECT_INSTANT: // All 17/7 pairs used for dest teleportation, A processed in effect code SetTargetMap(i, m_spellInfo->EffectImplicitTargetB[i], tmpUnitMap); @@ -1238,8 +1239,13 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask) unit->IncrDiminishing(m_diminishGroup); // Apply additional spell effects to target - if (m_preCastSpell) - m_caster->CastSpell(unit, m_preCastSpell, true, m_CastItem); + if (m_preCastSpells) + { + for (SpellPrecasts::const_iterator i = m_preCastSpells->begin(); i != m_preCastSpells->end(); ++i) + m_caster->CastSpell(unit, *i, true, m_CastItem); + delete m_preCastSpells; + m_preCastSpells = NULL; + } for(uint32 effectNumber = 0; effectNumber < 3; ++effectNumber) { @@ -2288,17 +2294,17 @@ void Spell::cast(bool skipCheck) case SPELLFAMILY_GENERIC: { if (m_spellInfo->Mechanic == MECHANIC_BANDAGE) // Bandages - m_preCastSpell = 11196; // Recently Bandaged + AddPrecastSpell(11196); // Recently Bandaged else if(m_spellInfo->SpellIconID == 1662 && m_spellInfo->AttributesEx & 0x20) // Blood Fury (Racial) - m_preCastSpell = 23230; // Blood Fury - Healing Reduction + AddPrecastSpell(23230); // Blood Fury - Healing Reduction break; } case SPELLFAMILY_MAGE: { // Ice Block if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000008000000000)) - m_preCastSpell = 41425; // Hypothermia + AddPrecastSpell(41425); // Hypothermia break; } case SPELLFAMILY_PRIEST: @@ -2306,27 +2312,27 @@ void Spell::cast(bool skipCheck) // Power Word: Shield if (m_spellInfo->Mechanic == MECHANIC_SHIELD && (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000000000001))) - m_preCastSpell = 6788; // Weakened Soul + AddPrecastSpell(6788); // Weakened Soul // Dispersion (transform) if (m_spellInfo->Id == 47585) - m_preCastSpell = 60069; // Dispersion (mana regen) + AddPrecastSpell(60069); // Dispersion (mana regen) break; } case SPELLFAMILY_PALADIN: { // Divine Shield, Divine Protection or Hand of Protection if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000000400080)) - m_preCastSpell = 25771; // Forbearance + AddPrecastSpell(25771); // Forbearance break; } case SPELLFAMILY_SHAMAN: { // Bloodlust if (m_spellInfo->Id == 2825) - m_preCastSpell = 57724; // Sated + AddPrecastSpell(57724); // Sated // Heroism else if (m_spellInfo->Id == 32182) - m_preCastSpell = 57723; // Exhaustion + AddPrecastSpell(57723); // Exhaustion break; } default: diff --git a/src/game/Spell.h b/src/game/Spell.h index 01c25060d..3583f546a 100644 --- a/src/game/Spell.h +++ b/src/game/Spell.h @@ -204,6 +204,7 @@ enum SpellTargets #define SPELL_SPELL_CHANNEL_UPDATE_INTERVAL (1*IN_MILISECONDS) typedef std::multimap SpellTargetTimeMap; +typedef std::list SpellPrecasts; class Spell { @@ -335,6 +336,13 @@ class Spell void TakeCastItem(); void TriggerSpell(); + void AddPrecastSpell(uint32 spellId) + { + if (!m_preCastSpells) + m_preCastSpells = new SpellPrecasts(); + m_preCastSpells->push_back(spellId); + } + SpellCastResult CheckCast(bool strict); SpellCastResult CheckPetCast(Unit* target); @@ -399,7 +407,7 @@ class Spell Item* m_CastItem; uint8 m_cast_count; uint32 m_glyphIndex; - uint32 m_preCastSpell; + SpellPrecasts *m_preCastSpells; SpellCastTargets m_targets; int32 GetCastTime() const { return m_casttime; }