diff options
| author | xinef1 <w.szyszko2@gmail.com> | 2017-02-05 23:14:19 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2019-07-21 21:06:54 +0200 |
| commit | ad4e63bae145ae49b584ab2fc621660430cec0d3 (patch) | |
| tree | 403c1e9348047f49b80fa719567259c388629318 /src/server/scripts/Commands | |
| parent | 241e79f434bdd520fb11dbc12b93ab41a7b39dd2 (diff) | |
Core/Misc: Moved CharacterInfo out of world to separate class
Closes #19030
(cherrypicked from 59ce3d6c9bd82d55cbfa505bb945b71cab21a12f)
Diffstat (limited to 'src/server/scripts/Commands')
| -rw-r--r-- | src/server/scripts/Commands/cs_arena.cpp | 5 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_ban.cpp | 3 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_character.cpp | 30 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_group.cpp | 3 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_guild.cpp | 7 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_lfg.cpp | 3 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_list.cpp | 3 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_misc.cpp | 9 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_ticket.cpp | 7 |
9 files changed, 39 insertions, 31 deletions
diff --git a/src/server/scripts/Commands/cs_arena.cpp b/src/server/scripts/Commands/cs_arena.cpp index 837bcc8462e..c238510474d 100644 --- a/src/server/scripts/Commands/cs_arena.cpp +++ b/src/server/scripts/Commands/cs_arena.cpp @@ -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; diff --git a/src/server/scripts/Commands/cs_ban.cpp b/src/server/scripts/Commands/cs_ban.cpp index 11d7002452d..6ecd3072298 100644 --- a/src/server/scripts/Commands/cs_ban.cpp +++ b/src/server/scripts/Commands/cs_ban.cpp @@ -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); diff --git a/src/server/scripts/Commands/cs_character.cpp b/src/server/scripts/Commands/cs_character.cpp index d7305193ff5..800d5b4a4af 100644 --- a/src/server/scripts/Commands/cs_character.cpp +++ b/src/server/scripts/Commands/cs_character.cpp @@ -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); diff --git a/src/server/scripts/Commands/cs_group.cpp b/src/server/scripts/Commands/cs_group.cpp index 4faf55963fe..3300efaafdd 100644 --- a/src/server/scripts/Commands/cs_group.cpp +++ b/src/server/scripts/Commands/cs_group.cpp @@ -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; diff --git a/src/server/scripts/Commands/cs_guild.cpp b/src/server/scripts/Commands/cs_guild.cpp index dccbbec60ac..dcde232edff 100644 --- a/src/server/scripts/Commands/cs_guild.cpp +++ b/src/server/scripts/Commands/cs_guild.cpp @@ -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 diff --git a/src/server/scripts/Commands/cs_lfg.cpp b/src/server/scripts/Commands/cs_lfg.cpp index c2ea1efd9f9..4ff73e0d61b 100644 --- a/src/server/scripts/Commands/cs_lfg.cpp +++ b/src/server/scripts/Commands/cs_lfg.cpp @@ -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; diff --git a/src/server/scripts/Commands/cs_list.cpp b/src/server/scripts/Commands/cs_list.cpp index fa7f8c27c47..c256fbc6f2e 100644 --- a/src/server/scripts/Commands/cs_list.cpp +++ b/src/server/scripts/Commands/cs_list.cpp @@ -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; diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 10cf9398c00..9f8d7148121 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -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); diff --git a/src/server/scripts/Commands/cs_ticket.cpp b/src/server/scripts/Commands/cs_ticket.cpp index e517235dac7..84a1f323b7a 100644 --- a/src/server/scripts/Commands/cs_ticket.cpp +++ b/src/server/scripts/Commands/cs_ticket.cpp @@ -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); } |
