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 | |
parent | 3c605ba614c45c4b8f99c12fb49f342c068054a5 (diff) |
Core/Misc: Moved CharacterInfo out of world to separate class
Closes #19030
42 files changed, 514 insertions, 386 deletions
diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp index 4ef50d93170..e957cfe5c28 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp @@ -31,6 +31,7 @@ #include "Item.h" #include "Language.h" #include "Log.h" +#include "CharacterCache.h" enum eAuctionHouse { @@ -136,10 +137,10 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction, SQLTransaction& } else { - bidderAccId = sObjectMgr->GetPlayerAccountIdByGUID(bidderGuid); + bidderAccId = sCharacterCache->GetCharacterAccountIdByGuid(bidderGuid); logGmTrade = AccountMgr::HasPermission(bidderAccId, rbac::RBAC_PERM_LOG_GM_TRADE, realm.Id.Realm); - if (logGmTrade && !sObjectMgr->GetPlayerNameByGUID(bidderGuid, bidderName)) + if (logGmTrade && !sCharacterCache->GetCharacterNameByGuid(bidderGuid, bidderName)) bidderName = sObjectMgr->GetTrinityStringForDBCLocale(LANG_UNKNOWN); } @@ -147,10 +148,10 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction, SQLTransaction& { ObjectGuid ownerGuid = ObjectGuid(HighGuid::Player, auction->owner); std::string ownerName; - if (!sObjectMgr->GetPlayerNameByGUID(ownerGuid, ownerName)) + if (!sCharacterCache->GetCharacterNameByGuid(ownerGuid, ownerName)) ownerName = sObjectMgr->GetTrinityStringForDBCLocale(LANG_UNKNOWN); - uint32 ownerAccId = sObjectMgr->GetPlayerAccountIdByGUID(ownerGuid); + uint32 ownerAccId = sCharacterCache->GetCharacterAccountIdByGuid(ownerGuid); sLog->outCommand(bidderAccId, "GM %s (Account: %u) won item in auction: %s (Entry: %u Count: %u) and pay money: %u. Original owner %s (Account: %u)", bidderName.c_str(), bidderAccId, pItem->GetTemplate()->Name1.c_str(), pItem->GetEntry(), pItem->GetCount(), auction->bid, ownerName.c_str(), ownerAccId); @@ -188,7 +189,7 @@ void AuctionHouseMgr::SendAuctionSalePendingMail(AuctionEntry* auction, SQLTrans { ObjectGuid owner_guid(HighGuid::Player, auction->owner); Player* owner = ObjectAccessor::FindConnectedPlayer(owner_guid); - uint32 owner_accId = sObjectMgr->GetPlayerAccountIdByGUID(owner_guid); + uint32 owner_accId = sCharacterCache->GetCharacterAccountIdByGuid(owner_guid); // owner exist (online or offline) if ((owner || owner_accId) && !sAuctionBotConfig->IsBotChar(auction->owner)) MailDraft(auction->BuildAuctionMailSubject(AUCTION_SALE_PENDING), AuctionEntry::BuildAuctionMailBody(auction->bidder, auction->bid, auction->buyout, auction->deposit, auction->GetAuctionCut())) @@ -200,7 +201,7 @@ void AuctionHouseMgr::SendAuctionSuccessfulMail(AuctionEntry* auction, SQLTransa { ObjectGuid owner_guid(HighGuid::Player, auction->owner); Player* owner = ObjectAccessor::FindConnectedPlayer(owner_guid); - uint32 owner_accId = sObjectMgr->GetPlayerAccountIdByGUID(owner_guid); + uint32 owner_accId = sCharacterCache->GetCharacterAccountIdByGuid(owner_guid); // owner exist if ((owner || owner_accId) && !sAuctionBotConfig->IsBotChar(auction->owner)) { @@ -231,7 +232,7 @@ void AuctionHouseMgr::SendAuctionExpiredMail(AuctionEntry* auction, SQLTransacti ObjectGuid owner_guid(HighGuid::Player, auction->owner); Player* owner = ObjectAccessor::FindConnectedPlayer(owner_guid); - uint32 owner_accId = sObjectMgr->GetPlayerAccountIdByGUID(owner_guid); + uint32 owner_accId = sCharacterCache->GetCharacterAccountIdByGuid(owner_guid); // owner exist if ((owner || owner_accId) && !sAuctionBotConfig->IsBotChar(auction->owner)) { @@ -257,7 +258,7 @@ void AuctionHouseMgr::SendAuctionOutbiddedMail(AuctionEntry* auction, uint32 new uint32 oldBidder_accId = 0; if (!oldBidder) - oldBidder_accId = sObjectMgr->GetPlayerAccountIdByGUID(oldBidder_guid); + oldBidder_accId = sCharacterCache->GetCharacterAccountIdByGuid(oldBidder_guid); // old bidder exist if ((oldBidder || oldBidder_accId) && !sAuctionBotConfig->IsBotChar(auction->bidder)) @@ -279,7 +280,7 @@ void AuctionHouseMgr::SendAuctionCancelledToBidderMail(AuctionEntry* auction, SQ uint32 bidder_accId = 0; if (!bidder) - bidder_accId = sObjectMgr->GetPlayerAccountIdByGUID(bidder_guid); + bidder_accId = sCharacterCache->GetCharacterAccountIdByGuid(bidder_guid); // bidder exist if ((bidder || bidder_accId) && !sAuctionBotConfig->IsBotChar(auction->bidder)) diff --git a/src/server/game/Battlegrounds/ArenaTeam.cpp b/src/server/game/Battlegrounds/ArenaTeam.cpp index 6dd833410f2..6a17012412e 100644 --- a/src/server/game/Battlegrounds/ArenaTeam.cpp +++ b/src/server/game/Battlegrounds/ArenaTeam.cpp @@ -25,6 +25,7 @@ #include "ArenaTeamMgr.h" #include "WorldSession.h" #include "Opcodes.h" +#include "CharacterCache.h" ArenaTeam::ArenaTeam() : TeamId(0), Type(0), TeamName(), CaptainGuid(), BackgroundColor(0), EmblemStyle(0), EmblemColor(0), @@ -95,7 +96,7 @@ bool ArenaTeam::AddMember(ObjectGuid playerGuid) if (GetMembersSize() >= GetType() * 2) return false; - // Get player name and class either from db or ObjectMgr + // Get player name and class either from db or character cache Player* player = ObjectAccessor::FindPlayer(playerGuid); if (player) { @@ -104,7 +105,7 @@ bool ArenaTeam::AddMember(ObjectGuid playerGuid) } else { - CharacterInfo const* cInfo = sWorld->GetCharacterInfo(playerGuid); + CharacterCacheEntry const* cInfo = sCharacterCache->GetCharacterCacheByGuid(playerGuid); if (!cInfo) return false; @@ -113,7 +114,7 @@ bool ArenaTeam::AddMember(ObjectGuid playerGuid) } // Check if player is already in a similar arena team - if ((player && player->GetArenaTeamId(GetSlot())) || Player::GetArenaTeamIdFromCharacterInfo(playerGuid, GetType()) != 0) + if ((player && player->GetArenaTeamId(GetSlot())) || sCharacterCache->GetCharacterArenaTeamIdByGuid(playerGuid, GetType()) != 0) { TC_LOG_DEBUG("bg.arena", "Arena: %s %s already has an arena team of type %u", playerGuid.ToString().c_str(), playerName.c_str(), GetType()); return false; @@ -156,7 +157,7 @@ bool ArenaTeam::AddMember(ObjectGuid playerGuid) newMember.MatchMakerRating = matchMakerRating; Members.push_back(newMember); - sWorld->UpdateCharacterArenaTeamId(playerGuid, GetSlot(), GetId()); + sCharacterCache->UpdateCharacterArenaTeamId(playerGuid, GetSlot(), GetId()); // Save player's arena team membership to db stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_TEAM_MEMBER); @@ -252,7 +253,7 @@ bool ArenaTeam::LoadMembersFromDB(QueryResult result) // Put the player in the team Members.push_back(newMember); - sWorld->UpdateCharacterArenaTeamId(newMember.Guid, GetSlot(), GetId()); + sCharacterCache->UpdateCharacterArenaTeamId(newMember.Guid, GetSlot(), GetId()); } while (result->NextRow()); @@ -316,7 +317,7 @@ void ArenaTeam::DelMember(ObjectGuid guid, bool cleanDb) if (itr->Guid == guid) { Members.erase(itr); - sWorld->UpdateCharacterArenaTeamId(guid, GetSlot(), 0); + sCharacterCache->UpdateCharacterArenaTeamId(guid, GetSlot(), 0); break; } } @@ -369,7 +370,7 @@ void ArenaTeam::Disband(WorldSession* session) CharacterDatabase.CommitTransaction(trans); - // Remove arena team from ObjectMgr + // Remove arena team from ArenaTeamMgr sArenaTeamMgr->RemoveArenaTeam(TeamId); } @@ -392,7 +393,7 @@ void ArenaTeam::Disband() CharacterDatabase.CommitTransaction(trans); - // Remove arena team from ObjectMgr + // Remove arena team from ArenaTeamMgr sArenaTeamMgr->RemoveArenaTeam(TeamId); } diff --git a/src/server/game/Cache/CharacterCache.cpp b/src/server/game/Cache/CharacterCache.cpp new file mode 100644 index 00000000000..49bc58745d5 --- /dev/null +++ b/src/server/game/Cache/CharacterCache.cpp @@ -0,0 +1,275 @@ +/* + * Copyright (C) 2008-2017 TrinityCore <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "CharacterCache.h" +#include "ArenaTeam.h" +#include "DatabaseEnv.h" +#include "Log.h" +#include "Player.h" +#include "Timer.h" +#include "World.h" +#include "WorldPacket.h" +#include <unordered_map> + +namespace +{ + std::unordered_map<ObjectGuid, CharacterCacheEntry> _characterCacheStore; + std::unordered_map<std::string, CharacterCacheEntry*> _characterCacheByNameStore; +} + +CharacterCache::CharacterCache() +{ +} + +CharacterCache::~CharacterCache() +{ +} + +CharacterCache* CharacterCache::instance() +{ + static CharacterCache instance; + return &instance; +} + +/** +* @brief Loads several pieces of information on server startup with the GUID +* There is no further database query necessary. +* These are a number of methods that work into the calling function. +* +* @param guid Requires a guid to call +* @return Name, Gender, Race, Class and Level of player character +* Example Usage: +* @code +* CharacterCacheEntry const* characterInfo = sCharacterCache->GetCharacterCacheByGuid(GUID); +* if (!characterInfo) +* return; +* +* std::string playerName = characterInfo->Name; +* uint8 playerGender = characterInfo->Sex; +* uint8 playerRace = characterInfo->Race; +* uint8 playerClass = characterInfo->Class; +* uint8 playerLevel = characterInfo->Level; +* @endcode +**/ + +void CharacterCache::LoadCharacterCacheStorage() +{ + _characterCacheStore.clear(); + uint32 oldMSTime = getMSTime(); + + QueryResult result = CharacterDatabase.Query("SELECT guid, name, account, race, gender, class, level FROM characters"); + if (!result) + { + TC_LOG_INFO("server.loading", "No character name data loaded, empty query"); + return; + } + + do + { + Field* fields = result->Fetch(); + AddCharacterCacheEntry(ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt32()) /*guid*/, fields[2].GetUInt32() /*account*/, fields[1].GetString() /*name*/, + fields[4].GetUInt8() /*gender*/, fields[3].GetUInt8() /*race*/, fields[5].GetUInt8() /*class*/, fields[6].GetUInt8() /*level*/); + } while (result->NextRow()); + + TC_LOG_INFO("server.loading", "Loaded character infos for " SZFMTD " characters in %u ms", _characterCacheStore.size(), GetMSTimeDiffToNow(oldMSTime)); +} + +/* +Modifying functions +*/ +void CharacterCache::AddCharacterCacheEntry(ObjectGuid const& guid, uint32 accountId, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level) +{ + CharacterCacheEntry& data = _characterCacheStore[guid]; + data.Guid = guid; + data.Name = name; + data.AccountId = accountId; + data.Race = race; + data.Sex = gender; + data.Class = playerClass; + data.Level = level; + data.GuildId = 0; // Will be set in guild loading or guild setting + for (uint8 i = 0; i < MAX_ARENA_SLOT; ++i) + data.ArenaTeamId[i] = 0; // Will be set in arena teams loading + + // Fill Name to Guid Store + _characterCacheByNameStore[name] = &data; +} + +void CharacterCache::DeleteCharacterCacheEntry(ObjectGuid const& guid, std::string const& name) +{ + _characterCacheStore.erase(guid); + _characterCacheByNameStore.erase(name); +} + +void CharacterCache::UpdateCharacterData(ObjectGuid const& guid, std::string const& name, uint8* gender /*= nullptr*/, uint8* race /*= nullptr*/) +{ + auto itr = _characterCacheStore.find(guid); + if (itr == _characterCacheStore.end()) + return; + + std::string oldName = itr->second.Name; + itr->second.Name = name; + + if (gender) + itr->second.Sex = *gender; + + if (race) + itr->second.Race = *race; + + WorldPacket data(SMSG_INVALIDATE_PLAYER, 8); + data << guid; + sWorld->SendGlobalMessage(&data); + + // Correct name -> pointer storage + _characterCacheByNameStore.erase(oldName); + _characterCacheByNameStore[name] = &itr->second; +} + +void CharacterCache::UpdateCharacterLevel(ObjectGuid const& guid, uint8 level) +{ + auto itr = _characterCacheStore.find(guid); + if (itr == _characterCacheStore.end()) + return; + + itr->second.Level = level; +} + +void CharacterCache::UpdateCharacterAccountId(ObjectGuid const& guid, uint32 accountId) +{ + auto itr = _characterCacheStore.find(guid); + if (itr == _characterCacheStore.end()) + return; + + itr->second.AccountId = accountId; +} + +void CharacterCache::UpdateCharacterGuildId(ObjectGuid const& guid, ObjectGuid::LowType guildId) +{ + auto itr = _characterCacheStore.find(guid); + if (itr == _characterCacheStore.end()) + return; + + itr->second.GuildId = guildId; +} + +void CharacterCache::UpdateCharacterArenaTeamId(ObjectGuid const& guid, uint8 slot, uint32 arenaTeamId) +{ + auto itr = _characterCacheStore.find(guid); + if (itr == _characterCacheStore.end()) + return; + + itr->second.ArenaTeamId[slot] = arenaTeamId; +} + +/* +Getters +*/ +bool CharacterCache::HasCharacterCacheEntry(ObjectGuid const& guid) const +{ + return _characterCacheStore.find(guid) != _characterCacheStore.end(); +} + +CharacterCacheEntry const* CharacterCache::GetCharacterCacheByGuid(ObjectGuid const& guid) const +{ + auto itr = _characterCacheStore.find(guid); + if (itr != _characterCacheStore.end()) + return &itr->second; + + return nullptr; +} + +CharacterCacheEntry const* CharacterCache::GetCharacterCacheByName(std::string const& name) const +{ + auto itr = _characterCacheByNameStore.find(name); + if (itr != _characterCacheByNameStore.end()) + return itr->second; + + return nullptr; +} + +ObjectGuid CharacterCache::GetCharacterGuidByName(std::string const& name) const +{ + auto itr = _characterCacheByNameStore.find(name); + if (itr != _characterCacheByNameStore.end()) + return itr->second->Guid; + + return ObjectGuid::Empty; +} + +bool CharacterCache::GetCharacterNameByGuid(ObjectGuid guid, std::string& name) const +{ + auto itr = _characterCacheStore.find(guid); + if (itr == _characterCacheStore.end()) + return false; + + name = itr->second.Name; + return true; +} + +uint32 CharacterCache::GetCharacterTeamByGuid(ObjectGuid guid) const +{ + auto itr = _characterCacheStore.find(guid); + if (itr == _characterCacheStore.end()) + return 0; + + return Player::TeamForRace(itr->second.Race); +} + +uint32 CharacterCache::GetCharacterAccountIdByGuid(ObjectGuid guid) const +{ + auto itr = _characterCacheStore.find(guid); + if (itr == _characterCacheStore.end()) + return 0; + + return itr->second.AccountId; +} + +uint32 CharacterCache::GetCharacterAccountIdByName(std::string const& name) const +{ + auto itr = _characterCacheByNameStore.find(name); + if (itr != _characterCacheByNameStore.end()) + return itr->second->AccountId; + + return 0; +} + +uint8 CharacterCache::GetCharacterLevelByGuid(ObjectGuid guid) const +{ + auto itr = _characterCacheStore.find(guid); + if (itr == _characterCacheStore.end()) + return 0; + + return itr->second.Level; +} + +ObjectGuid::LowType CharacterCache::GetCharacterGuildIdByGuid(ObjectGuid guid) const +{ + auto itr = _characterCacheStore.find(guid); + if (itr == _characterCacheStore.end()) + return 0; + + return itr->second.GuildId; +} + +uint32 CharacterCache::GetCharacterArenaTeamIdByGuid(ObjectGuid guid, uint8 type) const +{ + auto itr = _characterCacheStore.find(guid); + if (itr == _characterCacheStore.end()) + return 0; + + return itr->second.ArenaTeamId[ArenaTeam::GetSlotByType(type)]; +} diff --git a/src/server/game/Cache/CharacterCache.h b/src/server/game/Cache/CharacterCache.h new file mode 100644 index 00000000000..641339b730d --- /dev/null +++ b/src/server/game/Cache/CharacterCache.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2008-2017 TrinityCore <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef CharacterCache_h__ +#define CharacterCache_h__ + +#include "Define.h" +#include "ObjectGuid.h" +#include <string> + +struct CharacterCacheEntry +{ + ObjectGuid Guid; + std::string Name; + uint32 AccountId; + uint8 Class; + uint8 Race; + uint8 Sex; + uint8 Level; + ObjectGuid::LowType GuildId; + uint32 ArenaTeamId[3]; +}; + +class TC_GAME_API CharacterCache +{ + public: + CharacterCache(); + ~CharacterCache(); + static CharacterCache* instance(); + + void LoadCharacterCacheStorage(); + void AddCharacterCacheEntry(ObjectGuid const& guid, uint32 accountId, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level); + void DeleteCharacterCacheEntry(ObjectGuid const& guid, std::string const& name); + + void UpdateCharacterData(ObjectGuid const& guid, std::string const& name, uint8* gender = nullptr, uint8* race = nullptr); + void UpdateCharacterLevel(ObjectGuid const& guid, uint8 level); + void UpdateCharacterAccountId(ObjectGuid const& guid, uint32 accountId); + void UpdateCharacterGuildId(ObjectGuid const& guid, ObjectGuid::LowType guildId); + void UpdateCharacterArenaTeamId(ObjectGuid const& guid, uint8 slot, uint32 arenaTeamId); + + bool HasCharacterCacheEntry(ObjectGuid const& guid) const; + CharacterCacheEntry const* GetCharacterCacheByGuid(ObjectGuid const& guid) const; + CharacterCacheEntry const* GetCharacterCacheByName(std::string const& name) const; + + ObjectGuid GetCharacterGuidByName(std::string const& name) const; + bool GetCharacterNameByGuid(ObjectGuid guid, std::string& name) const; + uint32 GetCharacterTeamByGuid(ObjectGuid guid) const; + uint32 GetCharacterAccountIdByGuid(ObjectGuid guid) const; + uint32 GetCharacterAccountIdByName(std::string const& name) const; + uint8 GetCharacterLevelByGuid(ObjectGuid guid) const; + ObjectGuid::LowType GetCharacterGuildIdByGuid(ObjectGuid guid) const; + uint32 GetCharacterArenaTeamIdByGuid(ObjectGuid guid, uint8 type) const; +}; + +#define sCharacterCache CharacterCache::instance() + +#endif // CharacterCache_h__ diff --git a/src/server/game/Calendar/CalendarMgr.cpp b/src/server/game/Calendar/CalendarMgr.cpp index f3192d71e96..4e86fdd1775 100644 --- a/src/server/game/Calendar/CalendarMgr.cpp +++ b/src/server/game/Calendar/CalendarMgr.cpp @@ -16,6 +16,7 @@ */ #include "CalendarMgr.h" +#include "CharacterCache.h" #include "QueryResult.h" #include "Log.h" #include "Player.h" @@ -75,7 +76,7 @@ void CalendarMgr::LoadFromDB() ObjectGuid::LowType guildId = 0; if (flags & CALENDAR_FLAG_GUILD_EVENT || flags & CALENDAR_FLAG_WITHOUT_INVITES) - guildId = Player::GetGuildIdFromCharacterInfo(creatorGUID); + guildId = sCharacterCache->GetCharacterGuildIdByGuid(creatorGUID); CalendarEvent* calendarEvent = new CalendarEvent(eventId, creatorGUID, guildId, type, dungeonId, time_t(eventTime), flags, time_t(timezoneTime), title, description); _events.insert(calendarEvent); @@ -432,7 +433,7 @@ void CalendarMgr::SendCalendarEventInvite(CalendarInvite const& invite) ObjectGuid invitee = invite.GetInviteeGUID(); Player* player = ObjectAccessor::FindConnectedPlayer(invitee); - uint8 level = player ? player->getLevel() : Player::GetLevelFromCharacterInfo(invitee); + uint8 level = player ? player->getLevel() : sCharacterCache->GetCharacterLevelByGuid(invitee); WorldPacket data(SMSG_CALENDAR_EVENT_INVITE, 8 + 8 + 8 + 1 + 1 + 1 + (statusTime ? 4 : 0) + 1); data << invitee.WriteAsPacked(); @@ -578,8 +579,8 @@ void CalendarMgr::SendCalendarEvent(ObjectGuid guid, CalendarEvent const& calend ObjectGuid inviteeGuid = calendarInvite->GetInviteeGUID(); Player* invitee = ObjectAccessor::FindPlayer(inviteeGuid); - uint8 inviteeLevel = invitee ? invitee->getLevel() : Player::GetLevelFromCharacterInfo(inviteeGuid); - ObjectGuid::LowType inviteeGuildId = invitee ? invitee->GetGuildId() : Player::GetGuildIdFromCharacterInfo(inviteeGuid); + uint8 inviteeLevel = invitee ? invitee->getLevel() : sCharacterCache->GetCharacterLevelByGuid(inviteeGuid); + ObjectGuid::LowType inviteeGuildId = invitee ? invitee->GetGuildId() : sCharacterCache->GetCharacterGuildIdByGuid(inviteeGuid); data << inviteeGuid.WriteAsPacked(); data << uint8(inviteeLevel); diff --git a/src/server/game/Chat/Channels/ChannelAppenders.h b/src/server/game/Chat/Channels/ChannelAppenders.h index 151d7b0b0fd..03daf416f30 100644 --- a/src/server/game/Chat/Channels/ChannelAppenders.h +++ b/src/server/game/Chat/Channels/ChannelAppenders.h @@ -19,6 +19,7 @@ #define _CHANNELAPPENDERS_H #include "Channel.h" +#include "CharacterCache.h" // initial packet data (notify type and channel name) template<class PacketModifier> @@ -184,7 +185,7 @@ struct ChannelOwnerAppend { explicit ChannelOwnerAppend(Channel const* channel, ObjectGuid const& ownerGuid) : _channel(channel), _ownerGuid(ownerGuid) { - CharacterInfo const* cInfo = sWorld->GetCharacterInfo(_ownerGuid); + CharacterCacheEntry const* cInfo = sCharacterCache->GetCharacterCacheByGuid(_ownerGuid); if (!cInfo || cInfo->Name.empty()) _ownerName = "PLAYER_NOT_FOUND"; else diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp index 518d9c816ae..30aaee0787b 100644 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -24,6 +24,7 @@ #include "AccountMgr.h" #include "CellImpl.h" +#include "CharacterCache.h" #include "Chat.h" #include "GridNotifiersImpl.h" #include "Language.h" @@ -87,7 +88,7 @@ bool ChatHandler::HasLowerSecurity(Player* target, ObjectGuid guid, bool strong) if (target) target_session = target->GetSession(); else if (guid) - target_account = sObjectMgr->GetPlayerAccountIdByGUID(guid); + target_account = sCharacterCache->GetCharacterAccountIdByGuid(guid); if (!target_session && !target_account) { @@ -1030,10 +1031,9 @@ ObjectGuid::LowType ChatHandler::extractLowGuidFromLink(char* text, HighGuid& gu if (Player* player = ObjectAccessor::FindPlayerByName(name)) return player->GetGUID().GetCounter(); - if (ObjectGuid guid = sWorld->GetCharacterGuidByName(name)) - return guid.GetCounter(); + ObjectGuid guid = sCharacterCache->GetCharacterGuidByName(name); + return guid.GetCounter(); - return 0; } case GUID_LINK_CREATURE: { @@ -1086,7 +1086,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) ? sWorld->GetCharacterGuidByName(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) @@ -1245,7 +1245,7 @@ bool ChatHandler::GetPlayerGroupAndGUIDByName(char const* cname, Player*& player player = ObjectAccessor::FindPlayerByName(name); if (offline) - guid = sWorld->GetCharacterGuidByName(name); + guid = sCharacterCache->GetCharacterGuidByName(name); } } diff --git a/src/server/game/Entities/Corpse/Corpse.cpp b/src/server/game/Entities/Corpse/Corpse.cpp index 4536dcfd03f..990bd4e36a3 100644 --- a/src/server/game/Entities/Corpse/Corpse.cpp +++ b/src/server/game/Entities/Corpse/Corpse.cpp @@ -16,6 +16,7 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "CharacterCache.h" #include "Common.h" #include "Corpse.h" #include "Player.h" @@ -180,7 +181,7 @@ bool Corpse::LoadCorpseFromDB(ObjectGuid::LowType guid, Field* fields) bool Corpse::IsExpired(time_t t) const { // Deleted character - if (!sWorld->GetCharacterInfo(GetOwnerGUID())) + if (!sCharacterCache->HasCharacterCacheEntry(GetOwnerGUID())) return true; if (m_type == CORPSE_BONES) diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index a7735b9de19..f47634b8f56 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -30,6 +30,7 @@ #include "CellImpl.h" #include "Channel.h" #include "ChannelMgr.h" +#include "CharacterCache.h" #include "CharacterDatabaseCleaner.h" #include "Chat.h" #include "Common.h" @@ -4230,7 +4231,7 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe // Convert guid to low GUID for CharacterNameData, but also other methods on success ObjectGuid::LowType guid = playerguid.GetCounter(); uint32 charDelete_method = sWorld->getIntConfig(CONFIG_CHARDELETE_METHOD); - CharacterInfo const* characterInfo = sWorld->GetCharacterInfo(playerguid); + CharacterCacheEntry const* characterInfo = sCharacterCache->GetCharacterCacheByGuid(playerguid); std::string name; if (characterInfo) name = characterInfo->Name; @@ -4249,7 +4250,7 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe } SQLTransaction trans = CharacterDatabase.BeginTransaction(); - if (ObjectGuid::LowType guildId = Player::GetGuildIdFromCharacterInfo(playerguid)) + if (ObjectGuid::LowType guildId = sCharacterCache->GetCharacterGuildIdByGuid(playerguid)) if (Guild* guild = sGuildMgr->GetGuildById(guildId)) guild->DeleteMember(trans, playerguid, false, false, true); @@ -4360,7 +4361,7 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe stmt->setUInt32(0, mail_id); trans->Append(stmt); - uint32 pl_account = sObjectMgr->GetPlayerAccountIdByGUID(playerguid); + uint32 pl_account = sCharacterCache->GetCharacterAccountIdByGuid(playerguid); draft.AddMoney(money).SendReturnToSender(pl_account, guid, sender, trans); } @@ -4589,7 +4590,7 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe if (updateRealmChars) sWorld->UpdateRealmCharCount(accountId); - sWorld->DeleteCharacterInfo(playerguid, name); + sCharacterCache->DeleteCharacterCacheEntry(playerguid, name); } /** @@ -7001,15 +7002,6 @@ void Player::ModifyArenaPoints(int32 value, SQLTransaction trans) } } -ObjectGuid::LowType Player::GetGuildIdFromCharacterInfo(ObjectGuid guid) -{ - CharacterInfo const* characterInfo = sWorld->GetCharacterInfo(guid); - if (!characterInfo) - return 0; - - return characterInfo->GuildId; -} - void Player::SetInArenaTeam(uint32 ArenaTeamId, uint8 slot, uint8 type) { SetArenaTeamInfoField(slot, ARENA_TEAM_ID, ArenaTeamId); @@ -7021,15 +7013,6 @@ void Player::SetArenaTeamInfoField(uint8 slot, ArenaTeamInfoType type, uint32 va SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + type, value); } -uint32 Player::GetArenaTeamIdFromCharacterInfo(ObjectGuid guid, uint8 type) -{ - CharacterInfo const* characterInfo = sWorld->GetCharacterInfo(guid); - if (!characterInfo) - return 0; - - return characterInfo->ArenaTeamId[type]; -} - uint32 Player::GetZoneIdFromDB(ObjectGuid guid) { ObjectGuid::LowType guidLow = guid.GetCounter(); @@ -7076,15 +7059,6 @@ uint32 Player::GetZoneIdFromDB(ObjectGuid guid) return zone; } -uint32 Player::GetLevelFromCharacterInfo(ObjectGuid guid) -{ - CharacterInfo const* characterInfo = sWorld->GetCharacterInfo(guid); - if (!characterInfo) - return 0; - - return characterInfo->Level; -} - void Player::UpdateArea(uint32 newArea) { // FFA_PVP flags are area and not zone id dependent @@ -16984,7 +16958,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder) if (!result) { std::string name = "<unknown>"; - sObjectMgr->GetPlayerNameByGUID(guid, name); + sCharacterCache->GetCharacterNameByGuid(guid, name); TC_LOG_ERROR("entities.player", "Player::LoadFromDB: Player '%s' (%s) not found in table `characters`, can't load. ", name.c_str(), guid.ToString().c_str()); return false; } @@ -20985,7 +20959,7 @@ void Player::RemovePetitionsAndSigns(ObjectGuid guid, uint32 type) void Player::LeaveAllArenaTeams(ObjectGuid guid) { - CharacterInfo const* characterInfo = sWorld->GetCharacterInfo(guid); + CharacterCacheEntry const* characterInfo = sCharacterCache->GetCharacterCacheByGuid(guid); if (!characterInfo) return; @@ -26401,7 +26375,7 @@ std::string Player::GetCoordsMapAreaAndZoneString() const void Player::SetInGuild(uint32 guildId) { SetUInt32Value(PLAYER_GUILDID, guildId); - sWorld->UpdateCharacterGuildId(GetGUID(), guildId); + sCharacterCache->UpdateCharacterGuildId(GetGUID(), guildId); } Guild* Player::GetGuild() diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 09f546841a7..d376c6de5a3 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1447,7 +1447,6 @@ class TC_GAME_API Player : public Unit, public GridObject<Player> static uint32 GetUInt32ValueFromArray(Tokenizer const& data, uint16 index); static float GetFloatValueFromArray(Tokenizer const& data, uint16 index); static uint32 GetZoneIdFromDB(ObjectGuid guid); - static uint32 GetLevelFromCharacterInfo(ObjectGuid guid); static bool LoadPositionFromDB(uint32& mapid, float& x, float& y, float& z, float& o, bool& in_flight, ObjectGuid guid); static bool IsValidGender(uint8 Gender) { return Gender <= GENDER_FEMALE; } @@ -1686,14 +1685,12 @@ class TC_GAME_API Player : public Unit, public GridObject<Player> void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; } uint32 GetGuildId() const { return GetUInt32Value(PLAYER_GUILDID); } Guild* GetGuild(); - static ObjectGuid::LowType GetGuildIdFromCharacterInfo(ObjectGuid guid); int GetGuildIdInvited() const { return m_GuildIdInvited; } static void RemovePetitionsAndSigns(ObjectGuid guid, uint32 type); // Arena Team void SetInArenaTeam(uint32 ArenaTeamId, uint8 slot, uint8 type); void SetArenaTeamInfoField(uint8 slot, ArenaTeamInfoType type, uint32 value); - static uint32 GetArenaTeamIdFromCharacterInfo(ObjectGuid guid, uint8 slot); static void LeaveAllArenaTeams(ObjectGuid guid); uint32 GetArenaTeamId(uint8 slot) const { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + ARENA_TEAM_ID); } uint32 GetArenaPersonalRating(uint8 slot) const { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + ARENA_TEAM_PERSONAL_RATING); } diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 5338e65fb80..7f56f670e70 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -17,6 +17,7 @@ */ #include "Unit.h" +#include "CharacterCache.h" #include "Common.h" #include "Battlefield.h" #include "BattlefieldMgr.h" @@ -10259,7 +10260,7 @@ void Unit::SetLevel(uint8 lvl) if (player->GetGroup()) player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_LEVEL); - sWorld->UpdateCharacterInfoLevel(GetGUID(), lvl); + sCharacterCache->UpdateCharacterLevel(GetGUID(), lvl); } } diff --git a/src/server/game/Globals/ObjectAccessor.cpp b/src/server/game/Globals/ObjectAccessor.cpp index f6df3a7bf5b..71da19b1bc6 100644 --- a/src/server/game/Globals/ObjectAccessor.cpp +++ b/src/server/game/Globals/ObjectAccessor.cpp @@ -236,11 +236,6 @@ Player* ObjectAccessor::FindPlayer(ObjectGuid const& guid) return player && player->IsInWorld() ? player : nullptr; } -Player* ObjectAccessor::FindConnectedPlayer(ObjectGuid const& guid) -{ - return HashMapHolder<Player>::Find(guid); -} - Player* ObjectAccessor::FindPlayerByName(std::string const& name) { Player* player = PlayerNameMapHolder::Find(name); @@ -250,6 +245,17 @@ Player* ObjectAccessor::FindPlayerByName(std::string const& name) return player; } +Player* ObjectAccessor::FindPlayerByLowGUID(ObjectGuid::LowType lowguid) +{ + ObjectGuid guid(HighGuid::Player, lowguid); + return ObjectAccessor::FindPlayer(guid); +} + +Player* ObjectAccessor::FindConnectedPlayer(ObjectGuid const& guid) +{ + return HashMapHolder<Player>::Find(guid); +} + Player* ObjectAccessor::FindConnectedPlayerByName(std::string const& name) { return PlayerNameMapHolder::Find(name); diff --git a/src/server/game/Globals/ObjectAccessor.h b/src/server/game/Globals/ObjectAccessor.h index 10ab938e39b..b86ccccd5da 100644 --- a/src/server/game/Globals/ObjectAccessor.h +++ b/src/server/game/Globals/ObjectAccessor.h @@ -85,6 +85,7 @@ namespace ObjectAccessor // ACCESS LIKE THAT IS NOT THREAD SAFE TC_GAME_API Player* FindPlayer(ObjectGuid const&); TC_GAME_API Player* FindPlayerByName(std::string const& name); + TC_GAME_API Player* FindPlayerByLowGUID(ObjectGuid::LowType lowguid); // this returns Player even if he is not in world, for example teleporting TC_GAME_API Player* FindConnectedPlayer(ObjectGuid const&); diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index a880b527d17..183634bd68e 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -2220,47 +2220,6 @@ void ObjectMgr::RemoveGameobjectFromGrid(ObjectGuid::LowType guid, GameObjectDat } } -Player* ObjectMgr::GetPlayerByLowGUID(ObjectGuid::LowType lowguid) const -{ - ObjectGuid guid(HighGuid::Player, lowguid); - return ObjectAccessor::FindPlayer(guid); -} - -bool ObjectMgr::GetPlayerNameByGUID(ObjectGuid guid, std::string& name) const -{ - CharacterInfo const* characterInfo = sWorld->GetCharacterInfo(guid); - if (!characterInfo) - return false; - - name = characterInfo->Name; - return true; -} - -uint32 ObjectMgr::GetPlayerTeamByGUID(ObjectGuid guid) const -{ - CharacterInfo const* characterInfo = sWorld->GetCharacterInfo(guid); - if (!characterInfo) - return 0; - - return Player::TeamForRace(characterInfo->Race); -} - -uint32 ObjectMgr::GetPlayerAccountIdByGUID(ObjectGuid guid) const -{ - if (CharacterInfo const* characterInfo = sWorld->GetCharacterInfo(guid)) - return characterInfo->AccountId; - - return 0; -} - -uint32 ObjectMgr::GetPlayerAccountIdByPlayerName(std::string const& name) const -{ - ObjectGuid guid = sWorld->GetCharacterGuidByName(name); - if (!guid.IsEmpty()) - return GetPlayerAccountIdByGUID(guid); - - return 0; -} void ObjectMgr::LoadItemLocales() { diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index 087970fd31d..73508444786 100644 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -708,8 +708,6 @@ class TC_GAME_API ObjectMgr typedef std::map<uint32, uint32> CharacterConversionMap; - Player* GetPlayerByLowGUID(ObjectGuid::LowType lowguid) const; - GameObjectTemplate const* GetGameObjectTemplate(uint32 entry) const; GameObjectTemplateContainer const* GetGameObjectTemplates() const { return &_gameObjectTemplateStore; } int LoadReferenceVendor(int32 vendor, int32 item_id, std::set<uint32> *skip_vendors); @@ -773,24 +771,6 @@ class TC_GAME_API ObjectMgr } CreatureQuestItemMap const* GetCreatureQuestItemMap() const { return &_creatureQuestItemStore; } - /** - * Retrieves the player name by guid. - * - * If the player is online, the name is retrieved immediately otherwise - * a database query is done. - * - * @remark Use sWorld->GetCharacterInfo because it doesn't require a database query when player is offline - * - * @param guid player full guid - * @param name returned name - * - * @return true if player was found, false otherwise - */ - bool GetPlayerNameByGUID(ObjectGuid guid, std::string& name) const; - uint32 GetPlayerTeamByGUID(ObjectGuid guid) const; - uint32 GetPlayerAccountIdByGUID(ObjectGuid guid) const; - uint32 GetPlayerAccountIdByPlayerName(std::string const& name) const; - uint32 GetNearestTaxiNode(float x, float y, float z, uint32 mapid, uint32 team); void GetTaxiPath(uint32 source, uint32 destination, uint32 &path, uint32 &cost); uint32 GetTaxiMountDisplayId(uint32 id, uint32 team, bool allowed_alt_team = false); diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index 30ecfb83f59..617a955fea0 100644 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -16,6 +16,7 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "CharacterCache.h" #include "Common.h" #include "Opcodes.h" #include "WorldPacket.h" @@ -166,7 +167,7 @@ void Group::LoadGroupFromDB(Field* fields) m_leaderGuid = ObjectGuid(HighGuid::Player, fields[0].GetUInt32()); // group leader not exist - if (!sObjectMgr->GetPlayerNameByGUID(m_leaderGuid, m_leaderName)) + if (!sCharacterCache->GetCharacterNameByGuid(m_leaderGuid, m_leaderName)) return; m_lootMethod = LootMethod(fields[1].GetUInt8()); @@ -204,7 +205,7 @@ void Group::LoadMemberFromDB(ObjectGuid::LowType guidLow, uint8 memberFlags, uin member.guid = ObjectGuid(HighGuid::Player, guidLow); // skip non-existed member - if (!sObjectMgr->GetPlayerNameByGUID(member.guid, member.name)) + if (!sCharacterCache->GetCharacterNameByGuid(member.guid, member.name)) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GROUP_MEMBER); stmt->setUInt32(0, guidLow); diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp index 9a27c800a2b..488601d9536 100644 --- a/src/server/game/Guilds/Guild.cpp +++ b/src/server/game/Guilds/Guild.cpp @@ -18,6 +18,7 @@ #include "AccountMgr.h" #include "CalendarMgr.h" +#include "CharacterCache.h" #include "Chat.h" #include "Config.h" #include "DatabaseEnv.h" @@ -1568,7 +1569,7 @@ void Guild::HandleAcceptMember(WorldSession* session) { Player* player = session->GetPlayer(); if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && - player->GetTeam() != sObjectMgr->GetPlayerTeamByGUID(GetLeaderGUID())) + player->GetTeam() != sCharacterCache->GetCharacterTeamByGuid(GetLeaderGUID())) return; SQLTransaction trans(nullptr); @@ -1988,7 +1989,7 @@ bool Guild::LoadMemberFromDB(Field* fields) return false; } - sWorld->UpdateCharacterGuildId(playerGuid, GetId()); + sCharacterCache->UpdateCharacterGuildId(playerGuid, GetId()); m_members[lowguid] = member; return true; } @@ -2200,7 +2201,7 @@ void Guild::MassInviteToEvent(WorldSession* session, uint32 minLevel, uint32 max } Member* member = itr->second; - uint32 level = Player::GetLevelFromCharacterInfo(member->GetGUID()); + uint32 level = sCharacterCache->GetCharacterLevelByGuid(member->GetGUID()); if (member->GetGUID() != session->GetPlayer()->GetGUID() && level >= minLevel && level <= maxLevel && member->IsRankNotLower(minRank)) { @@ -2225,7 +2226,7 @@ bool Guild::AddMember(SQLTransaction& trans, ObjectGuid guid, uint8 rankId) if (player->GetGuildId() != 0) return false; } - else if (Player::GetGuildIdFromCharacterInfo(guid) != 0) + else if (sCharacterCache->GetCharacterGuildIdByGuid(guid) != 0) return false; // Remove all player signs from another petitions @@ -2277,7 +2278,7 @@ bool Guild::AddMember(SQLTransaction& trans, ObjectGuid guid, uint8 rankId) return false; } m_members[lowguid] = member; - sWorld->UpdateCharacterGuildId(guid, GetId()); + sCharacterCache->UpdateCharacterGuildId(guid, GetId()); } member->SaveToDB(trans); @@ -2346,7 +2347,7 @@ void Guild::DeleteMember(SQLTransaction& trans, ObjectGuid guid, bool isDisbandi player->SetRank(0); } else - sWorld->UpdateCharacterGuildId(guid, 0); + sCharacterCache->UpdateCharacterGuildId(guid, 0); _DeleteMemberFromDB(trans, lowguid); if (!isDisbanding) diff --git a/src/server/game/Handlers/ArenaTeamHandler.cpp b/src/server/game/Handlers/ArenaTeamHandler.cpp index 831f73332d3..63c766433fa 100644 --- a/src/server/game/Handlers/ArenaTeamHandler.cpp +++ b/src/server/game/Handlers/ArenaTeamHandler.cpp @@ -25,6 +25,7 @@ #include "Opcodes.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" +#include "CharacterCache.h" void WorldSession::HandleInspectArenaTeamsOpcode(WorldPacket& recvData) { @@ -180,7 +181,7 @@ void WorldSession::HandleArenaTeamAcceptOpcode(WorldPacket & /*recvData*/) } // Only allow members of the other faction to join the team if cross faction interaction is enabled - if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && _player->GetTeam() != sObjectMgr->GetPlayerTeamByGUID(arenaTeam->GetCaptain())) + if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && _player->GetTeam() != sCharacterCache->GetCharacterTeamByGuid(arenaTeam->GetCaptain())) { SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", "", ERR_ARENA_TEAM_NOT_ALLIED); return; diff --git a/src/server/game/Handlers/AuctionHouseHandler.cpp b/src/server/game/Handlers/AuctionHouseHandler.cpp index b0e6c8910b1..b575f5faf0e 100644 --- a/src/server/game/Handlers/AuctionHouseHandler.cpp +++ b/src/server/game/Handlers/AuctionHouseHandler.cpp @@ -23,6 +23,7 @@ #include "WorldSession.h" #include "AuctionHouseMgr.h" +#include "CharacterCache.h" #include "Log.h" #include "Language.h" #include "UpdateMask.h" @@ -443,7 +444,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket& recvData) // impossible have online own another character (use this for speedup check in case online owner) ObjectGuid ownerGuid(HighGuid::Player, auction->owner); Player* auction_owner = ObjectAccessor::FindPlayer(ownerGuid); - if (!auction_owner && sObjectMgr->GetPlayerAccountIdByGUID(ownerGuid) == player->GetSession()->GetAccountId()) + if (!auction_owner && sCharacterCache->GetCharacterAccountIdByGuid(ownerGuid) == player->GetSession()->GetAccountId()) { //you cannot bid your another character auction: SendAuctionCommandResult(0, AUCTION_PLACE_BID, ERR_AUCTION_BID_OWN); diff --git a/src/server/game/Handlers/CalendarHandler.cpp b/src/server/game/Handlers/CalendarHandler.cpp index 3b51170a49b..8b314838cf1 100644 --- a/src/server/game/Handlers/CalendarHandler.cpp +++ b/src/server/game/Handlers/CalendarHandler.cpp @@ -35,13 +35,13 @@ Copied events should probably have a new owner */ +#include "CharacterCache.h" #include "InstanceSaveMgr.h" #include "Log.h" #include "Opcodes.h" #include "Player.h" #include "SocialMgr.h" #include "CalendarMgr.h" -#include "ObjectMgr.h" #include "ObjectAccessor.h" #include "DatabaseEnv.h" #include "GuildMgr.h" @@ -445,10 +445,10 @@ void WorldSession::HandleCalendarEventInvite(WorldPacket& recvData) else { // Invitee offline, get data from storage - ObjectGuid guid = sWorld->GetCharacterGuidByName(name); + ObjectGuid guid = sCharacterCache->GetCharacterGuidByName(name); if (!guid.IsEmpty()) { - if (CharacterInfo const* characterInfo = sWorld->GetCharacterInfo(guid)) + if (CharacterCacheEntry const* characterInfo = sCharacterCache->GetCharacterCacheByGuid(guid)) { inviteeGuid = guid; inviteeTeam = Player::TeamForRace(characterInfo->Race); 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) { diff --git a/src/server/game/Handlers/GroupHandler.cpp b/src/server/game/Handlers/GroupHandler.cpp index c94c4dfce4e..2cf8823f588 100644 --- a/src/server/game/Handlers/GroupHandler.cpp +++ b/src/server/game/Handlers/GroupHandler.cpp @@ -16,6 +16,7 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "CharacterCache.h" #include "Common.h" #include "DatabaseEnv.h" #include "Group.h" @@ -605,7 +606,7 @@ void WorldSession::HandleGroupChangeSubGroupOpcode(WorldPacket& recvData) if (Player* movedPlayer = ObjectAccessor::FindConnectedPlayerByName(name)) guid = movedPlayer->GetGUID(); else - guid = sWorld->GetCharacterGuidByName(name); + guid = sCharacterCache->GetCharacterGuidByName(name); if (guid.IsEmpty()) return; diff --git a/src/server/game/Handlers/MailHandler.cpp b/src/server/game/Handlers/MailHandler.cpp index 0941074663a..91c3cf01449 100644 --- a/src/server/game/Handlers/MailHandler.cpp +++ b/src/server/game/Handlers/MailHandler.cpp @@ -28,6 +28,7 @@ #include "DBCStores.h" #include "Item.h" #include "AccountMgr.h" +#include "CharacterCache.h" bool WorldSession::CanOpenMailBox(ObjectGuid guid) { @@ -104,7 +105,7 @@ void WorldSession::HandleSendMail(WorldPacket& recvData) ObjectGuid receiverGuid; if (normalizePlayerName(receiverName)) - receiverGuid = sWorld->GetCharacterGuidByName(receiverName); + receiverGuid = sCharacterCache->GetCharacterGuidByName(receiverName); if (!receiverGuid) { @@ -160,7 +161,7 @@ void WorldSession::HandleSendMail(WorldPacket& recvData) } else { - if (CharacterInfo const* characterInfo = sWorld->GetCharacterInfo(receiverGuid)) + if (CharacterCacheEntry const* characterInfo = sCharacterCache->GetCharacterCacheByGuid(receiverGuid)) { receiverTeam = Player::TeamForRace(characterInfo->Race); receiverLevel = characterInfo->Level; @@ -508,16 +509,16 @@ void WorldSession::HandleMailTakeItem(WorldPacket& recvData) else { // can be calculated early - sender_accId = sObjectMgr->GetPlayerAccountIdByGUID(sender_guid); + sender_accId = sCharacterCache->GetCharacterAccountIdByGuid(sender_guid); - if (!sObjectMgr->GetPlayerNameByGUID(sender_guid, sender_name)) + if (!sCharacterCache->GetCharacterNameByGuid(sender_guid, sender_name)) sender_name = sObjectMgr->GetTrinityStringForDBCLocale(LANG_UNKNOWN); } sLog->outCommand(GetAccountId(), "GM %s (Account: %u) receiver mail item: %s (Entry: %u Count: %u) and send COD money: %u to player: %s (Account: %u)", GetPlayerName().c_str(), GetAccountId(), it->GetTemplate()->Name1.c_str(), it->GetEntry(), it->GetCount(), m->COD, sender_name.c_str(), sender_accId); } else if (!receiver) - sender_accId = sObjectMgr->GetPlayerAccountIdByGUID(sender_guid); + sender_accId = sCharacterCache->GetCharacterAccountIdByGuid(sender_guid); // check player existence if (receiver || sender_accId) diff --git a/src/server/game/Handlers/PetitionsHandler.cpp b/src/server/game/Handlers/PetitionsHandler.cpp index 38e2b5c3205..4481ed7505d 100644 --- a/src/server/game/Handlers/PetitionsHandler.cpp +++ b/src/server/game/Handlers/PetitionsHandler.cpp @@ -28,6 +28,7 @@ #include "Opcodes.h" #include "Guild.h" #include "ArenaTeam.h" +#include "CharacterCache.h" #define CHARTER_DISPLAY_ID 16161 @@ -475,7 +476,7 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket& recvData) return; // not let enemies sign guild charter - if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && GetPlayer()->GetTeam() != sObjectMgr->GetPlayerTeamByGUID(ownerGuid)) + if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && GetPlayer()->GetTeam() != sCharacterCache->GetCharacterTeamByGuid(ownerGuid)) { if (type != GUILD_CHARTER_TYPE) SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", "", ERR_ARENA_TEAM_NOT_ALLIED); diff --git a/src/server/game/Handlers/QueryHandler.cpp b/src/server/game/Handlers/QueryHandler.cpp index 2d801bd86ff..3feed3daca7 100644 --- a/src/server/game/Handlers/QueryHandler.cpp +++ b/src/server/game/Handlers/QueryHandler.cpp @@ -27,11 +27,12 @@ #include "UpdateMask.h" #include "NPCHandler.h" #include "MapManager.h" +#include "CharacterCache.h" void WorldSession::SendNameQueryOpcode(ObjectGuid guid) { Player* player = ObjectAccessor::FindConnectedPlayer(guid); - CharacterInfo const* nameData = sWorld->GetCharacterInfo(guid); + CharacterCacheEntry const* nameData = sCharacterCache->GetCharacterCacheByGuid(guid); WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8+1+1+1+1+1+10)); data << guid.WriteAsPacked(); diff --git a/src/server/game/Handlers/SocialHandler.cpp b/src/server/game/Handlers/SocialHandler.cpp index c0deec1b90d..752ac0dace5 100644 --- a/src/server/game/Handlers/SocialHandler.cpp +++ b/src/server/game/Handlers/SocialHandler.cpp @@ -15,6 +15,7 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "CharacterCache.h" #include "WorldSession.h" #include "Player.h" #include "QueryCallback.h" @@ -40,10 +41,10 @@ void WorldSession::HandleAddFriendOpcode(WorldPacket& recvData) GetPlayer()->GetName().c_str(), friendName.c_str()); FriendsResult friendResult = FRIEND_NOT_FOUND; - ObjectGuid friendGuid = sWorld->GetCharacterGuidByName(friendName); + ObjectGuid friendGuid = sCharacterCache->GetCharacterGuidByName(friendName); if (!friendGuid.IsEmpty()) { - if (CharacterInfo const* characterInfo = sWorld->GetCharacterInfo(friendGuid)) + if (CharacterCacheEntry const* characterInfo = sCharacterCache->GetCharacterCacheByGuid(friendGuid)) { uint32 team = Player::TeamForRace(characterInfo->Race); uint32 friendAccountId = characterInfo->AccountId; @@ -100,7 +101,7 @@ void WorldSession::HandleAddIgnoreOpcode(WorldPacket& recvData) TC_LOG_DEBUG("network", "WorldSession::HandleAddIgnoreOpcode: %s asked to Ignore: %s", GetPlayer()->GetName().c_str(), ignoreName.c_str()); - ObjectGuid ignoreGuid = sWorld->GetCharacterGuidByName(ignoreName); + ObjectGuid ignoreGuid = sCharacterCache->GetCharacterGuidByName(ignoreName); FriendsResult ignoreResult = FRIEND_IGNORE_NOT_FOUND; if (!ignoreGuid.IsEmpty()) { diff --git a/src/server/game/Mails/Mail.cpp b/src/server/game/Mails/Mail.cpp index ff7ed74c900..fe642aae1e6 100644 --- a/src/server/game/Mails/Mail.cpp +++ b/src/server/game/Mails/Mail.cpp @@ -26,6 +26,7 @@ #include "Item.h" #include "AuctionHouseMgr.h" #include "CalendarMgr.h" +#include "CharacterCache.h" MailSender::MailSender(Object* sender, MailStationery stationery) : m_stationery(stationery) { @@ -141,7 +142,7 @@ void MailDraft::SendReturnToSender(uint32 sender_acc, ObjectGuid::LowType sender uint32 rc_account = 0; if (!receiver) - rc_account = sObjectMgr->GetPlayerAccountIdByGUID(receiverGuid); + rc_account = sCharacterCache->GetCharacterAccountIdByGuid(receiverGuid); if (!receiver && !rc_account) // sender not exist { @@ -180,7 +181,7 @@ void MailDraft::SendReturnToSender(uint32 sender_acc, ObjectGuid::LowType sender void MailDraft::SendMailTo(SQLTransaction& trans, MailReceiver const& receiver, MailSender const& sender, MailCheckMask checked, uint32 deliver_delay) { Player* pReceiver = receiver.GetPlayer(); // can be NULL - Player* pSender = sObjectMgr->GetPlayerByLowGUID(sender.GetSenderId()); + Player* pSender = ObjectAccessor::FindPlayerByLowGUID(sender.GetSenderId()); if (pReceiver) prepareItems(pReceiver, trans); // generate mail template items diff --git a/src/server/game/Tickets/TicketMgr.cpp b/src/server/game/Tickets/TicketMgr.cpp index f6e7d2d50d0..dda34e24273 100644 --- a/src/server/game/Tickets/TicketMgr.cpp +++ b/src/server/game/Tickets/TicketMgr.cpp @@ -16,6 +16,7 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "CharacterCache.h" #include "Common.h" #include "TicketMgr.h" #include "DatabaseEnv.h" @@ -168,7 +169,7 @@ std::string GmTicket::FormatMessageString(ChatHandler& handler, bool detailed) c ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTAGE, (secsToTimeString(curTime - _lastModifiedTime, true, false)).c_str()); std::string name; - if (sObjectMgr->GetPlayerNameByGUID(_assignedTo, name)) + if (sCharacterCache->GetCharacterNameByGuid(_assignedTo, name)) ss << handler.PGetParseString(LANG_COMMAND_TICKETLISTASSIGNEDTO, name.c_str()); if (detailed) @@ -429,3 +430,13 @@ void TicketMgr::SendTicket(WorldSession* session, GmTicket* ticket) const session->SendPacket(&data); } + +std::string GmTicket::GetAssignedToName() const +{ + std::string name; + // save queries if ticket is not assigned + if (_assignedTo) + sCharacterCache->GetCharacterNameByGuid(_assignedTo, name); + + return name; +}
\ No newline at end of file diff --git a/src/server/game/Tickets/TicketMgr.h b/src/server/game/Tickets/TicketMgr.h index 9e77431d4db..5aab1f4ed94 100644 --- a/src/server/game/Tickets/TicketMgr.h +++ b/src/server/game/Tickets/TicketMgr.h @@ -104,15 +104,7 @@ public: std::string const& GetMessage() const { return _message; } Player* GetAssignedPlayer() const { return ObjectAccessor::FindPlayer(_assignedTo); } ObjectGuid GetAssignedToGUID() const { return _assignedTo; } - std::string GetAssignedToName() const - { - std::string name; - // save queries if ticket is not assigned - if (_assignedTo) - sObjectMgr->GetPlayerNameByGUID(_assignedTo, name); - - return name; - } + std::string GetAssignedToName() const; uint64 GetLastModifiedTime() const { return _lastModifiedTime; } GMTicketEscalationStatus GetEscalatedStatus() const { return _escalatedStatus; } diff --git a/src/server/game/Tools/PlayerDump.cpp b/src/server/game/Tools/PlayerDump.cpp index 67f314c713a..d1ec37b5858 100644 --- a/src/server/game/Tools/PlayerDump.cpp +++ b/src/server/game/Tools/PlayerDump.cpp @@ -23,6 +23,7 @@ #include "ObjectMgr.h" #include "Player.h" #include "AccountMgr.h" +#include "CharacterCache.h" #include "World.h" #define DUMP_TABLE_COUNT 32 @@ -677,7 +678,7 @@ DumpReturn PlayerDumpReader::LoadDump(std::string const& file, uint32 account, s CharacterDatabase.CommitTransaction(trans); // in case of name conflict player has to rename at login anyway - sWorld->AddCharacterInfo(ObjectGuid(HighGuid::Player, guid), account, name, gender, race, playerClass, level); + sCharacterCache->AddCharacterCacheEntry(ObjectGuid(HighGuid::Player, guid), account, name, gender, race, playerClass, level); sObjectMgr->GetGenerator<HighGuid::Item>().Set(sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed() + items.size()); diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 0dfc054e86f..2f72455ce6e 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -29,6 +29,7 @@ #include "BattlegroundMgr.h" #include "CalendarMgr.h" #include "Channel.h" +#include "CharacterCache.h" #include "CharacterDatabaseCleaner.h" #include "Chat.h" #include "Config.h" @@ -1474,8 +1475,8 @@ void World::SetInitialWorldSettings() sInstanceSaveMgr->LoadInstances(); // Load before guilds and arena teams - TC_LOG_INFO("server.loading", "Loading character info store..."); - LoadCharacterInfoStore(); + TC_LOG_INFO("server.loading", "Loading character cache store..."); + sCharacterCache->LoadCharacterCacheStorage(); TC_LOG_INFO("server.loading", "Loading Broadcast texts..."); sObjectMgr->LoadBroadcastTexts(); @@ -2611,7 +2612,7 @@ bool World::RemoveBanAccount(BanMode mode, std::string const& nameOrIP) if (mode == BAN_ACCOUNT) account = AccountMgr::GetId(nameOrIP); else if (mode == BAN_CHARACTER) - account = sObjectMgr->GetPlayerAccountIdByPlayerName(nameOrIP); + account = sCharacterCache->GetCharacterAccountIdByName(nameOrIP); if (!account) return false; @@ -2635,7 +2636,7 @@ BanReturn World::BanCharacter(std::string const& name, std::string const& durati /// Pick a player to ban if not online if (!banned) { - ObjectGuid fullGuid = sWorld->GetCharacterGuidByName(name); + ObjectGuid fullGuid = sCharacterCache->GetCharacterGuidByName(name); if (fullGuid.IsEmpty()) return BAN_NOTFOUND; // Nobody to ban @@ -2671,7 +2672,7 @@ bool World::RemoveBanCharacter(std::string const& name) /// Pick a player to ban if not online if (!banned) { - ObjectGuid fullGuid = sWorld->GetCharacterGuidByName(name); + ObjectGuid fullGuid = sCharacterCache->GetCharacterGuidByName(name); if (fullGuid.IsEmpty()) return false; @@ -3281,150 +3282,6 @@ void World::ProcessQueryCallbacks() _queryProcessor.ProcessReadyQueries(); } -CharacterInfo const* World::GetCharacterInfo(ObjectGuid const& guid) const -{ - CharacterInfoContainer::const_iterator itr = _characterInfoStore.find(guid); - if (itr != _characterInfoStore.end()) - return &itr->second; - - return nullptr; -} - -ObjectGuid World::GetCharacterGuidByName(std::string const& name) const -{ - auto itr = _characterGuidByNameStore.find(name); - if (itr != _characterGuidByNameStore.end()) - return itr->second; - - return ObjectGuid::Empty; -} - -/** -* @brief Loads several pieces of information on server startup with the GUID -* There is no further database query necessary. -* These are a number of methods that work into the calling function. -* -* @param guid Requires a guid to call -* @return Name, Gender, Race, Class and Level of player character -* Example Usage: -* @code -* CharacterInfo const* characterInfo = sWorld->GetCharacterInfo(GUID); -* if (!characterInfo) -* return; -* -* std::string playerName = characterInfo->Name; -* uint8 playerGender = characterInfo->Sex; -* uint8 playerRace = characterInfo->Race; -* uint8 playerClass = characterInfo->Class; -* uint8 playerLevel = characterInfo->Level; -* @endcode -**/ - -void World::LoadCharacterInfoStore() -{ - _characterInfoStore.clear(); - - QueryResult result = CharacterDatabase.Query("SELECT guid, name, account, race, gender, class, level FROM characters"); - if (!result) - { - TC_LOG_INFO("server.loading", "No character name data loaded, empty query"); - return; - } - - do - { - Field* fields = result->Fetch(); - AddCharacterInfo(ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt32()), fields[2].GetUInt32(), fields[1].GetString(), - fields[4].GetUInt8() /*gender*/, fields[3].GetUInt8() /*race*/, fields[5].GetUInt8() /*class*/, fields[6].GetUInt8() /*level*/); - } while (result->NextRow()); - - TC_LOG_INFO("server.loading", "Loaded character infos for " SZFMTD " characters", _characterInfoStore.size()); -} - -void World::AddCharacterInfo(ObjectGuid const& guid, uint32 accountId, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level) -{ - CharacterInfo& data = _characterInfoStore[guid]; - data.Name = name; - data.AccountId = accountId; - data.Race = race; - data.Sex = gender; - data.Class = playerClass; - data.Level = level; - data.GuildId = 0; // Will be set in guild loading or guild setting - for (uint8 i = 0; i < MAX_ARENA_SLOT; ++i) - data.ArenaTeamId[i] = 0; // Will be set in arena teams loading - - // Fill Name to Guid Store - _characterGuidByNameStore[name] = guid; -} - -void World::DeleteCharacterInfo(ObjectGuid const& guid, std::string const& name) -{ - _characterInfoStore.erase(guid); - _characterGuidByNameStore.erase(name); -} - -void World::UpdateCharacterInfo(ObjectGuid const& guid, std::string const& name, uint8 gender /*= GENDER_NONE*/, uint8 race /*= RACE_NONE*/) -{ - CharacterInfoContainer::iterator itr = _characterInfoStore.find(guid); - if (itr == _characterInfoStore.end()) - return; - - itr->second.Name = name; - - if (gender != GENDER_NONE) - itr->second.Sex = gender; - - if (race != RACE_NONE) - itr->second.Race = race; - - WorldPacket data(SMSG_INVALIDATE_PLAYER, 8); - data << guid; - SendGlobalMessage(&data); -} - -void World::UpdateCharacterInfoLevel(ObjectGuid const& guid, uint8 level) -{ - CharacterInfoContainer::iterator itr = _characterInfoStore.find(guid); - if (itr == _characterInfoStore.end()) - return; - - itr->second.Level = level; -} - -void World::UpdateCharacterInfoAccount(ObjectGuid const& guid, uint32 accountId) -{ - auto itr = _characterInfoStore.find(guid); - if (itr == _characterInfoStore.end()) - return; - - itr->second.AccountId = accountId; -} - -void World::UpdateCharacterGuildId(ObjectGuid const& guid, ObjectGuid::LowType guildId) -{ - auto itr = _characterInfoStore.find(guid); - if (itr == _characterInfoStore.end()) - return; - - itr->second.GuildId = guildId; -} - -void World::UpdateCharacterArenaTeamId(ObjectGuid const& guid, uint8 slot, uint32 arenaTeamId) -{ - auto itr = _characterInfoStore.find(guid); - if (itr == _characterInfoStore.end()) - return; - - itr->second.ArenaTeamId[slot] = arenaTeamId; -} - -void World::UpdateCharacterGuidByName(ObjectGuid const& guid, std::string const& oldName, std::string const& newName) -{ - _characterGuidByNameStore.erase(oldName); - _characterGuidByNameStore[newName] = guid; -} - void World::ReloadRBAC() { // Passive reload, we mark the data as invalidated and next time a permission is checked it will be reloaded diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h index 56896fa3644..c7669f7c222 100644 --- a/src/server/game/World/World.h +++ b/src/server/game/World/World.h @@ -767,18 +767,6 @@ class TC_GAME_API World void UpdateAreaDependentAuras(); - CharacterInfo const* GetCharacterInfo(ObjectGuid const& guid) const; - ObjectGuid GetCharacterGuidByName(std::string const& name) const; - void AddCharacterInfo(ObjectGuid const& guid, uint32 accountId, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level); - void DeleteCharacterInfo(ObjectGuid const& guid, std::string const& name); - bool HasCharacterInfo(ObjectGuid const& guid) { return _characterInfoStore.find(guid) != _characterInfoStore.end(); } - void UpdateCharacterInfo(ObjectGuid const& guid, std::string const& name, uint8 gender = GENDER_NONE, uint8 race = RACE_NONE); - void UpdateCharacterInfoLevel(ObjectGuid const& guid, uint8 level); - void UpdateCharacterInfoAccount(ObjectGuid const& guid, uint32 accountId); - void UpdateCharacterGuildId(ObjectGuid const& guid, ObjectGuid::LowType guildId); - void UpdateCharacterArenaTeamId(ObjectGuid const& guid, uint8 slot, uint32 arenaTeamId); - void UpdateCharacterGuidByName(ObjectGuid const& guid, std::string const& oldName, std::string const& newName); - uint32 GetCleaningFlags() const { return m_CleaningFlags; } void SetCleaningFlags(uint32 flags) { m_CleaningFlags = flags; } void ResetEventSeasonalQuests(uint16 event_id); @@ -884,12 +872,6 @@ class TC_GAME_API World typedef std::map<uint8, uint8> AutobroadcastsWeightMap; AutobroadcastsWeightMap m_AutobroadcastsWeights; - typedef std::unordered_map<std::string, ObjectGuid> CharacterGuidByNameContainer; - typedef std::unordered_map<ObjectGuid, CharacterInfo> CharacterInfoContainer; - CharacterInfoContainer _characterInfoStore; - CharacterGuidByNameContainer _characterGuidByNameStore; - void LoadCharacterInfoStore(); - void ProcessQueryCallbacks(); QueryCallbackProcessor _queryProcessor; }; diff --git a/src/server/scripts/Commands/cs_arena.cpp b/src/server/scripts/Commands/cs_arena.cpp index 9419d5eb9ea..bfcb82d3eba 100644 --- a/src/server/scripts/Commands/cs_arena.cpp +++ b/src/server/scripts/Commands/cs_arena.cpp @@ -28,6 +28,7 @@ EndScriptData */ #include "ArenaTeamMgr.h" #include "Player.h" #include "ScriptMgr.h" +#include "CharacterCache.h" class arena_commandscript : public CommandScript { @@ -83,7 +84,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); @@ -273,7 +274,7 @@ public: arena->SetCaptain(targetGuid); - CharacterInfo const* oldCaptainNameData = sWorld->GetCharacterInfo(arena->GetCaptain()); + CharacterCacheEntry const* oldCaptainNameData = sCharacterCache->GetCharacterCacheByGuid(arena->GetCaptain()); if (!oldCaptainNameData) { handler->SetSentErrorMessage(true); diff --git a/src/server/scripts/Commands/cs_ban.cpp b/src/server/scripts/Commands/cs_ban.cpp index 798ae06cc8c..9ccb904f7b4 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 "Language.h" #include "ObjectAccessor.h" @@ -307,7 +308,7 @@ public: if (!target) { - ObjectGuid fullGuid = sWorld->GetCharacterGuidByName(name); + ObjectGuid fullGuid = sCharacterCache->GetCharacterGuidByName(name); if (fullGuid.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 ebd28a1ac06..726e40db497 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 "ObjectMgr.h" #include "PlayerDump.h" @@ -208,7 +209,7 @@ public: return; } - if (sWorld->GetCharacterGuidByName(delInfo.name)) + if (sCharacterCache->GetCharacterGuidByName(delInfo.name)) { handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_NAME, delInfo.name.c_str(), delInfo.guid.GetCounter(), delInfo.accountId); return; @@ -223,7 +224,7 @@ public: stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_NAME_DATA); stmt->setUInt32(0, delInfo.guid.GetCounter()); if (PreparedQueryResult result = CharacterDatabase.Query(stmt)) - sWorld->AddCharacterInfo(delInfo.guid, delInfo.accountId, delInfo.name, (*result)[2].GetUInt8(), (*result)[0].GetUInt8(), (*result)[1].GetUInt8(), (*result)[3].GetUInt8()); + sCharacterCache->AddCharacterCacheEntry(delInfo.guid, delInfo.accountId, delInfo.name, (*result)[2].GetUInt8(), (*result)[0].GetUInt8(), (*result)[1].GetUInt8(), (*result)[3].GetUInt8()); } static void HandleCharacterLevel(Player* player, ObjectGuid playerGuid, uint32 oldLevel, uint32 newLevel, ChatHandler* handler) @@ -326,7 +327,7 @@ public: if (handler->HasLowerSecurity(NULL, targetGuid)) return false; - sObjectMgr->GetPlayerNameByGUID(targetGuid, playerOldName); + sCharacterCache->GetCharacterNameByGuid(targetGuid, playerOldName); } if (!normalizePlayerName(newName)) @@ -383,15 +384,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(), sObjectMgr->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()); @@ -447,7 +447,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) @@ -564,7 +564,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); @@ -616,7 +616,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()); @@ -863,14 +863,14 @@ public: } else { - characterGuid = sWorld->GetCharacterGuidByName(characterName); + characterGuid = sCharacterCache->GetCharacterGuidByName(characterName); if (characterGuid.IsEmpty()) { handler->PSendSysMessage(LANG_NO_PLAYER, characterName.c_str()); handler->SetSentErrorMessage(true); return false; } - accountId = sObjectMgr->GetPlayerAccountIdByGUID(characterGuid); + accountId = sCharacterCache->GetCharacterAccountIdByGuid(characterGuid); } std::string accountName; @@ -901,7 +901,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; @@ -999,7 +999,7 @@ public: return false; } - if (sObjectMgr->GetPlayerAccountIdByGUID(ObjectGuid(HighGuid::Player, guid))) + if (sCharacterCache->GetCharacterAccountIdByGuid(ObjectGuid(HighGuid::Player, guid))) { handler->PSendSysMessage(LANG_CHARACTER_GUID_IN_USE, guid); handler->SetSentErrorMessage(true); @@ -1058,10 +1058,10 @@ public: return false; } - guid = sWorld->GetCharacterGuidByName(name); + guid = sCharacterCache->GetCharacterGuidByName(name); } - if (!sObjectMgr->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 afb986ccbaa..ec09e960303 100644 --- a/src/server/scripts/Commands/cs_group.cpp +++ b/src/server/scripts/Commands/cs_group.cpp @@ -15,6 +15,7 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "CharacterCache.h" #include "Chat.h" #include "Language.h" #include "LFG.h" @@ -270,7 +271,7 @@ public: ObjectGuid parseGUID(HighGuid::Player, uint32(atoul(args))); // ... and try to extract a player out of it. - if (sObjectMgr->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 8ee2b6c4634..6c47cbbc02f 100644 --- a/src/server/scripts/Commands/cs_guild.cpp +++ b/src/server/scripts/Commands/cs_guild.cpp @@ -28,6 +28,7 @@ EndScriptData */ #include "GuildMgr.h" #include "ObjectAccessor.h" #include "ScriptMgr.h" +#include "CharacterCache.h" class guild_commandscript : public CommandScript { @@ -157,7 +158,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; @@ -184,7 +185,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; @@ -273,7 +274,7 @@ public: handler->PSendSysMessage(LANG_GUILD_INFO_NAME, guild->GetName().c_str(), guild->GetId()); // Guild Id + Name std::string guildMasterName; - if (sObjectMgr->GetPlayerNameByGUID(guild->GetLeaderGUID(), guildMasterName)) + if (sCharacterCache->GetCharacterNameByGuid(guild->GetLeaderGUID(), guildMasterName)) handler->PSendSysMessage(LANG_GUILD_INFO_GUILD_MASTER, guildMasterName.c_str(), guild->GetLeaderGUID().GetCounter()); // Guild Master // Format creation date diff --git a/src/server/scripts/Commands/cs_lfg.cpp b/src/server/scripts/Commands/cs_lfg.cpp index 9a730f20e1e..56836ebf1e9 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 "Language.h" #include "LFGMgr.h" @@ -80,7 +81,7 @@ public: ObjectGuid parseGUID(HighGuid::Player, uint32(atoul(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 221dea48ee7..299364aa998 100644 --- a/src/server/scripts/Commands/cs_list.cpp +++ b/src/server/scripts/Commands/cs_list.cpp @@ -29,6 +29,7 @@ EndScriptData */ #include "ObjectAccessor.h" #include "ObjectMgr.h" #include "Player.h" +#include "CharacterCache.h" #include <iostream> class list_commandscript : public CommandScript @@ -476,7 +477,7 @@ public: ObjectGuid parseGUID(HighGuid::Player, uint32(atoul(args))); - if (sObjectMgr->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 bcd919d5899..2cf1f39b394 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -15,6 +15,7 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "CharacterCache.h" #include "Chat.h" #include "ScriptMgr.h" #include "AccountMgr.h" @@ -176,7 +177,7 @@ public: { case HighGuid::Player: { - object = sObjectMgr->GetPlayerByLowGUID(guidLow); + object = ObjectAccessor::FindPlayerByLowGUID(guidLow); if (!object) { handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); @@ -789,7 +790,7 @@ public: { case HighGuid::Player: { - object = sObjectMgr->GetPlayerByLowGUID(guidLow); + object = ObjectAccessor::FindPlayerByLowGUID(guidLow); if (!object) { handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); @@ -1508,7 +1509,7 @@ public: ObjectGuid parseGUID(HighGuid::Player, uint32(atoul(args))); // ... and make sure we get a target, somehow. - if (sObjectMgr->GetPlayerNameByGUID(parseGUID, targetName)) + if (sCharacterCache->GetCharacterNameByGuid(parseGUID, targetName)) { target = ObjectAccessor::FindPlayer(parseGUID); targetGuid = parseGUID; @@ -1915,7 +1916,7 @@ public: if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &targetName)) return false; - uint32 accountId = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(targetGuid); + uint32 accountId = target ? target->GetSession()->GetAccountId() : sCharacterCache->GetCharacterAccountIdByGuid(targetGuid); // find only player from same account if any if (!target) @@ -1984,7 +1985,7 @@ public: if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName)) return false; - uint32 accountId = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(targetGuid); + uint32 accountId = target ? target->GetSession()->GetAccountId() : sCharacterCache->GetCharacterAccountIdByGuid(targetGuid); // find only player from same account if any if (!target) @@ -2550,7 +2551,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 8aaed4f2ad1..a8ed1d20a0b 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 "Language.h" #include "ObjectMgr.h" @@ -92,8 +93,8 @@ public: return true; } - ObjectGuid targetGuid = sWorld->GetCharacterGuidByName(target); - uint32 accountId = sObjectMgr->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)) { @@ -391,7 +392,7 @@ public: else { ObjectGuid guid = ticket->GetAssignedToGUID(); - uint32 accountId = sObjectMgr->GetPlayerAccountIdByGUID(guid); + uint32 accountId = sCharacterCache->GetCharacterAccountIdByGuid(guid); security = AccountMgr::GetSecurity(accountId, realm.Id.Realm); } @@ -452,7 +453,7 @@ public: if (Player* player = ObjectAccessor::FindPlayerByName(name)) guid = player->GetGUID(); else - guid = sWorld->GetCharacterGuidByName(name); + guid = sCharacterCache->GetCharacterGuidByName(name); // Target must exist if (guid.IsEmpty()) diff --git a/src/server/scripts/Northrend/IsleOfConquest/isle_of_conquest.cpp b/src/server/scripts/Northrend/IsleOfConquest/isle_of_conquest.cpp index 28e93fd1320..005abab81a4 100644 --- a/src/server/scripts/Northrend/IsleOfConquest/isle_of_conquest.cpp +++ b/src/server/scripts/Northrend/IsleOfConquest/isle_of_conquest.cpp @@ -212,7 +212,7 @@ class StartLaunchEvent : public BasicEvent bool Execute(uint64 /*time*/, uint32 /*diff*/) override { - Player* player = sObjectMgr->GetPlayerByLowGUID(_lowGuid); + Player* player = ObjectAccessor::FindPlayerByLowGUID(_lowGuid); if (!player || !player->GetVehicle()) return true; |