mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 04:37:00 +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
|
|
@ -134,9 +134,9 @@ void WorldSession::HandleGMTicketCreateOpcode( WorldPacket & recv_data )
|
|||
|
||||
//TODO: Guard player map
|
||||
HashMapHolder<Player>::MapType &m = sObjectAccessor.GetPlayers();
|
||||
for(HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
|
||||
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
if(itr->second->GetSession()->GetSecurity() >= SEC_GAMEMASTER && itr->second->isAcceptTickets())
|
||||
if (itr->second->GetSession()->GetSecurity() >= SEC_GAMEMASTER && itr->second->isAcceptTickets())
|
||||
ChatHandler(itr->second).PSendSysMessage(LANG_COMMAND_TICKETNEW,GetPlayer()->GetName());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,14 +142,14 @@ void WorldSession::SendLfgSearchResults(LfgType type, uint32 entry)
|
|||
data << uint32(playersSize); // players count
|
||||
data << uint32(playersSize); // players count (total?)
|
||||
|
||||
for(HashMapHolder<Player>::MapType::const_iterator iter = players.begin(); iter != players.end(); ++iter)
|
||||
for (HashMapHolder<Player>::MapType::const_iterator iter = players.begin(); iter != players.end(); ++iter)
|
||||
{
|
||||
Player *plr = iter->second;
|
||||
|
||||
if(!plr || plr->GetTeam() != _player->GetTeam())
|
||||
if (!plr || plr->GetTeam() != _player->GetTeam())
|
||||
continue;
|
||||
|
||||
if(!plr->IsInWorld())
|
||||
if (!plr->IsInWorld())
|
||||
continue;
|
||||
|
||||
data << plr->GetObjectGuid(); // guid
|
||||
|
|
@ -157,7 +157,7 @@ void WorldSession::SendLfgSearchResults(LfgType type, uint32 entry)
|
|||
uint32 flags = 0xFF;
|
||||
data << uint32(flags); // flags
|
||||
|
||||
if(flags & 0x1)
|
||||
if (flags & 0x1)
|
||||
{
|
||||
data << uint8(plr->getLevel());
|
||||
data << uint8(plr->getClass());
|
||||
|
|
@ -188,25 +188,25 @@ void WorldSession::SendLfgSearchResults(LfgType type, uint32 entry)
|
|||
data << uint32(0); // Expertise
|
||||
}
|
||||
|
||||
if(flags & 0x2)
|
||||
if (flags & 0x2)
|
||||
data << ""; // comment
|
||||
|
||||
if(flags & 0x4)
|
||||
if (flags & 0x4)
|
||||
data << uint8(0); // group leader
|
||||
|
||||
if(flags & 0x8)
|
||||
if (flags & 0x8)
|
||||
data << uint64(1); // group guid
|
||||
|
||||
if(flags & 0x10)
|
||||
if (flags & 0x10)
|
||||
data << uint8(0); // roles
|
||||
|
||||
if(flags & 0x20)
|
||||
if (flags & 0x20)
|
||||
data << uint32(plr->GetZoneId()); // areaid
|
||||
|
||||
if(flags & 0x40)
|
||||
if (flags & 0x40)
|
||||
data << uint8(0); // status
|
||||
|
||||
if(flags & 0x80)
|
||||
if (flags & 0x80)
|
||||
{
|
||||
data << uint64(0); // instance guid
|
||||
data << uint32(0); // completed encounters
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ bool ChatHandler::HandleGMListIngameCommand(char* /*args*/)
|
|||
{
|
||||
HashMapHolder<Player>::ReadGuard g(HashMapHolder<Player>::GetLock());
|
||||
HashMapHolder<Player>::MapType &m = sObjectAccessor.GetPlayers();
|
||||
for(HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
|
||||
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
AccountTypes itr_sec = itr->second->GetSession()->GetSecurity();
|
||||
if ((itr->second->isGameMaster() || (itr_sec > SEC_PLAYER && itr_sec <= (AccountTypes)sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_GM_LIST))) &&
|
||||
|
|
|
|||
|
|
@ -4985,7 +4985,7 @@ bool ChatHandler::HandleResetAllCommand(char* args)
|
|||
|
||||
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE (at_login & '%u') = '0'", atLogin, atLogin);
|
||||
HashMapHolder<Player>::MapType const& plist = sObjectAccessor.GetPlayers();
|
||||
for(HashMapHolder<Player>::MapType::const_iterator itr = plist.begin(); itr != plist.end(); ++itr)
|
||||
for (HashMapHolder<Player>::MapType::const_iterator itr = plist.begin(); itr != plist.end(); ++itr)
|
||||
itr->second->SetAtLoginFlag(atLogin);
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -144,47 +144,49 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data )
|
|||
|
||||
// TODO: Guard Player map
|
||||
HashMapHolder<Player>::MapType& m = sObjectAccessor.GetPlayers();
|
||||
for(HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
|
||||
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)
|
||||
for (uint32 i = 0; i < zones_count; ++i)
|
||||
{
|
||||
if(zoneids[i] == pzoneid)
|
||||
{
|
||||
|
|
@ -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,9 +208,9 @@ 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))
|
||||
if (!Utf8toWStr(gname,wgname))
|
||||
continue;
|
||||
wstrToLower(wgname);
|
||||
|
||||
|
|
@ -216,11 +218,11 @@ 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;
|
||||
for(uint32 i = 0; i < str_count; ++i)
|
||||
for (uint32 i = 0; i < str_count; ++i)
|
||||
{
|
||||
if (!str[i].empty())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -88,8 +88,8 @@ ObjectAccessor::FindPlayerByName(const char *name)
|
|||
{
|
||||
HashMapHolder<Player>::ReadGuard g(HashMapHolder<Player>::GetLock());
|
||||
HashMapHolder<Player>::MapType& m = sObjectAccessor.GetPlayers();
|
||||
for(HashMapHolder<Player>::MapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
if(iter->second->IsInWorld() && ( ::strcmp(name, iter->second->GetName()) == 0 ))
|
||||
for (HashMapHolder<Player>::MapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
if (iter->second->IsInWorld() && ( ::strcmp(name, iter->second->GetName()) == 0 ))
|
||||
return iter->second;
|
||||
|
||||
return NULL;
|
||||
|
|
@ -100,7 +100,7 @@ ObjectAccessor::SaveAllPlayers()
|
|||
{
|
||||
HashMapHolder<Player>::ReadGuard g(HashMapHolder<Player>::GetLock());
|
||||
HashMapHolder<Player>::MapType& m = sObjectAccessor.GetPlayers();
|
||||
for(HashMapHolder<Player>::MapType::iterator itr = m.begin(); itr != m.end(); ++itr)
|
||||
for (HashMapHolder<Player>::MapType::iterator itr = m.begin(); itr != m.end(); ++itr)
|
||||
itr->second->SaveToDB();
|
||||
}
|
||||
|
||||
|
|
@ -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