mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 19:37:02 +00:00
[11455] Use ObjectGuid in HashMapHolder
This commit is contained in:
parent
b647835469
commit
51031c2d24
8 changed files with 42 additions and 40 deletions
|
|
@ -146,42 +146,44 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data )
|
|||
HashMapHolder<Player>::MapType& m = sObjectAccessor.GetPlayers();
|
||||
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
Player* pl = itr->second;
|
||||
|
||||
if (security == SEC_PLAYER)
|
||||
{
|
||||
// player can see member of other team only if CONFIG_BOOL_ALLOW_TWO_SIDE_WHO_LIST
|
||||
if (itr->second->GetTeam() != team && !allowTwoSideWhoList )
|
||||
if (pl->GetTeam() != team && !allowTwoSideWhoList )
|
||||
continue;
|
||||
|
||||
// player can see MODERATOR, GAME MASTER, ADMINISTRATOR only if CONFIG_GM_IN_WHO_LIST
|
||||
if (itr->second->GetSession()->GetSecurity() > gmLevelInWhoList)
|
||||
if (pl->GetSession()->GetSecurity() > gmLevelInWhoList)
|
||||
continue;
|
||||
}
|
||||
|
||||
// do not process players which are not in world
|
||||
if(!(itr->second->IsInWorld()))
|
||||
if (!pl->IsInWorld())
|
||||
continue;
|
||||
|
||||
// check if target is globally visible for player
|
||||
if (!(itr->second->IsVisibleGloballyFor(_player)))
|
||||
if (!pl->IsVisibleGloballyFor(_player))
|
||||
continue;
|
||||
|
||||
// check if target's level is in level range
|
||||
uint32 lvl = itr->second->getLevel();
|
||||
uint32 lvl = pl->getLevel();
|
||||
if (lvl < level_min || lvl > level_max)
|
||||
continue;
|
||||
|
||||
// check if class matches classmask
|
||||
uint32 class_ = itr->second->getClass();
|
||||
uint32 class_ = pl->getClass();
|
||||
if (!(classmask & (1 << class_)))
|
||||
continue;
|
||||
|
||||
// check if race matches racemask
|
||||
uint32 race = itr->second->getRace();
|
||||
uint32 race = pl->getRace();
|
||||
if (!(racemask & (1 << race)))
|
||||
continue;
|
||||
|
||||
uint32 pzoneid = itr->second->GetZoneId();
|
||||
uint8 gender = itr->second->getGender();
|
||||
uint32 pzoneid = pl->GetZoneId();
|
||||
uint8 gender = pl->getGender();
|
||||
|
||||
bool z_show = true;
|
||||
for (uint32 i = 0; i < zones_count; ++i)
|
||||
|
|
@ -197,7 +199,7 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data )
|
|||
if (!z_show)
|
||||
continue;
|
||||
|
||||
std::string pname = itr->second->GetName();
|
||||
std::string pname = pl->GetName();
|
||||
std::wstring wpname;
|
||||
if(!Utf8toWStr(pname,wpname))
|
||||
continue;
|
||||
|
|
@ -206,7 +208,7 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data )
|
|||
if (!(wplayer_name.empty() || wpname.find(wplayer_name) != std::wstring::npos))
|
||||
continue;
|
||||
|
||||
std::string gname = sGuildMgr.GetGuildNameById(itr->second->GetGuildId());
|
||||
std::string gname = sGuildMgr.GetGuildNameById(pl->GetGuildId());
|
||||
std::wstring wgname;
|
||||
if (!Utf8toWStr(gname,wgname))
|
||||
continue;
|
||||
|
|
@ -216,7 +218,7 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data )
|
|||
continue;
|
||||
|
||||
std::string aname;
|
||||
if(AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(itr->second->GetZoneId()))
|
||||
if (AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(pzoneid))
|
||||
aname = areaEntry->area_name[GetSessionDbcLocale()];
|
||||
|
||||
bool s_show = true;
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@ void ObjectAccessor::RemoveOldCorpses()
|
|||
|
||||
/// Define the static member of HashMapHolder
|
||||
|
||||
template <class T> UNORDERED_MAP< uint64, T* > HashMapHolder<T>::m_objectMap;
|
||||
template <class T> typename HashMapHolder<T>::MapType HashMapHolder<T>::m_objectMap;
|
||||
template <class T> ACE_RW_Thread_Mutex HashMapHolder<T>::i_lock;
|
||||
|
||||
/// Global definitions for the hashmap storage
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class HashMapHolder
|
|||
{
|
||||
public:
|
||||
|
||||
typedef UNORDERED_MAP< uint64, T* > MapType;
|
||||
typedef UNORDERED_MAP<ObjectGuid, T*> MapType;
|
||||
typedef ACE_RW_Thread_Mutex LockType;
|
||||
typedef ACE_Read_Guard<LockType> ReadGuard;
|
||||
typedef ACE_Write_Guard<LockType> WriteGuard;
|
||||
|
|
@ -54,19 +54,19 @@ class HashMapHolder
|
|||
static void Insert(T* o)
|
||||
{
|
||||
WriteGuard guard(i_lock);
|
||||
m_objectMap[o->GetGUID()] = o;
|
||||
m_objectMap[o->GetObjectGuid()] = o;
|
||||
}
|
||||
|
||||
static void Remove(T* o)
|
||||
{
|
||||
WriteGuard guard(i_lock);
|
||||
m_objectMap.erase(o->GetGUID());
|
||||
m_objectMap.erase(o->GetObjectGuid());
|
||||
}
|
||||
|
||||
static T* Find(ObjectGuid guid)
|
||||
{
|
||||
ReadGuard guard(i_lock);
|
||||
typename MapType::iterator itr = m_objectMap.find(guid.GetRawValue());
|
||||
typename MapType::iterator itr = m_objectMap.find(guid);
|
||||
return (itr != m_objectMap.end()) ? itr->second : NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "11454"
|
||||
#define REVISION_NR "11455"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue