aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjoschiwald <joschiwald@online.de>2013-07-20 21:52:05 +0200
committerjoschiwald <joschiwald@online.de>2013-07-21 01:38:21 +0200
commit380cf5d241cdf9f55899d5c504b426b05be175bc (patch)
treef86aa20413295d809f0f6482129738a02b5b4dfa /src
parent1ac4f0a9c1d6bfd3d0432a76de415feb5349a821 (diff)
Core/Misc: replace (Player*) casts with ToPlayer()
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/CoreAI/PetAI.cpp14
-rw-r--r--src/server/game/AI/CoreAI/TotemAI.cpp18
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedEscortAI.h2
-rw-r--r--src/server/game/Entities/Pet/Pet.cpp4
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp39
-rw-r--r--src/server/game/Grids/Notifiers/GridNotifiers.cpp16
-rw-r--r--src/server/game/Grids/Notifiers/GridNotifiers.h6
-rw-r--r--src/server/game/Handlers/PetHandler.cpp18
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp20
-rw-r--r--src/server/game/Spells/Auras/SpellAuras.cpp2
-rw-r--r--src/server/game/Spells/Spell.cpp100
-rw-r--r--src/server/game/Spells/SpellEffects.cpp109
-rw-r--r--src/server/scripts/Commands/cs_debug.cpp2
-rw-r--r--src/server/scripts/Commands/cs_honor.cpp5
-rw-r--r--src/server/scripts/Commands/cs_misc.cpp12
15 files changed, 185 insertions, 182 deletions
diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp
index 2a13e5c71bf..4d657ec2b2b 100644
--- a/src/server/game/AI/CoreAI/PetAI.cpp
+++ b/src/server/game/AI/CoreAI/PetAI.cpp
@@ -260,15 +260,15 @@ void PetAI::UpdateAI(uint32 diff)
void PetAI::UpdateAllies()
{
- Unit* owner = me->GetCharmerOrOwner();
- Group* group = NULL;
-
- m_updateAlliesTimer = 10*IN_MILLISECONDS; //update friendly targets every 10 seconds, lesser checks increase performance
+ m_updateAlliesTimer = 10 * IN_MILLISECONDS; // update friendly targets every 10 seconds, lesser checks increase performance
+ Unit* owner = me->GetCharmerOrOwner();
if (!owner)
return;
- else if (owner->GetTypeId() == TYPEID_PLAYER)
- group = owner->ToPlayer()->GetGroup();
+
+ Group* group = NULL;
+ if (Player* player = owner->ToPlayer())
+ group = player->GetGroup();
//only pet and owner/not in group->ok
if (m_AllySet.size() == 2 && !group)
@@ -285,7 +285,7 @@ void PetAI::UpdateAllies()
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* Target = itr->GetSource();
- if (!Target || !group->SameSubGroup((Player*)owner, Target))
+ if (!Target || !group->SameSubGroup(owner->ToPlayer(), Target))
continue;
if (Target->GetGUID() == owner->GetGUID())
diff --git a/src/server/game/AI/CoreAI/TotemAI.cpp b/src/server/game/AI/CoreAI/TotemAI.cpp
index d8644c50b35..bc865b8b6aa 100644
--- a/src/server/game/AI/CoreAI/TotemAI.cpp
+++ b/src/server/game/AI/CoreAI/TotemAI.cpp
@@ -98,12 +98,14 @@ void TotemAI::UpdateAI(uint32 /*diff*/)
void TotemAI::AttackStart(Unit* /*victim*/)
{
// Sentry totem sends ping on attack
- if (me->GetEntry() == SENTRY_TOTEM_ENTRY && me->GetOwner()->GetTypeId() == TYPEID_PLAYER)
- {
- WorldPacket data(MSG_MINIMAP_PING, (8+4+4));
- data << me->GetGUID();
- data << me->GetPositionX();
- data << me->GetPositionY();
- ((Player*)me->GetOwner())->GetSession()->SendPacket(&data);
- }
+ if (me->GetEntry() == SENTRY_TOTEM_ENTRY)
+ if (Unit* owner = me->GetOwner())
+ if (Player* player = owner->ToPlayer())
+ {
+ WorldPacket data(MSG_MINIMAP_PING, (8+4+4));
+ data << me->GetGUID();
+ data << me->GetPositionX();
+ data << me->GetPositionY();
+ player->GetSession()->SendPacket(&data);
+ }
}
diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.h b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.h
index 4a350acab2c..919b24a916c 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.h
+++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.h
@@ -92,7 +92,7 @@ struct npc_escortAI : public ScriptedAI
uint64 GetEventStarterGUID() { return m_uiPlayerGUID; }
protected:
- Player* GetPlayerForEscort() { return (Player*)Unit::GetUnit(*me, m_uiPlayerGUID); }
+ Player* GetPlayerForEscort() { return ObjectAccessor::GetPlayer(*me, m_uiPlayerGUID); }
private:
bool AssistPlayerInCombat(Unit* who);
diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp
index 729a5466fe3..4c8d48222e5 100644
--- a/src/server/game/Entities/Pet/Pet.cpp
+++ b/src/server/game/Entities/Pet/Pet.cpp
@@ -372,7 +372,7 @@ void Pet::SavePetToDB(PetSaveMode mode)
if (!IS_PLAYER_GUID(GetOwnerGUID()))
return;
- Player* owner = (Player*)GetOwner();
+ Player* owner = GetOwner();
if (!owner)
return;
@@ -1142,7 +1142,7 @@ void Pet::_LoadSpellCooldowns()
while (result->NextRow());
if (!m_CreatureSpellCooldowns.empty() && GetOwner())
- ((Player*)GetOwner())->GetSession()->SendPacket(&data);
+ GetOwner()->GetSession()->SendPacket(&data);
}
}
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 021b86d4b51..37a2b7db215 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -9264,16 +9264,17 @@ Player* Unit::GetCharmerOrOwnerPlayerOrPlayerItself() const
if (IS_PLAYER_GUID(guid))
return ObjectAccessor::GetPlayer(*this, guid);
- return GetTypeId() == TYPEID_PLAYER ? (Player*)this : NULL;
+ return const_cast<Unit*>(this)->ToPlayer();
}
Player* Unit::GetAffectingPlayer() const
{
if (!GetCharmerOrOwnerGUID())
- return GetTypeId() == TYPEID_PLAYER ? (Player*)this : NULL;
+ return const_cast<Unit*>(this)->ToPlayer();
if (Unit* owner = GetCharmerOrOwner())
return owner->GetCharmerOrOwnerPlayerOrPlayerItself();
+
return NULL;
}
@@ -14386,13 +14387,14 @@ uint64 Unit::GetCharmerOrOwnerOrOwnGUID() const
Player* Unit::GetSpellModOwner() const
{
- if (GetTypeId() == TYPEID_PLAYER)
- return (Player*)this;
+ if (Player* player = const_cast<Unit*>(this)->ToPlayer())
+ return player;
+
if (ToCreature()->IsPet() || ToCreature()->IsTotem())
{
- Unit* owner = GetOwner();
- if (owner && owner->GetTypeId() == TYPEID_PLAYER)
- return (Player*)owner;
+ if (Unit* owner = GetOwner())
+ if (Player* player = owner->ToPlayer())
+ return player;
}
return NULL;
}
@@ -14904,7 +14906,7 @@ Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget, uint32 spell_id)
if (GetTypeId() != TYPEID_PLAYER)
return NULL;
- Pet* pet = new Pet((Player*)this, HUNTER_PET);
+ Pet* pet = new Pet(ToPlayer(), HUNTER_PET);
if (!pet->CreateBaseAtCreature(creatureTarget))
{
@@ -14928,7 +14930,7 @@ Pet* Unit::CreateTamedPetFrom(uint32 creatureEntry, uint32 spell_id)
if (!creatureInfo)
return NULL;
- Pet* pet = new Pet((Player*)this, HUNTER_PET);
+ Pet* pet = new Pet(ToPlayer(), HUNTER_PET);
if (!pet->CreateBaseAtCreatureInfo(creatureInfo, this) || !InitTamedPet(pet, getLevel(), spell_id))
{
@@ -15404,8 +15406,8 @@ void Unit::Kill(Unit* victim, bool durabilityLoss)
{
if (Battleground* bg = player->GetBattleground())
{
- if (victim->GetTypeId() == TYPEID_PLAYER)
- bg->HandleKillPlayer((Player*)victim, player);
+ if (Player* playerVictim = victim->ToPlayer())
+ bg->HandleKillPlayer(playerVictim, player);
else
bg->HandleKillUnit(victim->ToCreature(), player);
}
@@ -16368,14 +16370,15 @@ void Unit::UpdateObjectVisibility(bool forced)
void Unit::KnockbackFrom(float x, float y, float speedXY, float speedZ)
{
- Player* player = NULL;
- if (GetTypeId() == TYPEID_PLAYER)
- player = (Player*)this;
- else if (Unit* charmer = GetCharmer())
+ Player* player = ToPlayer();
+ if (!player)
{
- player = charmer->ToPlayer();
- if (player && player->m_mover != this)
- player = NULL;
+ if (Unit* charmer = GetCharmer())
+ {
+ player = charmer->ToPlayer();
+ if (player && player->m_mover != this)
+ player = NULL;
+ }
}
if (!player)
diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.cpp b/src/server/game/Grids/Notifiers/GridNotifiers.cpp
index e717389e919..b8ab75f213b 100644
--- a/src/server/game/Grids/Notifiers/GridNotifiers.cpp
+++ b/src/server/game/Grids/Notifiers/GridNotifiers.cpp
@@ -106,10 +106,10 @@ void VisibleChangesNotifier::Visit(CreatureMapType &m)
void VisibleChangesNotifier::Visit(DynamicObjectMapType &m)
{
for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
- if (IS_PLAYER_GUID(iter->GetSource()->GetCasterGUID()))
- if (Player* caster = (Player*)iter->GetSource()->GetCaster())
- if (caster->m_seer == iter->GetSource())
- caster->UpdateVisibilityOf(&i_object);
+ if (Unit* caster = iter->GetSource()->GetCaster())
+ if (Player* player = caster->ToPlayer())
+ if (player->m_seer == iter->GetSource())
+ player->UpdateVisibilityOf(&i_object);
}
inline void CreatureUnitRelocationWorker(Creature* c, Unit* u)
@@ -299,12 +299,12 @@ void MessageDistDeliverer::Visit(DynamicObjectMapType &m)
if (target->GetExactDist2dSq(i_source) > i_distSq)
continue;
- if (IS_PLAYER_GUID(target->GetCasterGUID()))
+ if (Unit* caster = target->GetCaster())
{
// Send packet back to the caster if the caster has vision of dynamic object
- Player* caster = (Player*)target->GetCaster();
- if (caster && caster->m_seer == target)
- SendPacket(caster);
+ Player* player = caster->ToPlayer();
+ if (player && player->m_seer == target)
+ SendPacket(player);
}
}
}
diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h
index f9d179795bc..0addcfc087c 100644
--- a/src/server/game/Grids/Notifiers/GridNotifiers.h
+++ b/src/server/game/Grids/Notifiers/GridNotifiers.h
@@ -130,10 +130,14 @@ namespace Trinity
Player const* skipped_receiver;
MessageDistDeliverer(WorldObject* src, WorldPacket* msg, float dist, bool own_team_only = false, Player const* skipped = NULL)
: i_source(src), i_message(msg), i_phaseMask(src->GetPhaseMask()), i_distSq(dist * dist)
- , team((own_team_only && src->GetTypeId() == TYPEID_PLAYER) ? ((Player*)src)->GetTeam() : 0)
+ , team(0)
, skipped_receiver(skipped)
{
+ if (own_team_only)
+ if (Player* player = src->ToPlayer())
+ team = player->GetTeam();
}
+
void Visit(PlayerMapType &m);
void Visit(CreatureMapType &m);
void Visit(DynamicObjectMapType &m);
diff --git a/src/server/game/Handlers/PetHandler.cpp b/src/server/game/Handlers/PetHandler.cpp
index 9d210201730..84bdaf4104f 100644
--- a/src/server/game/Handlers/PetHandler.cpp
+++ b/src/server/game/Handlers/PetHandler.cpp
@@ -329,19 +329,19 @@ void WorldSession::HandlePetActionHelper(Unit* pet, uint64 guid1, uint32 spellid
if (unit_target)
{
pet->SetInFront(unit_target);
- if (unit_target->GetTypeId() == TYPEID_PLAYER)
- pet->SendUpdateToPlayer((Player*)unit_target);
+ if (Player* player = unit_target->ToPlayer())
+ pet->SendUpdateToPlayer(player);
}
else if (Unit* unit_target2 = spell->m_targets.GetUnitTarget())
{
pet->SetInFront(unit_target2);
- if (unit_target2->GetTypeId() == TYPEID_PLAYER)
- pet->SendUpdateToPlayer((Player*)unit_target2);
+ if (Player* player = unit_target2->ToPlayer())
+ pet->SendUpdateToPlayer(player);
}
if (Unit* powner = pet->GetCharmerOrOwner())
- if (powner->GetTypeId() == TYPEID_PLAYER)
- pet->SendUpdateToPlayer(powner->ToPlayer());
+ if (Player* player = powner->ToPlayer())
+ pet->SendUpdateToPlayer(player);
result = SPELL_CAST_OK;
}
@@ -620,9 +620,9 @@ void WorldSession::HandlePetRename(WorldPacket& recvData)
pet->SetName(name);
- Unit* owner = pet->GetOwner();
- if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && owner->ToPlayer()->GetGroup())
- owner->ToPlayer()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_NAME);
+ Player* owner = pet->GetOwner();
+ if (owner && owner->GetGroup())
+ owner->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_NAME);
pet->RemoveByteFlag(UNIT_FIELD_BYTES_2, 2, UNIT_CAN_BE_RENAMED);
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index a361d54bbc8..20b6e67c5db 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -4999,20 +4999,19 @@ void AuraEffect::HandleForceReaction(AuraApplication const* aurApp, uint8 mode,
Unit* target = aurApp->GetTarget();
- if (target->GetTypeId() != TYPEID_PLAYER)
+ Player* player = target->ToPlayer();
+ if (!player)
return;
- Player* player = (Player*)target;
-
- uint32 faction_id = GetMiscValue();
- ReputationRank faction_rank = ReputationRank(m_amount);
+ uint32 factionId = GetMiscValue();
+ ReputationRank factionRank = ReputationRank(m_amount);
- player->GetReputationMgr().ApplyForceReaction(faction_id, faction_rank, apply);
+ player->GetReputationMgr().ApplyForceReaction(factionId, factionRank, apply);
player->GetReputationMgr().SendForceReactions();
// stop fighting if at apply forced rank friendly or at remove real rank friendly
- if ((apply && faction_rank >= REP_FRIENDLY) || (!apply && player->GetReputationRank(faction_id) >= REP_FRIENDLY))
- player->StopAttackFaction(faction_id);
+ if ((apply && factionRank >= REP_FRIENDLY) || (!apply && player->GetReputationRank(factionId) >= REP_FRIENDLY))
+ player->StopAttackFaction(factionId);
}
void AuraEffect::HandleAuraEmpathy(AuraApplication const* aurApp, uint8 mode, bool apply) const
@@ -5078,11 +5077,10 @@ void AuraEffect::HandleAuraConvertRune(AuraApplication const* aurApp, uint8 mode
Unit* target = aurApp->GetTarget();
- if (target->GetTypeId() != TYPEID_PLAYER)
+ Player* player = target->ToPlayer();
+ if (!player)
return;
- Player* player = (Player*)target;
-
if (player->getClass() != CLASS_DEATH_KNIGHT)
return;
diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp
index 32ccaf028ad..2acf9087c06 100644
--- a/src/server/game/Spells/Auras/SpellAuras.cpp
+++ b/src/server/game/Spells/Auras/SpellAuras.cpp
@@ -1071,7 +1071,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b
for (SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
{
// some auras remove at aura remove
- if (!itr->second->IsFitToRequirements((Player*)target, zone, area))
+ if (!itr->second->IsFitToRequirements(target->ToPlayer(), zone, area))
target->RemoveAurasDueToSpell(itr->second->spellId);
// some auras applied at aura apply
else if (itr->second->autocast)
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index a26c0356907..8976305445f 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -3542,11 +3542,10 @@ void Spell::_handle_finish_phase()
void Spell::SendSpellCooldown()
{
- if (m_caster->GetTypeId() != TYPEID_PLAYER)
+ Player* _player = m_caster->ToPlayer();
+ if (!_player)
return;
- Player* _player = (Player*)m_caster;
-
// mana/health/etc potions, disabled by client (until combat out as declarate)
if (m_CastItem && m_CastItem->IsPotion())
{
@@ -4343,7 +4342,11 @@ void Spell::SendResurrectRequest(Player* target)
void Spell::TakeCastItem()
{
- if (!m_CastItem || m_caster->GetTypeId() != TYPEID_PLAYER)
+ if (!m_CastItem)
+ return;
+
+ Player* player = m_caster->ToPlayer();
+ if (!player)
return;
// not remove cast item at triggered spell (equipping, weapon damage, etc)
@@ -4381,7 +4384,7 @@ void Spell::TakeCastItem()
(charges > 0) ? --charges : ++charges; // abs(charges) less at 1 after use
if (proto->Stackable == 1)
m_CastItem->SetSpellCharges(i, charges);
- m_CastItem->SetState(ITEM_CHANGED, (Player*)m_caster);
+ m_CastItem->SetState(ITEM_CHANGED, player);
}
// all charges used
@@ -4501,16 +4504,14 @@ SpellCastResult Spell::CheckRuneCost(uint32 runeCostID)
if (m_spellInfo->PowerType != POWER_RUNE || !runeCostID)
return SPELL_CAST_OK;
- if (m_caster->GetTypeId() != TYPEID_PLAYER)
+ Player* player = m_caster->ToPlayer();
+ if (!player)
return SPELL_CAST_OK;
- Player* player = (Player*)m_caster;
-
if (player->getClass() != CLASS_DEATH_KNIGHT)
return SPELL_CAST_OK;
SpellRuneCostEntry const* src = sSpellRuneCostStore.LookupEntry(runeCostID);
-
if (!src)
return SPELL_CAST_OK;
@@ -5851,11 +5852,10 @@ SpellCastResult Spell::CheckPower()
SpellCastResult Spell::CheckItems()
{
- if (m_caster->GetTypeId() != TYPEID_PLAYER)
+ Player* player = m_caster->ToPlayer();
+ if (!player)
return SPELL_CAST_OK;
- Player* p_caster = (Player*)m_caster;
-
if (!m_CastItem)
{
if (m_castItemGUID)
@@ -5864,14 +5864,14 @@ SpellCastResult Spell::CheckItems()
else
{
uint32 itemid = m_CastItem->GetEntry();
- if (!p_caster->HasItemCount(itemid))
+ if (!player->HasItemCount(itemid))
return SPELL_FAILED_ITEM_NOT_READY;
ItemTemplate const* proto = m_CastItem->GetTemplate();
if (!proto)
return SPELL_FAILED_ITEM_NOT_READY;
- for (int i = 0; i < MAX_ITEM_SPELLS; ++i)
+ for (uint8 i = 0; i < MAX_ITEM_SPELLS; ++i)
if (proto->Spells[i].SpellCharges)
if (m_CastItem->GetSpellCharges(i) == 0)
return SPELL_FAILED_NO_CHARGES_REMAIN;
@@ -5881,10 +5881,10 @@ SpellCastResult Spell::CheckItems()
{
// such items should only fail if there is no suitable effect at all - see Rejuvenation Potions for example
SpellCastResult failReason = SPELL_CAST_OK;
- for (int i = 0; i < MAX_SPELL_EFFECTS; i++)
+ for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
- // skip check, pet not required like checks, and for TARGET_UNIT_PET m_targets.GetUnitTarget() is not the real target but the caster
- if (m_spellInfo->Effects[i].TargetA.GetTarget() == TARGET_UNIT_PET)
+ // skip check, pet not required like checks, and for TARGET_UNIT_PET m_targets.GetUnitTarget() is not the real target but the caster
+ if (m_spellInfo->Effects[i].TargetA.GetTarget() == TARGET_UNIT_PET)
continue;
if (m_spellInfo->Effects[i].Effect == SPELL_EFFECT_HEAL)
@@ -5931,9 +5931,6 @@ SpellCastResult Spell::CheckItems()
// check target item
if (m_targets.GetItemTargetGUID())
{
- if (m_caster->GetTypeId() != TYPEID_PLAYER)
- return SPELL_FAILED_BAD_TARGETS;
-
if (!m_targets.GetItemTarget())
return SPELL_FAILED_ITEM_GONE;
@@ -5944,7 +5941,7 @@ SpellCastResult Spell::CheckItems()
else
{
if (!(_triggeredCastFlags & TRIGGERED_IGNORE_EQUIPPED_ITEM_REQUIREMENT))
- if (m_caster->GetTypeId() == TYPEID_PLAYER && !m_caster->ToPlayer()->HasItemFitToSpellRequirements(m_spellInfo))
+ if (!player->HasItemFitToSpellRequirements(m_spellInfo))
return SPELL_FAILED_EQUIPPED_ITEM_CLASS;
}
@@ -5971,7 +5968,7 @@ SpellCastResult Spell::CheckItems()
// do not take reagents for these item casts
if (!(m_CastItem && m_CastItem->GetTemplate()->Flags & ITEM_PROTO_FLAG_TRIGGERED_CAST))
{
- bool checkReagents = !(_triggeredCastFlags & TRIGGERED_IGNORE_POWER_AND_REAGENT_COST) && !p_caster->CanNoReagentCast(m_spellInfo);
+ bool checkReagents = !(_triggeredCastFlags & TRIGGERED_IGNORE_POWER_AND_REAGENT_COST) && !player->CanNoReagentCast(m_spellInfo);
// Not own traded item (in trader trade slot) requires reagents even if triggered spell
if (!checkReagents)
if (Item* targetItem = m_targets.GetItemTarget())
@@ -5995,7 +5992,7 @@ SpellCastResult Spell::CheckItems()
ItemTemplate const* proto = m_CastItem->GetTemplate();
if (!proto)
return SPELL_FAILED_ITEM_NOT_READY;
- for (int s=0; s < MAX_ITEM_PROTO_SPELLS; ++s)
+ for (uint8 s = 0; s < MAX_ITEM_PROTO_SPELLS; ++s)
{
// CastItem will be used up and does not count as reagent
int32 charges = m_CastItem->GetSpellCharges(s);
@@ -6006,35 +6003,36 @@ SpellCastResult Spell::CheckItems()
}
}
}
- if (!p_caster->HasItemCount(itemid, itemcount))
+ if (!player->HasItemCount(itemid, itemcount))
return SPELL_FAILED_REAGENTS;
}
}
// check totem-item requirements (items presence in inventory)
uint32 totems = 2;
- for (int i = 0; i < 2; ++i)
+ for (uint8 i = 0; i < 2; ++i)
{
if (m_spellInfo->Totem[i] != 0)
{
- if (p_caster->HasItemCount(m_spellInfo->Totem[i]))
+ if (player->HasItemCount(m_spellInfo->Totem[i]))
{
totems -= 1;
continue;
}
- }else
- totems -= 1;
+ }
+ else
+ totems -= 1;
}
if (totems != 0)
return SPELL_FAILED_TOTEMS; //0x7C
// Check items for TotemCategory (items presence in inventory)
uint32 TotemCategory = 2;
- for (int i= 0; i < 2; ++i)
+ for (uint8 i = 0; i < 2; ++i)
{
if (m_spellInfo->TotemCategory[i] != 0)
{
- if (p_caster->HasItemTotemCategory(m_spellInfo->TotemCategory[i]))
+ if (player->HasItemTotemCategory(m_spellInfo->TotemCategory[i]))
{
TotemCategory -= 1;
continue;
@@ -6048,7 +6046,7 @@ SpellCastResult Spell::CheckItems()
}
// special checks for spell effects
- for (int i = 0; i < MAX_SPELL_EFFECTS; i++)
+ for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
switch (m_spellInfo->Effects[i].Effect)
{
@@ -6058,24 +6056,24 @@ SpellCastResult Spell::CheckItems()
if (!IsTriggered() && m_spellInfo->Effects[i].ItemType)
{
ItemPosCountVec dest;
- InventoryResult msg = p_caster->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, m_spellInfo->Effects[i].ItemType, 1);
+ InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, m_spellInfo->Effects[i].ItemType, 1);
if (msg != EQUIP_ERR_OK)
{
ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(m_spellInfo->Effects[i].ItemType);
/// @todo Needs review
if (pProto && !(pProto->ItemLimitCategory))
{
- p_caster->SendEquipError(msg, NULL, NULL, m_spellInfo->Effects[i].ItemType);
+ player->SendEquipError(msg, NULL, NULL, m_spellInfo->Effects[i].ItemType);
return SPELL_FAILED_DONT_REPORT;
}
else
{
if (!(m_spellInfo->SpellFamilyName == SPELLFAMILY_MAGE && (m_spellInfo->SpellFamilyFlags[0] & 0x40000000)))
return SPELL_FAILED_TOO_MANY_OF_ITEM;
- else if (!(p_caster->HasItemCount(m_spellInfo->Effects[i].ItemType)))
+ else if (!(player->HasItemCount(m_spellInfo->Effects[i].ItemType)))
return SPELL_FAILED_TOO_MANY_OF_ITEM;
else
- p_caster->CastSpell(m_caster, m_spellInfo->Effects[EFFECT_1].CalcValue(), false); // move this to anywhere
+ player->CastSpell(m_caster, m_spellInfo->Effects[EFFECT_1].CalcValue(), false); // move this to anywhere
return SPELL_FAILED_DONT_REPORT;
}
}
@@ -6093,10 +6091,10 @@ SpellCastResult Spell::CheckItems()
if (m_CastItem && m_CastItem->GetTemplate()->Flags & ITEM_PROTO_FLAG_TRIGGERED_CAST)
return SPELL_FAILED_TOTEM_CATEGORY;
ItemPosCountVec dest;
- InventoryResult msg = p_caster->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, m_spellInfo->Effects[i].ItemType, 1);
+ InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, m_spellInfo->Effects[i].ItemType, 1);
if (msg != EQUIP_ERR_OK)
{
- p_caster->SendEquipError(msg, NULL, NULL, m_spellInfo->Effects[i].ItemType);
+ player->SendEquipError(msg, NULL, NULL, m_spellInfo->Effects[i].ItemType);
return SPELL_FAILED_DONT_REPORT;
}
}
@@ -6177,7 +6175,7 @@ SpellCastResult Spell::CheckItems()
uint32 item_disenchantskilllevel = itemProto->RequiredDisenchantSkill;
if (item_disenchantskilllevel == uint32(-1))
return SPELL_FAILED_CANT_BE_DISENCHANTED;
- if (item_disenchantskilllevel > p_caster->GetSkillValue(SKILL_ENCHANTING))
+ if (item_disenchantskilllevel > player->GetSkillValue(SKILL_ENCHANTING))
return SPELL_FAILED_LOW_CASTLEVEL;
if (item_quality > 4 || item_quality < 2)
return SPELL_FAILED_CANT_BE_DISENCHANTED;
@@ -6199,7 +6197,7 @@ SpellCastResult Spell::CheckItems()
return SPELL_FAILED_CANT_BE_PROSPECTED;
//Check for enough skill in jewelcrafting
uint32 item_prospectingskilllevel = m_targets.GetItemTarget()->GetTemplate()->RequiredSkillRank;
- if (item_prospectingskilllevel >p_caster->GetSkillValue(SKILL_JEWELCRAFTING))
+ if (item_prospectingskilllevel >player->GetSkillValue(SKILL_JEWELCRAFTING))
return SPELL_FAILED_LOW_CASTLEVEL;
//make sure the player has the required ores in inventory
if (m_targets.GetItemTarget()->GetCount() < 5)
@@ -6222,7 +6220,7 @@ SpellCastResult Spell::CheckItems()
return SPELL_FAILED_CANT_BE_MILLED;
//Check for enough skill in inscription
uint32 item_millingskilllevel = m_targets.GetItemTarget()->GetTemplate()->RequiredSkillRank;
- if (item_millingskilllevel >p_caster->GetSkillValue(SKILL_INSCRIPTION))
+ if (item_millingskilllevel > player->GetSkillValue(SKILL_INSCRIPTION))
return SPELL_FAILED_LOW_CASTLEVEL;
//make sure the player has the required herbs in inventory
if (m_targets.GetItemTarget()->GetCount() < 5)
@@ -6236,13 +6234,10 @@ SpellCastResult Spell::CheckItems()
case SPELL_EFFECT_WEAPON_DAMAGE:
case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL:
{
- if (m_caster->GetTypeId() != TYPEID_PLAYER)
- return SPELL_FAILED_TARGET_NOT_PLAYER;
-
if (m_attackType != RANGED_ATTACK)
break;
- Item* pItem = m_caster->ToPlayer()->GetWeaponForAttack(m_attackType);
+ Item* pItem = player->GetWeaponForAttack(m_attackType);
if (!pItem || pItem->IsBroken())
return SPELL_FAILED_EQUIPPED_ITEM;
@@ -6251,15 +6246,15 @@ SpellCastResult Spell::CheckItems()
case ITEM_SUBCLASS_WEAPON_THROWN:
{
uint32 ammo = pItem->GetEntry();
- if (!m_caster->ToPlayer()->HasItemCount(ammo))
+ if (!player->HasItemCount(ammo))
return SPELL_FAILED_NO_AMMO;
- };
- break;
+ break;
+ }
case ITEM_SUBCLASS_WEAPON_GUN:
case ITEM_SUBCLASS_WEAPON_BOW:
case ITEM_SUBCLASS_WEAPON_CROSSBOW:
{
- uint32 ammo = m_caster->ToPlayer()->GetUInt32Value(PLAYER_AMMO_ID);
+ uint32 ammo = player->GetUInt32Value(PLAYER_AMMO_ID);
if (!ammo)
{
// Requires No Ammo
@@ -6292,12 +6287,13 @@ SpellCastResult Spell::CheckItems()
return SPELL_FAILED_NO_AMMO;
}
- if (!m_caster->ToPlayer()->HasItemCount(ammo))
+ if (!player->HasItemCount(ammo))
{
- m_caster->ToPlayer()->SetUInt32Value(PLAYER_AMMO_ID, 0);
+ player->SetUInt32Value(PLAYER_AMMO_ID, 0);
return SPELL_FAILED_NO_AMMO;
}
- }; break;
+ break;
+ }
case ITEM_SUBCLASS_WEAPON_WAND:
break;
default:
@@ -6313,7 +6309,7 @@ SpellCastResult Spell::CheckItems()
if (!pProto)
return SPELL_FAILED_ITEM_AT_MAX_CHARGES;
- if (Item* pitem = p_caster->GetItemByEntry(item_id))
+ if (Item* pitem = player->GetItemByEntry(item_id))
{
for (int x = 0; x < MAX_ITEM_PROTO_SPELLS; ++x)
if (pProto->Spells[x].SpellCharges != 0 && pitem->GetSpellCharges(x) == pProto->Spells[x].SpellCharges)
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 22940c3f930..38d31a89e86 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -562,9 +562,9 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex)
// Eviscerate
else if (m_spellInfo->SpellFamilyFlags[0] & 0x00020000)
{
- if (m_caster->GetTypeId() == TYPEID_PLAYER)
+ if (Player* player = m_caster->ToPlayer())
{
- if (uint32 combo = ((Player*)m_caster)->GetComboPoints())
+ if (uint32 combo = player->GetComboPoints())
{
float ap = m_caster->GetTotalAttackPowerValue(BASE_ATTACK);
damage += irand(int32(ap * combo * 0.03f), int32(ap * combo * 0.07f));
@@ -2722,30 +2722,30 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return;
- if (m_caster->GetTypeId() != TYPEID_PLAYER)
- return;
if (!itemTarget)
return;
- Player* p_caster = (Player*)m_caster;
+ Player* player = m_caster->ToPlayer();
+ if (!player)
+ return;
// Handle vellums
if (itemTarget->IsWeaponVellum() || itemTarget->IsArmorVellum())
{
// destroy one vellum from stack
uint32 count = 1;
- p_caster->DestroyItemCount(itemTarget, count, true);
- unitTarget=p_caster;
+ player->DestroyItemCount(itemTarget, count, true);
+ unitTarget = player;
// and add a scroll
DoCreateItem(effIndex, m_spellInfo->Effects[effIndex].ItemType);
- itemTarget=NULL;
+ itemTarget = NULL;
m_targets.SetItemTarget(NULL);
}
else
{
// do not increase skill if vellum used
if (!(m_CastItem && m_CastItem->GetTemplate()->Flags & ITEM_PROTO_FLAG_TRIGGERED_CAST))
- p_caster->UpdateCraftSkill(m_spellInfo->Id);
+ player->UpdateCraftSkill(m_spellInfo->Id);
uint32 enchant_id = m_spellInfo->Effects[effIndex].MiscValue;
if (!enchant_id)
@@ -2760,10 +2760,10 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex)
if (!item_owner)
return;
- if (item_owner != p_caster && p_caster->GetSession()->HasPermission(RBAC_PERM_LOG_GM_TRADE))
+ if (item_owner != player && player->GetSession()->HasPermission(RBAC_PERM_LOG_GM_TRADE))
{
- sLog->outCommand(p_caster->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)",
- p_caster->GetName().c_str(), p_caster->GetSession()->GetAccountId(),
+ sLog->outCommand(player->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)",
+ player->GetName().c_str(), player->GetSession()->GetAccountId(),
itemTarget->GetTemplate()->Name1.c_str(), itemTarget->GetEntry(),
item_owner->GetName().c_str(), item_owner->GetSession()->GetAccountId());
}
@@ -2786,19 +2786,19 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return;
- if (m_caster->GetTypeId() != TYPEID_PLAYER)
- return;
if (!itemTarget)
return;
- Player* p_caster = (Player*)m_caster;
+ Player* player = m_caster->ToPlayer();
+ if (!player)
+ return;
- uint32 enchant_id = m_spellInfo->Effects[effIndex].MiscValue;
- if (!enchant_id)
+ uint32 enchantId = m_spellInfo->Effects[effIndex].MiscValue;
+ if (!enchantId)
return;
- SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
- if (!pEnchant)
+ SpellItemEnchantmentEntry const* enchant = sSpellItemEnchantmentStore.LookupEntry(enchantId);
+ if (!enchant)
return;
// support only enchantings with add socket in this slot
@@ -2806,7 +2806,7 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex)
bool add_socket = false;
for (uint8 i = 0; i < MAX_ITEM_ENCHANTMENT_EFFECTS; ++i)
{
- if (pEnchant->type[i] == ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET)
+ if (enchant->type[i] == ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET)
{
add_socket = true;
break;
@@ -2825,10 +2825,10 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex)
if (!item_owner)
return;
- if (item_owner != p_caster && p_caster->GetSession()->HasPermission(RBAC_PERM_LOG_GM_TRADE))
+ if (item_owner != player && player->GetSession()->HasPermission(RBAC_PERM_LOG_GM_TRADE))
{
- sLog->outCommand(p_caster->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)",
- p_caster->GetName().c_str(), p_caster->GetSession()->GetAccountId(),
+ sLog->outCommand(player->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)",
+ player->GetName().c_str(), player->GetSession()->GetAccountId(),
itemTarget->GetTemplate()->Name1.c_str(), itemTarget->GetEntry(),
item_owner->GetName().c_str(), item_owner->GetSession()->GetAccountId());
}
@@ -2836,7 +2836,7 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex)
// remove old enchanting before applying new if equipped
item_owner->ApplyEnchantment(itemTarget, PRISMATIC_ENCHANTMENT_SLOT, false);
- itemTarget->SetEnchantment(PRISMATIC_ENCHANTMENT_SLOT, enchant_id, 0, 0, m_caster->GetGUID());
+ itemTarget->SetEnchantment(PRISMATIC_ENCHANTMENT_SLOT, enchantId, 0, 0, m_caster->GetGUID());
// add new enchanting if equipped
item_owner->ApplyEnchantment(itemTarget, PRISMATIC_ENCHANTMENT_SLOT, true);
@@ -2850,11 +2850,10 @@ void Spell::EffectEnchantItemTmp(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return;
- if (m_caster->GetTypeId() != TYPEID_PLAYER)
+ Player* player = m_caster->ToPlayer();
+ if (!player)
return;
- Player* p_caster = (Player*)m_caster;
-
// Rockbiter Weapon apply to both weapon
if (!itemTarget)
return;
@@ -2894,7 +2893,7 @@ void Spell::EffectEnchantItemTmp(SpellEffIndex effIndex)
for (int j = BASE_ATTACK; j <= OFF_ATTACK; ++j)
{
- if (Item* item = p_caster->GetWeaponForAttack(WeaponAttackType(j)))
+ if (Item* item = player->GetWeaponForAttack(WeaponAttackType(j)))
{
if (item->IsFitToSpellRequirements(m_spellInfo))
{
@@ -2959,10 +2958,10 @@ void Spell::EffectEnchantItemTmp(SpellEffIndex effIndex)
if (!item_owner)
return;
- if (item_owner != p_caster && p_caster->GetSession()->HasPermission(RBAC_PERM_LOG_GM_TRADE))
+ if (item_owner != player && player->GetSession()->HasPermission(RBAC_PERM_LOG_GM_TRADE))
{
- sLog->outCommand(p_caster->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(temp): %s (Entry: %d) for player: %s (Account: %u)",
- p_caster->GetName().c_str(), p_caster->GetSession()->GetAccountId(),
+ sLog->outCommand(player->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(temp): %s (Entry: %d) for player: %s (Account: %u)",
+ player->GetName().c_str(), player->GetSession()->GetAccountId(),
itemTarget->GetTemplate()->Name1.c_str(), itemTarget->GetEntry(),
item_owner->GetName().c_str(), item_owner->GetSession()->GetAccountId());
}
@@ -4387,21 +4386,20 @@ void Spell::EffectStuck(SpellEffIndex /*effIndex*/)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
return;
- if (!m_caster || m_caster->GetTypeId() != TYPEID_PLAYER)
- return;
-
if (!sWorld->getBoolConfig(CONFIG_CAST_UNSTUCK))
return;
- Player* target = (Player*)m_caster;
+ Player* player = m_caster->ToPlayer();
+ if (!player)
+ return;
TC_LOG_DEBUG(LOG_FILTER_SPELLS_AURAS, "Spell Effect: Stuck");
- TC_LOG_INFO(LOG_FILTER_SPELLS_AURAS, "Player %s (guid %u) used auto-unstuck future at map %u (%f, %f, %f)", target->GetName().c_str(), target->GetGUIDLow(), m_caster->GetMapId(), m_caster->GetPositionX(), target->GetPositionY(), target->GetPositionZ());
+ TC_LOG_INFO(LOG_FILTER_SPELLS_AURAS, "Player %s (guid %u) used auto-unstuck future at map %u (%f, %f, %f)", player->GetName().c_str(), player->GetGUIDLow(), player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
- if (target->IsInFlight())
+ if (player->IsInFlight())
return;
- target->TeleportTo(target->GetStartPosition(), TELE_TO_SPELL);
+ player->TeleportTo(player->GetStartPosition(), TELE_TO_SPELL);
// homebind location is loaded always
// target->TeleportTo(target->m_homebindMapId, target->m_homebindX, target->m_homebindY, target->m_homebindZ, target->GetOrientation(), (m_caster == m_caster ? TELE_TO_SPELL : 0));
@@ -4409,7 +4407,7 @@ void Spell::EffectStuck(SpellEffIndex /*effIndex*/)
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(8690);
if (!spellInfo)
return;
- Spell spell(target, spellInfo, TRIGGERED_FULL_MASK);
+ Spell spell(player, spellInfo, TRIGGERED_FULL_MASK);
spell.SendSpellCooldown();
}
@@ -4459,10 +4457,12 @@ void Spell::EffectApplyGlyph(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
return;
- if (m_caster->GetTypeId() != TYPEID_PLAYER || m_glyphIndex >= MAX_GLYPH_SLOT_INDEX)
+ if (m_glyphIndex >= MAX_GLYPH_SLOT_INDEX)
return;
- Player* player = (Player*)m_caster;
+ Player* player = m_caster->ToPlayer();
+ if (!player)
+ return;
// glyph sockets level requirement
uint8 minLevel = 0;
@@ -5388,10 +5388,10 @@ void Spell::EffectProspecting(SpellEffIndex /*effIndex*/)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return;
- if (m_caster->GetTypeId() != TYPEID_PLAYER)
+ Player* player = m_caster->ToPlayer();
+ if (!player)
return;
- Player* p_caster = (Player*)m_caster;
if (!itemTarget || !(itemTarget->GetTemplate()->Flags & ITEM_PROTO_FLAG_PROSPECTABLE))
return;
@@ -5400,12 +5400,12 @@ void Spell::EffectProspecting(SpellEffIndex /*effIndex*/)
if (sWorld->getBoolConfig(CONFIG_SKILL_PROSPECTING))
{
- uint32 SkillValue = p_caster->GetPureSkillValue(SKILL_JEWELCRAFTING);
+ uint32 SkillValue = player->GetPureSkillValue(SKILL_JEWELCRAFTING);
uint32 reqSkillValue = itemTarget->GetTemplate()->RequiredSkillRank;
- p_caster->UpdateGatherSkill(SKILL_JEWELCRAFTING, SkillValue, reqSkillValue);
+ player->UpdateGatherSkill(SKILL_JEWELCRAFTING, SkillValue, reqSkillValue);
}
- m_caster->ToPlayer()->SendLoot(itemTarget->GetGUID(), LOOT_PROSPECTING);
+ player->SendLoot(itemTarget->GetGUID(), LOOT_PROSPECTING);
}
void Spell::EffectMilling(SpellEffIndex /*effIndex*/)
@@ -5413,10 +5413,10 @@ void Spell::EffectMilling(SpellEffIndex /*effIndex*/)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return;
- if (m_caster->GetTypeId() != TYPEID_PLAYER)
+ Player* player = m_caster->ToPlayer();
+ if (!player)
return;
- Player* p_caster = (Player*)m_caster;
if (!itemTarget || !(itemTarget->GetTemplate()->Flags & ITEM_PROTO_FLAG_MILLABLE))
return;
@@ -5425,12 +5425,12 @@ void Spell::EffectMilling(SpellEffIndex /*effIndex*/)
if (sWorld->getBoolConfig(CONFIG_SKILL_MILLING))
{
- uint32 SkillValue = p_caster->GetPureSkillValue(SKILL_INSCRIPTION);
+ uint32 SkillValue = player->GetPureSkillValue(SKILL_INSCRIPTION);
uint32 reqSkillValue = itemTarget->GetTemplate()->RequiredSkillRank;
- p_caster->UpdateGatherSkill(SKILL_INSCRIPTION, SkillValue, reqSkillValue);
+ player->UpdateGatherSkill(SKILL_INSCRIPTION, SkillValue, reqSkillValue);
}
- m_caster->ToPlayer()->SendLoot(itemTarget->GetGUID(), LOOT_MILLING);
+ player->SendLoot(itemTarget->GetGUID(), LOOT_MILLING);
}
void Spell::EffectSkill(SpellEffIndex /*effIndex*/)
@@ -5470,10 +5470,13 @@ void Spell::EffectSkinPlayerCorpse(SpellEffIndex /*effIndex*/)
return;
TC_LOG_DEBUG(LOG_FILTER_SPELLS_AURAS, "Effect: SkinPlayerCorpse");
- if ((m_caster->GetTypeId() != TYPEID_PLAYER) || (unitTarget->GetTypeId() != TYPEID_PLAYER) || (unitTarget->IsAlive()))
+
+ Player* player = m_caster->ToPlayer();
+ Player* target = unitTarget->ToPlayer();
+ if (!player || !target || target->IsAlive())
return;
- unitTarget->ToPlayer()->RemovedInsignia((Player*)m_caster);
+ target->RemovedInsignia(player);
}
void Spell::EffectStealBeneficialBuff(SpellEffIndex effIndex)
diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp
index fc7f1fac352..f6ee0faaa31 100644
--- a/src/server/scripts/Commands/cs_debug.cpp
+++ b/src/server/scripts/Commands/cs_debug.cpp
@@ -258,7 +258,7 @@ public:
if (!unit || (unit->GetTypeId() != TYPEID_PLAYER))
player = handler->GetSession()->GetPlayer();
else
- player = (Player*)unit;
+ player = unit->ToPlayer();
if (!unit)
unit = player;
diff --git a/src/server/scripts/Commands/cs_honor.cpp b/src/server/scripts/Commands/cs_honor.cpp
index 9732e2557e9..75c7fcf71e2 100644
--- a/src/server/scripts/Commands/cs_honor.cpp
+++ b/src/server/scripts/Commands/cs_honor.cpp
@@ -90,8 +90,9 @@ public:
}
// check online security
- if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity((Player*)target, 0))
- return false;
+ if (Player* player = target->ToPlayer())
+ if (handler->HasLowerSecurity(player, 0))
+ return false;
handler->GetSession()->GetPlayer()->RewardHonor(target, 1);
return true;
diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp
index 4e1427dabd2..fd7bcaab1d3 100644
--- a/src/server/scripts/Commands/cs_misc.cpp
+++ b/src/server/scripts/Commands/cs_misc.cpp
@@ -655,11 +655,9 @@ public:
return false;
}
- if (target->GetTypeId() == TYPEID_PLAYER)
- {
- if (handler->HasLowerSecurity((Player*)target, 0, false))
+ if (Player* player = target->ToPlayer())
+ if (handler->HasLowerSecurity(player, 0, false))
return false;
- }
if (target->IsAlive())
{
@@ -2227,11 +2225,9 @@ public:
return false;
}
- if (target->GetTypeId() == TYPEID_PLAYER)
- {
- if (handler->HasLowerSecurity((Player*)target, 0, false))
+ if (Player* player = target->ToPlayer())
+ if (handler->HasLowerSecurity(player, 0, false))
return false;
- }
if (!target->IsAlive())
return true;