Core: header cleanup, split realmlist, boost compatibility, cotire, remove stormlib/zlib and stormlib/bzip2 and instead use dep sources

This commit is contained in:
ariel- committed 2018-03-28 04:41:59 -03:00
1 parent 7fff6c424f
commit 5ff847159c
1243 files changed
+29780 -36517

No files matched your search

+190 -121
View File
@@ -16,48 +16,49 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Common.h"
#include "DatabaseEnv.h"
#include "WorldPacket.h"
#include "WorldSession.h"
#include "GameTime.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "Opcodes.h"
#include "Log.h"
#include "UpdateMask.h"
#include "World.h"
#include "ObjectMgr.h"
#include "SpellMgr.h"
#include "Player.h"
#include "Pet.h"
#include "Unit.h"
#include "Spell.h"
#include "DynamicObject.h"
#include "Guild.h"
#include "UpdateData.h"
#include "ObjectAccessor.h"
#include "CellImpl.h"
#include "SharedDefines.h"
#include "LootMgr.h"
#include "VMapFactory.h"
#include "Battleground.h"
#include "Util.h"
#include "TemporarySummon.h"
#include "Vehicle.h"
#include "SpellAuraEffects.h"
#include "ScriptMgr.h"
#include "ConditionMgr.h"
#include "DisableMgr.h"
#include "SpellScript.h"
#include "InstanceScript.h"
#include "SpellInfo.h"
#include "SpellHistory.h"
#include "DB2Stores.h"
#include "Battlefield.h"
#include "BattlefieldMgr.h"
#include "TradeData.h"
#include "Battleground.h"
#include "CellImpl.h"
#include "Common.h"
#include "DatabaseEnv.h"
#include "DBCStores.h"
#include "DB2Stores.h"
#include "DisableMgr.h"
#include "DynamicObject.h"
#include "GameObjectAI.h"
#include "GameTime.h"
#include "GridNotifiersImpl.h"
#include "Guild.h"
#include "InstanceScript.h"
#include "Item.h"
#include "Log.h"
#include "LootMgr.h"
#include "ObjectAccessor.h"
#include "ObjectMgr.h"
#include "Opcodes.h"
#include "PathGenerator.h"
#include "Pet.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "SharedDefines.h"
#include "SpellAuraEffects.h"
#include "SpellHistory.h"
#include "SpellInfo.h"
#include "SpellMgr.h"
#include "SpellScript.h"
#include "TemporarySummon.h"
#include "TradeData.h"
#include "Unit.h"
#include "UpdateData.h"
#include "UpdateMask.h"
#include "Util.h"
#include "Vehicle.h"
#include "VMapFactory.h"
#include "World.h"
#include "WorldPacket.h"
#include "WorldSession.h"
extern pEffect SpellEffects[TOTAL_SPELL_EFFECTS];
@@ -111,8 +112,8 @@ void SpellDestination::RelocateOffset(Position const& offset)
SpellCastTargets::SpellCastTargets() : m_elevation(0), m_speed(0), m_strTarget()
{
m_objectTarget = NULL;
m_itemTarget = NULL;
m_objectTarget = nullptr;
m_itemTarget = nullptr;
m_itemTargetEntry = 0;
@@ -246,7 +247,7 @@ Unit* SpellCastTargets::GetUnitTarget() const
if (m_objectTarget)
return m_objectTarget->ToUnit();
return NULL;
return nullptr;
}
void SpellCastTargets::SetUnitTarget(Unit* target)
@@ -272,7 +273,7 @@ GameObject* SpellCastTargets::GetGOTarget() const
if (m_objectTarget)
return m_objectTarget->ToGameObject();
return NULL;
return nullptr;
}
void SpellCastTargets::SetGOTarget(GameObject* target)
@@ -298,7 +299,7 @@ Corpse* SpellCastTargets::GetCorpseTarget() const
if (m_objectTarget)
return m_objectTarget->ToCorpse();
return NULL;
return nullptr;
}
WorldObject* SpellCastTargets::GetObjectTarget() const
@@ -313,7 +314,7 @@ ObjectGuid SpellCastTargets::GetObjectTargetGUID() const
void SpellCastTargets::RemoveObjectTarget()
{
m_objectTarget = NULL;
m_objectTarget = nullptr;
m_objectTargetGUID.Clear();
m_targetMask &= ~(TARGET_FLAG_UNIT_MASK | TARGET_FLAG_CORPSE_MASK | TARGET_FLAG_GAMEOBJECT_MASK);
}
@@ -443,11 +444,21 @@ 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 ? ((m_objectTargetGUID == caster->GetGUID()) ? caster : ObjectAccessor::GetWorldObject(*caster, m_objectTargetGUID)) : NULL;
m_objectTarget = m_objectTargetGUID ? ((m_objectTargetGUID == caster->GetGUID()) ? caster : ObjectAccessor::GetWorldObject(*caster, m_objectTargetGUID)) : nullptr;
m_itemTarget = NULL;
m_itemTarget = nullptr;
if (caster->GetTypeId() == TYPEID_PLAYER)
{
Player* player = caster->ToPlayer();
@@ -513,14 +524,28 @@ SpellValue::SpellValue(SpellInfo const* proto)
AuraStackAmount = 1;
}
class TC_GAME_API SpellEvent : public BasicEvent
{
public:
SpellEvent(Spell* spell);
~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(sSpellMgr->GetSpellForDifficultyFromSpell(info, caster)),
m_caster((info->HasAttribute(SPELL_ATTR6_CAST_BY_CHARMER) && caster->GetCharmerOrOwner()) ? caster->GetCharmerOrOwner() : caster)
, m_spellValue(new SpellValue(m_spellInfo)), m_preGeneratedPath(PathGenerator(m_caster))
, m_spellValue(new SpellValue(m_spellInfo))
{
m_customError = SPELL_CUSTOM_ERROR_NONE;
m_skipCheck = skipCheck;
m_selfContainer = NULL;
m_selfContainer = nullptr;
m_referencedFromCurrentSpell = false;
m_executedCurrently = false;
m_needComboPoints = m_spellInfo->NeedsComboPoints();
@@ -572,7 +597,7 @@ m_caster((info->HasAttribute(SPELL_ATTR6_CAST_BY_CHARMER) && caster->GetCharmerO
{
m_originalCaster = ObjectAccessor::GetUnit(*m_caster, m_originalCasterGUID);
if (m_originalCaster && !m_originalCaster->IsInWorld())
m_originalCaster = NULL;
m_originalCaster = nullptr;
}
m_spellState = SPELL_STATE_NULL;
@@ -580,14 +605,14 @@ m_caster((info->HasAttribute(SPELL_ATTR6_CAST_BY_CHARMER) && caster->GetCharmerO
if (info->HasAttribute(SPELL_ATTR4_CAN_CAST_WHILE_CASTING))
_triggeredCastFlags = TriggerCastFlags(uint32(_triggeredCastFlags) | TRIGGERED_IGNORE_CAST_IN_PROGRESS | TRIGGERED_CAST_DIRECTLY);
m_CastItem = NULL;
m_CastItem = nullptr;
m_castItemGUID.Clear();
m_castItemEntry = 0;
unitTarget = NULL;
itemTarget = NULL;
gameObjTarget = NULL;
destTarget = NULL;
unitTarget = nullptr;
itemTarget = nullptr;
gameObjTarget = nullptr;
destTarget = nullptr;
damage = 0;
targetMissInfo = SPELL_MISS_NONE;
effectHandleMode = SPELL_EFFECT_HANDLE_LAUNCH;
@@ -596,12 +621,12 @@ m_caster((info->HasAttribute(SPELL_ATTR6_CAST_BY_CHARMER) && caster->GetCharmerO
m_procAttacker = 0;
m_procVictim = 0;
m_hitMask = 0;
focusObject = NULL;
focusObject = nullptr;
m_cast_count = 0;
m_glyphIndex = 0;
m_preCastSpell = 0;
m_triggeredByAuraSpell = NULL;
m_spellAura = NULL;
m_triggeredByAuraSpell = nullptr;
m_spellAura = nullptr;
//Auto Shot & Shoot (wand)
m_autoRepeat = m_spellInfo->IsAutoRepeatRangedSpell();
@@ -642,7 +667,7 @@ Spell::~Spell()
// Clean the reference to avoid later crash.
// If this error is repeating, we may have to add an ASSERT to better track down how we get into this case.
TC_LOG_ERROR("spells", "SPELL: deleting spell for spell ID %u. However, spell still referenced.", m_spellInfo->Id);
*m_selfContainer = NULL;
*m_selfContainer = nullptr;
}
if (m_caster && m_caster->GetTypeId() == TYPEID_PLAYER)
@@ -677,7 +702,7 @@ void Spell::InitExplicitTargets(SpellCastTargets const& targets)
// try to select correct unit target if not provided by client or by serverside cast
if (neededTargets & (TARGET_FLAG_UNIT_MASK))
{
Unit* unit = NULL;
Unit* unit = nullptr;
// try to use player selection as a target
if (Player* playerCaster = m_caster->ToPlayer())
{
@@ -744,7 +769,7 @@ void Spell::SelectExplicitTargets()
redirect = m_caster->GetMeleeHitRedirectTarget(target, m_spellInfo);
break;
default:
redirect = NULL;
redirect = nullptr;
break;
}
if (redirect && (redirect != target))
@@ -1096,7 +1121,7 @@ void Spell::SelectImplicitNearbyTargets(SpellEffIndex effIndex, SpellImplicitTar
CallScriptObjectTargetSelectHandlers(target, effIndex, targetType);
if (!target)
{
TC_LOG_DEBUG("spells", "Spell::SelectImplicitNearbyTargets: OnObjectTargetSelect script hook for spell Id %u set NULL target, effect %u", m_spellInfo->Id, effIndex);
TC_LOG_DEBUG("spells", "Spell::SelectImplicitNearbyTargets: OnObjectTargetSelect script hook for spell Id %u set nullptr target, effect %u", m_spellInfo->Id, effIndex);
SendCastResult(SPELL_FAILED_BAD_IMPLICIT_TARGETS);
finish(false);
return;
@@ -1187,7 +1212,7 @@ void Spell::SelectImplicitConeTargets(SpellEffIndex effIndex, SpellImplicitTarge
void Spell::SelectImplicitAreaTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType, uint32 effMask)
{
Unit* referer = NULL;
Unit* referer = nullptr;
switch (targetType.GetReferenceType())
{
case TARGET_REFERENCE_TYPE_SRC:
@@ -1219,7 +1244,7 @@ void Spell::SelectImplicitAreaTargets(SpellEffIndex effIndex, SpellImplicitTarge
if (!referer)
return;
Position const* center = NULL;
Position const* center = nullptr;
switch (targetType.GetReferenceType())
{
case TARGET_REFERENCE_TYPE_SRC:
@@ -1447,7 +1472,7 @@ void Spell::SelectImplicitDestDestTargets(SpellEffIndex effIndex, SpellImplicitT
void Spell::SelectImplicitCasterObjectTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType)
{
WorldObject* target = NULL;
WorldObject* target = nullptr;
bool checkIfValid = true;
switch (targetType.GetTarget())
@@ -1516,7 +1541,7 @@ void Spell::SelectImplicitChainTargets(SpellEffIndex effIndex, SpellImplicitTarg
{
uint32 maxTargets = m_spellInfo->Effects[effIndex].ChainTarget;
if (Player* modOwner = m_caster->GetSpellModOwner())
modOwner->ApplySpellMod<SPELLMOD_JUMP_TARGETS>(m_spellInfo->Id, maxTargets, this);
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_JUMP_TARGETS, maxTargets, this);
if (maxTargets > 1)
{
@@ -1738,7 +1763,7 @@ void Spell::SelectEffectTypeImplicitTargets(uint8 effIndex)
if (!targetMask)
return;
WorldObject* target = NULL;
WorldObject* target = nullptr;
switch (m_spellInfo->Effects[effIndex].GetImplicitTargetType())
{
@@ -1851,10 +1876,10 @@ void Spell::SearchTargets(SEARCHER& searcher, uint32 containerMask, Unit* refere
WorldObject* Spell::SearchNearbyTarget(float range, SpellTargetObjectTypes objectType, SpellTargetCheckTypes selectionType, ConditionContainer* condList)
{
WorldObject* target = NULL;
WorldObject* target = nullptr;
uint32 containerTypeMask = GetSearcherTypeMask(objectType, condList);
if (!containerTypeMask)
return NULL;
return nullptr;
Trinity::WorldObjectSpellNearbyTargetCheck check(range, m_caster, m_spellInfo, selectionType, condList);
Trinity::WorldObjectLastSearcher<Trinity::WorldObjectSpellNearbyTargetCheck> searcher(m_caster, target, check, containerTypeMask);
SearchTargets<Trinity::WorldObjectLastSearcher<Trinity::WorldObjectSpellNearbyTargetCheck> > (searcher, containerTypeMask, m_caster, m_caster, range);
@@ -1969,7 +1994,7 @@ void Spell::SearchChainTargets(std::list<WorldObject*>& targets, uint32 chainTar
GameObject* Spell::SearchSpellFocus()
{
GameObject* focus = NULL;
GameObject* focus = nullptr;
Trinity::GameObjectFocusCheck check(m_caster, m_spellInfo->RequiresSpellFocus);
Trinity::GameObjectSearcher<Trinity::GameObjectFocusCheck> searcher(m_caster, focus, check);
SearchTargets<Trinity::GameObjectSearcher<Trinity::GameObjectFocusCheck> > (searcher, GRID_MAP_TYPE_MASK_GAMEOBJECT, m_caster, m_caster, m_caster->GetVisibilityRange());
@@ -2318,7 +2343,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
// can't use default call because of threading, do stuff as fast as possible
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
if (farMask & (1 << i))
HandleEffects(unit, NULL, NULL, i, SPELL_EFFECT_HANDLE_HIT_TARGET);
HandleEffects(unit, nullptr, nullptr, i, SPELL_EFFECT_HANDLE_HIT_TARGET);
return;
}
@@ -2760,7 +2785,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA
for (uint32 effectNumber = 0; effectNumber < MAX_SPELL_EFFECTS; ++effectNumber)
if (effectMask & (1 << effectNumber))
HandleEffects(unit, NULL, NULL, effectNumber, SPELL_EFFECT_HANDLE_HIT_TARGET);
HandleEffects(unit, nullptr, nullptr, effectNumber, SPELL_EFFECT_HANDLE_HIT_TARGET);
return SPELL_MISS_NONE;
}
@@ -2856,7 +2881,7 @@ void Spell::DoAllEffectOnTarget(GOTargetInfo* target)
for (uint32 effectNumber = 0; effectNumber < MAX_SPELL_EFFECTS; ++effectNumber)
if (effectMask & (1 << effectNumber))
HandleEffects(NULL, NULL, go, effectNumber, SPELL_EFFECT_HANDLE_HIT_TARGET);
HandleEffects(nullptr, nullptr, go, effectNumber, SPELL_EFFECT_HANDLE_HIT_TARGET);
if (go->AI())
go->AI()->SpellHit(m_caster, m_spellInfo);
@@ -2876,7 +2901,7 @@ void Spell::DoAllEffectOnTarget(ItemTargetInfo* target)
for (uint32 effectNumber = 0; effectNumber < MAX_SPELL_EFFECTS; ++effectNumber)
if (effectMask & (1 << effectNumber))
HandleEffects(NULL, target->item, NULL, effectNumber, SPELL_EFFECT_HANDLE_HIT_TARGET);
HandleEffects(nullptr, target->item, nullptr, effectNumber, SPELL_EFFECT_HANDLE_HIT_TARGET);
CallScriptOnHitHandlers();
@@ -2902,7 +2927,7 @@ bool Spell::UpdateChanneledTargetList()
{
range = m_spellInfo->GetMaxRange(m_spellInfo->IsPositive());
if (Player* modOwner = m_caster->GetSpellModOwner())
modOwner->ApplySpellMod<SPELLMOD_RANGE>(m_spellInfo->Id, range, this);
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RANGE, range, this);
// add little tolerance level
range += std::min(MAX_SPELL_RANGE_TOLERANCE, range*0.1f); // 10% but no more than MAX_SPELL_RANGE_TOLERANCE
@@ -3162,7 +3187,7 @@ void Spell::cancel()
SetReferencedFromCurrent(false);
if (m_selfContainer && *m_selfContainer == this)
*m_selfContainer = NULL;
*m_selfContainer = nullptr;
m_caster->RemoveDynObject(m_spellInfo->Id);
if (m_spellInfo->IsChanneled()) // if not channeled then the object for the current cast wasn't summoned yet
@@ -3383,7 +3408,7 @@ void Spell::_cast(bool skipCheck)
// Okay, everything is prepared. Now we need to distinguish between immediate and evented delayed spells
if ((m_spellInfo->Speed > 0.0f && !m_spellInfo->IsChanneled()) || m_spellInfo->HasAttribute(SPELL_ATTR4_UNK4))
{
// Remove used for cast item if need (it can be already NULL after TakeReagents call
// Remove used for cast item if need (it can be already nullptr after TakeReagents call
// in case delayed spell remove item at cast delay start
TakeCastItem();
@@ -3456,7 +3481,7 @@ void Spell::handle_immediate()
// First mod_duration then haste - see Missile Barrage
// Apply duration mod
if (Player* modOwner = m_caster->GetSpellModOwner())
modOwner->ApplySpellMod<SPELLMOD_DURATION>(m_spellInfo->Id, duration);
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration);
// Apply haste mods
m_caster->ModSpellDurationTime(m_spellInfo, duration, this);
@@ -3496,7 +3521,7 @@ void Spell::handle_immediate()
// spell is finished, perform some last features of the spell here
_handle_finish_phase();
// Remove used for cast item if need (it can be already NULL after TakeReagents call
// Remove used for cast item if need (it can be already nullptr after TakeReagents call
TakeCastItem();
// handle ammo consumption for thrown weapons
@@ -3584,7 +3609,7 @@ uint64 Spell::handle_delayed(uint64 t_offset)
void Spell::_handle_immediate_phase()
{
m_spellAura = NULL;
m_spellAura = nullptr;
// handle some immediate features of the spell here
HandleThreatSpells();
@@ -3599,7 +3624,7 @@ void Spell::_handle_immediate_phase()
continue;
// call effect handlers to handle destination hit
HandleEffects(NULL, NULL, NULL, j, SPELL_EFFECT_HANDLE_HIT);
HandleEffects(nullptr, nullptr, nullptr, j, SPELL_EFFECT_HANDLE_HIT);
}
// process items
@@ -4017,7 +4042,7 @@ void Spell::SendPetCastResult(SpellCastResult result)
WorldPacket data(SMSG_PET_CAST_FAILED, 1 + 4 + 1);
WriteCastResultInfo(data, player, m_spellInfo, m_cast_count, result, m_customError);
player->GetSession()->SendPacket(&data);
player->SendDirectMessage(&data);
}
void Spell::SendSpellStart()
@@ -4331,7 +4356,7 @@ void Spell::SendLogExecute()
data.append(*m_effectExecuteData[i]);
delete m_effectExecuteData[i];
m_effectExecuteData[i] = NULL;
m_effectExecuteData[i] = nullptr;
}
m_caster->SendMessageToSet(&data, true);
}
@@ -4538,7 +4563,7 @@ void Spell::SendResurrectRequest(Player* target)
// override delay sent with SMSG_CORPSE_RECLAIM_DELAY, set instant resurrection for spells with this attribute
// 4.2.2 edit : id of the spell used to resurect. (used client-side for Mass Resurect)
data << uint32(m_spellInfo->Id);
target->GetSession()->SendPacket(&data);
target->SendDirectMessage(&data);
}
void Spell::TakeCastItem()
@@ -4601,9 +4626,9 @@ void Spell::TakeCastItem()
// prevent crash at access to deleted m_targets.GetItemTarget
if (m_CastItem == m_targets.GetItemTarget())
m_targets.SetItemTarget(NULL);
m_targets.SetItemTarget(nullptr);
m_CastItem = NULL;
m_CastItem = nullptr;
m_castItemGUID.Clear();
m_castItemEntry = 0;
}
@@ -4626,8 +4651,11 @@ void Spell::TakePower()
if (m_caster->GetTypeId() == TYPEID_PLAYER)
{
if (powerType == POWER_RAGE || powerType == POWER_ENERGY || powerType == POWER_RUNE)
{
if (ObjectGuid targetGUID = m_targets.GetUnitTargetGUID())
for (std::list<TargetInfo>::iterator ihit= m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
{
for (std::list<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
{
if (ihit->targetGUID == targetGUID)
{
if (ihit->missCondition != SPELL_MISS_NONE)
@@ -4635,10 +4663,13 @@ void Spell::TakePower()
hit = false;
//lower spell cost on fail (by talent aura)
if (Player* modOwner = m_caster->ToPlayer()->GetSpellModOwner())
modOwner->ApplySpellMod<SPELLMOD_SPELL_COST_REFUND_ON_FAIL>(m_spellInfo->Id, m_powerCost);
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_SPELL_COST_REFUND_ON_FAIL, m_powerCost);
}
break;
}
}
}
}
}
if (powerType == POWER_RUNE)
@@ -4724,7 +4755,7 @@ SpellCastResult Spell::CheckRuneCost(uint32 runeCostID) const
{
runeCost[i] = src->RuneCost[i];
if (Player* modOwner = m_caster->GetSpellModOwner())
modOwner->ApplySpellMod<SPELLMOD_COST>(m_spellInfo->Id, runeCost[i], const_cast<Spell*>(this));
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_COST, runeCost[i], const_cast<Spell*>(this));
}
runeCost[RUNE_DEATH] = MAX_RUNES; // calculated later
@@ -4764,7 +4795,7 @@ void Spell::TakeRunePower(bool didHit)
{
runeCost[i] = runeCostData->RuneCost[i];
if (Player* modOwner = m_caster->GetSpellModOwner())
modOwner->ApplySpellMod<SPELLMOD_COST>(m_spellInfo->Id, runeCost[i], this);
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_COST, runeCost[i], this);
}
// Let's say we use a skill that requires a Frost rune. This is the order:
@@ -4841,7 +4872,7 @@ void Spell::TakeReagents()
if (m_caster->GetTypeId() != TYPEID_PLAYER)
return;
ItemTemplate const* castItemTemplate = m_CastItem ? m_CastItem->GetTemplate() : NULL;
ItemTemplate const* castItemTemplate = m_CastItem ? m_CastItem->GetTemplate() : nullptr;
// do not take reagents for these item casts
if (castItemTemplate && castItemTemplate->Flags & ITEM_FLAG_NO_REAGENT_COST)
@@ -4873,14 +4904,14 @@ void Spell::TakeReagents()
}
}
m_CastItem = NULL;
m_CastItem = nullptr;
m_castItemGUID.Clear();
m_castItemEntry = 0;
}
// if GetItemTarget is also spell reagent
if (m_targets.GetItemTargetEntry() == itemid)
m_targets.SetItemTarget(NULL);
m_targets.SetItemTarget(nullptr);
p_caster->DestroyItemCount(itemid, itemcount, true);
}
@@ -4966,7 +4997,7 @@ void Spell::HandleHolyPower(Player* caster)
// The spell did hit the target, apply aura cost mods if there are any.
if (hit)
{
modOwner->ApplySpellMod<SPELLMOD_COST>(m_spellInfo->Id, m_powerCost, this);
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_COST, m_powerCost, this);
m_caster->ModifyPower(POWER_HOLY_POWER, -m_powerCost);
}
}
@@ -5141,7 +5172,7 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
ConditionSourceInfo condInfo = ConditionSourceInfo(m_caster, m_targets.GetObjectTarget());
if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_SPELL, m_spellInfo->Id, condInfo))
{
// mLastFailedCondition can be NULL if there was an error processing the condition in Condition::Meets (i.e. wrong data for ConditionTarget or others)
// mLastFailedCondition can be nullptr if there was an error processing the condition in Condition::Meets (i.e. wrong data for ConditionTarget or others)
if (condInfo.mLastFailedCondition && condInfo.mLastFailedCondition->ErrorType)
{
if (condInfo.mLastFailedCondition->ErrorType == SPELL_FAILED_CUSTOM_ERROR)
@@ -5454,26 +5485,27 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
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;
}
@@ -5510,7 +5542,7 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
|| (m_spellInfo->Effects[i].TargetA.GetTarget() == TARGET_GAMEOBJECT_TARGET && !m_targets.GetGOTarget()))
return SPELL_FAILED_BAD_TARGETS;
Item* pTempItem = NULL;
Item* pTempItem = nullptr;
if (m_targets.GetTargetMask() & TARGET_FLAG_TRADE_ITEM)
{
if (TradeData* pTrade = m_caster->ToPlayer()->GetTradeData())
@@ -5610,7 +5642,7 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
{
if (strict) //starting cast, trigger pet stun (cast by pet so it doesn't attack player)
if (Pet* pet = m_caster->ToPlayer()->GetPet())
pet->CastSpell(pet, 32752, true, NULL, NULL, pet->GetGUID());
pet->CastSpell(pet, 32752, true, nullptr, nullptr, pet->GetGUID());
}
else if (!m_spellInfo->HasAttribute(SPELL_ATTR1_DISMISS_PET))
return SPELL_FAILED_ALREADY_HAVE_SUMMON;
@@ -6113,6 +6145,11 @@ SpellCastResult Spell::CheckArenaAndRatedBattlegroundCastRules() const
return SPELL_CAST_OK;
}
int32 Spell::CalculateDamage(uint8 i, Unit const* target) const
{
return m_caster->CalculateSpellDamage(target, m_spellInfo, i, &m_spellValue->EffectBasePoints[i]);
}
bool Spell::CanAutoCast(Unit* target)
{
if (!target)
@@ -6168,6 +6205,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) const
{
// Don't check for instant cast spells
@@ -6257,7 +6306,7 @@ std::pair<float, float> Spell::GetMinMaxRange(bool strict) const
maxRange *= ranged->GetTemplate()->RangedModRange * 0.01f;
if (Player* modOwner = m_caster->GetSpellModOwner())
modOwner->ApplySpellMod<SPELLMOD_RANGE>(m_spellInfo->Id, maxRange, const_cast<Spell*>(this));
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RANGE, maxRange, const_cast<Spell*>(this));
maxRange += rangeMod;
@@ -6786,7 +6835,7 @@ void Spell::Delayed() // only called in DealDamage()
//check pushback reduce
int32 delaytime = 500; // spellcasting delay is normally 500ms
int32 delayReduce = 100; // must be initialized to 100 for percent modifiers
m_caster->ToPlayer()->ApplySpellMod<SPELLMOD_NOT_LOSE_CASTING_TIME>(m_spellInfo->Id, delayReduce, this);
m_caster->ToPlayer()->ApplySpellMod(m_spellInfo->Id, SPELLMOD_NOT_LOSE_CASTING_TIME, delayReduce, this);
delayReduce += m_caster->GetTotalAuraModifier(SPELL_AURA_REDUCE_PUSHBACK) - 100;
if (delayReduce >= 100)
return;
@@ -6824,7 +6873,7 @@ void Spell::DelayedChannel()
int32 delaytime = CalculatePct(duration, 25); // channeling delay is normally 25% of its time per hit
int32 delayReduce = 100; // must be initialized to 100 for percent modifiers
m_caster->ToPlayer()->ApplySpellMod<SPELLMOD_NOT_LOSE_CASTING_TIME>(m_spellInfo->Id, delayReduce, this);
m_caster->ToPlayer()->ApplySpellMod(m_spellInfo->Id, SPELLMOD_NOT_LOSE_CASTING_TIME, delayReduce, this);
delayReduce += m_caster->GetTotalAuraModifier(SPELL_AURA_REDUCE_PUSHBACK) - 100;
if (delayReduce >= 100)
return;
@@ -6861,7 +6910,7 @@ bool Spell::UpdatePointers()
{
m_originalCaster = ObjectAccessor::GetUnit(*m_caster, m_originalCasterGUID);
if (m_originalCaster && !m_originalCaster->IsInWorld())
m_originalCaster = NULL;
m_originalCaster = nullptr;
}
if (m_castItemGUID && m_caster->GetTypeId() == TYPEID_PLAYER)
@@ -6883,7 +6932,7 @@ bool Spell::UpdatePointers()
return true;
// cache last transport
WorldObject* transport = NULL;
WorldObject* transport = nullptr;
// update effect destinations (in case of moved transport dest target)
for (uint8 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
@@ -6939,11 +6988,11 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff, Position const* lo
}
// check for ignore LOS on the effect itself
if (m_spellInfo->HasAttribute(SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) || DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, m_spellInfo->Id, NULL, SPELL_DISABLE_LOS))
if (m_spellInfo->HasAttribute(SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) || DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, m_spellInfo->Id, nullptr, SPELL_DISABLE_LOS))
return true;
// if spell is triggered, need to check for LOS disable on the aura triggering it and inherit that behaviour
if (IsTriggered() && m_triggeredByAuraSpell && (m_triggeredByAuraSpell->HasAttribute(SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) || DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, m_triggeredByAuraSpell->Id, NULL, SPELL_DISABLE_LOS)))
if (IsTriggered() && m_triggeredByAuraSpell && (m_triggeredByAuraSpell->HasAttribute(SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) || DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, m_triggeredByAuraSpell->Id, nullptr, SPELL_DISABLE_LOS)))
return true;
/// @todo shit below shouldn't be here, but it's temporary
@@ -6977,7 +7026,7 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff, Position const* lo
else
{
// Get GO cast coordinates if original caster -> GO
WorldObject* caster = NULL;
WorldObject* caster = nullptr;
if (m_originalCasterGUID.IsGameObject())
caster = m_caster->GetMap()->GetGameObject(m_originalCasterGUID);
if (!caster)
@@ -6992,6 +7041,26 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff, Position const* lo
return true;
}
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::IsProcDisabled() const
{
return (_triggeredCastFlags & TRIGGERED_DISALLOW_PROC_EVENTS) != 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?
@@ -7167,7 +7236,7 @@ void Spell::HandleLaunchPhase()
if (!m_spellInfo->Effects[i].IsEffect())
continue;
HandleEffects(NULL, NULL, NULL, i, SPELL_EFFECT_HANDLE_LAUNCH);
HandleEffects(nullptr, nullptr, nullptr, i, SPELL_EFFECT_HANDLE_LAUNCH);
}
float multiplier[MAX_SPELL_EFFECTS];
@@ -7221,7 +7290,7 @@ void Spell::HandleLaunchPhase()
void Spell::DoAllEffectOnLaunchTarget(TargetInfo& targetInfo, float* multiplier)
{
Unit* unit = NULL;
Unit* unit = nullptr;
// In case spell hit target, do all effect on that target
if (targetInfo.missCondition == SPELL_MISS_NONE)
unit = m_caster->GetGUID() == targetInfo.targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, targetInfo.targetGUID);
@@ -7238,7 +7307,7 @@ void Spell::DoAllEffectOnLaunchTarget(TargetInfo& targetInfo, float* multiplier)
m_damage = 0;
m_healing = 0;
HandleEffects(unit, NULL, NULL, i, SPELL_EFFECT_HANDLE_LAUNCH_TARGET);
HandleEffects(unit, nullptr, nullptr, i, SPELL_EFFECT_HANDLE_LAUNCH_TARGET);
if (m_damage > 0)
{
@@ -7731,7 +7800,7 @@ void Spell::TriggerGlobalCooldown()
{
// gcd modifier auras are applied only to own spells and only players have such mods
if (Player* modOwner = m_caster->GetSpellModOwner())
modOwner->ApplySpellMod<SPELLMOD_GLOBAL_COOLDOWN>(m_spellInfo->Id, gcd, this);
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_GLOBAL_COOLDOWN, gcd, this);
bool isMeleeOrRangedSpell = m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MELEE ||
m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_RANGED ||
@@ -7770,9 +7839,9 @@ WorldObjectSpellTargetCheck::WorldObjectSpellTargetCheck(Unit* caster, Unit* ref
_targetSelectionType(selectionType), _condList(condList)
{
if (condList)
_condSrcInfo = new ConditionSourceInfo(NULL, caster);
_condSrcInfo = new ConditionSourceInfo(nullptr, caster);
else
_condSrcInfo = NULL;
_condSrcInfo = nullptr;
}
WorldObjectSpellTargetCheck::~WorldObjectSpellTargetCheck()
@@ -7893,7 +7962,7 @@ bool WorldObjectSpellConeTargetCheck::operator()(WorldObject* target)
}
WorldObjectSpellTrajTargetCheck::WorldObjectSpellTrajTargetCheck(float range, Position const* position, Unit* caster, SpellInfo const* spellInfo)
: WorldObjectSpellAreaTargetCheck(range, position, caster, caster, spellInfo, TARGET_CHECK_DEFAULT, NULL) { }
: WorldObjectSpellAreaTargetCheck(range, position, caster, caster, spellInfo, TARGET_CHECK_DEFAULT, nullptr) { }
bool WorldObjectSpellTrajTargetCheck::operator()(WorldObject* target)
{