AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
WhoListCacheMgr Class Reference

#include "WhoListCacheMgr.h"

Public Member Functions

void Update ()
 
WhoListInfoVector const & GetWhoList () const
 

Static Public Member Functions

static WhoListCacheMgrinstance ()
 

Protected Attributes

WhoListInfoVector _whoListStorage
 

Private Member Functions

 WhoListCacheMgr ()=default
 
 ~WhoListCacheMgr ()=default
 
 WhoListCacheMgr (WhoListCacheMgr const &)=delete
 
 WhoListCacheMgr (WhoListCacheMgr &&)=delete
 
WhoListCacheMgroperator= (WhoListCacheMgr const &)=delete
 
WhoListCacheMgroperator= (WhoListCacheMgr &&)=delete
 

Detailed Description

Constructor & Destructor Documentation

◆ WhoListCacheMgr() [1/3]

WhoListCacheMgr::WhoListCacheMgr ( )
privatedefault

◆ ~WhoListCacheMgr()

WhoListCacheMgr::~WhoListCacheMgr ( )
privatedefault

◆ WhoListCacheMgr() [2/3]

WhoListCacheMgr::WhoListCacheMgr ( WhoListCacheMgr const &  )
privatedelete

◆ WhoListCacheMgr() [3/3]

WhoListCacheMgr::WhoListCacheMgr ( WhoListCacheMgr &&  )
privatedelete

Member Function Documentation

◆ GetWhoList()

WhoListInfoVector const & WhoListCacheMgr::GetWhoList ( ) const
inline
90{ return _whoListStorage; }
WhoListInfoVector _whoListStorage
Definition: WhoListCacheMgr.h:93

◆ instance()

WhoListCacheMgr * WhoListCacheMgr::instance ( )
static
24{
26 return &instance;
27}
Definition: WhoListCacheMgr.h:77
static WhoListCacheMgr * instance()
Definition: WhoListCacheMgr.cpp:23

References instance().

Referenced by instance().

◆ operator=() [1/2]

WhoListCacheMgr & WhoListCacheMgr::operator= ( WhoListCacheMgr &&  )
privatedelete

◆ operator=() [2/2]

WhoListCacheMgr & WhoListCacheMgr::operator= ( WhoListCacheMgr const &  )
privatedelete

◆ Update()

void WhoListCacheMgr::Update ( )
30{
31 // clear current list
32 _whoListStorage.clear();
33 _whoListStorage.reserve(sWorld->GetPlayerCount() + 1);
34
35 for (auto const& [guid, player] : ObjectAccessor::GetPlayers())
36 {
37 if (!player->FindMap() || player->GetSession()->PlayerLoading())
38 continue;
39
40 std::string playerName = player->GetName();
41 std::wstring widePlayerName;
42
43 if (!Utf8toWStr(playerName, widePlayerName))
44 continue;
45
46 wstrToLower(widePlayerName);
47
48 std::string guildName = sGuildMgr->GetGuildNameById(player->GetGuildId());
49 std::wstring wideGuildName;
50
51 if (!Utf8toWStr(guildName, wideGuildName))
52 continue;
53
54 wstrToLower(wideGuildName);
55
56 _whoListStorage.emplace_back(player->GetGUID(), player->GetTeamId(), player->GetSession()->GetSecurity(), player->GetLevel(),
57 player->getClass(), player->getRace(),
58 (player->IsSpectator() ? 4395 /*Dalaran*/ : player->GetZoneId()), player->getGender(), player->IsVisible(),
59 widePlayerName, wideGuildName, playerName, guildName);
60 }
61}
bool Utf8toWStr(char const *utf8str, std::size_t csize, wchar_t *wstr, std::size_t &wsize)
Definition: Util.cpp:281
void wstrToLower(std::wstring &str)
Definition: Util.cpp:382
#define sGuildMgr
Definition: GuildMgr.h:51
#define sWorld
Definition: World.h:444
HashMapHolder< Player >::MapType const & GetPlayers()
Definition: ObjectAccessor.cpp:78

References _whoListStorage, ObjectAccessor::GetPlayers(), sGuildMgr, sWorld, Utf8toWStr(), and wstrToLower().

Member Data Documentation

◆ _whoListStorage

WhoListInfoVector WhoListCacheMgr::_whoListStorage
protected

Referenced by Update().