mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-17 02:50:29 +00:00
refactor(Core): Make more use of helpers. (#19835)
* Init. * Reword. * Update codestyle script. Co-Authored-By: Kitzunu <24550914+Kitzunu@users.noreply.github.com> * Add gameobject type ID check, reorder checks. * Add helper/codestyle check for unit type. * `IsUnit()` -> `IsCreature()` * Add `IsUnit()` method. * Use type mask. https: //github.com/TrinityCore/TrinityCore/commit/cc71da35b5dc74abf71f8691161525a23d870bb5 Co-Authored-By: Giacomo Pozzoni <giacomopoz@gmail.com> Co-Authored-By: Ovahlord <18347559+Ovahlord@users.noreply.github.com> * Replace instances of `isType` with `IsUnit`. --------- Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Co-authored-by: Giacomo Pozzoni <giacomopoz@gmail.com> Co-authored-by: Ovahlord <18347559+Ovahlord@users.noreply.github.com>
This commit is contained in:
@@ -2385,7 +2385,7 @@ void Player::GiveXP(uint32 xp, Unit* victim, float group_rate, bool isLFGReward)
|
||||
return;
|
||||
}
|
||||
|
||||
if (victim && victim->GetTypeId() == TYPEID_UNIT && !victim->ToCreature()->hasLootRecipient())
|
||||
if (victim && victim->IsCreature() && !victim->ToCreature()->hasLootRecipient())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -6023,7 +6023,7 @@ bool Player::RewardHonor(Unit* uVictim, uint32 groupsize, int32 honor, bool awar
|
||||
// do not reward honor in arenas, but enable onkill spellproc
|
||||
if (InArena())
|
||||
{
|
||||
if (!uVictim || uVictim == this || uVictim->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!uVictim || uVictim == this || !uVictim->IsPlayer())
|
||||
return false;
|
||||
|
||||
if (GetBgTeamId() == uVictim->ToPlayer()->GetBgTeamId())
|
||||
@@ -9256,7 +9256,7 @@ void Player::StopCastingCharm(Aura* except /*= nullptr*/)
|
||||
return;
|
||||
}
|
||||
|
||||
if (charm->GetTypeId() == TYPEID_UNIT)
|
||||
if (charm->IsCreature())
|
||||
{
|
||||
if (charm->ToCreature()->HasUnitTypeMask(UNIT_MASK_PUPPET))
|
||||
{
|
||||
@@ -9611,7 +9611,7 @@ void Player::CharmSpellInitialize()
|
||||
}
|
||||
|
||||
uint8 addlist = 0;
|
||||
if (charm->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!charm->IsPlayer())
|
||||
{
|
||||
//CreatureInfo const* cinfo = charm->ToCreature()->GetCreatureTemplate();
|
||||
//if (cinfo && cinfo->type == CREATURE_TYPE_DEMON && getClass() == CLASS_WARLOCK)
|
||||
@@ -9627,7 +9627,7 @@ void Player::CharmSpellInitialize()
|
||||
data << uint16(0);
|
||||
data << uint32(0);
|
||||
|
||||
if (charm->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!charm->IsPlayer())
|
||||
data << uint8(charm->ToCreature()->GetReactState()) << uint8(charmInfo->GetCommandState()) << uint16(0);
|
||||
else
|
||||
data << uint32(0);
|
||||
@@ -12622,7 +12622,7 @@ bool Player::isHonorOrXPTarget(Unit* victim) const
|
||||
return false;
|
||||
}
|
||||
|
||||
if (victim->GetTypeId() == TYPEID_UNIT)
|
||||
if (victim->IsCreature())
|
||||
{
|
||||
if (victim->IsTotem() || victim->IsCritter() || victim->IsPet() || (victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP))
|
||||
{
|
||||
@@ -12684,7 +12684,7 @@ void Player::RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject* pRewar
|
||||
if (!pRewardSource)
|
||||
return;
|
||||
|
||||
ObjectGuid creature_guid = (pRewardSource->GetTypeId() == TYPEID_UNIT) ? pRewardSource->GetGUID() : ObjectGuid::Empty;
|
||||
ObjectGuid creature_guid = (pRewardSource->IsCreature()) ? pRewardSource->GetGUID() : ObjectGuid::Empty;
|
||||
|
||||
// prepare data for near group iteration
|
||||
if (Group* group = GetGroup())
|
||||
@@ -12818,7 +12818,7 @@ void Player::SetClientControl(Unit* target, bool allowMove, bool packetOnly /*=
|
||||
SetMover(target);
|
||||
|
||||
// Xinef: disable moving if target has disable move flag
|
||||
if (target->GetTypeId() != TYPEID_UNIT)
|
||||
if (!target->IsCreature())
|
||||
return;
|
||||
|
||||
if (allowMove && target->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE))
|
||||
@@ -12855,12 +12855,12 @@ void Player::SetMover(Unit* target)
|
||||
LOG_INFO("misc", "Player::SetMover (B2) - {}, {}, {}, {}, {}, {}, {}, {}", target->GetGUID().ToString(), target->GetMapId(), target->GetInstanceId(), target->FindMap()->GetId(), target->IsInWorld() ? 1 : 0, target->IsDuringRemoveFromWorld() ? 1 : 0, (target->ToPlayer() && target->ToPlayer()->IsBeingTeleported() ? 1 : 0), target->isBeingLoaded() ? 1 : 0);
|
||||
}
|
||||
m_mover->m_movedByPlayer = nullptr;
|
||||
if (m_mover->GetTypeId() == TYPEID_UNIT)
|
||||
if (m_mover->IsCreature())
|
||||
m_mover->GetMotionMaster()->Initialize();
|
||||
|
||||
m_mover = target;
|
||||
m_mover->m_movedByPlayer = this;
|
||||
if (m_mover->GetTypeId() == TYPEID_UNIT)
|
||||
if (m_mover->IsCreature())
|
||||
m_mover->GetMotionMaster()->Initialize();
|
||||
}
|
||||
|
||||
@@ -13105,7 +13105,7 @@ void Player::StopCastingBindSight(Aura* except /*= nullptr*/)
|
||||
{
|
||||
if (WorldObject* target = GetViewpoint())
|
||||
{
|
||||
if (target->isType(TYPEMASK_UNIT))
|
||||
if (target->IsUnit())
|
||||
{
|
||||
((Unit*)target)->RemoveAurasByType(SPELL_AURA_BIND_SIGHT, GetGUID(), except);
|
||||
((Unit*)target)->RemoveAurasByType(SPELL_AURA_MOD_POSSESS, GetGUID(), except);
|
||||
@@ -13129,7 +13129,7 @@ void Player::SetViewpoint(WorldObject* target, bool apply)
|
||||
// farsight dynobj or puppet may be very far away
|
||||
UpdateVisibilityOf(target);
|
||||
|
||||
if (target->isType(TYPEMASK_UNIT) && !GetVehicle())
|
||||
if (target->IsUnit() && !GetVehicle())
|
||||
((Unit*)target)->AddPlayerToVision(this);
|
||||
SetSeer(target);
|
||||
}
|
||||
@@ -13146,7 +13146,7 @@ void Player::SetViewpoint(WorldObject* target, bool apply)
|
||||
return;
|
||||
}
|
||||
|
||||
if (target->isType(TYPEMASK_UNIT) && !GetVehicle())
|
||||
if (target->IsUnit() && !GetVehicle())
|
||||
static_cast<Unit*>(target)->RemovePlayerFromVision(this);
|
||||
|
||||
// must immediately set seer back otherwise may crash
|
||||
|
||||
Reference in New Issue
Block a user