diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/server/game/Spells/SpellMgr.cpp | 109 |
1 files changed, 47 insertions, 62 deletions
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index f1879099a0a..db66e46eab1 100755 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -35,9 +35,9 @@ SpellSelectTargetTypes SpellTargetType[TOTAL_SPELL_TARGETS]; SpellMgr::SpellMgr() { - for (int i = 0; i < TOTAL_SPELL_EFFECTS; ++i) + for (uint8 i = 0; i < TOTAL_SPELL_EFFECTS; ++i) { - switch(i) + switch (i) { case SPELL_EFFECT_PERSISTENT_AREA_AURA: //27 case SPELL_EFFECT_SUMMON: //28 @@ -99,9 +99,9 @@ SpellMgr::SpellMgr() } } - for (int i = 0; i < TOTAL_SPELL_TARGETS; ++i) + for (uint8 i = 0; i < TOTAL_SPELL_TARGETS; ++i) { - switch(i) + switch (i) { case TARGET_UNIT_CASTER: case TARGET_UNIT_CASTER_FISHING: @@ -226,7 +226,7 @@ SpellMgr::SpellMgr() for (int32 i = 0; i < TOTAL_SPELL_TARGETS; ++i) { - switch(i) + switch (i) { case TARGET_UNIT_AREA_ENEMY_DST: case TARGET_UNIT_AREA_ENEMY_SRC: @@ -322,8 +322,8 @@ uint32 GetSpellCastTime(SpellEntry const* spellInfo, Spell* spell) int32 castTime = spellCastTimeEntry->CastTime; - if (spell && spell->GetCaster()) - spell->GetCaster()->ModSpellCastTime(spellInfo, castTime, spell); + if (Unit *caster = (spell ? spell->GetCaster() : NULL)) + caster->ModSpellCastTime(spellInfo, castTime, spell); if (spellInfo->Attributes & SPELL_ATTR0_REQ_AMMO && (!spell || !(spell->IsAutoRepeat()))) castTime += 500; @@ -492,7 +492,7 @@ AuraState GetSpellAuraState(SpellEntry const* spellInfo) return AURA_STATE_BLEEDING; if (GetSpellSchoolMask(spellInfo) & SPELL_SCHOOL_MASK_FROST) - for (uint8 i = 0; i<MAX_SPELL_EFFECTS; ++i) + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STUN || spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_ROOT) return AURA_STATE_FROZEN; @@ -1187,7 +1187,7 @@ void SpellMgr::LoadSpellTargetPositions() } bool found = false; - for (int i = 0; i < MAX_SPELL_EFFECTS; ++i) + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) { if (spellInfo->EffectImplicitTargetA[i] == TARGET_DST_DB || spellInfo->EffectImplicitTargetB[i] == TARGET_DST_DB) { @@ -1227,7 +1227,7 @@ void SpellMgr::LoadSpellTargetPositions() bool found = false; for (int j = 0; j < MAX_SPELL_EFFECTS; ++j) { - switch(spellInfo->EffectImplicitTargetA[j]) + switch (spellInfo->EffectImplicitTargetA[j]) { case TARGET_DST_DB: found = true; @@ -1235,7 +1235,7 @@ void SpellMgr::LoadSpellTargetPositions() } if (found) break; - switch(spellInfo->EffectImplicitTargetB[j]) + switch (spellInfo->EffectImplicitTargetB[j]) { case TARGET_DST_DB: found = true; @@ -1420,7 +1420,7 @@ bool SpellMgr::IsSpellProcEventCanTriggeredBy(SpellProcEventEntry const* spellPr // spellFamilyName is Ok need check for spellFamilyMask if present if (spellProcEvent->spellFamilyMask) { - if ((spellProcEvent->spellFamilyMask & procSpell->SpellFamilyFlags) == 0) + if (!(spellProcEvent->spellFamilyMask & procSpell->SpellFamilyFlags)) return false; hasFamilyMask = true; // Some spells are not considered as active even with have spellfamilyflags @@ -1661,8 +1661,6 @@ void SpellMgr::LoadSpellGroups() QueryResult result = WorldDatabase.Query("SELECT id, spell_id FROM spell_group"); if (!result) { - - sLog->outString(); sLog->outString(">> Loaded %u spell group definitions", count); return; @@ -1746,7 +1744,6 @@ void SpellMgr::LoadSpellGroupStackRules() QueryResult result = WorldDatabase.Query("SELECT group_id, stack_rule FROM spell_group_stack_rules"); if (!result) { - sLog->outString(">> Loaded 0 spell group stack rules"); sLog->outString(); return; @@ -1793,8 +1790,6 @@ void SpellMgr::LoadSpellThreats() QueryResult result = WorldDatabase.Query("SELECT entry, Threat FROM spell_threat"); if (!result) { - - sLog->outString(">> Loaded %u aggro generating spells", count); sLog->outString(); return; @@ -1844,9 +1839,9 @@ bool SpellMgr::canStackSpellRanks(SpellEntry const *spellInfo) return false; // All stance spells. if any better way, change it. - for (int i = 0; i < MAX_SPELL_EFFECTS; ++i) + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) { - switch(spellInfo->SpellFamilyName) + switch (spellInfo->SpellFamilyName) { case SPELLFAMILY_PALADIN: // Paladin aura Spell @@ -1982,7 +1977,7 @@ int32 SpellMgr::CalculateSpellEffectAmount(SpellEntry const* spellEntry, uint8 e } // roll in a range <1;EffectDieSides> as of patch 3.3.3 - switch(randomPoints) + switch (randomPoints) { case 0: break; case 1: basePoints += 1; break; // range 1..1 @@ -2036,20 +2031,16 @@ int32 SpellMgr::CalculateSpellEffectBaseAmount(int32 value, SpellEntry const* sp float SpellMgr::CalculateSpellEffectValueMultiplier(SpellEntry const* spellEntry, uint8 effIndex, Unit* caster, Spell* spell) { float multiplier = spellEntry->EffectValueMultiplier[effIndex]; - - if (caster) - if (Player* modOwner = caster->GetSpellModOwner()) - modOwner->ApplySpellMod(spellEntry->Id, SPELLMOD_VALUE_MULTIPLIER, multiplier, spell); + if (Player* modOwner = (caster ? caster->GetSpellModOwner() : NULL)) + modOwner->ApplySpellMod(spellEntry->Id, SPELLMOD_VALUE_MULTIPLIER, multiplier, spell); return multiplier; } float SpellMgr::CalculateSpellEffectDamageMultiplier(SpellEntry const* spellEntry, uint8 effIndex, Unit* caster, Spell* spell) { float multiplier = spellEntry->EffectDamageMultiplier[effIndex]; - - if (caster) - if (Player* modOwner = caster->GetSpellModOwner()) - modOwner->ApplySpellMod(spellEntry->Id, SPELLMOD_DAMAGE_MULTIPLIER, multiplier, spell); + if (Player* modOwner = (caster ? caster->GetSpellModOwner() : NULL)) + modOwner->ApplySpellMod(spellEntry->Id, SPELLMOD_DAMAGE_MULTIPLIER, multiplier, spell); return multiplier; } @@ -2060,7 +2051,7 @@ SpellEntry const* SpellMgr::SelectAuraRankForPlayerLevel(SpellEntry const* spell return spellInfo; bool needRankSelection = false; - for (int i = 0; i < MAX_SPELL_EFFECTS; ++i) + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) { if (IsPositiveEffect(spellInfo->Id, i) && ( spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA || @@ -2142,7 +2133,6 @@ void SpellMgr::LoadSpellLearnSpells() QueryResult result = WorldDatabase.Query("SELECT entry, SpellID, Active FROM spell_learn_spell"); if (!result) { - sLog->outString(">> Loaded 0 spell learn spells"); sLog->outString(); sLog->outErrorDb("`spell_learn_spell` table is empty!"); @@ -2207,7 +2197,7 @@ void SpellMgr::LoadSpellLearnSpells() continue; // talent or passive spells or skill-step spells auto-casted and not need dependent learning, - // pet teaching spells don't must be dependent learning (casted) + // pet teaching spells must not be dependent learning (casted) // other required explicit dependent learning dbc_node.autoLearned = entry->EffectImplicitTargetA[i] == TARGET_UNIT_PET || GetTalentSpellCost(spell) > 0 || IsPassiveSpell(spell) || IsSpellHaveEffect(entry, SPELL_EFFECT_SKILL_STEP); @@ -2312,7 +2302,6 @@ void SpellMgr::LoadPetLevelupSpellMap() for (uint32 i = 0; i < sCreatureFamilyStore.GetNumRows(); ++i) { - CreatureFamilyEntry const *creatureFamily = sCreatureFamilyStore.LookupEntry(i); if (!creatureFamily) // not exist continue; @@ -2835,7 +2824,7 @@ SpellCastResult SpellMgr::GetSpellAllowedInLocationError(SpellEntry const *spell } // bg spell checks - switch(spellInfo->Id) + switch (spellInfo->Id) { case 23333: // Warsong Flag case 23335: // Silverwing Flag @@ -3275,35 +3264,35 @@ bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32 return false; // Extra conditions -- leaving the possibility add extra conditions... - switch(spellId) + switch (spellId) { case 58600: // No fly Zone - Dalaran - { - if (!player) - return false; + { + if (!player) + return false; - AreaTableEntry const* pArea = GetAreaEntryByAreaID(player->GetAreaId()); - if (!(pArea && pArea->flags & AREA_FLAG_NO_FLY_ZONE)) - return false; - if (!player->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !player->HasAuraType(SPELL_AURA_FLY)) - return false; - break; - } - case SPELL_OIL_REFINERY: // Oil Refinery - Isle of Conquest. - case SPELL_QUARRY: // Quarry - Isle of Conquest. - { - if (player->GetBattlegroundTypeId() != BATTLEGROUND_IC || !player->GetBattleground()) - return false; + AreaTableEntry const* pArea = GetAreaEntryByAreaID(player->GetAreaId()); + if (!(pArea && pArea->flags & AREA_FLAG_NO_FLY_ZONE)) + return false; + if (!player->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !player->HasAuraType(SPELL_AURA_FLY)) + return false; + break; + } + case 68719: // Oil Refinery - Isle of Conquest. + case 68720: // Quarry - Isle of Conquest. + { + if (player->GetBattlegroundTypeId() != BATTLEGROUND_IC || !player->GetBattleground()) + return false; - uint8 nodeType = spellId == SPELL_OIL_REFINERY ? NODE_TYPE_REFINERY : NODE_TYPE_QUARRY; - uint8 nodeState = player->GetTeamId() == TEAM_ALLIANCE ? NODE_STATE_CONTROLLED_A : NODE_STATE_CONTROLLED_H; + uint8 nodeType = spellId == 68719 ? NODE_TYPE_REFINERY : NODE_TYPE_QUARRY; + uint8 nodeState = player->GetTeamId() == TEAM_ALLIANCE ? NODE_STATE_CONTROLLED_A : NODE_STATE_CONTROLLED_H; - BattlegroundIC* pIC = static_cast<BattlegroundIC*>(player->GetBattleground()); - if (pIC->GetNodeState(nodeType) == nodeState) - return true; + BattlegroundIC* pIC = static_cast<BattlegroundIC*>(player->GetBattleground()); + if (pIC->GetNodeState(nodeType) == nodeState) + return true; - return false; - } + return false; + } } return true; @@ -3341,7 +3330,7 @@ bool SpellMgr::CanAurasStack(Aura const *aura1, Aura const *aura2, bool sameCast // check same periodic auras for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i) { - switch(spellInfo_1->EffectApplyAuraName[i]) + switch (spellInfo_1->EffectApplyAuraName[i]) { // DOT or HOT from different casters will stack case SPELL_AURA_PERIODIC_DAMAGE: @@ -3460,7 +3449,6 @@ void SpellMgr::LoadSpellEnchantProcData() QueryResult result = WorldDatabase.Query("SELECT entry, customChance, PPMChance, procEx FROM spell_enchant_proc_data"); if (!result) { - sLog->outString(">> Loaded %u spell enchant proc event conditions", count); sLog->outString(); return; @@ -3505,7 +3493,6 @@ void SpellMgr::LoadSpellRequired() if (!result) { - sLog->outString(">> Loaded 0 spell required records"); sLog->outString(); sLog->outErrorDb("`spell_required` table is empty!"); @@ -3562,7 +3549,6 @@ void SpellMgr::LoadSpellRanks() if (!result) { - sLog->outString(">> Loaded 0 spell rank records"); sLog->outString(); sLog->outErrorDb("`spell_ranks` table is empty!"); @@ -4414,7 +4400,6 @@ void SpellMgr::LoadEnchantCustomAttr() for (uint32 i = 0; i < GetSpellStore()->GetNumRows(); ++i) { - SpellEntry * spellInfo = (SpellEntry*)GetSpellStore()->LookupEntry(i); if (!spellInfo) continue; @@ -4482,7 +4467,7 @@ void SpellMgr::LoadSpellLinked() if (trigger > 0) { - switch(type) + switch (type) { case 0: mSpellCustomAttr[trigger] |= SPELL_ATTR0_CU_LINK_CAST; break; case 1: mSpellCustomAttr[trigger] |= SPELL_ATTR0_CU_LINK_HIT; break; |