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
@@ -1905,13 +1905,13 @@ bool Creature::CanStartAttack(Unit const* who) const
// This set of checks is should be done only for creatures
if ((IsImmuneToNPC() && who->GetTypeId() != TYPEID_PLAYER) || // flag is valid only for non player characters
(IsImmuneToPC() && who->GetTypeId() == TYPEID_PLAYER)) // immune to PC and target is a player, return false
(IsImmuneToPC() && who->IsPlayer())) // immune to PC and target is a player, return false
{
return false;
}
if (Unit* owner = who->GetOwner())
if (owner->GetTypeId() == TYPEID_PLAYER && IsImmuneToPC()) // immune to PC and target has player owner
if (owner->IsPlayer() && IsImmuneToPC()) // immune to PC and target has player owner
return false;
// Do not attack non-combat pets
@@ -218,11 +218,11 @@ void TempSummon::InitStats(uint32 duration)
{
SetFaction(owner->GetFaction());
SetLevel(owner->GetLevel());
if (owner->GetTypeId() == TYPEID_PLAYER)
if (owner->IsPlayer())
m_ControlledByPlayer = true;
}
if (owner->GetTypeId() == TYPEID_PLAYER)
if (owner->IsPlayer())
m_CreatedByPlayer = true;
}
@@ -397,7 +397,7 @@ void Minion::setDeathState(DeathState s, bool despawn)
Creature::setDeathState(s, despawn);
if (s == DeathState::JustDied && IsGuardianPet())
if (Unit* owner = GetOwner())
if (owner->GetTypeId() == TYPEID_PLAYER && owner->GetMinionGUID() == GetGUID())
if (owner->IsPlayer() && owner->GetMinionGUID() == GetGUID())
for (Unit::ControlSet::const_iterator itr = owner->m_Controlled.begin(); itr != owner->m_Controlled.end(); ++itr)
if ((*itr)->IsAlive() && (*itr)->GetEntry() == GetEntry())
{
@@ -434,7 +434,7 @@ void Guardian::InitStats(uint32 duration)
{
InitStatsForLevel(m_owner->GetLevel());
if (m_owner->GetTypeId() == TYPEID_PLAYER && HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN))
if (m_owner->IsPlayer() && HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN))
m_charmInfo->InitCharmCreateSpells();
}
@@ -447,7 +447,7 @@ void Guardian::InitSummon()
if (Unit* m_owner = GetOwner())
{
if (m_owner->GetTypeId() == TYPEID_PLAYER && m_owner->GetMinionGUID() == GetGUID() && !m_owner->GetCharmGUID())
if (m_owner->IsPlayer() && m_owner->GetMinionGUID() == GetGUID() && !m_owner->GetCharmGUID())
{
m_owner->ToPlayer()->CharmSpellInitialize();
}
@@ -510,7 +510,7 @@ void GameObject::Update(uint32 diff)
{
// splash bobber (bobber ready now)
Unit* caster = GetOwner();
if (caster && caster->GetTypeId() == TYPEID_PLAYER)
if (caster && caster->IsPlayer())
{
SetGoState(GO_STATE_ACTIVE);
ReplaceAllGameObjectFlags(GO_FLAG_NODESPAWN);
@@ -634,7 +634,7 @@ void GameObject::Update(uint32 diff)
case GAMEOBJECT_TYPE_FISHINGNODE: // can't fish now
{
Unit* caster = GetOwner();
if (caster && caster->GetTypeId() == TYPEID_PLAYER)
if (caster && caster->IsPlayer())
{
caster->ToPlayer()->RemoveGameObject(this, false);
@@ -1635,7 +1635,7 @@ void GameObject::Use(Unit* user)
if (HasGameObjectFlag(GO_FLAG_IN_USE))
return;
if (user->GetTypeId() == TYPEID_PLAYER)
if (user->IsPlayer())
{
Player* player = user->ToPlayer();
+16 -16
View File
@@ -90,7 +90,7 @@ WorldObject::~WorldObject()
// this may happen because there are many !create/delete
if (IsWorldObject() && m_currMap)
{
if (GetTypeId() == TYPEID_CORPSE)
if (IsCorpse())
{
LOG_FATAL("entities.object", "Object::~Object Corpse {}, type={} deleted but still in map!!", GetGUID().ToString(), ((Corpse*)this)->GetType());
ABORT();
@@ -403,7 +403,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
*data << object->GetOrientation();
if (GetTypeId() == TYPEID_CORPSE)
if (IsCorpse())
*data << float(object->GetOrientation());
else
*data << float(0);
@@ -1087,7 +1087,7 @@ void WorldObject::setActive(bool on)
if (m_isActive == on)
return;
if (GetTypeId() == TYPEID_PLAYER)
if (IsPlayer())
return;
m_isActive = on;
@@ -1103,7 +1103,7 @@ void WorldObject::setActive(bool on)
{
if (GetTypeId() == TYPEID_UNIT)
map->AddToActive(this->ToCreature());
else if (GetTypeId() == TYPEID_DYNAMICOBJECT)
else if (IsDynamicObject())
map->AddToActive((DynamicObject*)this);
else if (GetTypeId() == TYPEID_GAMEOBJECT)
map->AddToActive((GameObject*)this);
@@ -1112,7 +1112,7 @@ void WorldObject::setActive(bool on)
{
if (GetTypeId() == TYPEID_UNIT)
map->RemoveFromActive(this->ToCreature());
else if (GetTypeId() == TYPEID_DYNAMICOBJECT)
else if (IsDynamicObject())
map->RemoveFromActive((DynamicObject*)this);
else if (GetTypeId() == TYPEID_GAMEOBJECT)
map->RemoveFromActive((GameObject*)this);
@@ -1122,7 +1122,7 @@ void WorldObject::setActive(bool on)
void WorldObject::SetVisibilityDistanceOverride(VisibilityDistanceType type)
{
ASSERT(type < VisibilityDistanceType::Max);
if (GetTypeId() == TYPEID_PLAYER)
if (IsPlayer())
{
return;
}
@@ -1329,7 +1329,7 @@ bool WorldObject::IsWithinLOS(float ox, float oy, float oz, VMAP::ModelIgnoreFla
{
oz += GetCollisionHeight();
float x, y, z;
if (GetTypeId() == TYPEID_PLAYER)
if (IsPlayer())
{
GetPosition(x, y, z);
z += GetCollisionHeight();
@@ -1350,7 +1350,7 @@ bool WorldObject::IsWithinLOSInMap(WorldObject const* obj, VMAP::ModelIgnoreFlag
return false;
float ox, oy, oz;
if (obj->GetTypeId() == TYPEID_PLAYER)
if (obj->IsPlayer())
{
obj->GetPosition(ox, oy, oz);
oz += obj->GetCollisionHeight();
@@ -1359,7 +1359,7 @@ bool WorldObject::IsWithinLOSInMap(WorldObject const* obj, VMAP::ModelIgnoreFlag
obj->GetHitSpherePointFor({ GetPositionX(), GetPositionY(), GetPositionZ() + (collisionHeight ? *collisionHeight : GetCollisionHeight()) }, ox, oy, oz);
float x, y, z;
if (GetTypeId() == TYPEID_PLAYER)
if (IsPlayer())
{
GetPosition(x, y, z);
z += GetCollisionHeight();
@@ -1634,7 +1634,7 @@ float WorldObject::GetGridActivationRange() const
{
return ToCreature()->m_SightDistance;
}
else if (((GetTypeId() == TYPEID_GAMEOBJECT && ToGameObject()->IsTransport()) || GetTypeId() == TYPEID_DYNAMICOBJECT) && isActiveObject())
else if (((GetTypeId() == TYPEID_GAMEOBJECT && ToGameObject()->IsTransport()) || IsDynamicObject()) && isActiveObject())
{
return GetMap()->GetVisibilityRange();
}
@@ -1762,7 +1762,7 @@ bool WorldObject::CanSeeOrDetect(WorldObject const* obj, bool ignoreStealth, boo
}
// pussywizard: arena spectator
if (obj->GetTypeId() == TYPEID_PLAYER)
if (obj->IsPlayer())
if (((Player const*)obj)->IsSpectator() && ((Player const*)obj)->FindMap()->IsBattleArena())
return false;
@@ -1858,7 +1858,7 @@ bool WorldObject::CanSeeOrDetect(WorldObject const* obj, bool ignoreStealth, boo
return false;
// pussywizard: arena spectator
if (this->GetTypeId() == TYPEID_PLAYER)
if (this->IsPlayer())
if (((Player const*)this)->IsSpectator() && ((Player const*)this)->FindMap()->IsBattleArena() && (obj->m_invisibility.GetFlags() || obj->m_stealth.GetFlags()))
return false;
@@ -2035,7 +2035,7 @@ bool WorldObject::CanDetectStealthOf(WorldObject const* obj, bool checkAlert) co
Unit const* unit = ToUnit();
// If this unit is an NPC then player detect range doesn't apply
if (unit && unit->GetTypeId() == TYPEID_PLAYER && visibilityRange > MAX_PLAYER_STEALTH_DETECT_RANGE)
if (unit && unit->IsPlayer() && visibilityRange > MAX_PLAYER_STEALTH_DETECT_RANGE)
visibilityRange = MAX_PLAYER_STEALTH_DETECT_RANGE;
if (checkAlert)
@@ -2058,7 +2058,7 @@ void WorldObject::SendPlayMusic(uint32 Music, bool OnlySelf)
{
WorldPacket data(SMSG_PLAY_MUSIC, 4);
data << Music;
if (OnlySelf && GetTypeId() == TYPEID_PLAYER)
if (OnlySelf && IsPlayer())
this->ToPlayer()->GetSession()->SendPacket(&data);
else
SendMessageToSet(&data, true); // ToSelf ignored in this case
@@ -2389,7 +2389,7 @@ GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float
if (respawnTime)
go->SetSpellId(1);
if (GetTypeId() == TYPEID_PLAYER || (GetTypeId() == TYPEID_UNIT && summonType == GO_SUMMON_TIMED_OR_CORPSE_DESPAWN)) //not sure how to handle this
if (IsPlayer() || (GetTypeId() == TYPEID_UNIT && summonType == GO_SUMMON_TIMED_OR_CORPSE_DESPAWN)) //not sure how to handle this
ToUnit()->AddGameObject(go);
else
go->SetSpawnedByDefault(false);
@@ -2406,7 +2406,7 @@ Creature* WorldObject::SummonTrigger(float x, float y, float z, float ang, uint3
return nullptr;
//summon->SetName(GetName());
if (setLevel && (GetTypeId() == TYPEID_PLAYER || GetTypeId() == TYPEID_UNIT))
if (setLevel && (IsPlayer() || GetTypeId() == TYPEID_UNIT))
{
summon->SetFaction(((Unit*)this)->GetFaction());
summon->SetLevel(((Unit*)this)->GetLevel());
+18 -11
View File
@@ -195,21 +195,28 @@ public:
void ForceValuesUpdateAtIndex(uint32);
[[nodiscard]] inline bool IsPlayer() const { return GetTypeId() == TYPEID_PLAYER; }
Player* ToPlayer() { if (GetTypeId() == TYPEID_PLAYER) return reinterpret_cast<Player*>(this); else return nullptr; }
[[nodiscard]] Player const* ToPlayer() const { if (GetTypeId() == TYPEID_PLAYER) return (Player const*)((Player*)this); else return nullptr; }
Player* ToPlayer() { if (IsPlayer()) return reinterpret_cast<Player*>(this); else return nullptr; }
[[nodiscard]] Player const* ToPlayer() const { if (IsPlayer()) return reinterpret_cast<Player const*>(this); else return nullptr; }
Creature* ToCreature() { if (GetTypeId() == TYPEID_UNIT) return reinterpret_cast<Creature*>(this); else return nullptr; }
[[nodiscard]] Creature const* ToCreature() const { if (GetTypeId() == TYPEID_UNIT) return (Creature const*)((Creature*)this); else return nullptr; }
[[nodiscard]] Creature const* ToCreature() const { if (GetTypeId() == TYPEID_UNIT) return reinterpret_cast<Creature const*>(this); else return nullptr; }
Unit* ToUnit() { if (GetTypeId() == TYPEID_UNIT || GetTypeId() == TYPEID_PLAYER) return reinterpret_cast<Unit*>(this); else return nullptr; }
[[nodiscard]] Unit const* ToUnit() const { if (GetTypeId() == TYPEID_UNIT || GetTypeId() == TYPEID_PLAYER) return (Unit const*)((Unit*)this); else return nullptr; }
GameObject* ToGameObject() { if (GetTypeId() == TYPEID_GAMEOBJECT) return reinterpret_cast<GameObject*>(this); else return nullptr; }
[[nodiscard]] GameObject const* ToGameObject() const { if (GetTypeId() == TYPEID_GAMEOBJECT) return (GameObject const*)((GameObject*)this); else return nullptr; }
Unit* ToUnit() { if (GetTypeId() == TYPEID_UNIT || IsPlayer()) return reinterpret_cast<Unit*>(this); else return nullptr; }
[[nodiscard]] Unit const* ToUnit() const { if (GetTypeId() == TYPEID_UNIT || IsPlayer()) return reinterpret_cast<Unit const*>(this); else return nullptr; }
Corpse* ToCorpse() { if (GetTypeId() == TYPEID_CORPSE) return reinterpret_cast<Corpse*>(this); else return nullptr; }
[[nodiscard]] Corpse const* ToCorpse() const { if (GetTypeId() == TYPEID_CORPSE) return (const Corpse*)((Corpse*)this); else return nullptr; }
[[nodiscard]] inline bool IsGameObject() const { return GetTypeId() == TYPEID_GAMEOBJECT; }
GameObject* ToGameObject() { if (IsGameObject()) return reinterpret_cast<GameObject*>(this); else return nullptr; }
[[nodiscard]] GameObject const* ToGameObject() const { if (IsGameObject()) return reinterpret_cast<GameObject const*>(this); else return nullptr; }
DynamicObject* ToDynObject() { if (GetTypeId() == TYPEID_DYNAMICOBJECT) return reinterpret_cast<DynamicObject*>(this); else return nullptr; }
[[nodiscard]] DynamicObject const* ToDynObject() const { if (GetTypeId() == TYPEID_DYNAMICOBJECT) return reinterpret_cast<DynamicObject const*>(this); else return nullptr; }
[[nodiscard]] inline bool IsCorpse() const { return GetTypeId() == TYPEID_CORPSE; }
Corpse* ToCorpse() { if (IsCorpse()) return reinterpret_cast<Corpse*>(this); else return nullptr; }
[[nodiscard]] Corpse const* ToCorpse() const { if (IsCorpse()) return reinterpret_cast<Corpse const*>(this); else return nullptr; }
[[nodiscard]] inline bool IsDynamicObject() const { return GetTypeId() == TYPEID_DYNAMICOBJECT; }
DynamicObject* ToDynObject() { if (IsDynamicObject()) return reinterpret_cast<DynamicObject*>(this); else return nullptr; }
[[nodiscard]] DynamicObject const* ToDynObject() const { if (IsDynamicObject()) return reinterpret_cast<DynamicObject const*>(this); else return nullptr; }
[[nodiscard]] inline bool IsItem() const { return GetTypeId() == TYPEID_ITEM; }
virtual std::string GetDebugInfo() const;
+7 -7
View File
@@ -52,7 +52,7 @@ Pet::Pet(Player* owner, PetType type) : Guardian(nullptr, owner ? owner->GetGUID
m_tempspellIsPositive(false),
m_tempspell(0)
{
ASSERT(m_owner && m_owner->GetTypeId() == TYPEID_PLAYER);
ASSERT(m_owner && m_owner->IsPlayer());
m_unitTypeMask |= UNIT_MASK_PET;
@@ -415,7 +415,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c
map->AddToMap(ToCreature(), true);
//set last used pet number (for use in BG's)
if (owner->GetTypeId() == TYPEID_PLAYER && isControlled() && !isTemporarySummoned() && (getPetType() == SUMMON_PET || getPetType() == HUNTER_PET))
if (owner->IsPlayer() && isControlled() && !isTemporarySummoned() && (getPetType() == SUMMON_PET || getPetType() == HUNTER_PET))
owner->ToPlayer()->SetLastPetNumber(petInfo->PetNumber);
owner->GetSession()->AddQueryHolderCallback(CharacterDatabase.DelayQueryHolder(std::make_shared<PetLoadQueryHolder>(ownerid, petInfo->PetNumber)))
@@ -1035,7 +1035,7 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
//Determine pet type
PetType petType = MAX_PET_TYPE;
if (owner->GetTypeId() == TYPEID_PLAYER)
if (owner->IsPlayer())
{
sScriptMgr->OnBeforeGuardianInitStatsForLevel(owner->ToPlayer(), this, cinfo, petType);
@@ -1132,8 +1132,8 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
// remove elite bonuses included in DB values
CreatureBaseStats const* stats = sObjectMgr->GetCreatureBaseStats(petlevel, cinfo->unit_class);
// xinef: multiply base values by creature_template factors!
float factorHealth = owner->GetTypeId() == TYPEID_PLAYER ? std::min(1.0f, cinfo->ModHealth) : cinfo->ModHealth;
float factorMana = owner->GetTypeId() == TYPEID_PLAYER ? std::min(1.0f, cinfo->ModMana) : cinfo->ModMana;
float factorHealth = owner->IsPlayer() ? std::min(1.0f, cinfo->ModHealth) : cinfo->ModHealth;
float factorMana = owner->IsPlayer() ? std::min(1.0f, cinfo->ModMana) : cinfo->ModMana;
if (sWorld->getBoolConfig(CONFIG_ALLOWS_RANK_MOD_FOR_PET_HEALTH))
{
@@ -1430,7 +1430,7 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
SetFullHealth();
SetPower(POWER_MANA, GetMaxPower(POWER_MANA));
if (owner->GetTypeId() == TYPEID_PLAYER)
if (owner->IsPlayer())
sScriptMgr->OnAfterGuardianInitStatsForLevel(owner->ToPlayer(), this);
return true;
@@ -2025,7 +2025,7 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab)
{
// need update action bar for last removed rank
if (Unit* owner = GetOwner())
if (owner->GetTypeId() == TYPEID_PLAYER)
if (owner->IsPlayer())
owner->ToPlayer()->PetSpellInitialize();
}
}
@@ -70,7 +70,7 @@ KillRewarder::KillRewarder(Player* killer, Unit* victim, bool isBattleGround) :
_isFullXP(false), _maxLevel(0), _isBattleGround(isBattleGround), _isPvP(false)
{
// mark the credit as pvp if victim is player
if (victim->GetTypeId() == TYPEID_PLAYER)
if (victim->IsPlayer())
_isPvP = true;
// or if its owned by player and its not a vehicle
else if (victim->GetCharmerOrOwnerGUID().IsPlayer())
@@ -201,7 +201,7 @@ void KillRewarder::_RewardPlayer(Player* player, bool isDungeon)
// 4.1. Give honor (player must be alive and not on BG).
_RewardHonor(player);
// 4.1.1 Send player killcredit for quests with PlayerSlain
if (_victim->GetTypeId() == TYPEID_PLAYER)
if (_victim->IsPlayer())
player->KilledPlayerCredit();
}
@@ -256,7 +256,7 @@ void KillRewarder::_RewardGroup()
{
_RewardPlayer(member, isDungeon);
// Xinef: only count players
//if (_victim->GetTypeId() == TYPEID_PLAYER)
//if (_victim->IsPlayer())
// member->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL, 1, 0, _victim);
}
}
+5 -5
View File
@@ -5904,7 +5904,7 @@ float Player::CalculateReputationGain(ReputationSource source, uint32 creatureOr
// Calculates how many reputation points player gains in victim's enemy factions
void Player::RewardReputation(Unit* victim)
{
if (!victim || victim->GetTypeId() == TYPEID_PLAYER)
if (!victim || victim->IsPlayer())
return;
if (victim->ToCreature()->IsReputationGainDisabled())
@@ -6036,7 +6036,7 @@ bool Player::RewardHonor(Unit* uVictim, uint32 groupsize, int32 honor, bool awar
return false;
/* check if player has same IP
if (uVictim && uVictim->GetTypeId() == TYPEID_PLAYER)
if (uVictim && uVictim->IsPlayer())
{
if (GetSession()->GetRemoteAddress() == uVictim->ToPlayer()->GetSession()->GetRemoteAddress())
return false;
@@ -6063,7 +6063,7 @@ bool Player::RewardHonor(Unit* uVictim, uint32 groupsize, int32 honor, bool awar
victim_guid = uVictim->GetGUID();
if (uVictim->GetTypeId() == TYPEID_PLAYER)
if (uVictim->IsPlayer())
{
Player* victim = uVictim->ToPlayer();
@@ -6174,7 +6174,7 @@ bool Player::RewardHonor(Unit* uVictim, uint32 groupsize, int32 honor, bool awar
if (!uVictim || uVictim == this || uVictim->HasAuraType(SPELL_AURA_NO_PVP_CREDIT))
return true;
if (uVictim->GetTypeId() == TYPEID_PLAYER)
if (uVictim->IsPlayer())
{
// Check if allowed to receive it in current map
uint8 MapType = sWorld->getIntConfig(CONFIG_PVP_TOKEN_MAP_TYPE);
@@ -9161,7 +9161,7 @@ Pet* Player::CreatePet(Creature* creatureTarget, uint32 spellID /*= 0*/)
return nullptr;
}
if (!creatureTarget || creatureTarget->IsPet() || creatureTarget->GetTypeId() == TYPEID_PLAYER)
if (!creatureTarget || creatureTarget->IsPet() || creatureTarget->IsPlayer())
{
return nullptr;
}
@@ -551,7 +551,7 @@ void Player::AddQuest(Quest const* quest, Object* questGiver)
uint32 timeAllowed = quest->GetTimeAllowed();
// shared timed quest
if (questGiver && questGiver->GetTypeId() == TYPEID_PLAYER)
if (questGiver && questGiver->IsPlayer())
timeAllowed = questGiver->ToPlayer()->getQuestStatusMap()[quest_id].Timer / IN_MILLISECONDS;
AddTimedQuest(quest_id);
@@ -1946,7 +1946,7 @@ void Player::UpdateCharmedAI()
1 << (CLASS_PRIEST - 1));
// Xinef: charmer type specific actions
if (charmer->GetTypeId() == TYPEID_PLAYER)
if (charmer->IsPlayer())
{
bool follow = false;
if (!target)
+1 -1
View File
@@ -51,7 +51,7 @@ void Totem::InitStats(uint32 duration)
if (Unit* owner = ObjectAccessor::GetUnit(*this, m_owner))
{
uint32 slot = m_Properties->Slot;
if (owner->GetTypeId() == TYPEID_PLAYER && slot >= SUMMON_SLOT_TOTEM && slot < MAX_TOTEM_SLOT)
if (owner->IsPlayer() && slot >= SUMMON_SLOT_TOTEM && slot < MAX_TOTEM_SLOT)
{
WorldPackets::Totem::TotemCreated data;
data.Totem = GetGUID();
@@ -442,7 +442,7 @@ void MotionTransport::UnloadNonStaticPassengers()
{
for (PassengerSet::iterator itr = _passengers.begin(); itr != _passengers.end(); )
{
if ((*itr)->GetTypeId() == TYPEID_PLAYER)
if ((*itr)->IsPlayer())
{
++itr;
continue;
@@ -518,7 +518,7 @@ bool MotionTransport::TeleportTransport(uint32 newMapid, float x, float y, float
// Teleport players, they need to know it
for (PassengerSet::iterator itr = _passengers.begin(); itr != _passengers.end(); ++itr)
{
if ((*itr)->GetTypeId() == TYPEID_PLAYER)
if ((*itr)->IsPlayer())
{
float destX, destY, destZ, destO;
(*itr)->m_movementInfo.transport.pos.GetPosition(destX, destY, destZ, destO);
+1 -1
View File
@@ -114,7 +114,7 @@ void CharmInfo::InitCharmCreateSpells()
{
InitPetActionBar();
if (_unit->GetTypeId() == TYPEID_PLAYER) // charmed players don't have spells
if (_unit->IsPlayer()) // charmed players don't have spells
return;
for (uint32 i = 0; i < MAX_SPELL_CHARM; ++i)
File diff suppressed because it is too large Load Diff
+10 -10
View File
@@ -82,7 +82,7 @@ void Vehicle::Install()
void Vehicle::InstallAllAccessories(bool evading)
{
if (GetBase()->GetTypeId() == TYPEID_PLAYER || !evading)
if (GetBase()->IsPlayer() || !evading)
RemoveAllPassengers(); // We might have aura's saved in the DB with now invalid casters - remove
VehicleAccessoryList const* accessories = sObjectMgr->GetVehicleAccessoryList(this);
@@ -116,7 +116,7 @@ void Vehicle::Uninstall()
void Vehicle::Reset(bool evading /*= false*/)
{
LOG_DEBUG("vehicles", "Vehicle::Reset: {}", _me->GetGUID().ToString());
if (_me->GetTypeId() == TYPEID_PLAYER)
if (_me->IsPlayer())
{
if (_usableSeatNum)
_me->SetNpcFlag(UNIT_NPC_FLAG_PLAYER_VEHICLE);
@@ -357,7 +357,7 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId)
--_usableSeatNum;
if (!_usableSeatNum)
{
if (_me->GetTypeId() == TYPEID_PLAYER)
if (_me->IsPlayer())
_me->RemoveNpcFlag(UNIT_NPC_FLAG_PLAYER_VEHICLE);
else
_me->RemoveNpcFlag(UNIT_NPC_FLAG_SPELLCLICK);
@@ -368,7 +368,7 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId)
return false;
// Xinef: moved from unit.cpp, if aura passes seatId == -1 (choose automaticly) we wont get appropriate flags
if (unit->GetTypeId() == TYPEID_PLAYER && !(seat->second.SeatInfo->m_flagsB & VEHICLE_SEAT_FLAG_B_KEEP_PET))
if (unit->IsPlayer() && !(seat->second.SeatInfo->m_flagsB & VEHICLE_SEAT_FLAG_B_KEEP_PET))
unit->ToPlayer()->UnsummonPetTemporaryIfAny();
if (seat->second.SeatInfo->m_flags & VEHICLE_SEAT_FLAG_PASSENGER_NOT_SELECTABLE)
@@ -383,7 +383,7 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId)
// xinef: removed seat->first == 0 check...
if (_me->GetTypeId() == TYPEID_UNIT
&& unit->GetTypeId() == TYPEID_PLAYER
&& unit->IsPlayer()
&& seat->second.SeatInfo->m_flags & VEHICLE_SEAT_FLAG_CAN_CONTROL)
{
// Removed try catch + ABORT() here, and make it as simple condition check.
@@ -460,7 +460,7 @@ void Vehicle::RemovePassenger(Unit* unit)
unit->GetName(), _me->GetEntry(), _vehicleInfo->m_ID, _me->GetGUID().ToString(), (int32)seat->first);
if (seat->second.SeatInfo->CanEnterOrExit() && ++_usableSeatNum)
_me->SetNpcFlag((_me->GetTypeId() == TYPEID_PLAYER ? UNIT_NPC_FLAG_PLAYER_VEHICLE : UNIT_NPC_FLAG_SPELLCLICK));
_me->SetNpcFlag((_me->IsPlayer() ? UNIT_NPC_FLAG_PLAYER_VEHICLE : UNIT_NPC_FLAG_SPELLCLICK));
// Remove UNIT_FLAG_NOT_SELECTABLE if passenger did not have it before entering vehicle
if (seat->second.SeatInfo->m_flags & VEHICLE_SEAT_FLAG_PASSENGER_NOT_SELECTABLE && !seat->second.Passenger.IsUnselectable)
@@ -468,7 +468,7 @@ void Vehicle::RemovePassenger(Unit* unit)
seat->second.Passenger.Reset();
if (_me->GetTypeId() == TYPEID_UNIT && unit->GetTypeId() == TYPEID_PLAYER && seat->second.SeatInfo->m_flags & VEHICLE_SEAT_FLAG_CAN_CONTROL)
if (_me->GetTypeId() == TYPEID_UNIT && unit->IsPlayer() && seat->second.SeatInfo->m_flags & VEHICLE_SEAT_FLAG_CAN_CONTROL)
_me->RemoveCharmedBy(unit);
if (_me->IsInWorld())
@@ -483,7 +483,7 @@ void Vehicle::RemovePassenger(Unit* unit)
}
// only for flyable vehicles
if (_me->IsFlying() && !_me->GetInstanceId() && unit->GetTypeId() == TYPEID_PLAYER && !(unit->ToPlayer()->GetDelayedOperations() & DELAYED_VEHICLE_TELEPORT) && _me->GetEntry() != 30275 /*NPC_WILD_WYRM*/)
if (_me->IsFlying() && !_me->GetInstanceId() && unit->IsPlayer() && !(unit->ToPlayer()->GetDelayedOperations() & DELAYED_VEHICLE_TELEPORT) && _me->GetEntry() != 30275 /*NPC_WILD_WYRM*/)
_me->CastSpell(unit, VEHICLE_SPELL_PARACHUTE, true);
if (_me->GetTypeId() == TYPEID_UNIT)
@@ -533,7 +533,7 @@ bool Vehicle::IsVehicleInUse()
for (SeatMap::const_iterator itr = Seats.begin(); itr != Seats.end(); ++itr)
if (Unit* passenger = ObjectAccessor::GetUnit(*GetBase(), itr->second.Passenger.Guid))
{
if (passenger->GetTypeId() == TYPEID_PLAYER)
if (passenger->IsPlayer())
return true;
else if (passenger->GetTypeId() == TYPEID_UNIT && passenger->GetVehicleKit() && passenger->GetVehicleKit()->IsVehicleInUse())
return true;
@@ -550,7 +550,7 @@ void Vehicle::TeleportVehicle(float x, float y, float z, float ang)
for (SeatMap::const_iterator itr = Seats.begin(); itr != Seats.end(); ++itr)
if (Unit* passenger = ObjectAccessor::GetUnit(*GetBase(), itr->second.Passenger.Guid))
{
if (passenger->GetTypeId() == TYPEID_PLAYER)
if (passenger->IsPlayer())
{
passenger->ToPlayer()->SetMover(passenger);
passenger->NearTeleportTo(x, y, z, ang, false, true);