diff options
| author | Shauren <shauren.trinity@gmail.com> | 2017-05-21 23:18:43 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2017-05-21 23:18:43 +0200 |
| commit | 3d7c2ef88f2ca3293a1df0411ad49e3eb5a96079 (patch) | |
| tree | d9a92cf30fcf560d837e2b3b0a212a6834534f46 /src/server/game/Spells | |
| parent | 3cb8f532dae1062c5f5bcda1b980463da99fe547 (diff) | |
Core/Game: Include cleanup, part 4 - packets and largest headers (after preprocessing, except player/objectmgr)
Diffstat (limited to 'src/server/game/Spells')
| -rw-r--r-- | src/server/game/Spells/Auras/SpellAuraDefines.h | 10 | ||||
| -rw-r--r-- | src/server/game/Spells/Spell.cpp | 98 | ||||
| -rw-r--r-- | src/server/game/Spells/Spell.h | 79 | ||||
| -rw-r--r-- | src/server/game/Spells/SpellEffects.cpp | 85 | ||||
| -rw-r--r-- | src/server/game/Spells/SpellHistory.cpp | 2 | ||||
| -rw-r--r-- | src/server/game/Spells/SpellInfo.cpp | 32 | ||||
| -rw-r--r-- | src/server/game/Spells/SpellInfo.h | 20 |
7 files changed, 201 insertions, 125 deletions
diff --git a/src/server/game/Spells/Auras/SpellAuraDefines.h b/src/server/game/Spells/Auras/SpellAuraDefines.h index 60781365cdf..4041f8c1335 100644 --- a/src/server/game/Spells/Auras/SpellAuraDefines.h +++ b/src/server/game/Spells/Auras/SpellAuraDefines.h @@ -48,6 +48,16 @@ enum AuraEffectHandleModes AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK = (AURA_EFFECT_HANDLE_REAPPLY | AURA_EFFECT_HANDLE_REAL) }; +enum AuraRemoveMode +{ + AURA_REMOVE_NONE = 0, + AURA_REMOVE_BY_DEFAULT = 1, // scripted remove, remove by stack with aura with different ids and sc aura remove + AURA_REMOVE_BY_CANCEL, + AURA_REMOVE_BY_ENEMY_SPELL, // dispel and absorb aura destroy + AURA_REMOVE_BY_EXPIRE, // aura duration has ended + AURA_REMOVE_BY_DEATH +}; + //m_schoolAbsorb enum DAMAGE_ABSORB_TYPE { diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 2a677dc50d1..867753ecfb6 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -420,6 +420,16 @@ void SpellCastTargets::RemoveDst() m_targetMask &= ~(TARGET_FLAG_DEST_LOCATION); } +bool SpellCastTargets::HasSrc() const +{ + return (GetTargetMask() & TARGET_FLAG_SOURCE_LOCATION) != 0; +} + +bool SpellCastTargets::HasDst() const +{ + return (GetTargetMask() & TARGET_FLAG_DEST_LOCATION) != 0; +} + void SpellCastTargets::Update(Unit* caster) { m_objectTarget = !m_objectTargetGUID.IsEmpty() ? ((m_objectTargetGUID == caster->GetGUID()) ? caster : ObjectAccessor::GetWorldObject(*caster, m_objectTargetGUID)) : NULL; @@ -498,9 +508,22 @@ SpellValue::SpellValue(Difficulty diff, SpellInfo const* proto) AuraStackAmount = 1; } +class TC_GAME_API SpellEvent : public BasicEvent +{ +public: + SpellEvent(Spell* spell); + virtual ~SpellEvent(); + + virtual bool Execute(uint64 e_time, uint32 p_time) override; + virtual void Abort(uint64 e_time) override; + virtual bool IsDeletable() const override; +protected: + Spell* m_Spell; +}; + Spell::Spell(Unit* caster, SpellInfo const* info, TriggerCastFlags triggerFlags, ObjectGuid originalCasterGUID, bool skipCheck) : m_spellInfo(info), m_caster((info->HasAttribute(SPELL_ATTR6_CAST_BY_CHARMER) && caster->GetCharmerOrOwner()) ? caster->GetCharmerOrOwner() : caster), -m_spellValue(new SpellValue(caster->GetMap()->GetDifficultyID(), m_spellInfo)), m_preGeneratedPath(PathGenerator(m_caster)) +m_spellValue(new SpellValue(caster->GetMap()->GetDifficultyID(), m_spellInfo)) { _effects = info->GetEffectsForDifficulty(caster->GetMap()->GetDifficultyID()); @@ -3927,10 +3950,10 @@ void Spell::SendSpellStart() if ((m_caster->GetTypeId() == TYPEID_PLAYER || (m_caster->GetTypeId() == TYPEID_UNIT && m_caster->IsPet())) - && std::find_if(m_powerCost.begin(), m_powerCost.end(), [](SpellInfo::CostData const& cost) { return cost.Power != POWER_HEALTH; }) != m_powerCost.end()) + && std::find_if(m_powerCost.begin(), m_powerCost.end(), [](SpellPowerCost const& cost) { return cost.Power != POWER_HEALTH; }) != m_powerCost.end()) castFlags |= CAST_FLAG_POWER_LEFT_SELF; - if (std::find_if(m_powerCost.begin(), m_powerCost.end(), [](SpellInfo::CostData const& cost) { return cost.Power == POWER_RUNES; }) != m_powerCost.end()) + if (std::find_if(m_powerCost.begin(), m_powerCost.end(), [](SpellPowerCost const& cost) { return cost.Power == POWER_RUNES; }) != m_powerCost.end()) castFlags |= CAST_FLAG_NO_GCD; // not needed, but Blizzard sends it WorldPackets::Spells::SpellStart packet; @@ -3954,7 +3977,7 @@ void Spell::SendSpellStart() if (castFlags & CAST_FLAG_POWER_LEFT_SELF) { - for (SpellInfo::CostData const& cost : m_powerCost) + for (SpellPowerCost const& cost : m_powerCost) { WorldPackets::Spells::SpellPowerData powerData; powerData.Type = cost.Power; @@ -4028,12 +4051,12 @@ void Spell::SendSpellGo() if ((m_caster->GetTypeId() == TYPEID_PLAYER || (m_caster->GetTypeId() == TYPEID_UNIT && m_caster->IsPet())) - && std::find_if(m_powerCost.begin(), m_powerCost.end(), [](SpellInfo::CostData const& cost) { return cost.Power != POWER_HEALTH; }) != m_powerCost.end()) + && std::find_if(m_powerCost.begin(), m_powerCost.end(), [](SpellPowerCost const& cost) { return cost.Power != POWER_HEALTH; }) != m_powerCost.end()) castFlags |= CAST_FLAG_POWER_LEFT_SELF; // should only be sent to self, but the current messaging doesn't make that possible if ((m_caster->GetTypeId() == TYPEID_PLAYER) && (m_caster->getClass() == CLASS_DEATH_KNIGHT) - && std::find_if(m_powerCost.begin(), m_powerCost.end(), [](SpellInfo::CostData const& cost) { return cost.Power == POWER_RUNES; }) != m_powerCost.end() + && std::find_if(m_powerCost.begin(), m_powerCost.end(), [](SpellPowerCost const& cost) { return cost.Power == POWER_RUNES; }) != m_powerCost.end() && !(_triggeredCastFlags & TRIGGERED_IGNORE_POWER_AND_REAGENT_COST)) { castFlags |= CAST_FLAG_NO_GCD; // not needed, but Blizzard sends it @@ -4072,7 +4095,7 @@ void Spell::SendSpellGo() if (castFlags & CAST_FLAG_POWER_LEFT_SELF) { - for (SpellInfo::CostData const& cost : m_powerCost) + for (SpellPowerCost const& cost : m_powerCost) { WorldPackets::Spells::SpellPowerData powerData; powerData.Type = cost.Power; @@ -4503,7 +4526,7 @@ void Spell::TakePower() return; } - for (SpellInfo::CostData& cost : m_powerCost) + for (SpellPowerCost& cost : m_powerCost) { Powers powerType = Powers(cost.Power); bool hit = true; @@ -4563,7 +4586,7 @@ void Spell::TakePower() SpellCastResult Spell::CheckRuneCost() { - auto runeCost = std::find_if(m_powerCost.begin(), m_powerCost.end(), [](SpellInfo::CostData const& cost) { return cost.Power == POWER_RUNES; }); + auto runeCost = std::find_if(m_powerCost.begin(), m_powerCost.end(), [](SpellPowerCost const& cost) { return cost.Power == POWER_RUNES; }); if (runeCost == m_powerCost.end()) return SPELL_CAST_OK; @@ -4593,7 +4616,7 @@ void Spell::TakeRunePower(bool didHit) Player* player = m_caster->ToPlayer(); m_runesState = player->GetRunesState(); // store previous state - int32 runeCost = std::find_if(m_powerCost.begin(), m_powerCost.end(), [](SpellInfo::CostData const& cost) + int32 runeCost = std::find_if(m_powerCost.begin(), m_powerCost.end(), [](SpellPowerCost const& cost) { return cost.Power == POWER_RUNES; })->Amount; @@ -5242,26 +5265,27 @@ SpellCastResult Spell::CheckCast(bool strict) float objSize = target->GetObjectSize(); float range = m_spellInfo->GetMaxRange(true, m_caster, this) * 1.5f + objSize; // can't be overly strict - m_preGeneratedPath.SetPathLengthLimit(range); + m_preGeneratedPath = Trinity::make_unique<PathGenerator>(m_caster); + m_preGeneratedPath->SetPathLengthLimit(range); // first try with raycast, if it fails fall back to normal path float targetObjectSize = std::min(target->GetObjectSize(), 4.0f); - bool result = m_preGeneratedPath.CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ() + targetObjectSize, false, true); - if (m_preGeneratedPath.GetPathType() & PATHFIND_SHORT) + bool result = m_preGeneratedPath->CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ() + targetObjectSize, false, true); + if (m_preGeneratedPath->GetPathType() & PATHFIND_SHORT) return SPELL_FAILED_OUT_OF_RANGE; - else if (!result || m_preGeneratedPath.GetPathType() & (PATHFIND_NOPATH | PATHFIND_INCOMPLETE)) + else if (!result || m_preGeneratedPath->GetPathType() & (PATHFIND_NOPATH | PATHFIND_INCOMPLETE)) { - result = m_preGeneratedPath.CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ() + targetObjectSize, false, false); - if (m_preGeneratedPath.GetPathType() & PATHFIND_SHORT) + result = m_preGeneratedPath->CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ() + targetObjectSize, false, false); + if (m_preGeneratedPath->GetPathType() & PATHFIND_SHORT) return SPELL_FAILED_OUT_OF_RANGE; - else if (!result || m_preGeneratedPath.GetPathType() & (PATHFIND_NOPATH | PATHFIND_INCOMPLETE)) + else if (!result || m_preGeneratedPath->GetPathType() & (PATHFIND_NOPATH | PATHFIND_INCOMPLETE)) return SPELL_FAILED_NOPATH; - else if (m_preGeneratedPath.IsInvalidDestinationZ(target)) // Check position z, if not in a straight line + else if (m_preGeneratedPath->IsInvalidDestinationZ(target)) // Check position z, if not in a straight line return SPELL_FAILED_NOPATH; } - else if (m_preGeneratedPath.IsInvalidDestinationZ(target)) // Check position z, if in a straight line + else if (m_preGeneratedPath->IsInvalidDestinationZ(target)) // Check position z, if in a straight line return SPELL_FAILED_NOPATH; - m_preGeneratedPath.ReducePathLenghtByDist(objSize); // move back + m_preGeneratedPath->ReducePathLenghtByDist(objSize); // move back } break; } @@ -5902,6 +5926,11 @@ SpellCastResult Spell::CheckArenaAndRatedBattlegroundCastRules() return SPELL_CAST_OK; } +int32 Spell::CalculateDamage(uint8 i, Unit const* target, float* var /*= nullptr*/) const +{ + return m_caster->CalculateSpellDamage(target, m_spellInfo, i, &m_spellValue->EffectBasePoints[i], var, m_castItemLevel); +} + bool Spell::CanAutoCast(Unit* target) { if (!target) @@ -5961,6 +5990,18 @@ bool Spell::CanAutoCast(Unit* target) return false; } +void Spell::CheckSrc() +{ + if (!m_targets.HasSrc()) + m_targets.SetSrc(*m_caster); +} + +void Spell::CheckDst() +{ + if (!m_targets.HasDst()) + m_targets.SetDst(*m_caster); +} + SpellCastResult Spell::CheckRange(bool strict) { // Don't check for instant cast spells @@ -6059,7 +6100,7 @@ SpellCastResult Spell::CheckPower() if (m_CastItem) return SPELL_CAST_OK; - for (SpellInfo::CostData const& cost : m_powerCost) + for (SpellPowerCost const& cost : m_powerCost) { // health as power used - need check health amount if (cost.Power == POWER_HEALTH) @@ -6801,6 +6842,21 @@ bool Spell::IsNextMeleeSwingSpell() const return m_spellInfo->HasAttribute(SPELL_ATTR0_ON_NEXT_SWING); } +bool Spell::IsTriggered() const +{ + return (_triggeredCastFlags & TRIGGERED_FULL_MASK) != 0; +} + +bool Spell::IsIgnoringCooldowns() const +{ + return (_triggeredCastFlags & TRIGGERED_IGNORE_SPELL_AND_CATEGORY_CD) != 0; +} + +bool Spell::IsChannelActive() const +{ + return m_caster->GetUInt32Value(UNIT_CHANNEL_SPELL) != 0; +} + bool Spell::IsAutoActionResetSpell() const { /// @todo changed SPELL_INTERRUPT_FLAG_AUTOATTACK -> SPELL_INTERRUPT_FLAG_INTERRUPT to fix compile - is this check correct at all? diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index 39a5b705563..e31fc53659b 100644 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -19,11 +19,12 @@ #ifndef __SPELL_H #define __SPELL_H -#include "GridDefines.h" +#include "ConditionMgr.h" +#include "DBCEnums.h" +#include "ObjectGuid.h" +#include "Position.h" #include "SharedDefines.h" -#include "ObjectMgr.h" -#include "SpellInfo.h" -#include "PathGenerator.h" +#include <memory> namespace WorldPackets { @@ -36,14 +37,31 @@ namespace WorldPackets } } -class Unit; -class Player; -class GameObject; -class DynamicObject; -class WorldObject; class Aura; +class AuraEffect; +class Corpse; +class DynamicObject; +class GameObject; +class Item; +class Object; +class PathGenerator; +class Player; +class SpellEffectInfo; +class SpellImplicitTargetInfo; +class SpellInfo; class SpellScript; -class ByteBuffer; +class Unit; +class WorldObject; +struct SpellPowerCost; +struct SummonPropertiesEntry; +enum CurrentSpellTypes : uint8; +enum LootType : uint8; +enum SpellCastTargetFlags : uint32; +enum SpellTargetCheckTypes : uint8; +enum SpellTargetObjectTypes : uint8; +enum SpellValueMod : uint8; +enum TriggerCastFlags : uint32; +enum WeaponAttackType : uint8; #define SPELL_CHANNEL_UPDATE_INTERVAL (1 * IN_MILLISECONDS) @@ -237,8 +255,8 @@ class TC_GAME_API SpellCastTargets void ModDst(SpellDestination const& spellDest); void RemoveDst(); - bool HasSrc() const { return (GetTargetMask() & TARGET_FLAG_SOURCE_LOCATION) != 0; } - bool HasDst() const { return (GetTargetMask() & TARGET_FLAG_DEST_LOCATION) != 0; } + bool HasSrc() const; + bool HasDst() const; bool HasTraj() const { return m_speed != 0; } float GetPitch() const { return m_pitch; } @@ -307,7 +325,7 @@ static const uint32 SPELL_INTERRUPT_NONPLAYER = 32747; class TC_GAME_API Spell { - friend void Unit::SetCurrentCastSpell(Spell* pSpell); + friend void SetUnitCurrentCastSpell(Unit* unit, Spell* spell); friend class SpellScript; public: @@ -519,7 +537,7 @@ class TC_GAME_API Spell SpellCastResult CheckCasterAuras() const; SpellCastResult CheckArenaAndRatedBattlegroundCastRules(); - int32 CalculateDamage(uint8 i, Unit const* target, float* var = nullptr) const { return m_caster->CalculateSpellDamage(target, m_spellInfo, i, &m_spellValue->EffectBasePoints[i], var, m_castItemLevel); } + int32 CalculateDamage(uint8 i, Unit const* target, float* var = nullptr) const; bool HaveTargetsForEffect(uint8 effect) const; void Delayed(); @@ -533,8 +551,8 @@ class TC_GAME_API Spell bool CheckEffectTarget(GameObject const* target, SpellEffectInfo const* effect) const; bool CheckEffectTarget(Item const* target, SpellEffectInfo const* effect) const; bool CanAutoCast(Unit* target); - void CheckSrc() { if (!m_targets.HasSrc()) m_targets.SetSrc(*m_caster); } - void CheckDst() { if (!m_targets.HasDst()) m_targets.SetDst(*m_caster); } + void CheckSrc(); + void CheckDst(); static void SendCastResult(Player* caster, SpellInfo const* spellInfo, uint32 spellVisual, ObjectGuid cast_count, SpellCastResult result, SpellCustomErrors customError = SPELL_CUSTOM_ERROR_NONE, uint32* misc = nullptr); void SendCastResult(SpellCastResult result); @@ -616,9 +634,9 @@ class TC_GAME_API Spell void SetAutoRepeat(bool rep) { m_autoRepeat = rep; } void ReSetTimer() { m_timer = m_casttime > 0 ? m_casttime : 0; } bool IsNextMeleeSwingSpell() const; - bool IsTriggered() const { return (_triggeredCastFlags & TRIGGERED_FULL_MASK) != 0; } - bool IsIgnoringCooldowns() const { return (_triggeredCastFlags & TRIGGERED_IGNORE_SPELL_AND_CATEGORY_CD) != 0; } - bool IsChannelActive() const { return m_caster->GetUInt32Value(UNIT_CHANNEL_SPELL) != 0; } + bool IsTriggered() const; + bool IsIgnoringCooldowns() const; + bool IsChannelActive() const; bool IsAutoActionResetSpell() const; bool IsDeletable() const { return !m_referencedFromCurrentSpell && !m_executedCurrently; } @@ -636,7 +654,7 @@ class TC_GAME_API Spell Unit* GetCaster() const { return m_caster; } Unit* GetOriginalCaster() const { return m_originalCaster; } SpellInfo const* GetSpellInfo() const { return m_spellInfo; } - std::vector<SpellInfo::CostData> const& GetPowerCost() const { return m_powerCost; } + std::vector<SpellPowerCost> const& GetPowerCost() const { return m_powerCost; } bool UpdatePointers(); // must be used at call Spell code after time delay (non triggered spell cast/update spell call/etc) @@ -644,7 +662,7 @@ class TC_GAME_API Spell void SetSpellValue(SpellValueMod mod, int32 value); - SpellEffectInfoVector const& GetEffects() const { return _effects; } + std::vector<SpellEffectInfo const*> const& GetEffects() const { return _effects; } SpellEffectInfo const* GetEffect(uint32 index) const { if (index >= _effects.size()) @@ -681,7 +699,7 @@ class TC_GAME_API Spell SpellSchoolMask m_spellSchoolMask; // Spell school (can be overwrite for some spells (wand shoot for example) WeaponAttackType m_attackType; // For weapon based attack - std::vector<SpellInfo::CostData> m_powerCost; // Calculated spell cost initialized only in Spell::prepare + std::vector<SpellPowerCost> m_powerCost; // Calculated spell cost initialized only in Spell::prepare int32 m_casttime; // Calculated spell cast time initialized only in Spell::prepare int32 m_channeledDuration; // Calculated channeled spell duration in order to calculate correct pushback. bool m_canReflect; // can reflect this spell? @@ -852,7 +870,7 @@ class TC_GAME_API Spell bool m_skipCheck; uint32 m_auraScaleMask; - PathGenerator m_preGeneratedPath; + std::unique_ptr<PathGenerator> m_preGeneratedPath; std::vector<SpellLogEffectPowerDrainParams> _powerDrainTargets[MAX_SPELL_EFFECTS]; std::vector<SpellLogEffectExtraAttacksParams> _extraAttacksTargets[MAX_SPELL_EFFECTS]; @@ -864,7 +882,7 @@ class TC_GAME_API Spell Spell(Spell const& right) = delete; Spell& operator=(Spell const& right) = delete; - SpellEffectInfoVector _effects; + std::vector<SpellEffectInfo const*> _effects; }; namespace Trinity @@ -918,17 +936,4 @@ namespace Trinity } typedef void(Spell::*pEffect)(SpellEffIndex effIndex); - -class TC_GAME_API SpellEvent : public BasicEvent -{ - public: - SpellEvent(Spell* spell); - virtual ~SpellEvent(); - - virtual bool Execute(uint64 e_time, uint32 p_time) override; - virtual void Abort(uint64 e_time) override; - virtual bool IsDeletable() const override; - protected: - Spell* m_Spell; -}; #endif diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 1eeb35f43ba..a5d97bc8843 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -16,54 +16,55 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "Spell.h" +#include "AccountMgr.h" +#include "AreaTrigger.h" +#include "Battleground.h" +#include "BattlegroundMgr.h" +#include "BattlePetMgr.h" +#include "CombatLogPackets.h" #include "Common.h" +#include "Conversation.h" +#include "Creature.h" +#include "CreatureAI.h" #include "DatabaseEnv.h" -#include "WorldPacket.h" -#include "Opcodes.h" -#include "Log.h" -#include "World.h" -#include "ObjectMgr.h" -#include "SpellMgr.h" -#include "Player.h" -#include "SkillExtraItems.h" -#include "Unit.h" -#include "Spell.h" +#include "DuelPackets.h" #include "DynamicObject.h" -#include "SpellAuras.h" -#include "SpellAuraEffects.h" -#include "SpellHistory.h" -#include "Group.h" -#include "SharedDefines.h" -#include "Pet.h" #include "GameObject.h" -#include "GossipDef.h" -#include "Creature.h" -#include "Totem.h" -#include "CreatureAI.h" -#include "BattlegroundMgr.h" -#include "Battleground.h" -#include "OutdoorPvPMgr.h" -#include "Language.h" -#include "SocialMgr.h" -#include "Util.h" -#include "TemporarySummon.h" -#include "ScriptMgr.h" #include "GameObjectAI.h" -#include "AccountMgr.h" +#include "Garrison.h" +#include "GossipDef.h" +#include "Group.h" +#include "Guild.h" #include "InstanceScript.h" +#include "Language.h" +#include "Log.h" +#include "LootMgr.h" +#include "MiscPackets.h" +#include "ObjectMgr.h" +#include "Opcodes.h" +#include "OutdoorPvPMgr.h" #include "PathGenerator.h" -#include "Guild.h" +#include "Pet.h" +#include "Player.h" #include "ReputationMgr.h" -#include "AreaTrigger.h" -#include "BattlePetMgr.h" -#include "Garrison.h" -#include "CombatLogPackets.h" -#include "DuelPackets.h" -#include "MiscPackets.h" +#include "ScriptMgr.h" +#include "SharedDefines.h" +#include "SkillExtraItems.h" +#include "SocialMgr.h" +#include "SpellAuraEffects.h" +#include "SpellAuras.h" +#include "SpellHistory.h" +#include "SpellMgr.h" #include "SpellPackets.h" #include "TalentPackets.h" -#include "Conversation.h" -#include "LootMgr.h" +#include "TemporarySummon.h" +#include "Totem.h" +#include "Unit.h" +#include "Util.h" +#include "World.h" +#include "WorldPacket.h" +#include <G3D/Quat.h> pEffect SpellEffects[TOTAL_SPELL_EFFECTS]= { @@ -4307,14 +4308,14 @@ void Spell::EffectCharge(SpellEffIndex /*effIndex*/) spellEffectExtraData->SpellVisualId = effectInfo->MiscValueB; } // Spell is not using explicit target - no generated path - if (m_preGeneratedPath.GetPathType() == PATHFIND_BLANK) + if (m_preGeneratedPath->GetPathType() == PATHFIND_BLANK) { //unitTarget->GetContactPoint(m_caster, pos.m_positionX, pos.m_positionY, pos.m_positionZ); Position pos = unitTarget->GetFirstCollisionPosition(unitTarget->GetObjectSize(), unitTarget->GetRelativeAngle(m_caster)); m_caster->GetMotionMaster()->MoveCharge(pos.m_positionX, pos.m_positionY, pos.m_positionZ, speed, EVENT_CHARGE, false, unitTarget, spellEffectExtraData.get_ptr()); } else - m_caster->GetMotionMaster()->MoveCharge(m_preGeneratedPath, speed, unitTarget, spellEffectExtraData.get_ptr()); + m_caster->GetMotionMaster()->MoveCharge(*m_preGeneratedPath, speed, unitTarget, spellEffectExtraData.get_ptr()); } if (effectHandleMode == SPELL_EFFECT_HANDLE_HIT_TARGET) @@ -4615,8 +4616,8 @@ void Spell::EffectDestroyAllTotems(SpellEffIndex /*effIndex*/) SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell_id); if (spellInfo) { - std::vector<SpellInfo::CostData> costs = spellInfo->CalcPowerCost(m_caster, spellInfo->GetSchoolMask()); - auto m = std::find_if(costs.begin(), costs.end(), [](SpellInfo::CostData const& cost) { return cost.Power == POWER_MANA; }); + std::vector<SpellPowerCost> costs = spellInfo->CalcPowerCost(m_caster, spellInfo->GetSchoolMask()); + auto m = std::find_if(costs.begin(), costs.end(), [](SpellPowerCost const& cost) { return cost.Power == POWER_MANA; }); if (m != costs.end()) mana += m->Amount; } diff --git a/src/server/game/Spells/SpellHistory.cpp b/src/server/game/Spells/SpellHistory.cpp index dee766daff3..e614709b10c 100644 --- a/src/server/game/Spells/SpellHistory.cpp +++ b/src/server/game/Spells/SpellHistory.cpp @@ -17,9 +17,11 @@ #include "SpellHistory.h" #include "DatabaseEnv.h" +#include "ObjectMgr.h" #include "Pet.h" #include "PetPackets.h" #include "Player.h" +#include "Spell.h" #include "SpellInfo.h" #include "SpellPackets.h" #include "World.h" diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index 4a3aa150bdb..8ea71d76484 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -16,18 +16,20 @@ */ #include "SpellInfo.h" -#include "Log.h" -#include "SpellAuraDefines.h" -#include "SpellAuraEffects.h" -#include "SpellMgr.h" -#include "Spell.h" +#include "Battleground.h" #include "ConditionMgr.h" +#include "Corpse.h" #include "GameTables.h" +#include "InstanceScript.h" +#include "Log.h" +#include "ObjectAccessor.h" +#include "Pet.h" #include "Player.h" -#include "Battleground.h" +#include "Random.h" +#include "Spell.h" +#include "SpellAuraEffects.h" +#include "SpellMgr.h" #include "Vehicle.h" -#include "Pet.h" -#include "InstanceScript.h" uint32 GetTargetFlagMask(SpellTargetObjectTypes objType) { @@ -2570,9 +2572,9 @@ uint32 SpellInfo::GetRecoveryTime() const return RecoveryTime > CategoryRecoveryTime ? RecoveryTime : CategoryRecoveryTime; } -std::vector<SpellInfo::CostData> SpellInfo::CalcPowerCost(Unit const* caster, SpellSchoolMask schoolMask) const +std::vector<SpellPowerCost> SpellInfo::CalcPowerCost(Unit const* caster, SpellSchoolMask schoolMask) const { - std::vector<CostData> costs; + std::vector<SpellPowerCost> costs; auto collector = [this, caster, schoolMask, &costs](std::vector<SpellPowerEntry const*> const& powers) { costs.reserve(powers.size()); @@ -2596,7 +2598,7 @@ std::vector<SpellInfo::CostData> SpellInfo::CalcPowerCost(Unit const* caster, Sp // Else drain all power if (power->PowerType < MAX_POWERS) { - CostData cost; + SpellPowerCost cost; cost.Power = Powers(power->PowerType); cost.Amount = caster->GetPower(cost.Power); costs.push_back(cost); @@ -2713,7 +2715,7 @@ std::vector<SpellInfo::CostData> SpellInfo::CalcPowerCost(Unit const* caster, Sp } bool found = false; - for (CostData& cost : costs) + for (SpellPowerCost& cost : costs) { if (cost.Power == Powers(power->PowerType)) { @@ -2724,7 +2726,7 @@ std::vector<SpellInfo::CostData> SpellInfo::CalcPowerCost(Unit const* caster, Sp if (!found) { - CostData cost; + SpellPowerCost cost; cost.Power = Powers(power->PowerType); cost.Amount = powerCost; costs.push_back(cost); @@ -2733,7 +2735,7 @@ std::vector<SpellInfo::CostData> SpellInfo::CalcPowerCost(Unit const* caster, Sp if (healthCost > 0) { - CostData cost; + SpellPowerCost cost; cost.Power = POWER_HEALTH; cost.Amount = healthCost; costs.push_back(cost); @@ -2746,7 +2748,7 @@ std::vector<SpellInfo::CostData> SpellInfo::CalcPowerCost(Unit const* caster, Sp collector(sDB2Manager.GetSpellPowers(Id, caster->GetMap()->GetDifficultyID())); // POWER_RUNES is handled by SpellRuneCost.db2, and cost.Amount is always 0 (see Spell::TakeRunePower) - costs.erase(std::remove_if(costs.begin(), costs.end(), [](CostData const& cost) { return cost.Power != POWER_RUNES && cost.Amount <= 0; }), costs.end()); + costs.erase(std::remove_if(costs.begin(), costs.end(), [](SpellPowerCost const& cost) { return cost.Power != POWER_RUNES && cost.Amount <= 0; }), costs.end()); return costs; } diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h index 752cd908eea..818b7d5e901 100644 --- a/src/server/game/Spells/SpellInfo.h +++ b/src/server/game/Spells/SpellInfo.h @@ -36,7 +36,7 @@ struct SpellModifier; struct SpellTargetPosition; struct Condition; -enum SpellCastTargetFlags +enum SpellCastTargetFlags : uint32 { TARGET_FLAG_NONE = 0x00000000, TARGET_FLAG_UNUSED_1 = 0x00000001, // not used @@ -93,7 +93,7 @@ enum SpellTargetReferenceTypes TARGET_REFERENCE_TYPE_DEST }; -enum SpellTargetObjectTypes +enum SpellTargetObjectTypes : uint8 { TARGET_OBJECT_TYPE_NONE = 0, TARGET_OBJECT_TYPE_SRC, @@ -109,7 +109,7 @@ enum SpellTargetObjectTypes TARGET_OBJECT_TYPE_CORPSE_ALLY }; -enum SpellTargetCheckTypes +enum SpellTargetCheckTypes : uint8 { TARGET_CHECK_DEFAULT, TARGET_CHECK_ENTRY, @@ -320,6 +320,12 @@ typedef std::vector<AuraEffect*> AuraEffectVector; struct SpellInfoLoadHelper; +struct SpellPowerCost +{ + Powers Power; + int32 Amount; +}; + class TC_GAME_API SpellInfo { public: @@ -513,13 +519,7 @@ public: uint32 CalcCastTime(uint8 level = 0, Spell* spell = NULL) const; uint32 GetRecoveryTime() const; - struct CostData - { - Powers Power; - int32 Amount; - }; - - std::vector<CostData> CalcPowerCost(Unit const* caster, SpellSchoolMask schoolMask) const; + std::vector<SpellPowerCost> CalcPowerCost(Unit const* caster, SpellSchoolMask schoolMask) const; float CalcProcPPM(Unit* caster, int32 itemLevel) const; |
