From 881a46792d462ffc69818bae53e5571f0104cc3e Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Fri, 19 Feb 2010 04:27:24 +0300 Subject: [PATCH] [9411] More SpellEffectIndex using in apropriate cases --- src/game/AchievementMgr.cpp | 6 +- src/game/Creature.cpp | 2 +- src/game/Creature.h | 4 +- src/game/CreatureEventAI.cpp | 2 +- src/game/DBCStructure.h | 4 +- src/game/DynamicObject.cpp | 2 +- src/game/DynamicObject.h | 6 +- src/game/GridNotifiersImpl.h | 2 +- src/game/Level3.cpp | 2 +- src/game/ObjectMgr.cpp | 16 ++--- src/game/Pet.cpp | 4 +- src/game/Player.cpp | 28 ++++---- src/game/Player.h | 4 +- src/game/Spell.cpp | 121 +++++++++++++++++------------------ src/game/Spell.h | 20 +++--- src/game/SpellAuras.cpp | 21 +++--- src/game/SpellAuras.h | 18 +++--- src/game/SpellEffects.cpp | 8 +-- src/game/SpellMgr.cpp | 35 ++++++---- src/game/SpellMgr.h | 12 ++-- src/game/StatSystem.cpp | 2 +- src/game/Totem.cpp | 2 +- src/game/Totem.h | 2 +- src/game/Unit.cpp | 46 ++++++------- src/game/Unit.h | 24 +++---- src/shared/revision_nr.h | 2 +- 26 files changed, 199 insertions(+), 196 deletions(-) diff --git a/src/game/AchievementMgr.cpp b/src/game/AchievementMgr.cpp index 045973f7c4f..2a02372dd5a 100644 --- a/src/game/AchievementMgr.cpp +++ b/src/game/AchievementMgr.cpp @@ -163,7 +163,7 @@ bool AchievementCriteriaRequirement::IsValid(AchievementCriteriaEntry const* cri criteria->ID, criteria->requiredType,(requirementType==ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA?"ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA":"ACHIEVEMENT_CRITERIA_REQUIRE_T_AURA"),requirementType,aura.spell_id); return false; } - if (aura.effect_idx >= 3) + if (aura.effect_idx >= MAX_EFFECT_INDEX) { sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement %s (%u) have wrong spell effect index in value2 (%u), ignore.", criteria->ID, criteria->requiredType,(requirementType==ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA?"ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA":"ACHIEVEMENT_CRITERIA_REQUIRE_T_AURA"),requirementType,aura.effect_idx); @@ -276,7 +276,7 @@ bool AchievementCriteriaRequirement::Meets(uint32 criteria_id, Player const* sou // flag set == must be same team, not set == different team return (((Player*)target)->GetTeam() == source->GetTeam()) == (player_dead.own_team_flag != 0); case ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA: - return source->HasAura(aura.spell_id,aura.effect_idx); + return source->HasAura(aura.spell_id,SpellEffectIndex(aura.effect_idx)); case ACHIEVEMENT_CRITERIA_REQUIRE_S_AREA: { uint32 zone_id,area_id; @@ -284,7 +284,7 @@ bool AchievementCriteriaRequirement::Meets(uint32 criteria_id, Player const* sou return area.id==zone_id || area.id==area_id; } case ACHIEVEMENT_CRITERIA_REQUIRE_T_AURA: - return target && target->HasAura(aura.spell_id,aura.effect_idx); + return target && target->HasAura(aura.spell_id,SpellEffectIndex(aura.effect_idx)); case ACHIEVEMENT_CRITERIA_REQUIRE_VALUE: return miscvalue1 >= value.minvalue; case ACHIEVEMENT_CRITERIA_REQUIRE_T_LEVEL: diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 65c2ad61c51..55ac4ba8f34 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -1358,7 +1358,7 @@ bool Creature::IsImmunedToSpell(SpellEntry const* spellInfo) return Unit::IsImmunedToSpell(spellInfo); } -bool Creature::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const +bool Creature::IsImmunedToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex index) const { if (GetCreatureInfo()->MechanicImmuneMask & (1 << (spellInfo->EffectMechanic[index] - 1))) return true; diff --git a/src/game/Creature.h b/src/game/Creature.h index 1e7f2cbe96b..024adc1a193 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -206,7 +206,7 @@ struct CreatureData struct CreatureDataAddonAura { uint32 spell_id; - uint8 effect_idx; + SpellEffectIndex effect_idx; }; // from `creature_addon` table @@ -413,7 +413,7 @@ class MANGOS_DLL_SPEC Creature : public Unit bool IsOutOfThreatArea(Unit* pVictim) const; bool IsImmunedToSpell(SpellEntry const* spellInfo); // redefine Unit::IsImmunedToSpell - bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const; + bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex index) const; // redefine Unit::IsImmunedToSpellEffect bool isElite() const { diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index 60accce4087..d036e9909da 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -458,7 +458,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 if(action.cast.castFlags & CAST_AURA_NOT_PRESENT) { for(int i = 0; i < MAX_EFFECT_INDEX; ++i) - if(target->HasAura(action.cast.spellId, i)) + if(target->HasAura(action.cast.spellId, SpellEffectIndex(i))) return; } diff --git a/src/game/DBCStructure.h b/src/game/DBCStructure.h index 0ee21ac7468..1677e3e5cac 100644 --- a/src/game/DBCStructure.h +++ b/src/game/DBCStructure.h @@ -1454,8 +1454,8 @@ struct SpellEntry //uint32 SpellDifficultyId; // 239 3.3.0 // helpers - int32 CalculateSimpleValue(uint8 eff) const { return EffectBasePoints[eff]+int32(EffectBaseDice[eff]); } - uint32 const* GetEffectSpellClassMask(uint8 effect) const + int32 CalculateSimpleValue(SpellEffectIndex eff) const { return EffectBasePoints[eff]+int32(EffectBaseDice[eff]); } + uint32 const* GetEffectSpellClassMask(SpellEffectIndex effect) const { return EffectSpellClassMaskA + effect * 3; } diff --git a/src/game/DynamicObject.cpp b/src/game/DynamicObject.cpp index da35b9bffc7..7778b164e30 100644 --- a/src/game/DynamicObject.cpp +++ b/src/game/DynamicObject.cpp @@ -55,7 +55,7 @@ void DynamicObject::RemoveFromWorld() Object::RemoveFromWorld(); } -bool DynamicObject::Create( uint32 guidlow, Unit *caster, uint32 spellId, uint32 effIndex, float x, float y, float z, int32 duration, float radius ) +bool DynamicObject::Create( uint32 guidlow, Unit *caster, uint32 spellId, SpellEffectIndex effIndex, float x, float y, float z, int32 duration, float radius ) { WorldObject::_Create(guidlow, HIGHGUID_DYNAMICOBJECT, caster->GetPhaseMask()); SetMap(caster->GetMap()); diff --git a/src/game/DynamicObject.h b/src/game/DynamicObject.h index 9adf6b7bc29..cd454cabafc 100644 --- a/src/game/DynamicObject.h +++ b/src/game/DynamicObject.h @@ -33,11 +33,11 @@ class DynamicObject : public WorldObject void AddToWorld(); void RemoveFromWorld(); - bool Create(uint32 guidlow, Unit *caster, uint32 spellId, uint32 effIndex, float x, float y, float z, int32 duration, float radius); + bool Create(uint32 guidlow, Unit *caster, uint32 spellId, SpellEffectIndex effIndex, float x, float y, float z, int32 duration, float radius); void Update(uint32 p_time); void Delete(); uint32 GetSpellId() const { return m_spellId; } - uint32 GetEffIndex() const { return m_effIndex; } + SpellEffectIndex GetEffIndex() const { return m_effIndex; } uint32 GetDuration() const { return m_aliveDuration; } uint64 GetCasterGUID() const { return GetUInt64Value(DYNAMICOBJECT_CASTER); } Unit* GetCaster() const; @@ -59,7 +59,7 @@ class DynamicObject : public WorldObject bool isActiveObject() const { return m_isActiveObject; } protected: uint32 m_spellId; - uint32 m_effIndex; + SpellEffectIndex m_effIndex; int32 m_aliveDuration; float m_radius; // radius apply persistent effect, 0 = no persistent effect AffectedSet m_affected; diff --git a/src/game/GridNotifiersImpl.h b/src/game/GridNotifiersImpl.h index 79e6351082b..2cd26cefcb8 100644 --- a/src/game/GridNotifiersImpl.h +++ b/src/game/GridNotifiersImpl.h @@ -172,7 +172,7 @@ inline void MaNGOS::DynamicObjectUpdater::VisitHelper(Unit* target) return; SpellEntry const *spellInfo = sSpellStore.LookupEntry(i_dynobject.GetSpellId()); - uint32 eff_index = i_dynobject.GetEffIndex(); + SpellEffectIndex eff_index = i_dynobject.GetEffIndex(); // Check target immune to spell or aura if (target->IsImmunedToSpell(spellInfo) || target->IsImmunedToSpellEffect(spellInfo, eff_index)) return; diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 38e6582cf97..73918b927c1 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -3603,7 +3603,7 @@ bool ChatHandler::HandleAuraCommand(const char* args) eff == SPELL_EFFECT_APPLY_AURA || eff == SPELL_EFFECT_PERSISTENT_AREA_AURA ) { - Aura *Aur = CreateAura(spellInfo, i, NULL, target); + Aura *Aur = CreateAura(spellInfo, SpellEffectIndex(i), NULL, target); target->AddAura(Aur); } } diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 03bb370c85e..2e20342af1b 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -790,8 +790,8 @@ void ObjectMgr::ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* for(uint32 j = 0; j < val.size()/2; ++j) { CreatureDataAddonAura& cAura = const_cast(addon->auras[i]); - cAura.spell_id = (uint32)val[2*j+0]; - cAura.effect_idx = (uint32)val[2*j+1]; + cAura.spell_id = uint32(val[2*j+0]); + cAura.effect_idx = SpellEffectIndex(val[2*j+1]); if (cAura.effect_idx >= MAX_EFFECT_INDEX) { sLog.outErrorDb("Creature (%s: %u) has wrong effect %u for spell %u in `auras` field in `%s`.",guidEntryStr,addon->guidOrEntry,cAura.effect_idx,cAura.spell_id,table); @@ -7386,7 +7386,7 @@ bool PlayerCondition::Meets(Player const * player) const case CONDITION_NONE: return true; // empty condition, always met case CONDITION_AURA: - return player->HasAura(value1, value2); + return player->HasAura(value1, SpellEffectIndex(value2)); case CONDITION_ITEM: return player->HasItemCount(value1, value2); case CONDITION_ITEM_EQUIPPED: @@ -7418,7 +7418,7 @@ bool PlayerCondition::Meets(Player const * player) const return false; } case CONDITION_NO_AURA: - return !player->HasAura(value1, value2); + return !player->HasAura(value1, SpellEffectIndex(value2)); case CONDITION_ACTIVE_EVENT: return sGameEventMgr.IsActiveEvent(value1); case CONDITION_AREA_FLAG: @@ -7467,9 +7467,9 @@ bool PlayerCondition::IsValid(ConditionType condition, uint32 value1, uint32 val sLog.outErrorDb("Aura condition requires to have non existing spell (Id: %d), skipped", value1); return false; } - if(value2 > EFFECT_INDEX_2) + if(value2 >= MAX_EFFECT_INDEX) { - sLog.outErrorDb("Aura condition requires to have non existing effect index (%u) (must be 0..2), skipped", value2); + sLog.outErrorDb("Aura condition requires to have non existing effect index (%u) (must be 0..%u), skipped", value2, MAX_EFFECT_INDEX-1); return false; } break; @@ -7571,9 +7571,9 @@ bool PlayerCondition::IsValid(ConditionType condition, uint32 value1, uint32 val sLog.outErrorDb("Aura condition requires to have non existing spell (Id: %d), skipped", value1); return false; } - if(value2 > EFFECT_INDEX_2) + if(value2 > MAX_EFFECT_INDEX) { - sLog.outErrorDb("Aura condition requires to have non existing effect index (%u) (must be 0..2), skipped", value2); + sLog.outErrorDb("Aura condition requires to have non existing effect index (%u) (must be 0..%u), skipped", value2, MAX_EFFECT_INDEX-1); return false; } break; diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 22e07e12bfa..3f65eb3cad2 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -1152,7 +1152,7 @@ void Pet::_LoadAuras(uint32 timediff) Field *fields = result->Fetch(); uint64 caster_guid = fields[0].GetUInt64(); uint32 spellid = fields[1].GetUInt32(); - uint32 effindex = fields[2].GetUInt32(); + SpellEffectIndex effindex = SpellEffectIndex(fields[2].GetUInt32()); uint32 stackcount= fields[3].GetUInt32(); int32 damage = (int32)fields[4].GetUInt32(); int32 maxduration = (int32)fields[5].GetUInt32(); @@ -1194,7 +1194,7 @@ void Pet::_LoadAuras(uint32 timediff) if (caster_guid != GetGUID() && IsSingleTargetSpell(spellproto)) continue; - for(uint32 i=0; iId), lastAffected(NULL) +SpellModifier::SpellModifier( SpellModOp _op, SpellModType _type, int32 _value, SpellEntry const* spellEntry, SpellEffectIndex eff, int16 _charges /*= 0*/ ) : op(_op), type(_type), charges(_charges), value(_value), spellId(spellEntry->Id), lastAffected(NULL) { uint32 const* ptr = spellEntry->GetEffectSpellClassMask(eff); mask = uint64(ptr[0]) | (uint64(ptr[1]) << 32); @@ -3280,7 +3280,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo // remove pet auras for(int i = 0; i < MAX_EFFECT_INDEX; ++i) - if(PetAura const* petSpell = sSpellMgr.GetPetAura(spell_id, i)) + if(PetAura const* petSpell = sSpellMgr.GetPetAura(spell_id, SpellEffectIndex(i))) RemovePetAura(petSpell); // free talent points @@ -4256,9 +4256,9 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness) { int32 delta = (int32(getLevel()) - startLevel + 1)*MINUTE; - for(int i =0; i < MAX_EFFECT_INDEX; ++i) + for(int i = 0; i < MAX_EFFECT_INDEX; ++i) { - if(Aura* Aur = GetAura(SPELL_ID_PASSIVE_RESURRECTION_SICKNESS,i)) + if(Aura* Aur = GetAura(SPELL_ID_PASSIVE_RESURRECTION_SICKNESS,SpellEffectIndex(i))) { Aur->SetAuraDuration(delta*IN_MILISECONDS); Aur->SendAuraUpdate(false); @@ -7080,7 +7080,7 @@ void Player::ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply bool found = false; for (int k=0; k < MAX_EFFECT_INDEX; ++k) { - spellEffectPair spair = spellEffectPair(spellInfo->Id, k); + spellEffectPair spair = spellEffectPair(spellInfo->Id, SpellEffectIndex(k)); for (AuraMap::const_iterator iter = m_Auras.lower_bound(spair); iter != m_Auras.upper_bound(spair); ++iter) { if(!item || iter->second->GetCastItemGUID() == item->GetGUID()) @@ -15266,7 +15266,7 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff) Field *fields = result->Fetch(); uint64 caster_guid = fields[0].GetUInt64(); uint32 spellid = fields[1].GetUInt32(); - uint32 effindex = fields[2].GetUInt32(); + SpellEffectIndex effindex = SpellEffectIndex(fields[2].GetUInt32()); uint32 stackcount = fields[3].GetUInt32(); int32 damage = fields[4].GetInt32(); int32 maxduration = fields[5].GetInt32(); @@ -15274,13 +15274,13 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff) int32 remaincharges = fields[7].GetInt32(); SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid); - if(!spellproto) + if (!spellproto) { sLog.outError("Unknown aura (spellid %u, effindex %u), ignore.",spellid,effindex); continue; } - if(effindex >= 3) + if (effindex >= MAX_EFFECT_INDEX) { sLog.outError("Invalid effect index (spellid %u, effindex %u), ignore.",spellid,effindex); continue; @@ -15296,19 +15296,19 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff) } // prevent wrong values of remaincharges - if(spellproto->procCharges) + if (spellproto->procCharges) { - if(remaincharges <= 0 || remaincharges > (int32)spellproto->procCharges) + if (remaincharges <= 0 || remaincharges > (int32)spellproto->procCharges) remaincharges = spellproto->procCharges; } else remaincharges = 0; - for(uint32 i=0; i < stackcount; ++i) + for(uint32 i = 0; i < stackcount; ++i) { Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL); - if(!damage) + if (!damage) damage = aura->GetModifier()->m_amount; // reset stolen single target auras @@ -19242,7 +19242,7 @@ void Player::SendAurasForTarget(Unit *target) { for(int j = 0; j < MAX_EFFECT_INDEX; ++j) { - if(Aura *aura = target->GetAura(itr->second, j)) + if(Aura *aura = target->GetAura(itr->second, SpellEffectIndex(j))) { data << uint8(aura->GetAuraSlot()); data << uint32(aura->GetId()); @@ -21535,7 +21535,7 @@ void Player::SendDuelCountdown(uint32 counter) GetSession()->SendPacket(&data); } -bool Player::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const +bool Player::IsImmunedToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex index) const { switch(spellInfo->Effect[index]) { diff --git a/src/game/Player.h b/src/game/Player.h index 5e85a252800..dae63b5fb86 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -104,7 +104,7 @@ struct SpellModifier : op(_op), type(_type), charges(_charges), value(_value), mask(_mask), mask2(_mask2), spellId(_spellId), lastAffected(NULL) {} - SpellModifier(SpellModOp _op, SpellModType _type, int32 _value, SpellEntry const* spellEntry, uint8 eff, int16 _charges = 0); + SpellModifier(SpellModOp _op, SpellModType _type, int32 _value, SpellEntry const* spellEntry, SpellEffectIndex eff, int16 _charges = 0); SpellModifier(SpellModOp _op, SpellModType _type, int32 _value, Aura const* aura, int16 _charges = 0); @@ -1544,7 +1544,7 @@ class MANGOS_DLL_SPEC Player : public Unit TrainerSpellState GetTrainerSpellState(TrainerSpell const* trainer_spell) const; bool IsSpellFitByClassAndRace( uint32 spell_id ) const; bool IsNeedCastPassiveSpellAtLearn(SpellEntry const* spellInfo) const; - bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const; + bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex index) const; void SendProficiency(uint8 pr1, uint32 pr2); void SendInitialSpells(); diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 8bde990162f..d2ca8628eed 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -467,7 +467,7 @@ void Spell::FillTargetMap() { // TODO: ADD the correct target FILLS!!!!!! - for(uint32 i = 0; i < MAX_EFFECT_INDEX; ++i) + for(int i = 0; i < MAX_EFFECT_INDEX; ++i) { // not call for empty effect. // Also some spells use not used effect targets for store targets for dummy effect in triggered spells @@ -486,7 +486,7 @@ void Spell::FillTargetMap() // TODO: find a way so this is not needed? // for area auras always add caster as target (needed for totems for example) if(IsAreaAuraEffect(m_spellInfo->Effect[i])) - AddUnitTarget(m_caster, i); + AddUnitTarget(m_caster, SpellEffectIndex(i)); std::list tmpUnitMap; @@ -498,10 +498,10 @@ void Spell::FillTargetMap() switch(m_spellInfo->EffectImplicitTargetB[i]) { case 0: - SetTargetMap(i, TARGET_EFFECT_SELECT, tmpUnitMap); + SetTargetMap(SpellEffectIndex(i), TARGET_EFFECT_SELECT, tmpUnitMap); break; default: - SetTargetMap(i, m_spellInfo->EffectImplicitTargetB[i], tmpUnitMap); + SetTargetMap(SpellEffectIndex(i), m_spellInfo->EffectImplicitTargetB[i], tmpUnitMap); break; } break; @@ -510,19 +510,19 @@ void Spell::FillTargetMap() { case 0: case TARGET_EFFECT_SELECT: - SetTargetMap(i, m_spellInfo->EffectImplicitTargetA[i], tmpUnitMap); + SetTargetMap(SpellEffectIndex(i), m_spellInfo->EffectImplicitTargetA[i], tmpUnitMap); break; case TARGET_AREAEFFECT_INSTANT: // use B case that not dependent from from A in fact if((m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) == 0) m_targets.setDestination(m_caster->GetPositionX(), m_caster->GetPositionY(), m_caster->GetPositionZ()); - SetTargetMap(i, m_spellInfo->EffectImplicitTargetB[i], tmpUnitMap); + SetTargetMap(SpellEffectIndex(i), m_spellInfo->EffectImplicitTargetB[i], tmpUnitMap); break; case TARGET_BEHIND_VICTIM: // use B case that not dependent from from A in fact - SetTargetMap(i, m_spellInfo->EffectImplicitTargetB[i], tmpUnitMap); + SetTargetMap(SpellEffectIndex(i), m_spellInfo->EffectImplicitTargetB[i], tmpUnitMap); break; default: - SetTargetMap(i, m_spellInfo->EffectImplicitTargetA[i], tmpUnitMap); - SetTargetMap(i, m_spellInfo->EffectImplicitTargetB[i], tmpUnitMap); + SetTargetMap(SpellEffectIndex(i), m_spellInfo->EffectImplicitTargetA[i], tmpUnitMap); + SetTargetMap(SpellEffectIndex(i), m_spellInfo->EffectImplicitTargetB[i], tmpUnitMap); break; } break; @@ -531,7 +531,7 @@ void Spell::FillTargetMap() { case 0: case TARGET_EFFECT_SELECT: - SetTargetMap(i, m_spellInfo->EffectImplicitTargetA[i], tmpUnitMap); + SetTargetMap(SpellEffectIndex(i), m_spellInfo->EffectImplicitTargetA[i], tmpUnitMap); break; case TARGET_INNKEEPER_COORDINATES: case TARGET_TABLE_X_Y_Z_COORDINATES: @@ -549,11 +549,11 @@ void Spell::FillTargetMap() case TARGET_POINT_AT_SE: case TARGET_POINT_AT_SW: // need some target for processing - SetTargetMap(i, m_spellInfo->EffectImplicitTargetA[i], tmpUnitMap); - SetTargetMap(i, m_spellInfo->EffectImplicitTargetB[i], tmpUnitMap); + SetTargetMap(SpellEffectIndex(i), m_spellInfo->EffectImplicitTargetA[i], tmpUnitMap); + SetTargetMap(SpellEffectIndex(i), m_spellInfo->EffectImplicitTargetB[i], tmpUnitMap); break; default: - SetTargetMap(i, m_spellInfo->EffectImplicitTargetB[i], tmpUnitMap); + SetTargetMap(SpellEffectIndex(i), m_spellInfo->EffectImplicitTargetB[i], tmpUnitMap); break; } break; @@ -571,17 +571,17 @@ void Spell::FillTargetMap() } else { - SetTargetMap(i, m_spellInfo->EffectImplicitTargetA[i], tmpUnitMap); - SetTargetMap(i, m_spellInfo->EffectImplicitTargetB[i], tmpUnitMap); + SetTargetMap(SpellEffectIndex(i), m_spellInfo->EffectImplicitTargetA[i], tmpUnitMap); + SetTargetMap(SpellEffectIndex(i), m_spellInfo->EffectImplicitTargetB[i], tmpUnitMap); } break; case 0: - SetTargetMap(i, m_spellInfo->EffectImplicitTargetA[i], tmpUnitMap); + SetTargetMap(SpellEffectIndex(i), m_spellInfo->EffectImplicitTargetA[i], tmpUnitMap); tmpUnitMap.push_back(m_caster); break; default: - SetTargetMap(i, m_spellInfo->EffectImplicitTargetA[i], tmpUnitMap); - SetTargetMap(i, m_spellInfo->EffectImplicitTargetB[i], tmpUnitMap); + SetTargetMap(SpellEffectIndex(i), m_spellInfo->EffectImplicitTargetA[i], tmpUnitMap); + SetTargetMap(SpellEffectIndex(i), m_spellInfo->EffectImplicitTargetB[i], tmpUnitMap); break; } break; @@ -589,17 +589,17 @@ void Spell::FillTargetMap() switch(m_spellInfo->EffectImplicitTargetB[i]) { case 0: - SetTargetMap(i, m_spellInfo->EffectImplicitTargetA[i], tmpUnitMap); + SetTargetMap(SpellEffectIndex(i), m_spellInfo->EffectImplicitTargetA[i], tmpUnitMap); // need some target for processing - SetTargetMap(i, TARGET_EFFECT_SELECT, tmpUnitMap); + SetTargetMap(SpellEffectIndex(i), TARGET_EFFECT_SELECT, tmpUnitMap); 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); + SetTargetMap(SpellEffectIndex(i), m_spellInfo->EffectImplicitTargetB[i], tmpUnitMap); break; default: - SetTargetMap(i, m_spellInfo->EffectImplicitTargetA[i], tmpUnitMap); - SetTargetMap(i, m_spellInfo->EffectImplicitTargetB[i], tmpUnitMap); + SetTargetMap(SpellEffectIndex(i), m_spellInfo->EffectImplicitTargetA[i], tmpUnitMap); + SetTargetMap(SpellEffectIndex(i), m_spellInfo->EffectImplicitTargetB[i], tmpUnitMap); break; } break; @@ -608,11 +608,11 @@ void Spell::FillTargetMap() { case 0: case TARGET_EFFECT_SELECT: - SetTargetMap(i, m_spellInfo->EffectImplicitTargetA[i], tmpUnitMap); + SetTargetMap(SpellEffectIndex(i), m_spellInfo->EffectImplicitTargetA[i], tmpUnitMap); break; // most A/B target pairs is self->negative and not expect adding caster to target list default: - SetTargetMap(i, m_spellInfo->EffectImplicitTargetB[i], tmpUnitMap); + SetTargetMap(SpellEffectIndex(i), m_spellInfo->EffectImplicitTargetB[i], tmpUnitMap); break; } break; @@ -621,14 +621,14 @@ void Spell::FillTargetMap() { case 0: case TARGET_EFFECT_SELECT: - SetTargetMap(i, m_spellInfo->EffectImplicitTargetA[i], tmpUnitMap); + SetTargetMap(SpellEffectIndex(i), m_spellInfo->EffectImplicitTargetA[i], tmpUnitMap); break; case TARGET_SCRIPT_COORDINATES: // B case filled in CheckCast but we need fill unit list base at A case - SetTargetMap(i, m_spellInfo->EffectImplicitTargetA[i], tmpUnitMap); + SetTargetMap(SpellEffectIndex(i), m_spellInfo->EffectImplicitTargetA[i], tmpUnitMap); break; default: - SetTargetMap(i, m_spellInfo->EffectImplicitTargetA[i], tmpUnitMap); - SetTargetMap(i, m_spellInfo->EffectImplicitTargetB[i], tmpUnitMap); + SetTargetMap(SpellEffectIndex(i), m_spellInfo->EffectImplicitTargetA[i], tmpUnitMap); + SetTargetMap(SpellEffectIndex(i), m_spellInfo->EffectImplicitTargetB[i], tmpUnitMap); break; } break; @@ -652,7 +652,7 @@ void Spell::FillTargetMap() for (std::list::iterator itr = tmpUnitMap.begin(); itr != tmpUnitMap.end();) { - if (!CheckTarget (*itr, i)) + if (!CheckTarget (*itr, SpellEffectIndex(i))) { itr = tmpUnitMap.erase(itr); continue; @@ -662,7 +662,7 @@ void Spell::FillTargetMap() } for(std::list::const_iterator iunit = tmpUnitMap.begin(); iunit != tmpUnitMap.end(); ++iunit) - AddUnitTarget((*iunit), i); + AddUnitTarget((*iunit), SpellEffectIndex(i)); } } @@ -782,7 +782,7 @@ void Spell::CleanupTargetList() m_delayMoment = 0; } -void Spell::AddUnitTarget(Unit* pVictim, uint32 effIndex) +void Spell::AddUnitTarget(Unit* pVictim, SpellEffectIndex effIndex) { if( m_spellInfo->Effect[effIndex] == 0 ) return; @@ -848,14 +848,14 @@ void Spell::AddUnitTarget(Unit* pVictim, uint32 effIndex) m_UniqueTargetInfo.push_back(target); } -void Spell::AddUnitTarget(uint64 unitGUID, uint32 effIndex) +void Spell::AddUnitTarget(uint64 unitGUID, SpellEffectIndex effIndex) { Unit* unit = m_caster->GetGUID() == unitGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, unitGUID); if (unit) AddUnitTarget(unit, effIndex); } -void Spell::AddGOTarget(GameObject* pVictim, uint32 effIndex) +void Spell::AddGOTarget(GameObject* pVictim, SpellEffectIndex effIndex) { if( m_spellInfo->Effect[effIndex] == 0 ) return; @@ -897,14 +897,14 @@ void Spell::AddGOTarget(GameObject* pVictim, uint32 effIndex) m_UniqueGOTargetInfo.push_back(target); } -void Spell::AddGOTarget(uint64 goGUID, uint32 effIndex) +void Spell::AddGOTarget(uint64 goGUID, SpellEffectIndex effIndex) { GameObject* go = m_caster->GetMap()->GetGameObject(goGUID); if (go) AddGOTarget(go, effIndex); } -void Spell::AddItemTarget(Item* pitem, uint32 effIndex) +void Spell::AddItemTarget(Item* pitem, SpellEffectIndex effIndex) { if( m_spellInfo->Effect[effIndex] == 0 ) return; @@ -1295,7 +1295,7 @@ struct TargetDistanceOrder : public std::binary_functionEffectRadiusIndex[effIndex]) @@ -2818,7 +2818,7 @@ void Spell::_handle_immediate_phase() continue; // apply Send Event effect to ground in case empty target lists - if( m_spellInfo->Effect[j] == SPELL_EFFECT_SEND_EVENT && !HaveTargetsForEffect(j) ) + if( m_spellInfo->Effect[j] == SPELL_EFFECT_SEND_EVENT && !HaveTargetsForEffect(SpellEffectIndex(j)) ) { HandleEffects(NULL, NULL, NULL, SpellEffectIndex(j)); continue; @@ -3036,7 +3036,7 @@ void Spell::finish(bool ok) if (unit && unit->isAlive()) { SpellEntry const *auraSpellInfo = (*i)->GetSpellProto(); - uint32 auraSpellIdx = (*i)->GetEffIndex(); + SpellEffectIndex auraSpellIdx = (*i)->GetEffIndex(); // Calculate chance at that moment (can be depend for example from combo points) int32 chance = m_caster->CalculateSpellDamage(auraSpellInfo, auraSpellIdx, (*i)->GetBasePoints(),unit); if(roll_chance_i(chance)) @@ -3903,7 +3903,7 @@ void Spell::HandleEffects(Unit *pUnitTarget,Item *pItemTarget,GameObject *pGOTar uint8 eff = m_spellInfo->Effect[i]; - damage = int32(CalculateDamage((uint8)i, unitTarget) * DamageMultiplier); + damage = int32(CalculateDamage(i, unitTarget) * DamageMultiplier); sLog.outDebug( "Spell %u Effect%d : %u", m_spellInfo->Id, i, eff); @@ -4093,7 +4093,8 @@ SpellCastResult Spell::CheckCast(bool strict) for(int i = 0; i < MAX_EFFECT_INDEX; ++i) { // check only spell that apply positive auras - if (IsPositiveEffect(m_spellInfo->Id, i) && m_spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA && + if (m_spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA && + IsPositiveEffect(m_spellInfo->Id, SpellEffectIndex(i)) && // at not self target !IsCasterSourceTarget(m_spellInfo->EffectImplicitTargetA[i]) && // and target low level @@ -4387,14 +4388,14 @@ SpellCastResult Spell::CheckCast(bool strict) m_targets.setDestination(creatureScriptTarget->GetPositionX(),creatureScriptTarget->GetPositionY(),creatureScriptTarget->GetPositionZ()); if (m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT_COORDINATES && m_spellInfo->Effect[j] != SPELL_EFFECT_PERSISTENT_AREA_AURA) - AddUnitTarget(creatureScriptTarget, j); + AddUnitTarget(creatureScriptTarget, SpellEffectIndex(j)); } // store explicit target for TARGET_SCRIPT else { if (m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT || m_spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT) - AddUnitTarget(creatureScriptTarget, j); + AddUnitTarget(creatureScriptTarget, SpellEffectIndex(j)); } } else if (goScriptTarget) @@ -4406,14 +4407,14 @@ SpellCastResult Spell::CheckCast(bool strict) m_targets.setDestination(goScriptTarget->GetPositionX(),goScriptTarget->GetPositionY(),goScriptTarget->GetPositionZ()); if (m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT_COORDINATES && m_spellInfo->Effect[j] != SPELL_EFFECT_PERSISTENT_AREA_AURA) - AddGOTarget(goScriptTarget, j); + AddGOTarget(goScriptTarget, SpellEffectIndex(j)); } // store explicit target for TARGET_FOCUS_OR_SCRIPTED_GAMEOBJECT else { if (m_spellInfo->EffectImplicitTargetA[j] == TARGET_FOCUS_OR_SCRIPTED_GAMEOBJECT || m_spellInfo->EffectImplicitTargetB[j] == TARGET_FOCUS_OR_SCRIPTED_GAMEOBJECT) - AddGOTarget(goScriptTarget, j); + AddGOTarget(goScriptTarget, SpellEffectIndex(j)); } } //Missing DB Entry or targets for this spellEffect. @@ -4732,7 +4733,7 @@ SpellCastResult Spell::CheckCast(bool strict) int32 skillValue = 0; // check lock compatibility - SpellCastResult res = CanOpenLock(i, lockId, skillId, reqSkillValue, skillValue); + SpellCastResult res = CanOpenLock(SpellEffectIndex(i), lockId, skillId, reqSkillValue, skillValue); if(res != SPELL_CAST_OK) return res; @@ -4906,7 +4907,7 @@ SpellCastResult Spell::CheckCast(bool strict) if(m_targets.getUnitTarget()->GetCharmerGUID()) return SPELL_FAILED_CHARMED; - if(int32(m_targets.getUnitTarget()->getLevel()) > CalculateDamage(i,m_targets.getUnitTarget())) + if(int32(m_targets.getUnitTarget()->getLevel()) > CalculateDamage(SpellEffectIndex(i),m_targets.getUnitTarget())) return SPELL_FAILED_HIGHLEVEL; break; @@ -4931,7 +4932,7 @@ SpellCastResult Spell::CheckCast(bool strict) if(m_targets.getUnitTarget()->GetCharmerGUID()) return SPELL_FAILED_CHARMED; - if(int32(m_targets.getUnitTarget()->getLevel()) > CalculateDamage(i,m_targets.getUnitTarget())) + if(int32(m_targets.getUnitTarget()->getLevel()) > CalculateDamage(SpellEffectIndex(i),m_targets.getUnitTarget())) return SPELL_FAILED_HIGHLEVEL; break; @@ -5217,19 +5218,19 @@ bool Spell::CanAutoCast(Unit* target) { if( m_spellInfo->StackAmount <= 1) { - if( target->HasAura(m_spellInfo->Id, j) ) + if( target->HasAura(m_spellInfo->Id, SpellEffectIndex(j)) ) return false; } else { - if(Aura* aura = target->GetAura(m_spellInfo->Id, j)) + if(Aura* aura = target->GetAura(m_spellInfo->Id, SpellEffectIndex(j))) if(aura->GetStackAmount() >= m_spellInfo->StackAmount) return false; } } else if ( IsAreaAuraEffect( m_spellInfo->Effect[j] )) { - if( target->HasAura(m_spellInfo->Id, j) ) + if( target->HasAura(m_spellInfo->Id, SpellEffectIndex(j)) ) return false; } } @@ -5889,13 +5890,10 @@ void Spell::DelayedChannel() { if ((*ihit).missCondition == SPELL_MISS_NONE) { - Unit* unit = m_caster->GetGUID() == ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID); - if (unit) - { + if (Unit* unit = m_caster->GetGUID() == ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID)) for (int j = 0; j < MAX_EFFECT_INDEX; ++j) - if( ihit->effectMask & (1 << j) ) - unit->DelayAura(m_spellInfo->Id, j, delaytime); - } + if (ihit->effectMask & (1 << j)) + unit->DelayAura(m_spellInfo->Id, SpellEffectIndex(j), delaytime); } } @@ -5903,8 +5901,7 @@ void Spell::DelayedChannel() for(int j = 0; j < MAX_EFFECT_INDEX; ++j) { // partially interrupt persistent area auras - DynamicObject* dynObj = m_caster->GetDynObject(m_spellInfo->Id, j); - if(dynObj) + if (DynamicObject* dynObj = m_caster->GetDynObject(m_spellInfo->Id, SpellEffectIndex(j))) dynObj->Delay(delaytime); } @@ -5981,7 +5978,7 @@ CurrentSpellTypes Spell::GetCurrentContainer() return(CURRENT_GENERIC_SPELL); } -bool Spell::CheckTarget( Unit* target, uint32 eff ) +bool Spell::CheckTarget( Unit* target, SpellEffectIndex eff ) { // Check targets for creature type mask and remove not appropriate (skip explicit self target case, maybe need other explicit targets) if(m_spellInfo->EffectImplicitTargetA[eff] != TARGET_SELF ) @@ -6075,7 +6072,7 @@ bool Spell::IsTriggeredSpellWithRedundentData() const return m_IsTriggeredSpell && (m_spellInfo->manaCost || m_spellInfo->ManaCostPercentage); } -bool Spell::HaveTargetsForEffect( uint8 effect ) const +bool Spell::HaveTargetsForEffect(SpellEffectIndex effect) const { for(std::list::const_iterator itr = m_UniqueTargetInfo.begin(); itr != m_UniqueTargetInfo.end(); ++itr) if(itr->effectMask & (1 << effect)) @@ -6211,7 +6208,7 @@ bool SpellEvent::IsDeletable() const return m_Spell->IsDeletable(); } -SpellCastResult Spell::CanOpenLock(uint32 effIndex, uint32 lockId, SkillType& skillId, int32& reqSkillValue, int32& skillValue) +SpellCastResult Spell::CanOpenLock(SpellEffectIndex effIndex, uint32 lockId, SkillType& skillId, int32& reqSkillValue, int32& skillValue) { if(!lockId) // possible case for GO and maybe for items. return SPELL_CAST_OK; diff --git a/src/game/Spell.h b/src/game/Spell.h index eabb581c3b3..594f732d38a 100644 --- a/src/game/Spell.h +++ b/src/game/Spell.h @@ -354,10 +354,10 @@ class Spell SpellCastResult CheckOrTakeRunePower(bool take); SpellCastResult CheckCasterAuras() const; - int32 CalculateDamage(uint8 i, Unit* target) { return m_caster->CalculateSpellDamage(m_spellInfo,i,m_currentBasePoints[i],target); } + int32 CalculateDamage(SpellEffectIndex i, Unit* target) { return m_caster->CalculateSpellDamage(m_spellInfo,i,m_currentBasePoints[i],target); } int32 CalculatePowerCost(); - bool HaveTargetsForEffect(uint8 effect) const; + bool HaveTargetsForEffect(SpellEffectIndex effect) const; void Delayed(); void DelayedChannel(); uint32 getState() const { return m_spellState; } @@ -375,7 +375,7 @@ class Spell typedef std::list UnitList; void FillTargetMap(); - void SetTargetMap(uint32 effIndex, uint32 targetMode, UnitList &targetUnitMap); + void SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList &targetUnitMap); void FillAreaTargets(UnitList &targetUnitMap, float x, float y, float radius, SpellNotifyPushType pushType, SpellTargets spellTargets); void FillRaidOrPartyTargets(UnitList &targetUnitMap, Unit* member, Unit* center, float radius, bool raid, bool withPets, bool withcaster); @@ -384,7 +384,7 @@ class Spell template WorldObject* FindCorpseUsing(); - bool CheckTarget( Unit* target, uint32 eff ); + bool CheckTarget( Unit* target, SpellEffectIndex eff ); bool CanAutoCast(Unit* target); static void MANGOS_DLL_SPEC SendCastResult(Player* caster, SpellEntry const* spellInfo, uint8 cast_count, SpellCastResult result); @@ -567,17 +567,17 @@ class Spell }; std::list m_UniqueItemInfo; - void AddUnitTarget(Unit* target, uint32 effIndex); - void AddUnitTarget(uint64 unitGUID, uint32 effIndex); - void AddGOTarget(GameObject* target, uint32 effIndex); - void AddGOTarget(uint64 goGUID, uint32 effIndex); - void AddItemTarget(Item* target, uint32 effIndex); + void AddUnitTarget(Unit* target, SpellEffectIndex effIndex); + void AddUnitTarget(uint64 unitGUID, SpellEffectIndex effIndex); + void AddGOTarget(GameObject* target, SpellEffectIndex effIndex); + void AddGOTarget(uint64 goGUID, SpellEffectIndex effIndex); + void AddItemTarget(Item* target, SpellEffectIndex effIndex); void DoAllEffectOnTarget(TargetInfo *target); void DoSpellHitOnUnit(Unit *unit, uint32 effectMask); void DoAllEffectOnTarget(GOTargetInfo *target); void DoAllEffectOnTarget(ItemTargetInfo *target); bool IsAliveUnitPresentInTargetList(); - SpellCastResult CanOpenLock(uint32 effIndex, uint32 lockid, SkillType& skillid, int32& reqSkillValue, int32& skillValue); + SpellCastResult CanOpenLock(SpellEffectIndex effIndex, uint32 lockid, SkillType& skillid, int32& reqSkillValue, int32& skillValue); // ------------------------------------------- //List For Triggered Spells diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 6facdb7310c..c6b07e472aa 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -371,7 +371,7 @@ pAuraHandler AuraHandler[TOTAL_AURAS]= static AuraType const frozenAuraTypes[] = { SPELL_AURA_MOD_ROOT, SPELL_AURA_MOD_STUN, SPELL_AURA_NONE }; -Aura::Aura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem) : +Aura::Aura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem) : m_spellmod(NULL), m_caster_guid(0), m_target(target), m_castItemGuid(castItem?castItem->GetGUID():0), m_timeCla(1000), m_periodicTimer(0), m_periodicTick(0), m_removeMode(AURA_REMOVE_BY_DEFAULT), m_AuraDRGroup(DIMINISHING_NONE), m_effIndex(eff), m_auraSlot(MAX_AURAS), m_auraFlags(AFLAG_NONE), m_auraLevel(1), m_procCharges(0), m_stackAmount(1), @@ -449,7 +449,6 @@ m_isRemovedOnShapeLost(true), m_in_use(0), m_deleted(false) sLog.outDebug("Aura: construct Spellid : %u, Aura : %u Duration : %d Target : %d Damage : %d", m_spellProto->Id, m_spellProto->EffectApplyAuraName[eff], m_maxduration, m_spellProto->EffectImplicitTargetA[eff],damage); - m_effIndex = eff; SetModifier(AuraType(m_spellProto->EffectApplyAuraName[eff]), damage, m_spellProto->EffectAmplitude[eff], m_spellProto->EffectMiscValue[eff]); // Apply periodic time mod @@ -483,7 +482,7 @@ Aura::~Aura() { } -AreaAura::AreaAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, +AreaAura::AreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, target, caster, castItem) { m_isAreaAura = true; @@ -537,7 +536,7 @@ AreaAura::~AreaAura() { } -PersistentAreaAura::PersistentAreaAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, +PersistentAreaAura::PersistentAreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, target, caster, castItem) { m_isPersistent = true; @@ -547,7 +546,7 @@ PersistentAreaAura::~PersistentAreaAura() { } -SingleEnemyTargetAura::SingleEnemyTargetAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, +SingleEnemyTargetAura::SingleEnemyTargetAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, target, caster, castItem) { if (caster) @@ -565,7 +564,7 @@ Unit* SingleEnemyTargetAura::GetTriggerTarget() const return ObjectAccessor::GetUnit(*m_target, m_casters_target_guid); } -Aura* CreateAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem) +Aura* CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem) { if (IsAreaAuraEffect(spellproto->Effect[eff])) return new AreaAura(spellproto, eff, currentBasePoints, target, caster, castItem); @@ -982,7 +981,7 @@ void Aura::_AddAura() // Lookup for some spell auras (and get slot from it) for(uint8 i = 0; i < m_effIndex; ++i) { - Unit::spellEffectPair spair = Unit::spellEffectPair(GetId(), i); + Unit::spellEffectPair spair = Unit::spellEffectPair(GetId(), SpellEffectIndex(i)); for(Unit::AuraMap::const_iterator itr = m_target->GetAuras().lower_bound(spair); itr != m_target->GetAuras().upper_bound(spair); ++itr) { // allow use single slot only by auras from same caster @@ -1119,7 +1118,7 @@ bool Aura::_RemoveAura() // find other aura in same slot (current already removed from list) for(int i = 0; i < MAX_EFFECT_INDEX; ++i) { - Unit::spellEffectPair spair = Unit::spellEffectPair(GetId(), i); + Unit::spellEffectPair spair = Unit::spellEffectPair(GetId(), SpellEffectIndex(i)); for(Unit::AuraMap::const_iterator itr = m_target->GetAuras().lower_bound(spair); itr != m_target->GetAuras().upper_bound(spair); ++itr) { if(itr->second->GetAuraSlot() == slot) @@ -4563,8 +4562,8 @@ void Aura::HandlePeriodicTriggerSpell(bool apply, bool /*Real*/) return; case 42783: //Wrath of the Astrom... - if (m_removeMode == AURA_REMOVE_BY_DEFAULT && GetEffIndex() + 1 < 3) - m_target->CastSpell(m_target, m_spellProto->CalculateSimpleValue(GetEffIndex()+1), true); + if (m_removeMode == AURA_REMOVE_BY_DEFAULT && GetEffIndex() + 1 < MAX_EFFECT_INDEX) + m_target->CastSpell(m_target, m_spellProto->CalculateSimpleValue(SpellEffectIndex(GetEffIndex()+1)), true); return; default: break; @@ -6675,7 +6674,7 @@ void Aura::PeriodicTick() { uint32 percent = GetEffIndex() < EFFECT_INDEX_2 && GetSpellProto()->Effect[GetEffIndex()] == SPELL_EFFECT_DUMMY ? - pCaster->CalculateSpellDamage(GetSpellProto(), GetEffIndex() + 1, GetSpellProto()->EffectBasePoints[GetEffIndex() + 1], m_target) : + pCaster->CalculateSpellDamage(GetSpellProto(), SpellEffectIndex(GetEffIndex() + 1), GetSpellProto()->EffectBasePoints[GetEffIndex() + 1], m_target) : 100; if(m_target->GetHealth() * 100 >= m_target->GetMaxHealth() * percent ) { diff --git a/src/game/SpellAuras.h b/src/game/SpellAuras.h index a09b1f41df0..16296893ea6 100644 --- a/src/game/SpellAuras.h +++ b/src/game/SpellAuras.h @@ -56,7 +56,7 @@ typedef void(Aura::*pAuraHandler)(bool Apply, bool Real); class MANGOS_DLL_SPEC Aura { friend struct ReapplyAffectedPassiveAurasHelper; - friend Aura* CreateAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem); + friend Aura* CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem); public: //aura handlers @@ -232,7 +232,7 @@ class MANGOS_DLL_SPEC Aura SpellEntry const* GetSpellProto() const { return m_spellProto; } uint32 GetId() const{ return m_spellProto->Id; } uint64 GetCastItemGUID() const { return m_castItemGuid; } - uint32 GetEffIndex() const{ return m_effIndex; } + SpellEffectIndex GetEffIndex() const{ return m_effIndex; } int32 GetBasePoints() const { return m_currentBasePoints; } int32 GetAuraMaxDuration() const { return m_maxduration; } @@ -352,7 +352,7 @@ class MANGOS_DLL_SPEC Aura uint32 const *getAuraSpellClassMask() const { return m_spellProto->GetEffectSpellClassMask(m_effIndex); } bool isAffectedOnSpell(SpellEntry const *spell) const; protected: - Aura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster = NULL, Item* castItem = NULL); + Aura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, Unit *target, Unit *caster = NULL, Item* castItem = NULL); // must be called only from Aura::UpdateAura virtual void Update(uint32 diff); @@ -383,7 +383,7 @@ class MANGOS_DLL_SPEC Aura AuraRemoveMode m_removeMode:8; // Store info for know remove aura reason DiminishingGroup m_AuraDRGroup:8; // Diminishing - uint8 m_effIndex; // Aura effect index in spell + SpellEffectIndex m_effIndex :8; // Aura effect index in spell uint8 m_auraSlot; // Aura slot on unit (for show in client) uint8 m_auraFlags; // Aura info flag (for send data to client) uint8 m_auraLevel; // Aura level (store caster level for correct show level dep amount) @@ -411,7 +411,7 @@ class MANGOS_DLL_SPEC Aura class MANGOS_DLL_SPEC AreaAura : public Aura { public: - AreaAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster = NULL, Item* castItem = NULL); + AreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, Unit *target, Unit *caster = NULL, Item* castItem = NULL); ~AreaAura(); protected: void Update(uint32 diff); @@ -423,7 +423,7 @@ class MANGOS_DLL_SPEC AreaAura : public Aura class MANGOS_DLL_SPEC PersistentAreaAura : public Aura { public: - PersistentAreaAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster = NULL, Item* castItem = NULL); + PersistentAreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, Unit *target, Unit *caster = NULL, Item* castItem = NULL); ~PersistentAreaAura(); protected: void Update(uint32 diff); @@ -431,16 +431,16 @@ class MANGOS_DLL_SPEC PersistentAreaAura : public Aura class MANGOS_DLL_SPEC SingleEnemyTargetAura : public Aura { - friend Aura* CreateAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem); + friend Aura* CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem); public: ~SingleEnemyTargetAura(); Unit* GetTriggerTarget() const; protected: - SingleEnemyTargetAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster = NULL, Item* castItem = NULL); + SingleEnemyTargetAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, Unit *target, Unit *caster = NULL, Item* castItem = NULL); uint64 m_casters_target_guid; }; -Aura* CreateAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster = NULL, Item* castItem = NULL); +Aura* CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, Unit *target, Unit *caster = NULL, Item* castItem = NULL); #endif diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 9e2192b9456..9a88a6be391 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -1899,7 +1899,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) { Unit::AttackerSet::iterator aItr = attackers.begin(); std::advance(aItr, rand() % attackers.size()); - AddUnitTarget((*aItr), 1); + AddUnitTarget((*aItr), EFFECT_INDEX_1); attackers.erase(aItr); } @@ -4792,14 +4792,14 @@ void Spell::EffectWeaponDmg(SpellEffectIndex eff_idx) { case SPELL_EFFECT_WEAPON_DAMAGE: case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: - fixed_bonus += CalculateDamage(j, unitTarget); + fixed_bonus += CalculateDamage(SpellEffectIndex(j), unitTarget); break; case SPELL_EFFECT_NORMALIZED_WEAPON_DMG: - fixed_bonus += CalculateDamage(j, unitTarget); + fixed_bonus += CalculateDamage(SpellEffectIndex(j), unitTarget); normalized = true; break; case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE: - weaponDamagePercentMod *= float(CalculateDamage(j, unitTarget)) / 100.0f; + weaponDamagePercentMod *= float(CalculateDamage(SpellEffectIndex(j), unitTarget)) / 100.0f; // applied only to prev.effects fixed damage fixed_bonus = int32(fixed_bonus*weaponDamagePercentMod); diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index ebf7de3d86a..3057981b804 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -154,7 +154,7 @@ bool IsPassiveSpell(uint32 spellId) return (spellInfo->Attributes & SPELL_ATTR_PASSIVE) != 0; } -bool IsNoStackAuraDueToAura(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2) +bool IsNoStackAuraDueToAura(uint32 spellId_1, SpellEffectIndex effIndex_1, uint32 spellId_2, SpellEffectIndex effIndex_2) { SpellEntry const *spellInfo_1 = sSpellStore.LookupEntry(spellId_1); SpellEntry const *spellInfo_2 = sSpellStore.LookupEntry(spellId_2); @@ -170,7 +170,7 @@ bool IsNoStackAuraDueToAura(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_ return true; } -int32 CompareAuraRanks(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2) +int32 CompareAuraRanks(uint32 spellId_1, SpellEffectIndex effIndex_1, uint32 spellId_2, SpellEffectIndex effIndex_2) { SpellEntry const*spellInfo_1 = sSpellStore.LookupEntry(spellId_1); SpellEntry const*spellInfo_2 = sSpellStore.LookupEntry(spellId_2); @@ -464,7 +464,7 @@ bool IsExplicitNegativeTarget(uint32 targetA) return false; } -bool IsPositiveEffect(uint32 spellId, uint32 effIndex) +bool IsPositiveEffect(uint32 spellId, SpellEffectIndex effIndex) { SpellEntry const *spellproto = sSpellStore.LookupEntry(spellId); if (!spellproto) return false; @@ -542,19 +542,20 @@ bool IsPositiveEffect(uint32 spellId, uint32 effIndex) case SPELL_AURA_ADD_TARGET_TRIGGER: return true; case SPELL_AURA_PERIODIC_TRIGGER_SPELL: - if(spellId != spellproto->EffectTriggerSpell[effIndex]) + if (spellId != spellproto->EffectTriggerSpell[effIndex]) { uint32 spellTriggeredId = spellproto->EffectTriggerSpell[effIndex]; SpellEntry const *spellTriggeredProto = sSpellStore.LookupEntry(spellTriggeredId); - if(spellTriggeredProto) + if (spellTriggeredProto) { // non-positive targets of main spell return early for(int i = 0; i < MAX_EFFECT_INDEX; ++i) { // if non-positive trigger cast targeted to positive target this main cast is non-positive // this will place this spell auras as debuffs - if(IsPositiveTarget(spellTriggeredProto->EffectImplicitTargetA[effIndex],spellTriggeredProto->EffectImplicitTargetB[effIndex]) && !IsPositiveEffect(spellTriggeredId,i)) + if (IsPositiveTarget(spellTriggeredProto->EffectImplicitTargetA[effIndex],spellTriggeredProto->EffectImplicitTargetB[effIndex]) && + !IsPositiveEffect(spellTriggeredId,SpellEffectIndex(i))) return false; } } @@ -681,12 +682,13 @@ bool IsPositiveEffect(uint32 spellId, uint32 effIndex) bool IsPositiveSpell(uint32 spellId) { SpellEntry const *spellproto = sSpellStore.LookupEntry(spellId); - if (!spellproto) return false; + if (!spellproto) + return false; // spells with atleast one negative effect are considered negative // some self-applied spells have negative effects but in self casting case negative check ignored. for (int i = 0; i < MAX_EFFECT_INDEX; ++i) - if (!IsPositiveEffect(spellId, i)) + if (!IsPositiveEffect(spellId, SpellEffectIndex(i))) return false; return true; } @@ -1872,11 +1874,10 @@ SpellEntry const* SpellMgr::SelectAuraRankForPlayerLevel(SpellEntry const* spell bool needRankSelection = false; for(int i=0;i<3;++i) { - if( IsPositiveEffect(spellInfo->Id, i) && ( + if (IsPositiveEffect(spellInfo->Id, SpellEffectIndex(i)) && ( spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA || spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_PARTY || - spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_RAID - ) ) + spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_RAID)) { needRankSelection = true; break; @@ -2098,8 +2099,8 @@ void SpellMgr::LoadSpellLearnSkills() if ( dbc_node.skill != SKILL_RIDING ) dbc_node.value = 1; else - dbc_node.value = entry->CalculateSimpleValue(i)*75; - dbc_node.maxvalue = entry->CalculateSimpleValue(i)*75; + dbc_node.value = entry->CalculateSimpleValue(SpellEffectIndex(i))*75; + dbc_node.maxvalue = entry->CalculateSimpleValue(SpellEffectIndex(i))*75; mSpellLearnSkills[spell] = dbc_node; ++dbc_count; @@ -2388,10 +2389,16 @@ void SpellMgr::LoadSpellPetAuras() bar.step(); uint32 spell = fields[0].GetUInt32(); - uint8 eff = fields[1].GetUInt8(); + SpellEffectIndex eff = SpellEffectIndex(fields[1].GetUInt32()); uint32 pet = fields[2].GetUInt32(); uint32 aura = fields[3].GetUInt32(); + if (eff >= MAX_EFFECT_INDEX) + { + sLog.outErrorDb("Spell %u listed in `spell_pet_auras` with wrong spell effect index (%u)", spell, eff); + continue; + } + SpellPetAuraMap::iterator itr = mSpellPetAuraMap.find((spell<<8) + eff); if(itr != mSpellPetAuraMap.end()) { diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h index e85c13a1334..c50a35cf8af 100644 --- a/src/game/SpellMgr.h +++ b/src/game/SpellMgr.h @@ -144,7 +144,7 @@ inline bool IsSpellHaveAura(SpellEntry const *spellInfo, AuraType aura) return false; } -inline bool IsSpellLastAuraEffect(SpellEntry const *spellInfo, int effecIdx) +inline bool IsSpellLastAuraEffect(SpellEntry const *spellInfo, SpellEffectIndex effecIdx) { for(int i = effecIdx+1; i < MAX_EFFECT_INDEX; ++i) if(spellInfo->EffectApplyAuraName[i]) @@ -152,7 +152,7 @@ inline bool IsSpellLastAuraEffect(SpellEntry const *spellInfo, int effecIdx) return true; } -bool IsNoStackAuraDueToAura(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2); +bool IsNoStackAuraDueToAura(uint32 spellId_1, SpellEffectIndex effIndex_1, uint32 spellId_2, SpellEffectIndex effIndex_2); inline bool IsSealSpell(SpellEntry const *spellInfo) { @@ -184,7 +184,7 @@ inline bool IsLootCraftingSpell(SpellEntry const *spellInfo) (spellInfo->Effect[EFFECT_INDEX_0] == SPELL_EFFECT_CREATE_ITEM_2 && spellInfo->TotemCategory[0] != 0)); } -int32 CompareAuraRanks(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2); +int32 CompareAuraRanks(uint32 spellId_1, SpellEffectIndex effIndex_1, uint32 spellId_2, SpellEffectIndex effIndex_2); // order from less to more strict bool IsSingleFromSpellSpecificPerTargetPerCaster(SpellSpecific spellSpec1,SpellSpecific spellSpec2); @@ -218,7 +218,7 @@ inline bool IsNonCombatSpell(SpellEntry const *spellInfo) } bool IsPositiveSpell(uint32 spellId); -bool IsPositiveEffect(uint32 spellId, uint32 effIndex); +bool IsPositiveEffect(uint32 spellId, SpellEffectIndex effIndex); bool IsPositiveTarget(uint32 targetA, uint32 targetB); bool IsExplicitPositiveTarget(uint32 targetA); @@ -407,7 +407,7 @@ inline uint32 GetAllSpellMechanicMask(SpellEntry const* spellInfo) return mask; } -inline Mechanics GetEffectMechanic(SpellEntry const* spellInfo, int32 effect) +inline Mechanics GetEffectMechanic(SpellEntry const* spellInfo, SpellEffectIndex effect) { if (spellInfo->EffectMechanic[effect]) return Mechanics(spellInfo->EffectMechanic[effect]); @@ -932,7 +932,7 @@ class SpellMgr return SkillLineAbilityMapBounds(mSkillLineAbilityMap.lower_bound(spell_id),mSkillLineAbilityMap.upper_bound(spell_id)); } - PetAura const* GetPetAura(uint32 spell_id, uint8 eff) + PetAura const* GetPetAura(uint32 spell_id, SpellEffectIndex eff) { SpellPetAuraMap::const_iterator itr = mSpellPetAuraMap.find((spell_id<<8) + eff); if(itr != mSpellPetAuraMap.end()) diff --git a/src/game/StatSystem.cpp b/src/game/StatSystem.cpp index 16cfc198d1f..aee8afdb97e 100644 --- a/src/game/StatSystem.cpp +++ b/src/game/StatSystem.cpp @@ -305,7 +305,7 @@ void Player::UpdateAttackPowerAndDamage(bool ranged ) for(Unit::AuraList::const_iterator itr = mDummy.begin(); itr != mDummy.end(); ++itr) { // Predatory Strikes (effect 0) - if ((*itr)->GetEffIndex()==0 && (*itr)->GetSpellProto()->SpellIconID == 1563) + if ((*itr)->GetEffIndex() == EFFECT_INDEX_0 && (*itr)->GetSpellProto()->SpellIconID == 1563) { mLevelMult = (*itr)->GetModifier()->m_amount / 100.0f; break; diff --git a/src/game/Totem.cpp b/src/game/Totem.cpp index 6c07ea32c9e..81e8ae49072 100644 --- a/src/game/Totem.cpp +++ b/src/game/Totem.cpp @@ -156,7 +156,7 @@ void Totem::SetTypeBySummonSpell(SpellEntry const * spellProto) m_type = TOTEM_STATUE; //Jewelery statue } -bool Totem::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const +bool Totem::IsImmunedToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex index) const { // TODO: possibly all negative auras immune? switch(spellInfo->Effect[index]) diff --git a/src/game/Totem.h b/src/game/Totem.h index de0f8361992..b88b13b6bed 100644 --- a/src/game/Totem.h +++ b/src/game/Totem.h @@ -53,7 +53,7 @@ class Totem : public Creature void UpdateAttackPowerAndDamage(bool /*ranged*/ ) {} void UpdateDamagePhysical(WeaponAttackType /*attType*/) {} - bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const; + bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex index) const; protected: TotemType m_type; diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 1b8207f8ddc..ad758c8f738 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -2746,7 +2746,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell) // Get effects mechanic and chance for(int eff = 0; eff < MAX_EFFECT_INDEX; ++eff) { - int32 effect_mech = GetEffectMechanic(spell, eff); + int32 effect_mech = GetEffectMechanic(spell, SpellEffectIndex(eff)); if (effect_mech) { int32 temp = pVictim->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_MECHANIC_RESISTANCE, effect_mech); @@ -2889,7 +2889,7 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell) // Get effects mechanic and chance for(int eff = 0; eff < MAX_EFFECT_INDEX; ++eff) { - int32 effect_mech = GetEffectMechanic(spell, eff); + int32 effect_mech = GetEffectMechanic(spell, SpellEffectIndex(eff)); if (effect_mech) { int32 temp = pVictim->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_MECHANIC_RESISTANCE, effect_mech); @@ -3919,7 +3919,7 @@ bool Unit::RemoveNoStackAurasDueToAura(Aura *Aur) return false; uint32 spellId = Aur->GetId(); - uint32 effIndex = Aur->GetEffIndex(); + SpellEffectIndex effIndex = Aur->GetEffIndex(); // passive spell special case (only non stackable with ranks) if(IsPassiveSpell(spellId)) @@ -3956,7 +3956,7 @@ bool Unit::RemoveNoStackAurasDueToAura(Aura *Aur) continue; } - uint32 i_effIndex = (*i).second->GetEffIndex(); + SpellEffectIndex i_effIndex = (*i).second->GetEffIndex(); if(i_spellId == spellId) continue; @@ -4068,7 +4068,7 @@ bool Unit::RemoveNoStackAurasDueToAura(Aura *Aur) return true; } -void Unit::RemoveAura(uint32 spellId, uint32 effindex, Aura* except) +void Unit::RemoveAura(uint32 spellId, SpellEffectIndex effindex, Aura* except) { spellEffectPair spair = spellEffectPair(spellId, effindex); for(AuraMap::iterator iter = m_Auras.lower_bound(spair); iter != m_Auras.upper_bound(spair);) @@ -4095,7 +4095,7 @@ void Unit::RemoveAurasByCasterSpell(uint32 spellId, uint64 casterGUID) } } -void Unit::RemoveAurasByCasterSpell(uint32 spellId, uint32 effindex, uint64 casterGUID) +void Unit::RemoveAurasByCasterSpell(uint32 spellId, SpellEffectIndex effindex, uint64 casterGUID) { spellEffectPair spair = spellEffectPair(spellId, effindex); for(AuraMap::iterator iter = m_Auras.lower_bound(spair); iter != m_Auras.upper_bound(spair);) @@ -4265,7 +4265,7 @@ void Unit::RemoveSingleAuraFromStack(AuraMap::iterator &i, AuraRemoveMode mode) } -void Unit::RemoveSingleAuraFromStack(uint32 spellId, uint32 effindex, AuraRemoveMode mode) +void Unit::RemoveSingleAuraFromStack(uint32 spellId, SpellEffectIndex effindex, AuraRemoveMode mode) { AuraMap::iterator iter = m_Auras.find(spellEffectPair(spellId, effindex)); if(iter != m_Auras.end()) @@ -4274,17 +4274,17 @@ void Unit::RemoveSingleAuraFromStack(uint32 spellId, uint32 effindex, AuraRemove void Unit::RemoveSingleSpellAurasFromStack(uint32 spellId, AuraRemoveMode mode) { - for (int i=0; i<3; ++i) - RemoveSingleAuraFromStack(spellId, i, mode); + for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + RemoveSingleAuraFromStack(spellId, SpellEffectIndex(i), mode); } void Unit::RemoveSingleSpellAurasByCasterSpell(uint32 spellId, uint64 casterGUID, AuraRemoveMode mode) { - for (int i=0; i<3; ++i) - RemoveSingleAuraByCasterSpell(spellId, i, casterGUID, mode); + for (int i = 0; i < MAX_EFFECT_INDEX; ++i) + RemoveSingleAuraByCasterSpell(spellId, SpellEffectIndex(i), casterGUID, mode); } -void Unit::RemoveSingleAuraByCasterSpell(uint32 spellId, uint32 effindex, uint64 casterGUID, AuraRemoveMode mode) +void Unit::RemoveSingleAuraByCasterSpell(uint32 spellId, SpellEffectIndex effindex, uint64 casterGUID, AuraRemoveMode mode) { spellEffectPair spair = spellEffectPair(spellId, effindex); for(AuraMap::iterator iter = m_Auras.lower_bound(spair); iter != m_Auras.upper_bound(spair); ++iter) @@ -4302,14 +4302,14 @@ void Unit::RemoveSingleAuraByCasterSpell(uint32 spellId, uint32 effindex, uint64 void Unit::RemoveAurasDueToSpell(uint32 spellId, Aura* except) { for (int i = 0; i < MAX_EFFECT_INDEX; ++i) - RemoveAura(spellId,i,except); + RemoveAura(spellId,SpellEffectIndex(i),except); } void Unit::RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId) { for (int k=0; k < MAX_EFFECT_INDEX; ++k) { - spellEffectPair spair = spellEffectPair(spellId, k); + spellEffectPair spair = spellEffectPair(spellId, SpellEffectIndex(k)); for (AuraMap::iterator iter = m_Auras.lower_bound(spair); iter != m_Auras.upper_bound(spair);) { if (iter->second->GetCastItemGUID() == castItem->GetGUID()) @@ -4491,7 +4491,7 @@ void Unit::RemoveAllAurasOnDeath() } } -void Unit::DelayAura(uint32 spellId, uint32 effindex, int32 delaytime) +void Unit::DelayAura(uint32 spellId, SpellEffectIndex effindex, int32 delaytime) { AuraMap::const_iterator iter = m_Auras.find(spellEffectPair(spellId, effindex)); if (iter != m_Auras.end()) @@ -4521,7 +4521,7 @@ void Unit::_ApplyAllAuraMods() } } -Aura* Unit::GetAura(uint32 spellId, uint32 effindex) +Aura* Unit::GetAura(uint32 spellId, SpellEffectIndex effindex) { AuraMap::const_iterator iter = m_Auras.find(spellEffectPair(spellId, effindex)); if (iter != m_Auras.end()) @@ -4549,7 +4549,7 @@ bool Unit::HasAura(uint32 spellId) const { for (int i = 0; i < MAX_EFFECT_INDEX ; ++i) { - AuraMap::const_iterator iter = m_Auras.find(spellEffectPair(spellId, i)); + AuraMap::const_iterator iter = m_Auras.find(spellEffectPair(spellId, SpellEffectIndex(i))); if (iter != m_Auras.end()) return true; } @@ -4593,7 +4593,7 @@ void Unit::RemoveAllDynObjects() } } -DynamicObject * Unit::GetDynObject(uint32 spellId, uint32 effIndex) +DynamicObject * Unit::GetDynObject(uint32 spellId, SpellEffectIndex effIndex) { for (DynObjectGUIDs::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end();) { @@ -5031,7 +5031,7 @@ bool Unit::HandleSpellCritChanceAuraProc(Unit *pVictim, uint32 /*damage*/, Aura* bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown) { SpellEntry const *dummySpell = triggeredByAura->GetSpellProto (); - uint32 effIndex = triggeredByAura->GetEffIndex(); + SpellEffectIndex effIndex = triggeredByAura->GetEffIndex(); int32 triggerAmount = triggeredByAura->GetModifier()->m_amount; Item* castItem = triggeredByAura->GetCastItemGUID() && GetTypeId()==TYPEID_PLAYER @@ -9695,7 +9695,7 @@ bool Unit::IsImmunedToSpell(SpellEntry const* spellInfo) return false; } -bool Unit::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const +bool Unit::IsImmunedToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex index) const { //If m_immuneToEffect type contain this effect type, IMMUNE effect. uint32 effect = spellInfo->Effect[index]; @@ -11139,7 +11139,7 @@ bool Unit::SelectHostileTarget() //====================================================================== //====================================================================== -int32 Unit::CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_index, int32 effBasePoints, Unit const* target) +int32 Unit::CalculateSpellDamage(SpellEntry const* spellProto, SpellEffectIndex effect_index, int32 effBasePoints, Unit const* target) { Player* unitPlayer = (GetTypeId() == TYPEID_PLAYER) ? (Player*)this : NULL; @@ -11194,7 +11194,7 @@ int32 Unit::CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_inde return value; } -int32 Unit::CalculateSpellDuration(SpellEntry const* spellProto, uint8 effect_index, Unit const* target) +int32 Unit::CalculateSpellDuration(SpellEntry const* spellProto, SpellEffectIndex effect_index, Unit const* target) { Player* unitPlayer = (GetTypeId() == TYPEID_PLAYER) ? (Player*)this : NULL; @@ -13158,7 +13158,7 @@ bool Unit::HandleMendingAuraProc( Aura* triggeredByAura ) { // aura can be deleted at casts SpellEntry const* spellProto = triggeredByAura->GetSpellProto(); - uint32 effIdx = triggeredByAura->GetEffIndex(); + SpellEffectIndex effIdx = triggeredByAura->GetEffIndex(); int32 heal = triggeredByAura->GetModifier()->m_amount; uint64 caster_guid = triggeredByAura->GetCasterGUID(); diff --git a/src/game/Unit.h b/src/game/Unit.h index 9ceebc0fe05..eb566ec653d 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1068,7 +1068,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject { public: typedef std::set AttackerSet; - typedef std::pair spellEffectPair; + typedef std::pair spellEffectPair; typedef std::multimap< spellEffectPair, Aura*> AuraMap; typedef std::list AuraList; typedef std::list Diminishing; @@ -1311,7 +1311,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject uint32 GetCombatTimer() const { return m_CombatTimer; } bool HasAuraType(AuraType auraType) const; - bool HasAura(uint32 spellId, uint32 effIndex) const + bool HasAura(uint32 spellId, SpellEffectIndex effIndex) const { return m_Auras.find(spellEffectPair(spellId, effIndex)) != m_Auras.end(); } @@ -1450,13 +1450,13 @@ class MANGOS_DLL_SPEC Unit : public WorldObject // removing specific aura stack void RemoveAura(Aura* aura, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); void RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); - void RemoveAura(uint32 spellId, uint32 effindex, Aura* except = NULL); + void RemoveAura(uint32 spellId, SpellEffectIndex effindex, Aura* except = NULL); // removing specific aura stacks by diff reasons and selections void RemoveAurasDueToSpell(uint32 spellId, Aura* except = NULL); void RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId); void RemoveAurasByCasterSpell(uint32 spellId, uint64 casterGUID); - void RemoveAurasByCasterSpell(uint32 spellId, uint32 effindex, uint64 casterGUID); + void RemoveAurasByCasterSpell(uint32 spellId, SpellEffectIndex effindex, uint64 casterGUID); void RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit *stealer); void RemoveAurasDueToSpellByCancel(uint32 spellId); @@ -1473,16 +1473,16 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void RemoveAllAurasOnDeath(); // removing specific aura FROM stack - void RemoveSingleAuraFromStack(uint32 spellId, uint32 effindex, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); + void RemoveSingleAuraFromStack(uint32 spellId, SpellEffectIndex effindex, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); void RemoveSingleAuraFromStack(AuraMap::iterator &i, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); // removing specific aura FROM stack by diff reasons and selections void RemoveSingleSpellAurasFromStack(uint32 spellId, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); void RemoveSingleSpellAurasByCasterSpell(uint32 spellId, uint64 casterGUID, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); - void RemoveSingleAuraByCasterSpell(uint32 spellId, uint32 effindex, uint64 casterGUID, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); + void RemoveSingleAuraByCasterSpell(uint32 spellId, SpellEffectIndex effindex, uint64 casterGUID, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); void RemoveSingleAuraDueToSpellByDispel(uint32 spellId, uint64 casterGUID, Unit *dispeler); - void DelayAura(uint32 spellId, uint32 effindex, int32 delaytime); + void DelayAura(uint32 spellId, SpellEffectIndex effindex, int32 delaytime); float GetResistanceBuffMods(SpellSchools school, bool positive) const { return GetFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school ); } void SetResistanceBuffMods(SpellSchools school, bool positive, float val) { SetFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school,val); } @@ -1627,7 +1627,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject VisibleAuraMap const *GetVisibleAuras() { return &m_visibleAuras; } uint8 GetVisibleAurasCount() { return m_visibleAuras.size(); } - Aura* GetAura(uint32 spellId, uint32 effindex); + Aura* GetAura(uint32 spellId, SpellEffectIndex effindex); Aura* GetAura(AuraType type, uint32 family, uint64 familyFlag, uint32 familyFlag2 = 0, uint64 casterGUID = 0); AuraMap & GetAuras() { return m_Auras; } @@ -1664,7 +1664,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void setTransForm(uint32 spellid) { m_transform = spellid;} uint32 getTransForm() const { return m_transform;} - DynamicObject* GetDynObject(uint32 spellId, uint32 effIndex); + DynamicObject* GetDynObject(uint32 spellId, SpellEffectIndex effIndex); DynamicObject* GetDynObject(uint32 spellId); void AddDynObject(DynamicObject* dynObj); void RemoveDynObject(uint32 spellid); @@ -1716,7 +1716,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject virtual bool IsImmunedToSpell(SpellEntry const* spellInfo); // redefined in Creature bool IsImmunedToDamage(SpellSchoolMask meleeSchoolMask); - virtual bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const; + virtual bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex index) const; // redefined in Creature uint32 CalcArmorReducedDamage(Unit* pVictim, const uint32 damage); @@ -1736,11 +1736,11 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void _RemoveAllAuraMods(); void _ApplyAllAuraMods(); - int32 CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_index, int32 basePoints, Unit const* target); + int32 CalculateSpellDamage(SpellEntry const* spellProto, SpellEffectIndex effect_index, int32 basePoints, Unit const* target); uint32 CalcNotIgnoreAbsorbDamage( uint32 damage, SpellSchoolMask damageSchoolMask, SpellEntry const* spellInfo = NULL); uint32 CalcNotIgnoreDamageRedunction( uint32 damage, SpellSchoolMask damageSchoolMask); - int32 CalculateSpellDuration(SpellEntry const* spellProto, uint8 effect_index, Unit const* target); + int32 CalculateSpellDuration(SpellEntry const* spellProto, SpellEffectIndex effect_index, Unit const* target); float CalculateLevelPenalty(SpellEntry const* spellProto) const; void addFollower(FollowerReference* pRef) { m_FollowingRefManager.insertFirst(pRef); } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 7a9f3a2dd85..0eb5b7fcd6d 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9410" + #define REVISION_NR "9411" #endif // __REVISION_NR_H__