mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[9578] Use ObjectGuid in visibility sets
This commit is contained in:
parent
29b2c80449
commit
acde81fc54
8 changed files with 37 additions and 32 deletions
|
|
@ -100,7 +100,7 @@ VisibleNotifier::Notify()
|
|||
|
||||
#ifdef MANGOS_DEBUG
|
||||
if((sLog.getLogFilter() & LOG_FILTER_VISIBILITY_CHANGES)==0)
|
||||
sLog.outDebug("Object %u (Type: %u) is out of range (no in active cells set) now for player %u",GUID_LOPART(*itr),GuidHigh2TypeId(GUID_HIPART(*itr)),i_player.GetGUIDLow());
|
||||
sLog.outDebug("%s is out of range (no in active cells set) now for player %u",itr->GetString().c_str(),i_player.GetGUIDLow());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -123,10 +123,10 @@ VisibleNotifier::Notify()
|
|||
i_player.GetSession()->SendPacket(&packet);
|
||||
|
||||
// send out of range to other players if need
|
||||
std::set<uint64> const& oor = i_data.GetOutOfRangeGUIDs();
|
||||
for(std::set<uint64>::const_iterator iter = oor.begin(); iter != oor.end(); ++iter)
|
||||
std::set<ObjectGuid> const& oor = i_data.GetOutOfRangeGUIDs();
|
||||
for(std::set<ObjectGuid>::const_iterator iter = oor.begin(); iter != oor.end(); ++iter)
|
||||
{
|
||||
if(!IS_PLAYER_GUID(*iter))
|
||||
if(!iter->IsPlayer())
|
||||
continue;
|
||||
|
||||
if (Player* plr = ObjectAccessor::FindPlayer(*iter))
|
||||
|
|
|
|||
|
|
@ -71,7 +71,6 @@ enum HighGuid
|
|||
//*** Must be replaced by ObjectGuid use ***
|
||||
#define IS_CREATURE_GUID(Guid) ( GUID_HIPART(Guid) == HIGHGUID_UNIT )
|
||||
#define IS_PET_GUID(Guid) ( GUID_HIPART(Guid) == HIGHGUID_PET )
|
||||
#define IS_VEHICLE_GUID(Guid) ( GUID_HIPART(Guid) == HIGHGUID_VEHICLE )
|
||||
#define IS_CREATURE_OR_PET_GUID(Guid)( IS_CREATURE_GUID(Guid) || IS_PET_GUID(Guid) )
|
||||
#define IS_PLAYER_GUID(Guid) ( GUID_HIPART(Guid) == HIGHGUID_PLAYER && Guid!=0 )
|
||||
#define IS_UNIT_GUID(Guid) ( IS_CREATURE_OR_PET_GUID(Guid) || IS_PLAYER_GUID(Guid) )
|
||||
|
|
@ -169,6 +168,7 @@ class ObjectGuid
|
|||
bool IsPet() const { return GetHigh() == HIGHGUID_PET; }
|
||||
bool IsVehicle() const { return GetHigh() == HIGHGUID_VEHICLE; }
|
||||
bool IsCreatureOrPet() const { return IsCreature() || IsPet(); }
|
||||
bool IsCreatureOrVehicle() const { return IsCreature() || IsVehicle(); }
|
||||
bool IsPlayer() const { return !IsEmpty() && GetHigh() == HIGHGUID_PLAYER; }
|
||||
bool IsUnit() const { return IsCreatureOrPet() || IsPlayer(); }
|
||||
bool IsItem() const { return GetHigh() == HIGHGUID_ITEM; }
|
||||
|
|
@ -199,6 +199,8 @@ class ObjectGuid
|
|||
|
||||
TypeID GetTypeId() const { return GetTypeId(GetHigh()); }
|
||||
|
||||
bool operator< (ObjectGuid const& guid) const { return GetRawValue() < guid.GetRawValue(); }
|
||||
|
||||
public: // accessors - for debug
|
||||
static char const* GetTypeName(HighGuid high);
|
||||
char const* GetTypeName() const { return !IsEmpty() ? GetTypeName(GetHigh()) : "None"; }
|
||||
|
|
|
|||
|
|
@ -17664,12 +17664,13 @@ void Player::HandleStealthedUnitsDetection()
|
|||
{
|
||||
if(!hasAtClient)
|
||||
{
|
||||
ObjectGuid i_guid = (*i)->GetGUID();
|
||||
(*i)->SendCreateUpdateToPlayer(this);
|
||||
m_clientGUIDs.insert((*i)->GetGUID());
|
||||
m_clientGUIDs.insert(i_guid);
|
||||
|
||||
#ifdef MANGOS_DEBUG
|
||||
if((sLog.getLogFilter() & LOG_FILTER_VISIBILITY_CHANGES)==0)
|
||||
sLog.outDebug("Object %u (Type: %u) is detected in stealth by player %u. Distance = %f",(*i)->GetGUIDLow(),(*i)->GetTypeId(),GetGUIDLow(),GetDistance(*i));
|
||||
sLog.outDebug("%s is detected in stealth by player %u. Distance = %f",i_guid.GetString().c_str(),GetGUIDLow(),GetDistance(*i));
|
||||
#endif
|
||||
|
||||
// target aura duration for caster show only if target exist at caster client
|
||||
|
|
@ -18839,12 +18840,14 @@ void Player::UpdateVisibilityOf(WorldObject const* viewPoint, WorldObject* targe
|
|||
if (target->GetTypeId()==TYPEID_UNIT)
|
||||
BeforeVisibilityDestroy<Creature>((Creature*)target,this);
|
||||
|
||||
ObjectGuid t_guid = target->GetGUID();
|
||||
|
||||
target->DestroyForPlayer(this);
|
||||
m_clientGUIDs.erase(target->GetGUID());
|
||||
m_clientGUIDs.erase(t_guid);
|
||||
|
||||
#ifdef MANGOS_DEBUG
|
||||
if((sLog.getLogFilter() & LOG_FILTER_VISIBILITY_CHANGES)==0)
|
||||
sLog.outDebug("Object %u (Type: %u) out of range for player %u. Distance = %f",target->GetGUIDLow(),target->GetTypeId(),GetGUIDLow(),GetDistance(target));
|
||||
sLog.outDebug("%s out of range for player %u. Distance = %f",t_guid.GetString().c_str(),GetGUIDLow(),GetDistance(target));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
@ -18873,13 +18876,13 @@ void Player::UpdateVisibilityOf(WorldObject const* viewPoint, WorldObject* targe
|
|||
}
|
||||
|
||||
template<class T>
|
||||
inline void UpdateVisibilityOf_helper(std::set<uint64>& s64, T* target)
|
||||
inline void UpdateVisibilityOf_helper(std::set<ObjectGuid>& s64, T* target)
|
||||
{
|
||||
s64.insert(target->GetGUID());
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void UpdateVisibilityOf_helper(std::set<uint64>& s64, GameObject* target)
|
||||
inline void UpdateVisibilityOf_helper(std::set<ObjectGuid>& s64, GameObject* target)
|
||||
{
|
||||
if(!target->IsTransport())
|
||||
s64.insert(target->GetGUID());
|
||||
|
|
@ -18894,12 +18897,14 @@ void Player::UpdateVisibilityOf(WorldObject const* viewPoint, T* target, UpdateD
|
|||
{
|
||||
BeforeVisibilityDestroy<T>(target,this);
|
||||
|
||||
ObjectGuid t_guid = target->GetGUID();
|
||||
|
||||
target->BuildOutOfRangeUpdateBlock(&data);
|
||||
m_clientGUIDs.erase(target->GetGUID());
|
||||
m_clientGUIDs.erase(t_guid);
|
||||
|
||||
#ifdef MANGOS_DEBUG
|
||||
if((sLog.getLogFilter() & LOG_FILTER_VISIBILITY_CHANGES)==0)
|
||||
sLog.outDebug("Object %u (Type: %u, Entry: %u) is out of range for player %u. Distance = %f",target->GetGUIDLow(),target->GetTypeId(),target->GetEntry(),GetGUIDLow(),GetDistance(target));
|
||||
sLog.outDebug("%s is out of range for player %u. Distance = %f",t_guid.GetString().c_str(),GetGUIDLow(),GetDistance(target));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
@ -19526,13 +19531,12 @@ void Player::UpdateForQuestWorldObjects()
|
|||
WorldPacket packet;
|
||||
for(ClientGUIDs::const_iterator itr=m_clientGUIDs.begin(); itr!=m_clientGUIDs.end(); ++itr)
|
||||
{
|
||||
if(IS_GAMEOBJECT_GUID(*itr))
|
||||
if (itr->IsGameobject())
|
||||
{
|
||||
GameObject *obj = GetMap()->GetGameObject(*itr);
|
||||
if(obj)
|
||||
if (GameObject *obj = GetMap()->GetGameObject(*itr))
|
||||
obj->BuildValuesUpdateBlockForPlayer(&udata,this);
|
||||
}
|
||||
else if(IS_CREATURE_GUID(*itr) || IS_VEHICLE_GUID(*itr))
|
||||
else if (itr->IsCreatureOrVehicle())
|
||||
{
|
||||
Creature *obj = GetMap()->GetCreatureOrPetOrVehicle(*itr);
|
||||
if(!obj)
|
||||
|
|
|
|||
|
|
@ -2178,7 +2178,7 @@ class MANGOS_DLL_SPEC Player : public Unit
|
|||
Object* GetObjectByTypeMask(ObjectGuid guid, TypeMask typemask);
|
||||
|
||||
// currently visible objects at player client
|
||||
typedef std::set<uint64> ClientGUIDs;
|
||||
typedef std::set<ObjectGuid> ClientGUIDs;
|
||||
ClientGUIDs m_clientGUIDs;
|
||||
|
||||
bool HaveAtClient(WorldObject const* u) { return u==this || m_clientGUIDs.find(u->GetGUID())!=m_clientGUIDs.end(); }
|
||||
|
|
|
|||
|
|
@ -644,7 +644,7 @@ void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket
|
|||
uint8 questStatus = DIALOG_STATUS_NONE;
|
||||
uint8 defstatus = DIALOG_STATUS_NONE;
|
||||
|
||||
if (IS_CREATURE_OR_PET_GUID(*itr))
|
||||
if (itr->IsCreatureOrPet())
|
||||
{
|
||||
// need also pet quests case support
|
||||
Creature *questgiver = GetPlayer()->GetMap()->GetCreatureOrPetOrVehicle(*itr);
|
||||
|
|
@ -660,7 +660,7 @@ void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket
|
|||
data << uint8(questStatus);
|
||||
++count;
|
||||
}
|
||||
else if(IS_GAMEOBJECT_GUID(*itr))
|
||||
else if (itr->IsGameobject())
|
||||
{
|
||||
GameObject *questgiver = GetPlayer()->GetMap()->GetGameObject(*itr);
|
||||
if(!questgiver)
|
||||
|
|
|
|||
|
|
@ -23,18 +23,19 @@
|
|||
#include "Log.h"
|
||||
#include "Opcodes.h"
|
||||
#include "World.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include <zlib/zlib.h>
|
||||
|
||||
UpdateData::UpdateData() : m_blockCount(0)
|
||||
{
|
||||
}
|
||||
|
||||
void UpdateData::AddOutOfRangeGUID(std::set<uint64>& guids)
|
||||
void UpdateData::AddOutOfRangeGUID(std::set<ObjectGuid>& guids)
|
||||
{
|
||||
m_outOfRangeGUIDs.insert(guids.begin(),guids.end());
|
||||
}
|
||||
|
||||
void UpdateData::AddOutOfRangeGUID(const uint64 &guid)
|
||||
void UpdateData::AddOutOfRangeGUID(ObjectGuid const &guid)
|
||||
{
|
||||
m_outOfRangeGUIDs.insert(guid);
|
||||
}
|
||||
|
|
@ -114,10 +115,8 @@ bool UpdateData::BuildPacket(WorldPacket *packet)
|
|||
buf << (uint8) UPDATETYPE_OUT_OF_RANGE_OBJECTS;
|
||||
buf << (uint32) m_outOfRangeGUIDs.size();
|
||||
|
||||
for(std::set<uint64>::const_iterator i = m_outOfRangeGUIDs.begin(); i != m_outOfRangeGUIDs.end(); ++i)
|
||||
{
|
||||
buf.appendPackGUID(*i);
|
||||
}
|
||||
for(std::set<ObjectGuid>::const_iterator i = m_outOfRangeGUIDs.begin(); i != m_outOfRangeGUIDs.end(); ++i)
|
||||
buf << i->WriteAsPacked();
|
||||
}
|
||||
|
||||
buf.append(m_data);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#include "ByteBuffer.h"
|
||||
|
||||
class WorldPacket;
|
||||
|
||||
class ObjectGuid;
|
||||
|
||||
enum OBJECT_UPDATE_TYPE
|
||||
{
|
||||
|
|
@ -54,18 +54,18 @@ class UpdateData
|
|||
public:
|
||||
UpdateData();
|
||||
|
||||
void AddOutOfRangeGUID(std::set<uint64>& guids);
|
||||
void AddOutOfRangeGUID(const uint64 &guid);
|
||||
void AddOutOfRangeGUID(std::set<ObjectGuid>& guids);
|
||||
void AddOutOfRangeGUID(ObjectGuid const &guid);
|
||||
void AddUpdateBlock(const ByteBuffer &block);
|
||||
bool BuildPacket(WorldPacket *packet);
|
||||
bool HasData() { return m_blockCount > 0 || !m_outOfRangeGUIDs.empty(); }
|
||||
void Clear();
|
||||
|
||||
std::set<uint64> const& GetOutOfRangeGUIDs() const { return m_outOfRangeGUIDs; }
|
||||
std::set<ObjectGuid> const& GetOutOfRangeGUIDs() const { return m_outOfRangeGUIDs; }
|
||||
|
||||
protected:
|
||||
uint32 m_blockCount;
|
||||
std::set<uint64> m_outOfRangeGUIDs;
|
||||
std::set<ObjectGuid> m_outOfRangeGUIDs;
|
||||
ByteBuffer m_data;
|
||||
|
||||
void Compress(void* dst, uint32 *dst_size, void* src, int src_size);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "9577"
|
||||
#define REVISION_NR "9578"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue