feat(Core/Misc): implement ObjectGuid class (port from TC) (#4885)

This commit is contained in:
UltraNix
2021-04-25 22:18:03 +02:00
committed by GitHub
parent 91081f4ad8
commit f4c226423d
568 changed files with 10655 additions and 11019 deletions

View File

@@ -61,14 +61,14 @@ void VisibleNotifier::SendToSelf()
}
}
for (Player::ClientGUIDs::const_iterator it = vis_guids.begin(); it != vis_guids.end(); ++it)
for (GuidUnorderedSet::const_iterator it = vis_guids.begin(); it != vis_guids.end(); ++it)
{
if (WorldObject* obj = ObjectAccessor::GetWorldObject(i_player, *it))
if (i_largeOnly != obj->IsVisibilityOverridden())
continue;
// pussywizard: static transports are removed only in RemovePlayerFromMap and here if can no longer detect (eg. phase changed)
if (IS_TRANSPORT_GUID(*it))
if ((*it).IsTransport())
if (GameObject* staticTrans = i_player.GetMap()->GetGameObject(*it))
if (i_player.CanSeeOrDetect(staticTrans, false, true))
continue;
@@ -76,7 +76,7 @@ void VisibleNotifier::SendToSelf()
i_player.m_clientGUIDs.erase(*it);
i_data.AddOutOfRangeGUID(*it);
if (IS_PLAYER_GUID(*it))
if ((*it).IsPlayer())
{
Player* player = ObjectAccessor::FindPlayer(*it);
if (player && player->IsInMap(&i_player))
@@ -127,7 +127,7 @@ 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 (iter->GetSource()->GetCasterGUID().IsPlayer())
if (Unit* caster = iter->GetSource()->GetCaster())
if (Player* player = caster->ToPlayer())
if (player->m_seer == iter->GetSource())
@@ -245,7 +245,7 @@ void MessageDistDeliverer::Visit(DynamicObjectMapType& m)
for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
{
DynamicObject* target = iter->GetSource();
if (!IS_PLAYER_GUID(target->GetCasterGUID()) || !target->InSamePhase(i_phaseMask))
if (!target->GetCasterGUID().IsPlayer() || !target->InSamePhase(i_phaseMask))
continue;
// Xinef: Check whether the dynobject allows to see through it
@@ -311,7 +311,7 @@ void MessageDistDelivererToHostile::Visit(DynamicObjectMapType& m)
for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
{
DynamicObject* target = iter->GetSource();
if (!IS_PLAYER_GUID(target->GetCasterGUID()) || !target->InSamePhase(i_phaseMask))
if (!target->GetCasterGUID().IsPlayer() || !target->InSamePhase(i_phaseMask))
continue;
if (target->GetExactDist2dSq(i_source) > i_distSq)

View File

@@ -28,7 +28,7 @@ namespace acore
struct VisibleNotifier
{
Player& i_player;
Player::ClientGUIDs vis_guids;
GuidUnorderedSet vis_guids;
std::vector<Unit*>& i_visibleNow;
bool i_gobjOnly;
bool i_largeOnly;
@@ -718,18 +718,6 @@ namespace acore
NearestGameObjectTypeInObjectRangeCheck(NearestGameObjectTypeInObjectRangeCheck const&);
};
class GameObjectWithDbGUIDCheck
{
public:
GameObjectWithDbGUIDCheck(uint32 db_guid) : i_db_guid(db_guid) {}
bool operator()(GameObject const* go) const
{
return go->GetDBTableGUIDLow() == i_db_guid;
}
private:
uint32 i_db_guid;
};
// Unit checks
class MostHPMissingInRange
@@ -859,18 +847,6 @@ namespace acore
float i_range;
};
class CreatureWithDbGUIDCheck
{
public:
CreatureWithDbGUIDCheck(uint32 lowguid) : i_lowguid(lowguid) {}
bool operator()(Creature* u)
{
return u->GetDBTableGUIDLow() == i_lowguid;
}
private:
uint32 i_lowguid;
};
class AnyFriendlyUnitInObjectRangeCheck
{
public:
@@ -1402,21 +1378,21 @@ namespace acore
class ObjectGUIDCheck
{
public:
ObjectGUIDCheck(uint64 GUID, bool equals) : _GUID(GUID), _equals(equals) {}
ObjectGUIDCheck(ObjectGuid GUID, bool equals) : _GUID(GUID), _equals(equals) {}
bool operator()(WorldObject const* object)
{
return (object->GetGUID() == _GUID) == _equals;
}
private:
uint64 _GUID;
ObjectGuid _GUID;
bool _equals;
};
class UnitAuraCheck
{
public:
UnitAuraCheck(bool present, uint32 spellId, uint64 casterGUID = 0) : _present(present), _spellId(spellId), _casterGUID(casterGUID) {}
UnitAuraCheck(bool present, uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty) : _present(present), _spellId(spellId), _casterGUID(casterGUID) {}
bool operator()(Unit const* unit) const
{
return unit->HasAura(_spellId, _casterGUID) == _present;
@@ -1430,7 +1406,7 @@ namespace acore
private:
bool _present;
uint32 _spellId;
uint64 _casterGUID;
ObjectGuid _casterGUID;
};
class AllWorldObjectsInExactRange