refactor(Core/Object): adds consistency in the use of type object check (#19671)

This commit is contained in:
Grimdhex
2024-08-25 14:57:37 +02:00
committed by GitHub
parent 61f3a631c3
commit 643362d697
189 changed files with 783 additions and 775 deletions

View File

@@ -1134,7 +1134,7 @@ public:
return true;
// check index
if (unit->GetTypeId() == TYPEID_PLAYER)
if (unit->IsPlayer())
{
if (index >= PLAYER_END)
return true;

View File

@@ -1130,7 +1130,7 @@ public:
return false;
}
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
{
if (handler->HasLowerSecurity(target->ToPlayer()))
{
@@ -2659,7 +2659,7 @@ public:
return false;
}
handler->PSendSysMessage(LANG_MOVEGENS_LIST, (unit->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), unit->GetGUID().ToString());
handler->PSendSysMessage(LANG_MOVEGENS_LIST, (unit->IsPlayer() ? "Player" : "Creature"), unit->GetGUID().ToString());
MotionMaster* motionMaster = unit->GetMotionMaster();
float x, y, z;
@@ -2694,7 +2694,7 @@ public:
case CHASE_MOTION_TYPE:
{
Unit* target = nullptr;
if (unit->GetTypeId() == TYPEID_PLAYER)
if (unit->IsPlayer())
{
target = static_cast<ChaseMovementGenerator<Player> const*>(movementGenerator)->GetTarget();
}
@@ -2707,7 +2707,7 @@ public:
{
handler->SendSysMessage(LANG_MOVEGENS_CHASE_NULL);
}
else if (target->GetTypeId() == TYPEID_PLAYER)
else if (target->IsPlayer())
{
handler->PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName(), target->GetGUID().ToString());
}
@@ -2720,7 +2720,7 @@ public:
case FOLLOW_MOTION_TYPE:
{
Unit* target = nullptr;
if (unit->GetTypeId() == TYPEID_PLAYER)
if (unit->IsPlayer())
{
target = static_cast<FollowMovementGenerator<Player> const*>(movementGenerator)->GetTarget();
}
@@ -2733,7 +2733,7 @@ public:
{
handler->SendSysMessage(LANG_MOVEGENS_FOLLOW_NULL);
}
else if (target->GetTypeId() == TYPEID_PLAYER)
else if (target->IsPlayer())
{
handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName(), target->GetGUID().ToString());
}
@@ -2809,7 +2809,7 @@ public:
return false;
}
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
{
if (handler->HasLowerSecurity(target->ToPlayer()))
{

View File

@@ -355,7 +355,7 @@ public:
return false;
}
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
{
// check online security
if (handler->HasLowerSecurity(target->ToPlayer()))
@@ -370,7 +370,7 @@ public:
else if (target->IsPet())
{
Unit* owner = target->GetOwner();
if (owner && owner->GetTypeId() == TYPEID_PLAYER && ((Pet*)target)->IsPermanentPetFor(owner->ToPlayer()))
if (owner && owner->IsPlayer() && ((Pet*)target)->IsPermanentPetFor(owner->ToPlayer()))
{
// check online security
if (handler->HasLowerSecurity(owner->ToPlayer()))
@@ -666,7 +666,7 @@ public:
}
// check online security
if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer()))
if (target->IsPlayer() && handler->HasLowerSecurity(target->ToPlayer()))
{
return false;
}
@@ -843,7 +843,7 @@ public:
{
target = handler->GetSession()->GetPlayer();
}
else if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer())) // check online security
else if (target->IsPlayer() && handler->HasLowerSecurity(target->ToPlayer())) // check online security
{
return false;
}
@@ -860,7 +860,7 @@ public:
{
target = handler->GetSession()->GetPlayer();
}
else if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer())) // check online security
else if (target->IsPlayer() && handler->HasLowerSecurity(target->ToPlayer())) // check online security
{
return false;
}
@@ -873,7 +873,7 @@ public:
{
Player* target = handler->getSelectedPlayerOrSelf();
if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer())) // check online security
if (target->IsPlayer() && handler->HasLowerSecurity(target->ToPlayer())) // check online security
return false;
if (!target->GetAuraEffectsByType(SPELL_AURA_MOUNTED).empty())
@@ -892,7 +892,7 @@ public:
{
target = handler->GetSession()->GetPlayer();
}
else if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer())) // check online security
else if (target->IsPlayer() && handler->HasLowerSecurity(target->ToPlayer())) // check online security
{
return false;
}

View File

@@ -54,7 +54,7 @@ public:
Player* player = handler->GetSession()->GetPlayer();
Creature* creatureTarget = handler->getSelectedCreature();
if (!creatureTarget || creatureTarget->IsPet() || creatureTarget->GetTypeId() == TYPEID_PLAYER)
if (!creatureTarget || creatureTarget->IsPet() || creatureTarget->IsPlayer())
{
handler->SendErrorMessage(LANG_SELECT_CREATURE);
return false;