diff options
author | xinef1 <w.szyszko2@gmail.com> | 2017-02-05 23:14:19 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2017-02-05 23:14:19 +0100 |
commit | 59ce3d6c9bd82d55cbfa505bb945b71cab21a12f (patch) | |
tree | 11e0f0f2ae3f3baffff0586f785ebbc7b7efd8aa /src/server/game/Handlers/CharacterHandler.cpp | |
parent | 3c605ba614c45c4b8f99c12fb49f342c068054a5 (diff) |
Core/Misc: Moved CharacterInfo out of world to separate class
Closes #19030
Diffstat (limited to 'src/server/game/Handlers/CharacterHandler.cpp')
-rw-r--r-- | src/server/game/Handlers/CharacterHandler.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index e40de4d8cd3..61531984d65 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -21,6 +21,7 @@ #include "ArenaTeamMgr.h" #include "Battleground.h" #include "CalendarMgr.h" +#include "CharacterCache.h" #include "Chat.h" #include "Common.h" #include "DatabaseEnv.h" @@ -233,8 +234,8 @@ void WorldSession::HandleCharEnum(PreparedQueryResult result) if (!(*result)[23].GetUInt32()) _legitCharacters.insert(guid); - if (!sWorld->HasCharacterInfo(guid)) // This can happen if characters are inserted into the database manually. Core hasn't loaded name data yet. - sWorld->AddCharacterInfo(guid, GetAccountId(), (*result)[1].GetString(), (*result)[4].GetUInt8(), (*result)[2].GetUInt8(), (*result)[3].GetUInt8(), (*result)[10].GetUInt8()); + if (!sCharacterCache->HasCharacterCacheEntry(guid)) // This can happen if characters are inserted into the database manually. Core hasn't loaded name data yet. + sCharacterCache->AddCharacterCacheEntry(guid, GetAccountId(), (*result)[1].GetString(), (*result)[4].GetUInt8(), (*result)[2].GetUInt8(), (*result)[3].GetUInt8(), (*result)[10].GetUInt8()); ++num; } } @@ -588,7 +589,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recvData) TC_LOG_INFO("entities.player.character", "Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), GetRemoteAddress().c_str(), createInfo->Name.c_str(), newChar.GetGUID().GetCounter()); sScriptMgr->OnPlayerCreate(&newChar); - sWorld->AddCharacterInfo(newChar.GetGUID(), GetAccountId(), newChar.GetName(), newChar.GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER), newChar.getRace(), newChar.getClass(), newChar.getLevel()); + sCharacterCache->AddCharacterCacheEntry(newChar.GetGUID(), GetAccountId(), newChar.GetName(), newChar.GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER), newChar.getRace(), newChar.getClass(), newChar.getLevel()); newChar.CleanupsBeforeDelete(); }; @@ -640,7 +641,7 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket& recvData) return; } - CharacterInfo const* characterInfo = sWorld->GetCharacterInfo(guid); + CharacterCacheEntry const* characterInfo = sCharacterCache->GetCharacterCacheByGuid(guid); if (!characterInfo) { sScriptMgr->OnPlayerFailedDelete(guid, initAccountId); @@ -1119,8 +1120,7 @@ void WorldSession::HandleCharRenameCallback(std::shared_ptr<CharacterRenameInfo> SendCharRename(RESPONSE_SUCCESS, renameInfo.get()); - sWorld->UpdateCharacterInfo(renameInfo->Guid, renameInfo->Name); - sWorld->UpdateCharacterGuidByName(renameInfo->Guid, oldName, renameInfo->Name); + sCharacterCache->UpdateCharacterData(renameInfo->Guid, renameInfo->Name); } void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recvData) @@ -1131,7 +1131,7 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recvData) // not accept declined names for unsupported languages std::string name; - if (!sObjectMgr->GetPlayerNameByGUID(guid, name)) + if (!sCharacterCache->GetCharacterNameByGuid(guid, name)) { SendSetPlayerDeclinedNamesResult(DECLINED_NAMES_RESULT_ERROR, guid); return; @@ -1378,7 +1378,7 @@ void WorldSession::HandleCharCustomizeCallback(std::shared_ptr<CharacterCustomiz } // character with this name already exist - if (ObjectGuid newGuid = sWorld->GetCharacterGuidByName(customizeInfo->Name)) + if (ObjectGuid newGuid = sCharacterCache->GetCharacterGuidByName(customizeInfo->Name)) { if (newGuid != customizeInfo->Guid) { @@ -1412,8 +1412,7 @@ void WorldSession::HandleCharCustomizeCallback(std::shared_ptr<CharacterCustomiz CharacterDatabase.CommitTransaction(trans); - sWorld->UpdateCharacterInfo(customizeInfo->Guid, customizeInfo->Name, customizeInfo->Gender); - sWorld->UpdateCharacterGuidByName(customizeInfo->Guid, oldName, customizeInfo->Name); + sCharacterCache->UpdateCharacterData(customizeInfo->Guid, customizeInfo->Name, customizeInfo->Gender); SendCharCustomize(RESPONSE_SUCCESS, customizeInfo.get()); @@ -1587,7 +1586,7 @@ void WorldSession::HandleCharFactionOrRaceChangeCallback(std::shared_ptr<Charact } // get the players old (at this moment current) race - CharacterInfo const* characterInfo = sWorld->GetCharacterInfo(factionChangeInfo->Guid); + CharacterCacheEntry const* characterInfo = sCharacterCache->GetCharacterCacheByGuid(factionChangeInfo->Guid); if (!characterInfo) { SendCharFactionChange(CHAR_CREATE_ERROR, factionChangeInfo.get()); @@ -1662,7 +1661,7 @@ void WorldSession::HandleCharFactionOrRaceChangeCallback(std::shared_ptr<Charact } // character with this name already exist - ObjectGuid newGuid = sWorld->GetCharacterGuidByName(factionChangeInfo->Name); + ObjectGuid newGuid = sCharacterCache->GetCharacterGuidByName(factionChangeInfo->Name); if (!newGuid.IsEmpty()) { if (newGuid != factionChangeInfo->Guid) @@ -1713,8 +1712,7 @@ void WorldSession::HandleCharFactionOrRaceChangeCallback(std::shared_ptr<Charact trans->Append(stmt); } - sWorld->UpdateCharacterInfo(factionChangeInfo->Guid, factionChangeInfo->Name, factionChangeInfo->Gender, factionChangeInfo->Race); - sWorld->UpdateCharacterGuidByName(factionChangeInfo->Guid, oldName, factionChangeInfo->Name); + sCharacterCache->UpdateCharacterData(factionChangeInfo->Guid, factionChangeInfo->Name, factionChangeInfo->Gender, factionChangeInfo->Race); if (oldRace != factionChangeInfo->Race) { |