Core/Misc: replace (Player*) casts with ToPlayer()
This commit is contained in:
1 parent
1ac4f0a9c1
commit
380cf5d241
15 files changed
+189
-186
No files matched your search
@@ -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;
|
||||
|
||||
uint32 enchant_id = m_spellInfo->Effects[effIndex].MiscValue;
|
||||
if (!enchant_id)
|
||||
Player* player = m_caster->ToPlayer();
|
||||
if (!player)
|
||||
return;
|
||||
|
||||
SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
|
||||
if (!pEnchant)
|
||||
uint32 enchantId = m_spellInfo->Effects[effIndex].MiscValue;
|
||||
if (!enchantId)
|
||||
return;
|
||||
|
||||
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;
|
||||
|
||||
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());
|
||||
|
||||
if (target->IsInFlight())
|
||||
Player* player = m_caster->ToPlayer();
|
||||
if (!player)
|
||||
return;
|
||||
|
||||
target->TeleportTo(target->GetStartPosition(), TELE_TO_SPELL);
|
||||
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)", player->GetName().c_str(), player->GetGUIDLow(), player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
|
||||
|
||||
if (player->IsInFlight())
|
||||
return;
|
||||
|
||||
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)
|
||||
|
||||
Reference in new issue
Block a user