mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-24 14:16:31 +00:00
refactor(Core/Cache): move the GlobalPlayerCache to its own class (#9166)
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "AccountMgr.h"
|
||||
#include "ChannelMgr.h"
|
||||
#include "CharacterCache.h"
|
||||
#include "Chat.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "ObjectMgr.h"
|
||||
@@ -356,14 +357,15 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b
|
||||
{
|
||||
if (ban && (AccountMgr::IsGMAccount(sec) || isGoodConstantModerator))
|
||||
{
|
||||
if (ObjectGuid guid = sWorld->GetGlobalPlayerGUID(badname))
|
||||
if (const GlobalPlayerData* gpd = sWorld->GetGlobalPlayerData(guid.GetCounter()))
|
||||
if (ObjectGuid guid = sCharacterCache->GetCharacterGuidByName(badname))
|
||||
{
|
||||
if (CharacterCacheEntry const* gpd = sCharacterCache->GetCharacterCacheByGuid(guid))
|
||||
{
|
||||
if (Player::TeamIdForRace(gpd->race) == Player::TeamIdForRace(player->getRace()))
|
||||
if (Player::TeamIdForRace(gpd->Race) == Player::TeamIdForRace(player->getRace()))
|
||||
{
|
||||
banOffline = true;
|
||||
victim = guid;
|
||||
badAccId = gpd->accountId;
|
||||
victim = guid;
|
||||
badAccId = gpd->AccountId;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -371,6 +373,7 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!banOffline)
|
||||
{
|
||||
@@ -493,8 +496,10 @@ void Channel::UnBan(Player const* player, std::string const& badname)
|
||||
}
|
||||
|
||||
ObjectGuid victim;
|
||||
if (ObjectGuid guid = sWorld->GetGlobalPlayerGUID(badname))
|
||||
if (ObjectGuid guid = sCharacterCache->GetCharacterGuidByName(badname))
|
||||
{
|
||||
victim = guid;
|
||||
}
|
||||
|
||||
if (!victim || !IsBanned(victim))
|
||||
{
|
||||
@@ -1042,7 +1047,7 @@ void Channel::MakeChannelOwner(WorldPacket* data)
|
||||
{
|
||||
std::string name = "";
|
||||
|
||||
if (!sObjectMgr->GetPlayerNameByGUID(_ownerGUID.GetCounter(), name) || name.empty())
|
||||
if (!sCharacterCache->GetCharacterNameByGuid(_ownerGUID, name) || name.empty())
|
||||
name = "PLAYER_NOT_FOUND";
|
||||
|
||||
MakeNotifyPacket(data, CHAT_CHANNEL_OWNER_NOTICE);
|
||||
|
||||
@@ -63,7 +63,7 @@ bool ChatHandler::HasLowerSecurity(Player* target, ObjectGuid guid, bool strong)
|
||||
if (target)
|
||||
target_session = target->GetSession();
|
||||
else if (guid)
|
||||
target_account = sObjectMgr->GetPlayerAccountIdByGUID(guid.GetCounter());
|
||||
target_account = sCharacterCache->GetCharacterAccountIdByGuid(guid);
|
||||
|
||||
if (!target_session && !target_account)
|
||||
{
|
||||
@@ -633,7 +633,7 @@ ObjectGuid::LowType ChatHandler::extractLowGuidFromLink(char* text, HighGuid& gu
|
||||
if (Player* player = ObjectAccessor::FindPlayerByName(name, false))
|
||||
return player->GetGUID().GetCounter();
|
||||
|
||||
if (ObjectGuid guid = sObjectMgr->GetPlayerGUIDByName(name))
|
||||
if (ObjectGuid guid = sCharacterCache->GetCharacterGuidByName(name))
|
||||
return guid.GetCounter();
|
||||
|
||||
return 0;
|
||||
@@ -699,7 +699,7 @@ bool ChatHandler::extractPlayerTarget(char* args, Player** player, ObjectGuid* p
|
||||
*player = pl;
|
||||
|
||||
// if need guid value from DB (in name case for check player existence)
|
||||
ObjectGuid guid = !pl && (player_guid || player_name) ? sObjectMgr->GetPlayerGUIDByName(name) : ObjectGuid::Empty;
|
||||
ObjectGuid guid = !pl && (player_guid || player_name) ? sCharacterCache->GetCharacterGuidByName(name) : ObjectGuid::Empty;
|
||||
|
||||
// if allowed player guid (if no then only online players allowed)
|
||||
if (player_guid)
|
||||
@@ -851,7 +851,9 @@ bool ChatHandler::GetPlayerGroupAndGUIDByName(const char* cname, Player*& player
|
||||
|
||||
player = ObjectAccessor::FindPlayerByName(name, false);
|
||||
if (offline)
|
||||
guid = sObjectMgr->GetPlayerGUIDByName(name.c_str());
|
||||
{
|
||||
guid = sCharacterCache->GetCharacterGuidByName(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,9 +99,13 @@ ChatCommandResult Acore::ChatCommands::PlayerIdentifier::TryConsume(ChatHandler
|
||||
_guid = ObjectGuid::Create<HighGuid::Player>(val.get<ObjectGuid::LowType>());
|
||||
|
||||
if ((_player = ObjectAccessor::FindPlayerByLowGUID(_guid.GetCounter())))
|
||||
{
|
||||
_name = _player->GetName();
|
||||
else if (!sObjectMgr->GetPlayerNameByGUID(_guid.GetCounter(), _name))
|
||||
}
|
||||
else if (!sCharacterCache->GetCharacterNameByGuid(_guid, _name))
|
||||
{
|
||||
return FormatAcoreString(handler, LANG_CMDPARSER_CHAR_GUID_NO_EXIST, _guid.ToString().c_str());
|
||||
}
|
||||
|
||||
return next;
|
||||
}
|
||||
@@ -116,9 +120,13 @@ ChatCommandResult Acore::ChatCommands::PlayerIdentifier::TryConsume(ChatHandler
|
||||
return FormatAcoreString(handler, LANG_CMDPARSER_CHAR_NAME_INVALID, STRING_VIEW_FMT_ARG(_name));
|
||||
|
||||
if ((_player = ObjectAccessor::FindPlayerByName(_name)))
|
||||
{
|
||||
_guid = _player->GetGUID();
|
||||
else if (!(_guid = sObjectMgr->GetPlayerGUIDByName(_name)))
|
||||
}
|
||||
else if (!(_guid = sCharacterCache->GetCharacterGuidByName(_name)))
|
||||
{
|
||||
return FormatAcoreString(handler, LANG_CMDPARSER_CHAR_NAME_NO_EXIST, STRING_VIEW_FMT_ARG(_name));
|
||||
}
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user