mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 10:26:28 +01:00
Core/Misc: Moved CharacterInfo out of world to separate class
Closes #19030
(cherrypicked from 59ce3d6c9b)
This commit is contained in:
@@ -24,6 +24,7 @@ EndScriptData */
|
||||
|
||||
#include "ScriptMgr.h"
|
||||
#include "ArenaTeamMgr.h"
|
||||
#include "CharacterCache.h"
|
||||
#include "Chat.h"
|
||||
#include "Language.h"
|
||||
#include "Log.h"
|
||||
@@ -86,7 +87,7 @@ public:
|
||||
|
||||
if (type == 2 || type == 3 || type == 5 )
|
||||
{
|
||||
if (Player::GetArenaTeamIdFromCharacterInfo(target->GetGUID(), type) != 0)
|
||||
if (sCharacterCache->GetCharacterArenaTeamIdByGuid(target->GetGUID(), type) != 0)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_ARENA_ERROR_SIZE, target->GetName().c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
@@ -277,7 +278,7 @@ public:
|
||||
arena->SetCaptain(targetGuid);
|
||||
|
||||
std::string oldCaptainName;
|
||||
if (!ObjectMgr::GetPlayerNameByGUID(arena->GetCaptain(), oldCaptainName))
|
||||
if (!sCharacterCache->GetCharacterNameByGuid(arena->GetCaptain(), oldCaptainName))
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
|
||||
@@ -23,6 +23,7 @@ Category: commandscripts
|
||||
EndScriptData */
|
||||
|
||||
#include "AccountMgr.h"
|
||||
#include "CharacterCache.h"
|
||||
#include "Chat.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "Language.h"
|
||||
@@ -313,7 +314,7 @@ public:
|
||||
|
||||
if (!target)
|
||||
{
|
||||
targetGuid = sWorld->GetCharacterGuidByName(name);
|
||||
targetGuid = sCharacterCache->GetCharacterGuidByName(name);
|
||||
if (targetGuid.IsEmpty())
|
||||
{
|
||||
handler->SendSysMessage(LANG_BANINFO_NOCHARACTER);
|
||||
|
||||
@@ -23,6 +23,7 @@ Category: commandscripts
|
||||
EndScriptData */
|
||||
|
||||
#include "AccountMgr.h"
|
||||
#include "CharacterCache.h"
|
||||
#include "Chat.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "DB2Stores.h"
|
||||
@@ -214,7 +215,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sWorld->GetCharacterGuidByName(delInfo.name).IsEmpty())
|
||||
if (!sCharacterCache->GetCharacterGuidByName(delInfo.name).IsEmpty())
|
||||
{
|
||||
handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_NAME, delInfo.name.c_str(), delInfo.guid.ToString().c_str(), delInfo.accountId);
|
||||
return;
|
||||
@@ -226,7 +227,7 @@ public:
|
||||
stmt->setUInt64(2, delInfo.guid.GetCounter());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
sWorld->UpdateCharacterInfoDeleted(delInfo.guid, false, &delInfo.name);
|
||||
sCharacterCache->UpdateCharacterInfoDeleted(delInfo.guid, false, &delInfo.name);
|
||||
}
|
||||
|
||||
static void HandleCharacterLevel(Player* player, ObjectGuid playerGuid, uint32 oldLevel, uint32 newLevel, ChatHandler* handler)
|
||||
@@ -328,7 +329,7 @@ public:
|
||||
if (handler->HasLowerSecurity(NULL, targetGuid))
|
||||
return false;
|
||||
|
||||
ObjectMgr::GetPlayerNameByGUID(targetGuid, playerOldName);
|
||||
sCharacterCache->GetCharacterNameByGuid(targetGuid, playerOldName);
|
||||
}
|
||||
|
||||
if (!normalizePlayerName(newName))
|
||||
@@ -385,15 +386,14 @@ public:
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
sWorld->UpdateCharacterInfo(targetGuid, newName);
|
||||
sWorld->UpdateCharacterGuidByName(targetGuid, playerOldName, newName);
|
||||
sCharacterCache->UpdateCharacterData(targetGuid, newName);
|
||||
|
||||
handler->PSendSysMessage(LANG_RENAME_PLAYER_WITH_NEW_NAME, playerOldName.c_str(), newName.c_str());
|
||||
|
||||
if (WorldSession* session = handler->GetSession())
|
||||
{
|
||||
if (Player* player = session->GetPlayer())
|
||||
sLog->outCommand(session->GetAccountId(), "GM %s (Account: %u) forced rename %s to player %s (Account: %u)", player->GetName().c_str(), session->GetAccountId(), newName.c_str(), playerOldName.c_str(), ObjectMgr::GetPlayerAccountIdByGUID(targetGuid));
|
||||
sLog->outCommand(session->GetAccountId(), "GM %s (Account: %u) forced rename %s to player %s (Account: %u)", player->GetName().c_str(), session->GetAccountId(), newName.c_str(), playerOldName.c_str(), sCharacterCache->GetCharacterAccountIdByGuid(targetGuid));
|
||||
}
|
||||
else
|
||||
sLog->outCommand(0, "CONSOLE forced rename '%s' to '%s' (%s)", playerOldName.c_str(), newName.c_str(), targetGuid.ToString().c_str());
|
||||
@@ -449,7 +449,7 @@ public:
|
||||
if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &targetName))
|
||||
return false;
|
||||
|
||||
int32 oldlevel = target ? target->getLevel() : Player::GetLevelFromCharacterInfo(targetGuid);
|
||||
int32 oldlevel = target ? target->getLevel() : sCharacterCache->GetCharacterLevelByGuid(targetGuid);
|
||||
int32 newlevel = levelStr ? atoi(levelStr) : oldlevel;
|
||||
|
||||
if (newlevel < 1)
|
||||
@@ -566,7 +566,7 @@ public:
|
||||
if (!handler->extractPlayerTarget(playerNameStr, nullptr, &targetGuid, &targetName))
|
||||
return false;
|
||||
|
||||
CharacterInfo const* characterInfo = sWorld->GetCharacterInfo(targetGuid);
|
||||
CharacterCacheEntry const* characterInfo = sCharacterCache->GetCharacterCacheByGuid(targetGuid);
|
||||
if (!characterInfo)
|
||||
{
|
||||
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
@@ -618,7 +618,7 @@ public:
|
||||
sWorld->UpdateRealmCharCount(oldAccountId);
|
||||
sWorld->UpdateRealmCharCount(newAccountId);
|
||||
|
||||
sWorld->UpdateCharacterInfoAccount(targetGuid, newAccountId);
|
||||
sCharacterCache->UpdateCharacterAccountId(targetGuid, newAccountId);
|
||||
|
||||
handler->PSendSysMessage(LANG_CHANGEACCOUNT_SUCCESS, targetName.c_str(), accountName.c_str());
|
||||
|
||||
@@ -865,14 +865,14 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
characterGuid = sWorld->GetCharacterGuidByName(characterName);
|
||||
characterGuid = sCharacterCache->GetCharacterGuidByName(characterName);
|
||||
if (!characterGuid)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_NO_PLAYER, characterName.c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
accountId = ObjectMgr::GetPlayerAccountIdByGUID(characterGuid);
|
||||
accountId = sCharacterCache->GetCharacterAccountIdByGuid(characterGuid);
|
||||
}
|
||||
|
||||
std::string accountName;
|
||||
@@ -903,7 +903,7 @@ public:
|
||||
if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &targetName))
|
||||
return false;
|
||||
|
||||
int32 oldlevel = target ? target->getLevel() : Player::GetLevelFromCharacterInfo(targetGuid);
|
||||
int32 oldlevel = target ? target->getLevel() : sCharacterCache->GetCharacterLevelByGuid(targetGuid);
|
||||
int32 addlevel = levelStr ? atoi(levelStr) : 1;
|
||||
int32 newlevel = oldlevel + addlevel;
|
||||
|
||||
@@ -1001,7 +1001,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ObjectMgr::GetPlayerAccountIdByGUID(ObjectGuid::Create<HighGuid::Player>(guid)))
|
||||
if (sCharacterCache->GetCharacterAccountIdByGuid(ObjectGuid::Create<HighGuid::Player>(guid)))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_CHARACTER_GUID_IN_USE, std::to_string(guid).c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
@@ -1060,10 +1060,10 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
guid = sWorld->GetCharacterGuidByName(name);
|
||||
guid = sCharacterCache->GetCharacterGuidByName(name);
|
||||
}
|
||||
|
||||
if (!ObjectMgr::GetPlayerAccountIdByGUID(guid))
|
||||
if (!sCharacterCache->GetCharacterAccountIdByGuid(guid))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
handler->SetSentErrorMessage(true);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "ScriptMgr.h"
|
||||
#include "CharacterCache.h"
|
||||
#include "Chat.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "DB2Stores.h"
|
||||
@@ -277,7 +278,7 @@ public:
|
||||
ObjectGuid parseGUID = ObjectGuid::Create<HighGuid::Player>(strtoull(args, nullptr, 10));
|
||||
|
||||
// ... and try to extract a player out of it.
|
||||
if (ObjectMgr::GetPlayerNameByGUID(parseGUID, nameTarget))
|
||||
if (sCharacterCache->GetCharacterNameByGuid(parseGUID, nameTarget))
|
||||
{
|
||||
playerTarget = ObjectAccessor::FindPlayer(parseGUID);
|
||||
guidTarget = parseGUID;
|
||||
|
||||
@@ -24,6 +24,7 @@ EndScriptData */
|
||||
|
||||
#include "ScriptMgr.h"
|
||||
#include "AchievementMgr.h"
|
||||
#include "CharacterCache.h"
|
||||
#include "Chat.h"
|
||||
#include "Language.h"
|
||||
#include "Guild.h"
|
||||
@@ -162,7 +163,7 @@ public:
|
||||
if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid))
|
||||
return false;
|
||||
|
||||
ObjectGuid::LowType guildId = target ? target->GetGuildId() : Player::GetGuildIdFromCharacterInfo(targetGuid);
|
||||
ObjectGuid::LowType guildId = target ? target->GetGuildId() : sCharacterCache->GetCharacterGuildIdByGuid(targetGuid);
|
||||
if (!guildId)
|
||||
return false;
|
||||
|
||||
@@ -189,7 +190,7 @@ public:
|
||||
if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &target_name))
|
||||
return false;
|
||||
|
||||
ObjectGuid::LowType guildId = target ? target->GetGuildId() : Player::GetGuildIdFromCharacterInfo(targetGuid);
|
||||
ObjectGuid::LowType guildId = target ? target->GetGuildId() : sCharacterCache->GetCharacterGuildIdByGuid(targetGuid);
|
||||
if (!guildId)
|
||||
return false;
|
||||
|
||||
@@ -272,7 +273,7 @@ public:
|
||||
handler->PSendSysMessage(LANG_GUILD_INFO_NAME, guild->GetName().c_str(), std::to_string(guild->GetId()).c_str()); // Guild Id + Name
|
||||
|
||||
std::string guildMasterName;
|
||||
if (ObjectMgr::GetPlayerNameByGUID(guild->GetLeaderGUID(), guildMasterName))
|
||||
if (sCharacterCache->GetCharacterNameByGuid(guild->GetLeaderGUID(), guildMasterName))
|
||||
handler->PSendSysMessage(LANG_GUILD_INFO_GUILD_MASTER, guildMasterName.c_str(), guild->GetLeaderGUID().ToString().c_str()); // Guild Master
|
||||
|
||||
// Format creation date
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "ScriptMgr.h"
|
||||
#include "CharacterCache.h"
|
||||
#include "Chat.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "Group.h"
|
||||
@@ -83,7 +84,7 @@ public:
|
||||
|
||||
ObjectGuid parseGUID = ObjectGuid::Create<HighGuid::Player>(uint64(atoull(args)));
|
||||
|
||||
if (sObjectMgr->GetPlayerNameByGUID(parseGUID, nameTarget))
|
||||
if (sCharacterCache->GetCharacterNameByGuid(parseGUID, nameTarget))
|
||||
{
|
||||
playerTarget = ObjectAccessor::FindPlayer(parseGUID);
|
||||
guidTarget = parseGUID;
|
||||
|
||||
@@ -23,6 +23,7 @@ Category: commandscripts
|
||||
EndScriptData */
|
||||
|
||||
#include "ScriptMgr.h"
|
||||
#include "CharacterCache.h"
|
||||
#include "Chat.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "Language.h"
|
||||
@@ -479,7 +480,7 @@ public:
|
||||
|
||||
ObjectGuid parseGUID = ObjectGuid::Create<HighGuid::Player>(strtoull(args, nullptr, 10));
|
||||
|
||||
if (ObjectMgr::GetPlayerNameByGUID(parseGUID, targetName))
|
||||
if (sCharacterCache->GetCharacterNameByGuid(parseGUID, targetName))
|
||||
{
|
||||
target = ObjectAccessor::FindPlayer(parseGUID);
|
||||
targetGuid = parseGUID;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "AccountMgr.h"
|
||||
#include "ArenaTeamMgr.h"
|
||||
#include "CellImpl.h"
|
||||
#include "CharacterCache.h"
|
||||
#include "Chat.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "DB2Stores.h"
|
||||
@@ -1599,7 +1600,7 @@ public:
|
||||
ObjectGuid parseGUID = ObjectGuid::Create<HighGuid::Player>(strtoull(args, nullptr, 10));
|
||||
|
||||
// ... and make sure we get a target, somehow.
|
||||
if (ObjectMgr::GetPlayerNameByGUID(parseGUID, targetName))
|
||||
if (sCharacterCache->GetCharacterNameByGuid(parseGUID, targetName))
|
||||
{
|
||||
target = ObjectAccessor::FindPlayer(parseGUID);
|
||||
targetGuid = parseGUID;
|
||||
@@ -1995,7 +1996,7 @@ public:
|
||||
if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &targetName))
|
||||
return false;
|
||||
|
||||
uint32 accountId = target ? target->GetSession()->GetAccountId() : ObjectMgr::GetPlayerAccountIdByGUID(targetGuid);
|
||||
uint32 accountId = target ? target->GetSession()->GetAccountId() : sCharacterCache->GetCharacterAccountIdByGuid(targetGuid);
|
||||
|
||||
// find only player from same account if any
|
||||
if (!target)
|
||||
@@ -2064,7 +2065,7 @@ public:
|
||||
if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
|
||||
return false;
|
||||
|
||||
uint32 accountId = target ? target->GetSession()->GetAccountId() : ObjectMgr::GetPlayerAccountIdByGUID(targetGuid);
|
||||
uint32 accountId = target ? target->GetSession()->GetAccountId() : sCharacterCache->GetCharacterAccountIdByGuid(targetGuid);
|
||||
|
||||
// find only player from same account if any
|
||||
if (!target)
|
||||
@@ -2621,7 +2622,7 @@ public:
|
||||
if (targetName)
|
||||
{
|
||||
// Check for offline players
|
||||
ObjectGuid guid = sWorld->GetCharacterGuidByName(name);
|
||||
ObjectGuid guid = sCharacterCache->GetCharacterGuidByName(name);
|
||||
if (guid.IsEmpty())
|
||||
{
|
||||
handler->SendSysMessage(LANG_COMMAND_FREEZE_WRONG);
|
||||
|
||||
@@ -23,6 +23,7 @@ Category: commandscripts
|
||||
EndScriptData */
|
||||
|
||||
#include "AccountMgr.h"
|
||||
#include "CharacterCache.h"
|
||||
#include "Chat.h"
|
||||
#include "Config.h"
|
||||
#include "Language.h"
|
||||
@@ -125,8 +126,8 @@ bool ticket_commandscript::HandleTicketAssignToCommand(ChatHandler* handler, cha
|
||||
return true;
|
||||
}
|
||||
|
||||
ObjectGuid targetGuid = sWorld->GetCharacterGuidByName(target);
|
||||
uint32 accountId = ObjectMgr::GetPlayerAccountIdByGUID(targetGuid);
|
||||
ObjectGuid targetGuid = sCharacterCache->GetCharacterGuidByName(target);
|
||||
uint32 accountId = sCharacterCache->GetCharacterAccountIdByGuid(targetGuid);
|
||||
// Target must exist and have administrative rights
|
||||
if (!AccountMgr::HasPermission(accountId, rbac::RBAC_PERM_COMMANDS_BE_ASSIGNED_TICKET, realm.Id.Realm))
|
||||
{
|
||||
@@ -326,7 +327,7 @@ bool ticket_commandscript::HandleTicketUnAssignCommand(ChatHandler* handler, cha
|
||||
else
|
||||
{
|
||||
ObjectGuid guid = ticket->GetAssignedToGUID();
|
||||
uint32 accountId = ObjectMgr::GetPlayerAccountIdByGUID(guid);
|
||||
uint32 accountId = sCharacterCache->GetCharacterAccountIdByGuid(guid);
|
||||
security = AccountMgr::GetSecurity(accountId, realm.Id.Realm);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user