Skip to content

Commit

Permalink
Some styling cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
billy1arm committed Aug 25, 2024
1 parent bff9195 commit 3acdd06
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 22 deletions.
65 changes: 44 additions & 21 deletions src/game/WorldHandlers/Spell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ void Spell::AddUnitTarget(Unit* pVictim, SpellEffectIndex effIndex)
{
if (!immuned)
{
ihit->effectMask |= 1 << effIndex; // Add only effect mask if not immuned
ihit->effectMask |= 1 << effIndex; // Add only effect mask if not immuned
}
return;
}
Expand Down Expand Up @@ -1658,7 +1658,7 @@ bool Spell::IsAliveUnitPresentInTargetList()
// either unit is alive and normal spell, or unit dead and deathonly-spell
if (unit && (unit->IsAlive() != IsDeathOnlySpell(m_spellInfo)))
{
needAliveTargetMask &= ~ihit->effectMask; // remove from need alive mask effect that have alive target
needAliveTargetMask &= ~ihit->effectMask; // remove from need alive mask effect that have alive target
}
}
}
Expand Down Expand Up @@ -2307,7 +2307,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
case TARGET_ALL_FRIENDLY_UNITS_IN_AREA:
FillAreaTargets(targetUnitMap, radius, PUSH_DEST_CENTER, SPELL_TARGETS_FRIENDLY);
break;
// TARGET_SINGLE_PARTY means that the spells can only be casted on a party member and not on the caster (some seals, fire shield from imp, etc..)
// TARGET_SINGLE_PARTY means that the spells can only be casted on a party member and not on the caster (some seals, fire shield from imp, etc..)
case TARGET_SINGLE_PARTY:
{
Unit* target = m_targets.getUnitTarget();
Expand Down Expand Up @@ -2455,7 +2455,6 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
{
m_targets.setUnitTarget(pUnitTarget);
}

targetUnitMap.push_back(pUnitTarget);
}
}
Expand Down Expand Up @@ -3131,7 +3130,7 @@ void Spell::prepare(SpellCastTargets const* targets, Aura* triggeredByAura)

if (triggeredByAura)
{
m_triggeredByAuraSpell = triggeredByAura->GetSpellProto();
m_triggeredByAuraSpell = triggeredByAura->GetSpellProto();
}

// create and add update event for this spell
Expand Down Expand Up @@ -3363,7 +3362,9 @@ void Spell::cast(bool skipCheck)
break;
}
case SPELLFAMILY_WARRIOR:
{
break;
}
case SPELLFAMILY_PRIEST:
{
// Power Word: Shield
Expand Down Expand Up @@ -4445,8 +4446,6 @@ void Spell::SendChannelUpdate(uint32 time)
}
}



m_caster->RemoveAurasByCasterSpell(m_spellInfo->Id, m_caster->GetObjectGuid());

ObjectGuid target_guid = m_caster->GetChannelObjectGuid();
Expand Down Expand Up @@ -4754,10 +4753,12 @@ void Spell::HandleThreatSpells()
bool positive = true;
uint8 effectMask = 0;
for (int i = 0; i < MAX_EFFECT_INDEX; ++i)
{
if (m_spellInfo->Effect[i])
{
effectMask |= (1 << i);
}
}

if (m_negativeEffectMask & effectMask)
{
Expand Down Expand Up @@ -5816,11 +5817,15 @@ SpellCastResult Spell::CheckCast(bool strict)
{
// Can be area effect, Check only for players and not check if target - caster (spell can have multiply drain/burn effects)
if (m_caster->GetTypeId() == TYPEID_PLAYER)
{
if (Unit* target = m_targets.getUnitTarget())
{
if (target != m_caster && int32(target->GetPowerType()) != m_spellInfo->EffectMiscValue[i])
{
return SPELL_FAILED_BAD_TARGETS;
}
}
}
break;
}
case SPELL_EFFECT_CHARGE:
Expand Down Expand Up @@ -5900,9 +5905,9 @@ SpellCastResult Spell::CheckCast(bool strict)
// In BattleGround players can use only flags and banners
if (((Player*)m_caster)->InBattleGround() &&
!((Player*)m_caster)->CanUseBattleGroundObject())
{
return SPELL_FAILED_TRY_AGAIN;
}
{
return SPELL_FAILED_TRY_AGAIN;
}

lockId = go->GetGOInfo()->GetLockId();
if (!lockId)
Expand Down Expand Up @@ -6084,10 +6089,12 @@ SpellCastResult Spell::CheckCast(bool strict)

// not allow use this effect at battleground until battleground start
if (BattleGround const* bg = ((Player*)m_caster)->GetBattleGround())
{
if (bg->GetStatus() != STATUS_IN_PROGRESS)
{
return SPELL_FAILED_TRY_AGAIN;
}
}
}

break;
Expand Down Expand Up @@ -6699,12 +6706,12 @@ SpellCastResult Spell::CheckRange(bool strict)
// special range cases
switch (m_spellInfo->rangeIndex)
{
// self cast doesn't need range checking -- also for Starshards fix
// spells that can be cast anywhere also need no check
// self cast doesn't need range checking -- also for Starshards fix
// spells that can be cast anywhere also need no check
case SPELL_RANGE_IDX_SELF_ONLY:
case SPELL_RANGE_IDX_ANYWHERE:
return SPELL_CAST_OK;
// combat range spells are treated differently
// combat range spells are treated differently
case SPELL_RANGE_IDX_COMBAT:
{
if (target)
Expand All @@ -6715,7 +6722,6 @@ SpellCastResult Spell::CheckRange(bool strict)
}

float range_mod = strict ? 0.0f : 5.0f;
float base = ATTACK_DISTANCE;
if (Player* modOwner = m_caster->GetSpellModOwner())
{
float base = ATTACK_DISTANCE;
Expand Down Expand Up @@ -6825,6 +6831,7 @@ uint32 Spell::CalculatePowerCost(SpellEntry const* spellInfo, Unit* caster, Spel
return 0;
}
}

SpellSchools school = GetFirstSchoolInMask(spell ? spell->m_spellSchoolMask : GetSpellSchoolMask(spellInfo));
// Flat mod from caster auras by spell school
powerCost += caster->GetInt32Value(UNIT_FIELD_POWER_COST_MODIFIER + school);
Expand Down Expand Up @@ -7553,19 +7560,19 @@ CurrentSpellTypes Spell::GetCurrentContainer()
{
if (IsNextMeleeSwingSpell())
{
return(CURRENT_MELEE_SPELL);
return (CURRENT_MELEE_SPELL);
}
else if (IsAutoRepeat())
{
return(CURRENT_AUTOREPEAT_SPELL);
return (CURRENT_AUTOREPEAT_SPELL);
}
else if (IsChanneledSpell(m_spellInfo))
{
return(CURRENT_CHANNELED_SPELL);
return (CURRENT_CHANNELED_SPELL);
}
else
{
return(CURRENT_GENERIC_SPELL);
return (CURRENT_GENERIC_SPELL);
}
}

Expand Down Expand Up @@ -7665,10 +7672,14 @@ bool Spell::CheckTarget(Unit* target, SpellEffectIndex eff)
default: // normal case
// Get GO cast coordinates if original caster -> GO
if (target != m_caster)
if (WorldObject* caster = GetCastingObject())
if (!target->IsWithinLOSInMap(caster))
{
return false;
if (WorldObject* caster = GetCastingObject())
{
if (!target->IsWithinLOSInMap(caster))
{
return false;
}
}
}
break;
}
Expand Down Expand Up @@ -7707,22 +7718,28 @@ bool Spell::IsTriggeredSpellWithRedundentCastTime() const
bool Spell::HaveTargetsForEffect(SpellEffectIndex effect) const
{
for (TargetList::const_iterator itr = m_UniqueTargetInfo.begin(); itr != m_UniqueTargetInfo.end(); ++itr)
{
if (itr->effectMask & (1 << effect))
{
return true;
}
}

for (GOTargetList::const_iterator itr = m_UniqueGOTargetInfo.begin(); itr != m_UniqueGOTargetInfo.end(); ++itr)
{
if (itr->effectMask & (1 << effect))
{
return true;
}
}

for (ItemTargetList::const_iterator itr = m_UniqueItemInfo.begin(); itr != m_UniqueItemInfo.end(); ++itr)
{
if (itr->effectMask & (1 << effect))
{
return true;
}
}

return false;
}
Expand Down Expand Up @@ -7875,13 +7892,15 @@ SpellCastResult Spell::CanOpenLock(SpellEffectIndex effIndex, uint32 lockId, Ski
{
// check key item (many fit cases can be)
case LOCK_KEY_ITEM:
{
if (lockInfo->Index[j] && m_CastItem && m_CastItem->GetEntry() == lockInfo->Index[j])
{
return SPELL_CAST_OK;
}
reqKey = true;
break;
// check key skill (only single first fit case can be)
}
case LOCK_KEY_SKILL:
{
reqKey = true;
Expand Down Expand Up @@ -7986,12 +8005,16 @@ void Spell::FillRaidOrPartyTargets(UnitList& targetUnitMap, Unit* member, float
}

if (withPets)
{
if (Pet* pet = ownerOrSelf->GetPet())
{
if ((pet == m_caster && withcaster) ||
(pet != m_caster && m_caster->IsWithinDistInMap(pet, radius)))
{
targetUnitMap.push_back(pet);
}
}
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/game/WorldHandlers/SpellAuras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2528,7 +2528,6 @@ void Aura::HandleAuraDummy(bool apply, bool Real)
}

// AT APPLY & REMOVE

switch (GetSpellProto()->SpellFamilyName)
{
case SPELLFAMILY_GENERIC:
Expand Down Expand Up @@ -2813,7 +2812,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real)
break;
}
case SPELLFAMILY_ROGUE:
{
break;
}
case SPELLFAMILY_HUNTER:
{
switch (GetId())
Expand Down

0 comments on commit 3acdd06

Please sign in to comment.