diff --git a/src/game/GridNotifiers.cpp b/src/game/GridNotifiers.cpp index e654cc7f3..d25078b83 100644 --- a/src/game/GridNotifiers.cpp +++ b/src/game/GridNotifiers.cpp @@ -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 const& oor = i_data.GetOutOfRangeGUIDs(); - for(std::set::const_iterator iter = oor.begin(); iter != oor.end(); ++iter) + std::set const& oor = i_data.GetOutOfRangeGUIDs(); + for(std::set::const_iterator iter = oor.begin(); iter != oor.end(); ++iter) { - if(!IS_PLAYER_GUID(*iter)) + if(!iter->IsPlayer()) continue; if (Player* plr = ObjectAccessor::FindPlayer(*iter)) diff --git a/src/game/ObjectGuid.h b/src/game/ObjectGuid.h index fdbe0f642..c8ac65228 100644 --- a/src/game/ObjectGuid.h +++ b/src/game/ObjectGuid.h @@ -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"; } diff --git a/src/game/Player.cpp b/src/game/Player.cpp index ea3f1e15c..867f16297 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -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*)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 -inline void UpdateVisibilityOf_helper(std::set& s64, T* target) +inline void UpdateVisibilityOf_helper(std::set& s64, T* target) { s64.insert(target->GetGUID()); } template<> -inline void UpdateVisibilityOf_helper(std::set& s64, GameObject* target) +inline void UpdateVisibilityOf_helper(std::set& s64, GameObject* target) { if(!target->IsTransport()) s64.insert(target->GetGUID()); @@ -18894,12 +18897,14 @@ void Player::UpdateVisibilityOf(WorldObject const* viewPoint, T* target, UpdateD { BeforeVisibilityDestroy(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) diff --git a/src/game/Player.h b/src/game/Player.h index 613e22b0b..a4166be9a 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -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 ClientGUIDs; + typedef std::set ClientGUIDs; ClientGUIDs m_clientGUIDs; bool HaveAtClient(WorldObject const* u) { return u==this || m_clientGUIDs.find(u->GetGUID())!=m_clientGUIDs.end(); } diff --git a/src/game/QuestHandler.cpp b/src/game/QuestHandler.cpp index 07cecb34f..e925099af 100644 --- a/src/game/QuestHandler.cpp +++ b/src/game/QuestHandler.cpp @@ -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) diff --git a/src/game/UpdateData.cpp b/src/game/UpdateData.cpp index 49105bfad..ec3ba1434 100644 --- a/src/game/UpdateData.cpp +++ b/src/game/UpdateData.cpp @@ -23,18 +23,19 @@ #include "Log.h" #include "Opcodes.h" #include "World.h" +#include "ObjectGuid.h" #include UpdateData::UpdateData() : m_blockCount(0) { } -void UpdateData::AddOutOfRangeGUID(std::set& guids) +void UpdateData::AddOutOfRangeGUID(std::set& 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::const_iterator i = m_outOfRangeGUIDs.begin(); i != m_outOfRangeGUIDs.end(); ++i) - { - buf.appendPackGUID(*i); - } + for(std::set::const_iterator i = m_outOfRangeGUIDs.begin(); i != m_outOfRangeGUIDs.end(); ++i) + buf << i->WriteAsPacked(); } buf.append(m_data); diff --git a/src/game/UpdateData.h b/src/game/UpdateData.h index e4e583b60..d6845b286 100644 --- a/src/game/UpdateData.h +++ b/src/game/UpdateData.h @@ -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& guids); - void AddOutOfRangeGUID(const uint64 &guid); + void AddOutOfRangeGUID(std::set& 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 const& GetOutOfRangeGUIDs() const { return m_outOfRangeGUIDs; } + std::set const& GetOutOfRangeGUIDs() const { return m_outOfRangeGUIDs; } protected: uint32 m_blockCount; - std::set m_outOfRangeGUIDs; + std::set m_outOfRangeGUIDs; ByteBuffer m_data; void Compress(void* dst, uint32 *dst_size, void* src, int src_size); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 6309ed85d..d00a99ed8 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9577" + #define REVISION_NR "9578" #endif // __REVISION_NR_H__