Core/Misc: Moved CharacterInfo out of world to separate class
This commit is contained in:
1 parent
5373e2bd3b
commit
5e1a7bcfbb
43 files changed
+520
-391
No files matched your search
@@ -32,6 +32,7 @@
|
||||
#include "Language.h"
|
||||
#include "Log.h"
|
||||
#include "GameTime.h"
|
||||
#include "CharacterCache.h"
|
||||
|
||||
enum eAuctionHouse
|
||||
{
|
||||
@@ -137,10 +138,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);
|
||||
}
|
||||
|
||||
@@ -148,10 +149,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);
|
||||
@@ -189,7 +190,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()))
|
||||
@@ -201,7 +202,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))
|
||||
{
|
||||
@@ -232,7 +233,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))
|
||||
{
|
||||
@@ -258,7 +259,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))
|
||||
@@ -280,7 +281,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);
|
||||
|
||||
if (bidder)
|
||||
bidder->GetSession()->SendAuctionRemovedNotification(auction->Id, auction->itemEntry, item->GetItemRandomPropertyId());
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -367,7 +368,7 @@ void ArenaTeam::Disband(WorldSession* session)
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
// Remove arena team from ObjectMgr
|
||||
// Remove arena team from ArenaTeamMgr
|
||||
sArenaTeamMgr->RemoveArenaTeam(TeamId);
|
||||
}
|
||||
|
||||
@@ -390,7 +391,7 @@ void ArenaTeam::Disband()
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
// Remove arena team from ObjectMgr
|
||||
// Remove arena team from ArenaTeamMgr
|
||||
sArenaTeamMgr->RemoveArenaTeam(TeamId);
|
||||
}
|
||||
|
||||
|
||||
@@ -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)];
|
||||
}
|
||||
@@ -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__
|
||||
@@ -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();
|
||||
@@ -584,8 +585,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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "AccountMgr.h"
|
||||
#include "CellImpl.h"
|
||||
#include "CharacterCache.h"
|
||||
#include "Chat.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "Language.h"
|
||||
@@ -89,7 +90,7 @@ bool ChatHandler::HasLowerSecurity(Player* target, ObjectGuid guid, bool strong)
|
||||
if (target)
|
||||
target_session = target->GetSession();
|
||||
else if (!guid.IsEmpty())
|
||||
target_account = sObjectMgr->GetPlayerAccountIdByGUID(guid);
|
||||
target_account = sCharacterCache->GetCharacterAccountIdByGuid(guid);
|
||||
|
||||
if (!target_session && !target_account)
|
||||
{
|
||||
@@ -1049,10 +1050,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:
|
||||
{
|
||||
@@ -1105,7 +1105,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)
|
||||
@@ -1274,7 +1274,7 @@ bool ChatHandler::GetPlayerGroupAndGUIDByName(char const* cname, Player*& player
|
||||
|
||||
player = ObjectAccessor::FindPlayerByName(name);
|
||||
if (offline)
|
||||
guid = sWorld->GetCharacterGuidByName(name);
|
||||
guid = sCharacterCache->GetCharacterGuidByName(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
@@ -188,7 +189,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)
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "CellImpl.h"
|
||||
#include "Channel.h"
|
||||
#include "ChannelMgr.h"
|
||||
#include "CharacterCache.h"
|
||||
#include "CharacterDatabaseCleaner.h"
|
||||
#include "Chat.h"
|
||||
#include "Common.h"
|
||||
@@ -4240,7 +4241,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;
|
||||
@@ -4259,7 +4260,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);
|
||||
|
||||
@@ -4370,7 +4371,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);
|
||||
}
|
||||
@@ -4600,7 +4601,7 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe
|
||||
if (updateRealmChars)
|
||||
sWorld->UpdateRealmCharCount(accountId);
|
||||
|
||||
sWorld->DeleteCharacterInfo(playerguid, name);
|
||||
sCharacterCache->DeleteCharacterCacheEntry(playerguid, name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -7270,16 +7271,7 @@ void Player::SetInGuild(uint32 guildId)
|
||||
|
||||
ApplyModFlag(PLAYER_FLAGS, PLAYER_FLAGS_GUILD_LEVEL_ENABLED, guildId != 0 && sWorld->getBoolConfig(CONFIG_GUILD_LEVELING_ENABLED));
|
||||
SetUInt16Value(OBJECT_FIELD_TYPE, 1, guildId != 0);
|
||||
sWorld->UpdateCharacterGuildId(GetGUID(), guildId);
|
||||
}
|
||||
|
||||
ObjectGuid::LowType Player::GetGuildIdFromCharacterInfo(ObjectGuid guid)
|
||||
{
|
||||
CharacterInfo const* characterInfo = sWorld->GetCharacterInfo(guid);
|
||||
if (!characterInfo)
|
||||
return 0;
|
||||
|
||||
return characterInfo->GuildId;
|
||||
sCharacterCache->UpdateCharacterGuildId(GetGUID(), guildId);
|
||||
}
|
||||
|
||||
void Player::SetArenaTeamInfoField(uint8 slot, ArenaTeamInfoType type, uint32 value)
|
||||
@@ -7298,15 +7290,6 @@ void Player::SetInArenaTeam(uint32 ArenaTeamId, uint8 slot, uint8 type)
|
||||
SetArenaTeamInfoField(slot, ARENA_TEAM_TYPE, type);
|
||||
}
|
||||
|
||||
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();
|
||||
@@ -7353,15 +7336,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
|
||||
@@ -17109,7 +17083,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;
|
||||
}
|
||||
@@ -18267,7 +18241,7 @@ void Player::_LoadVoidStorage(PreparedQueryResult result)
|
||||
}
|
||||
|
||||
std::string name;
|
||||
if (creatorGuid && !sObjectMgr->GetPlayerNameByGUID(creatorGuid, name))
|
||||
if (creatorGuid && !sCharacterCache->GetCharacterNameByGuid(creatorGuid, name))
|
||||
{
|
||||
TC_LOG_ERROR("entities.player", "Player::_LoadVoidStorage - Player (GUID: %u, name: %s) has an item with an invalid creator guid, set to 0 (item id: " UI64FMTD ", entry: %u, creator: %s).", GetGUID().GetCounter(), GetName().c_str(), itemId, itemEntry, creatorGuid.ToString().c_str());
|
||||
creatorGuid.Clear();
|
||||
@@ -21368,7 +21342,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;
|
||||
|
||||
|
||||
@@ -1666,7 +1666,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; }
|
||||
@@ -1926,14 +1925,12 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
|
||||
void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; }
|
||||
uint32 GetGuildId() const { return GetUInt32Value(OBJECT_FIELD_DATA); /* return only lower part */ }
|
||||
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); }
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "Unit.h"
|
||||
#include "CharacterCache.h"
|
||||
#include "Common.h"
|
||||
#include "Battlefield.h"
|
||||
#include "BattlefieldMgr.h"
|
||||
@@ -9759,7 +9760,7 @@ void Unit::SetLevel(uint8 lvl)
|
||||
if (player->GetGroup())
|
||||
player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_LEVEL);
|
||||
|
||||
sWorld->UpdateCharacterInfoLevel(GetGUID(), lvl);
|
||||
sCharacterCache->UpdateCharacterLevel(GetGUID(), lvl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -245,11 +245,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);
|
||||
@@ -259,6 +254,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);
|
||||
|
||||
@@ -86,6 +86,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&);
|
||||
|
||||
@@ -2331,48 +2331,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()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
@@ -740,8 +740,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, uint8 type, std::set<uint32> *skip_vendors);
|
||||
@@ -792,24 +790,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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "AccountMgr.h"
|
||||
#include "CalendarMgr.h"
|
||||
#include "CharacterCache.h"
|
||||
#include "Chat.h"
|
||||
#include "Config.h"
|
||||
#include "DatabaseEnv.h"
|
||||
@@ -1875,7 +1876,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);
|
||||
@@ -2469,7 +2470,7 @@ bool Guild::LoadMemberFromDB(Field* fields)
|
||||
return false;
|
||||
}
|
||||
|
||||
sWorld->UpdateCharacterGuildId(playerGuid, GetId());
|
||||
sCharacterCache->UpdateCharacterGuildId(playerGuid, GetId());
|
||||
m_members[lowguid] = member;
|
||||
return true;
|
||||
}
|
||||
@@ -2719,7 +2720,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))
|
||||
{
|
||||
@@ -2744,7 +2745,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
|
||||
@@ -2798,7 +2799,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);
|
||||
@@ -2874,7 +2875,7 @@ void Guild::DeleteMember(SQLTransaction& trans, ObjectGuid guid, bool isDisbandi
|
||||
player->RemoveSpell(entry->SpellId, false, false);
|
||||
}
|
||||
else
|
||||
sWorld->UpdateCharacterGuildId(guid, 0);
|
||||
sCharacterCache->UpdateCharacterGuildId(guid, 0);
|
||||
|
||||
_DeleteMemberFromDB(trans, lowguid);
|
||||
if (!isDisbanding)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#ifndef __TRINITY_GUILDFINDER_H
|
||||
#define __TRINITY_GUILDFINDER_H
|
||||
|
||||
#include "CharacterCache.h"
|
||||
#include "Common.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include "World.h"
|
||||
@@ -81,12 +82,12 @@ struct MembershipRequest
|
||||
uint8 GetAvailability() const { return _availability; }
|
||||
uint8 GetClassRoles() const { return _classRoles; }
|
||||
uint8 GetInterests() const { return _interests; }
|
||||
uint8 GetClass() const { return sWorld->GetCharacterInfo(GetPlayerGUID())->Class; }
|
||||
uint8 GetLevel() const { return sWorld->GetCharacterInfo(GetPlayerGUID())->Level; }
|
||||
uint8 GetClass() const { return sCharacterCache->GetCharacterCacheByGuid(GetPlayerGUID())->Class; }
|
||||
uint8 GetLevel() const { return sCharacterCache->GetCharacterCacheByGuid(GetPlayerGUID())->Level; }
|
||||
time_t GetSubmitTime() const { return _time; }
|
||||
time_t GetExpiryTime() const { return time_t(_time + 30 * 24 * 3600); } // Adding 30 days
|
||||
std::string const& GetComment() const { return _comment; }
|
||||
std::string const& GetName() const { return sWorld->GetCharacterInfo(GetPlayerGUID())->Name; }
|
||||
std::string const& GetName() const { return sCharacterCache->GetCharacterCacheByGuid(GetPlayerGUID())->Name; }
|
||||
private:
|
||||
std::string _comment;
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "Opcodes.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "CharacterCache.h"
|
||||
|
||||
void WorldSession::HandleInspectArenaTeamsOpcode(WorldPacket& recvData)
|
||||
{
|
||||
@@ -234,7 +235,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;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "WorldSession.h"
|
||||
|
||||
#include "AuctionHouseMgr.h"
|
||||
#include "CharacterCache.h"
|
||||
#include "Log.h"
|
||||
#include "Language.h"
|
||||
#include "UpdateMask.h"
|
||||
@@ -481,7 +482,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(NULL, AUCTION_PLACE_BID, ERR_AUCTION_BID_OWN);
|
||||
|
||||
@@ -452,10 +452,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);
|
||||
|
||||
@@ -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"
|
||||
@@ -257,8 +258,9 @@ 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());
|
||||
|
||||
} while (result->NextRow());
|
||||
}
|
||||
else
|
||||
@@ -615,7 +617,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();
|
||||
};
|
||||
@@ -667,7 +669,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);
|
||||
@@ -1298,8 +1300,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)
|
||||
@@ -1310,7 +1311,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;
|
||||
@@ -1558,7 +1559,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)
|
||||
{
|
||||
@@ -1592,8 +1593,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());
|
||||
|
||||
@@ -1773,7 +1773,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());
|
||||
@@ -1848,7 +1848,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)
|
||||
@@ -1857,7 +1857,7 @@ void WorldSession::HandleCharFactionOrRaceChangeCallback(std::shared_ptr<Charact
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (sArenaTeamMgr->GetArenaTeamByCaptain(factionChangeInfo->Guid))
|
||||
{
|
||||
SendCharFactionChange(CHAR_CREATE_CHARACTER_ARENA_LEADER, factionChangeInfo.get());
|
||||
@@ -1900,8 +1900,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)
|
||||
{
|
||||
|
||||
@@ -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"
|
||||
@@ -858,7 +859,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;
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "AccountMgr.h"
|
||||
#include "BattlenetAccountMgr.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "CharacterCache.h"
|
||||
|
||||
bool WorldSession::CanOpenMailBox(ObjectGuid guid)
|
||||
{
|
||||
@@ -154,7 +155,7 @@ void WorldSession::HandleSendMail(WorldPacket& recvData)
|
||||
|
||||
ObjectGuid receiverGuid;
|
||||
if (normalizePlayerName(receiverName))
|
||||
receiverGuid = sWorld->GetCharacterGuidByName(receiverName);
|
||||
receiverGuid = sCharacterCache->GetCharacterGuidByName(receiverName);
|
||||
|
||||
if (!receiverGuid)
|
||||
{
|
||||
@@ -212,7 +213,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;
|
||||
@@ -563,16 +564,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: " UI64FMTD " 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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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"
|
||||
@@ -41,10 +42,10 @@ void WorldSession::HandleAddFriendOpcode(WorldPacket& recvData)
|
||||
|
||||
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;
|
||||
@@ -101,7 +102,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())
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
@@ -173,7 +174,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)
|
||||
@@ -434,3 +435,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;
|
||||
}
|
||||
@@ -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; }
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "ObjectMgr.h"
|
||||
#include "Player.h"
|
||||
#include "AccountMgr.h"
|
||||
#include "CharacterCache.h"
|
||||
#include "World.h"
|
||||
|
||||
// static data
|
||||
@@ -951,7 +952,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());
|
||||
|
||||
|
||||
@@ -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"
|
||||
@@ -1544,8 +1545,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();
|
||||
@@ -2645,7 +2646,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;
|
||||
@@ -2669,7 +2670,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
|
||||
|
||||
@@ -2705,7 +2706,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;
|
||||
|
||||
@@ -3365,150 +3366,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
|
||||
|
||||
@@ -796,18 +796,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);
|
||||
@@ -911,12 +899,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;
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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"
|
||||
@@ -340,7 +341,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;
|
||||
|
||||
@@ -29,6 +29,7 @@ EndScriptData */
|
||||
#include "GuildMgr.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "CharacterCache.h"
|
||||
#include <iomanip>
|
||||
|
||||
class guild_commandscript : public CommandScript
|
||||
@@ -159,7 +160,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;
|
||||
|
||||
@@ -186,7 +187,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;
|
||||
|
||||
@@ -275,7 +276,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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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"
|
||||
@@ -175,7 +176,7 @@ public:
|
||||
{
|
||||
case HighGuid::Player:
|
||||
{
|
||||
object = sObjectMgr->GetPlayerByLowGUID(guidLow);
|
||||
object = ObjectAccessor::FindPlayerByLowGUID(guidLow);
|
||||
if (!object)
|
||||
{
|
||||
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
@@ -810,7 +811,7 @@ public:
|
||||
{
|
||||
case HighGuid::Player:
|
||||
{
|
||||
object = sObjectMgr->GetPlayerByLowGUID(guidLow);
|
||||
object = ObjectAccessor::FindPlayerByLowGUID(guidLow);
|
||||
if (!object)
|
||||
{
|
||||
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
@@ -1529,7 +1530,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;
|
||||
@@ -1936,7 +1937,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)
|
||||
@@ -2005,7 +2006,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)
|
||||
@@ -2562,7 +2563,7 @@ public:
|
||||
if (targetName)
|
||||
{
|
||||
// Check for offline players
|
||||
ObjectGuid guid = sWorld->GetCharacterGuidByName(name);
|
||||
ObjectGuid guid = sCharacterCache->GetCharacterGuidByName(name);
|
||||
if (guid.IsEmpty())
|
||||
{
|
||||
handler->SendSysMessage(LANG_COMMAND_FREEZE_WRONG);
|
||||
|
||||
@@ -23,6 +23,7 @@ Category: commandscripts
|
||||
EndScriptData */
|
||||
|
||||
#include "AccountMgr.h"
|
||||
#include "CharacterCache.h"
|
||||
#include "Chat.h"
|
||||
#include "Language.h"
|
||||
#include "ObjectMgr.h"
|
||||
@@ -95,8 +96,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))
|
||||
{
|
||||
@@ -394,7 +395,7 @@ public:
|
||||
else
|
||||
{
|
||||
ObjectGuid guid = ticket->GetAssignedToGUID();
|
||||
uint32 accountId = sObjectMgr->GetPlayerAccountIdByGUID(guid);
|
||||
uint32 accountId = sCharacterCache->GetCharacterAccountIdByGuid(guid);
|
||||
security = AccountMgr::GetSecurity(accountId, realm.Id.Realm);
|
||||
}
|
||||
|
||||
@@ -455,7 +456,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())
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in new issue
Block a user