Core/World: Store account id in CharacterInfo to reduce the amount of database queries
(cherry picked from commit aaaa1c34410c160c7b0382f5ecdb39fa01ba007c)
(cherry picked from commit 4a36850167)
Conflicts:
src/server/game/Handlers/CharacterHandler.cpp
src/server/game/World/World.cpp
This commit is contained in:
1 parent
b7d37daa74
commit
ce7fc03930
15 files changed
+91
-104
No files matched your search
@@ -157,7 +157,6 @@ void CharacterDatabaseConnection::DoPrepareStatements()
|
||||
PrepareStatement(CHAR_DEL_GIFT, "DELETE FROM character_gifts WHERE item_guid = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_SEL_CHARACTER_GIFT_BY_ITEM, "SELECT entry, flags FROM character_gifts WHERE item_guid = ?", CONNECTION_SYNCH);
|
||||
PrepareStatement(CHAR_SEL_ACCOUNT_BY_NAME, "SELECT account FROM characters WHERE name = ?", CONNECTION_SYNCH);
|
||||
PrepareStatement(CHAR_SEL_ACCOUNT_BY_GUID, "SELECT account FROM characters WHERE guid = ?", CONNECTION_SYNCH);
|
||||
PrepareStatement(CHAR_SEL_CHARACTER_DATA_BY_GUID, "SELECT account, name, level FROM characters WHERE guid = ?", CONNECTION_SYNCH);
|
||||
PrepareStatement(CHAR_DEL_ACCOUNT_INSTANCE_LOCK_TIMES, "DELETE FROM account_instance_times WHERE accountId = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_INS_ACCOUNT_INSTANCE_LOCK_TIMES, "INSERT INTO account_instance_times (accountId, instanceId, releaseTime) VALUES (?, ?, ?)", CONNECTION_ASYNC);
|
||||
|
||||
@@ -156,7 +156,6 @@ enum CharacterDatabaseStatements
|
||||
CHAR_DEL_GIFT,
|
||||
CHAR_SEL_CHARACTER_GIFT_BY_ITEM,
|
||||
CHAR_SEL_ACCOUNT_BY_NAME,
|
||||
CHAR_SEL_ACCOUNT_BY_GUID,
|
||||
CHAR_DEL_ACCOUNT_INSTANCE_LOCK_TIMES,
|
||||
CHAR_INS_ACCOUNT_INSTANCE_LOCK_TIMES,
|
||||
CHAR_SEL_CHARACTER_NAME_CLASS,
|
||||
|
||||
@@ -187,7 +187,7 @@ bool Corpse::LoadCorpseFromDB(ObjectGuid::LowType guid, Field* fields)
|
||||
bool Corpse::IsExpired(time_t t) const
|
||||
{
|
||||
// Deleted character
|
||||
if (!sWorld->GetCharacterNameData(GetOwnerGUID()))
|
||||
if (!sWorld->GetCharacterInfo(GetOwnerGUID()))
|
||||
return true;
|
||||
|
||||
if (m_type == CORPSE_BONES)
|
||||
|
||||
@@ -4551,14 +4551,14 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe
|
||||
|
||||
if (deleteFinally)
|
||||
charDelete_method = CHAR_DELETE_REMOVE;
|
||||
else if (CharacterNameData const* nameData = sWorld->GetCharacterNameData(playerguid)) // To avoid a query, we select loaded data. If it doesn't exist, return.
|
||||
else if (CharacterInfo const* nameData = sWorld->GetCharacterInfo(playerguid)) // To avoid a query, we select loaded data. If it doesn't exist, return.
|
||||
{
|
||||
// Define the required variables
|
||||
uint32 charDelete_minLvl = sWorld->getIntConfig(nameData->m_class != CLASS_DEATH_KNIGHT ? CONFIG_CHARDELETE_MIN_LEVEL : CONFIG_CHARDELETE_HEROIC_MIN_LEVEL);
|
||||
uint32 charDelete_minLvl = sWorld->getIntConfig(nameData->Class != CLASS_DEATH_KNIGHT ? CONFIG_CHARDELETE_MIN_LEVEL : CONFIG_CHARDELETE_HEROIC_MIN_LEVEL);
|
||||
|
||||
// if we want to finalize the character removal or the character does not meet the level requirement of either heroic or non-heroic settings,
|
||||
// we set it to mode CHAR_DELETE_REMOVE
|
||||
if (nameData->m_level < charDelete_minLvl)
|
||||
if (nameData->Level < charDelete_minLvl)
|
||||
charDelete_method = CHAR_DELETE_REMOVE;
|
||||
}
|
||||
|
||||
@@ -4885,7 +4885,7 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe
|
||||
if (updateRealmChars)
|
||||
sWorld->UpdateRealmCharCount(accountId);
|
||||
|
||||
sWorld->DeleteCharacterNameData(playerguid);
|
||||
sWorld->DeleteCharacterInfo(playerguid);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11741,7 +11741,7 @@ void Unit::SetLevel(uint8 lvl)
|
||||
if (player->GetGroup())
|
||||
player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_LEVEL);
|
||||
|
||||
sWorld->UpdateCharacterNameDataLevel(GetGUID(), lvl);
|
||||
sWorld->UpdateCharacterInfoLevel(GetGUID(), lvl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2255,23 +2255,10 @@ uint32 ObjectMgr::GetPlayerTeamByGUID(ObjectGuid guid) const
|
||||
|
||||
uint32 ObjectMgr::GetPlayerAccountIdByGUID(ObjectGuid guid) const
|
||||
{
|
||||
// prevent DB access for online player
|
||||
if (Player* player = ObjectAccessor::FindConnectedPlayer(guid))
|
||||
{
|
||||
return player->GetSession()->GetAccountId();
|
||||
}
|
||||
if (CharacterInfo const* characterInfo = sWorld->GetCharacterInfo(guid))
|
||||
return characterInfo->AccountId;
|
||||
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ACCOUNT_BY_GUID);
|
||||
|
||||
stmt->setUInt32(0, guid.GetCounter());
|
||||
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (result)
|
||||
{
|
||||
uint32 acc = (*result)[0].GetUInt32();
|
||||
return acc;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -781,7 +781,7 @@ class ObjectMgr
|
||||
* If the player is online, the name is retrieved immediately otherwise
|
||||
* a database query is done.
|
||||
*
|
||||
* @remark Use sWorld->GetCharacterNameData because it doesn't require a database query when player is offline
|
||||
* @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
|
||||
|
||||
@@ -81,12 +81,12 @@ struct MembershipRequest
|
||||
uint8 GetAvailability() const { return _availability; }
|
||||
uint8 GetClassRoles() const { return _classRoles; }
|
||||
uint8 GetInterests() const { return _interests; }
|
||||
uint8 GetClass() const { return sWorld->GetCharacterNameData(GetPlayerGUID())->m_class; }
|
||||
uint8 GetLevel() const { return sWorld->GetCharacterNameData(GetPlayerGUID())->m_level; }
|
||||
uint8 GetClass() const { return sWorld->GetCharacterInfo(GetPlayerGUID())->Class; }
|
||||
uint8 GetLevel() const { return sWorld->GetCharacterInfo(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->GetCharacterNameData(GetPlayerGUID())->m_name; }
|
||||
std::string const& GetName() const { return sWorld->GetCharacterInfo(GetPlayerGUID())->Name; }
|
||||
private:
|
||||
std::string _comment;
|
||||
|
||||
|
||||
@@ -254,8 +254,8 @@ void WorldSession::HandleCharEnum(PreparedQueryResult result)
|
||||
if (!(*result)[20].GetUInt32())
|
||||
_legitCharacters.insert(guid);
|
||||
|
||||
if (!sWorld->HasCharacterNameData(guid)) // This can happen if characters are inserted into the database manually. Core hasn't loaded name data yet.
|
||||
sWorld->AddCharacterNameData(guid, (*result)[1].GetString(), (*result)[4].GetUInt8(), (*result)[2].GetUInt8(), (*result)[3].GetUInt8(), (*result)[7].GetUInt8());
|
||||
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)[7].GetUInt8());
|
||||
} while (result->NextRow());
|
||||
}
|
||||
else
|
||||
@@ -671,7 +671,7 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte
|
||||
|
||||
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->AddCharacterNameData(newChar.GetGUID(), newChar.GetName(), newChar.getGender(), newChar.getRace(), newChar.getClass(), newChar.getLevel());
|
||||
sWorld->AddCharacterInfo(newChar.GetGUID(), GetAccountId(), newChar.GetName(), newChar.getGender(), newChar.getRace(), newChar.getClass(), newChar.getLevel());
|
||||
|
||||
newChar.CleanupsBeforeDelete();
|
||||
delete createInfo;
|
||||
@@ -1257,7 +1257,7 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(PreparedQueryResult resu
|
||||
|
||||
SendCharRename(RESPONSE_SUCCESS, *renameInfo);
|
||||
|
||||
sWorld->UpdateCharacterNameData(renameInfo->Guid, renameInfo->Name);
|
||||
sWorld->UpdateCharacterInfo(renameInfo->Guid, renameInfo->Name);
|
||||
}
|
||||
|
||||
void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recvData)
|
||||
@@ -1547,7 +1547,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recvData)
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
sWorld->UpdateCharacterNameData(customizeInfo.Guid, customizeInfo.Name, customizeInfo.Gender);
|
||||
sWorld->UpdateCharacterInfo(customizeInfo.Guid, customizeInfo.Name, customizeInfo.Gender);
|
||||
|
||||
SendCharCustomize(RESPONSE_SUCCESS, customizeInfo);
|
||||
}
|
||||
@@ -1696,16 +1696,16 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData)
|
||||
ObjectGuid::LowType lowGuid = factionChangeInfo.Guid.GetCounter();
|
||||
|
||||
// get the players old (at this moment current) race
|
||||
CharacterNameData const* nameData = sWorld->GetCharacterNameData(factionChangeInfo.Guid);
|
||||
CharacterInfo const* nameData = sWorld->GetCharacterInfo(factionChangeInfo.Guid);
|
||||
if (!nameData)
|
||||
{
|
||||
SendCharFactionChange(CHAR_CREATE_ERROR, factionChangeInfo);
|
||||
return;
|
||||
}
|
||||
|
||||
uint8 oldRace = nameData->m_race;
|
||||
uint8 playerClass = nameData->m_class;
|
||||
uint8 level = nameData->m_level;
|
||||
uint8 oldRace = nameData->Race;
|
||||
uint8 playerClass = nameData->Class;
|
||||
uint8 level = nameData->Level;
|
||||
|
||||
// TO Do: Make async
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_AT_LOGIN_TITLES);
|
||||
@@ -1795,7 +1795,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData)
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
trans->Append(stmt);
|
||||
|
||||
sWorld->UpdateCharacterNameData(factionChangeInfo.Guid, factionChangeInfo.Name, factionChangeInfo.Gender, factionChangeInfo.Race);
|
||||
sWorld->UpdateCharacterInfo(factionChangeInfo.Guid, factionChangeInfo.Name, factionChangeInfo.Gender, factionChangeInfo.Race);
|
||||
|
||||
if (oldRace != factionChangeInfo.Race)
|
||||
{
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
void WorldSession::SendNameQueryOpcode(ObjectGuid guid)
|
||||
{
|
||||
Player* player = ObjectAccessor::FindConnectedPlayer(guid);
|
||||
CharacterNameData const* nameData = sWorld->GetCharacterNameData(guid);
|
||||
CharacterInfo const* nameData = sWorld->GetCharacterInfo(guid);
|
||||
|
||||
WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8+1+1+1+1+1+10));
|
||||
data << guid.WriteAsPacked();
|
||||
@@ -43,11 +43,11 @@ void WorldSession::SendNameQueryOpcode(ObjectGuid guid)
|
||||
}
|
||||
|
||||
data << uint8(0); // name known
|
||||
data << nameData->m_name; // played name
|
||||
data << nameData->Name; // played name
|
||||
data << uint8(0); // realm name - only set for cross realm interaction (such as Battlegrounds)
|
||||
data << uint8(nameData->m_race);
|
||||
data << uint8(nameData->m_gender);
|
||||
data << uint8(nameData->m_class);
|
||||
data << uint8(nameData->Race);
|
||||
data << uint8(nameData->Sex);
|
||||
data << uint8(nameData->Class);
|
||||
|
||||
if (DeclinedName const* names = (player ? player->GetDeclinedNames() : NULL))
|
||||
{
|
||||
|
||||
@@ -679,7 +679,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->AddCharacterNameData(ObjectGuid(HighGuid::Player, guid), name, gender, race, playerClass, level);
|
||||
sWorld->AddCharacterInfo(ObjectGuid(HighGuid::Player, guid), account, name, gender, race, playerClass, level);
|
||||
|
||||
sObjectMgr->GetGenerator<HighGuid::Item>().Set(sObjectMgr->GetGenerator<HighGuid::Item>().GetNextAfterMaxUsed() + items.size());
|
||||
sObjectMgr->_mailId += mails.size();
|
||||
|
||||
@@ -1951,7 +1951,7 @@ void World::SetInitialWorldSettings()
|
||||
TC_LOG_INFO("server.loading", "Calculate next currency reset time...");
|
||||
InitCurrencyResetTime();
|
||||
|
||||
LoadCharacterNameData();
|
||||
LoadCharacterInfoStore();
|
||||
|
||||
TC_LOG_INFO("misc", "Initializing Opcodes...");
|
||||
opcodeTable.Initialize();
|
||||
@@ -3269,6 +3269,15 @@ void World::ProcessQueryCallbacks()
|
||||
}
|
||||
}
|
||||
|
||||
CharacterInfo const* World::GetCharacterInfo(ObjectGuid const& guid) const
|
||||
{
|
||||
CharacterInfoContainer::const_iterator itr = _characterInfoStore.find(guid);
|
||||
if (itr != _characterInfoStore.end())
|
||||
return &itr->second;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Loads several pieces of information on server startup with the GUID
|
||||
* There is no further database query necessary.
|
||||
@@ -3278,87 +3287,78 @@ void World::ProcessQueryCallbacks()
|
||||
* @return Name, Gender, Race, Class and Level of player character
|
||||
* Example Usage:
|
||||
* @code
|
||||
* CharacterNameData const* nameData = sWorld->GetCharacterNameData(GUID);
|
||||
* if (!nameData)
|
||||
* CharacterInfo const* characterInfo = sWorld->GetCharacterInfo(GUID);
|
||||
* if (!characterInfo)
|
||||
* return;
|
||||
*
|
||||
* std::string playerName = nameData->m_name;
|
||||
* uint8 playerGender = nameData->m_gender;
|
||||
* uint8 playerRace = nameData->m_race;
|
||||
* uint8 playerClass = nameData->m_class;
|
||||
* uint8 playerLevel = nameData->m_level;
|
||||
* std::string playerName = characterInfo->Name;
|
||||
* uint8 playerGender = characterInfo->Sex;
|
||||
* uint8 playerRace = characterInfo->Race;
|
||||
* uint8 playerClass = characterInfo->Class;
|
||||
* uint8 playerLevel = characterInfo->Level;
|
||||
* @endcode
|
||||
**/
|
||||
|
||||
void World::LoadCharacterNameData()
|
||||
void World::LoadCharacterInfoStore()
|
||||
{
|
||||
TC_LOG_INFO("server.loading", "Loading character name data");
|
||||
TC_LOG_INFO("server.loading", "Loading character info store");
|
||||
|
||||
QueryResult result = CharacterDatabase.Query("SELECT guid, name, race, gender, class, level FROM characters WHERE deleteDate IS NULL");
|
||||
_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;
|
||||
}
|
||||
|
||||
uint32 count = 0;
|
||||
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
AddCharacterNameData(ObjectGuid(HighGuid::Player, fields[0].GetUInt32()), fields[1].GetString(),
|
||||
fields[3].GetUInt8() /*gender*/, fields[2].GetUInt8() /*race*/, fields[4].GetUInt8() /*class*/, fields[5].GetUInt8() /*level*/);
|
||||
++count;
|
||||
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 name data for %u characters", count);
|
||||
TC_LOG_INFO("server.loading", "Loaded character infos for " SZFMTD " characters", _characterInfoStore.size());
|
||||
}
|
||||
|
||||
void World::AddCharacterNameData(ObjectGuid guid, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level)
|
||||
void World::AddCharacterInfo(ObjectGuid const& guid, uint32 accountId, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level)
|
||||
{
|
||||
CharacterNameData& data = _characterNameDataMap[guid];
|
||||
data.m_name = name;
|
||||
data.m_race = race;
|
||||
data.m_gender = gender;
|
||||
data.m_class = playerClass;
|
||||
data.m_level = level;
|
||||
CharacterInfo& data = _characterInfoStore[guid];
|
||||
data.Name = name;
|
||||
data.AccountId = accountId;
|
||||
data.Race = race;
|
||||
data.Sex = gender;
|
||||
data.Class = playerClass;
|
||||
data.Level = level;
|
||||
}
|
||||
|
||||
void World::UpdateCharacterNameData(ObjectGuid guid, std::string const& name, uint8 gender /*= GENDER_NONE*/, uint8 race /*= RACE_NONE*/)
|
||||
void World::UpdateCharacterInfo(ObjectGuid const& guid, std::string const& name, uint8 gender /*= GENDER_NONE*/, uint8 race /*= RACE_NONE*/)
|
||||
{
|
||||
std::map<ObjectGuid, CharacterNameData>::iterator itr = _characterNameDataMap.find(guid);
|
||||
if (itr == _characterNameDataMap.end())
|
||||
CharacterInfoContainer::iterator itr = _characterInfoStore.find(guid);
|
||||
if (itr == _characterInfoStore.end())
|
||||
return;
|
||||
|
||||
itr->second.m_name = name;
|
||||
itr->second.Name = name;
|
||||
|
||||
if (gender != GENDER_NONE)
|
||||
itr->second.m_gender = gender;
|
||||
itr->second.Sex = gender;
|
||||
|
||||
if (race != RACE_NONE)
|
||||
itr->second.m_race = race;
|
||||
itr->second.Race = race;
|
||||
|
||||
WorldPacket data(SMSG_INVALIDATE_PLAYER, 8);
|
||||
data << guid;
|
||||
SendGlobalMessage(&data);
|
||||
}
|
||||
|
||||
void World::UpdateCharacterNameDataLevel(ObjectGuid guid, uint8 level)
|
||||
void World::UpdateCharacterInfoLevel(ObjectGuid const& guid, uint8 level)
|
||||
{
|
||||
std::map<ObjectGuid, CharacterNameData>::iterator itr = _characterNameDataMap.find(guid);
|
||||
if (itr == _characterNameDataMap.end())
|
||||
CharacterInfoContainer::iterator itr = _characterInfoStore.find(guid);
|
||||
if (itr == _characterInfoStore.end())
|
||||
return;
|
||||
|
||||
itr->second.m_level = level;
|
||||
}
|
||||
|
||||
CharacterNameData const* World::GetCharacterNameData(ObjectGuid guid) const
|
||||
{
|
||||
std::map<ObjectGuid, CharacterNameData>::const_iterator itr = _characterNameDataMap.find(guid);
|
||||
if (itr != _characterNameDataMap.end())
|
||||
return &itr->second;
|
||||
else
|
||||
return NULL;
|
||||
itr->second.Level = level;
|
||||
}
|
||||
|
||||
void World::ReloadRBAC()
|
||||
|
||||
@@ -543,13 +543,14 @@ private:
|
||||
|
||||
typedef std::unordered_map<uint32, WorldSession*> SessionMap;
|
||||
|
||||
struct CharacterNameData
|
||||
struct CharacterInfo
|
||||
{
|
||||
std::string m_name;
|
||||
uint8 m_class;
|
||||
uint8 m_race;
|
||||
uint8 m_gender;
|
||||
uint8 m_level;
|
||||
std::string Name;
|
||||
uint32 AccountId;
|
||||
uint8 Class;
|
||||
uint8 Race;
|
||||
uint8 Sex;
|
||||
uint8 Level;
|
||||
};
|
||||
|
||||
/// The World
|
||||
@@ -769,12 +770,12 @@ class World
|
||||
|
||||
void UpdateAreaDependentAuras();
|
||||
|
||||
CharacterNameData const* GetCharacterNameData(ObjectGuid guid) const;
|
||||
void AddCharacterNameData(ObjectGuid guid, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level);
|
||||
void UpdateCharacterNameData(ObjectGuid guid, std::string const& name, uint8 gender = GENDER_NONE, uint8 race = RACE_NONE);
|
||||
void UpdateCharacterNameDataLevel(ObjectGuid guid, uint8 level);
|
||||
void DeleteCharacterNameData(ObjectGuid guid) { _characterNameDataMap.erase(guid); }
|
||||
bool HasCharacterNameData(ObjectGuid guid) { return _characterNameDataMap.find(guid) != _characterNameDataMap.end(); }
|
||||
CharacterInfo const* GetCharacterInfo(ObjectGuid const& guid) 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) { _characterInfoStore.erase(guid); }
|
||||
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);
|
||||
|
||||
uint32 GetCleaningFlags() const { return m_CleaningFlags; }
|
||||
void SetCleaningFlags(uint32 flags) { m_CleaningFlags = flags; }
|
||||
@@ -883,8 +884,9 @@ class World
|
||||
typedef std::map<uint8, uint8> AutobroadcastsWeightMap;
|
||||
AutobroadcastsWeightMap m_AutobroadcastsWeights;
|
||||
|
||||
std::map<ObjectGuid, CharacterNameData> _characterNameDataMap;
|
||||
void LoadCharacterNameData();
|
||||
typedef std::unordered_map<ObjectGuid, CharacterInfo> CharacterInfoContainer;
|
||||
CharacterInfoContainer _characterInfoStore;
|
||||
void LoadCharacterInfoStore();
|
||||
|
||||
void ProcessQueryCallbacks();
|
||||
std::deque<std::future<PreparedQueryResult>> m_realmCharCallbacks;
|
||||
|
||||
@@ -275,14 +275,14 @@ public:
|
||||
|
||||
arena->SetCaptain(targetGuid);
|
||||
|
||||
CharacterNameData const* oldCaptainNameData = sWorld->GetCharacterNameData(arena->GetCaptain());
|
||||
CharacterInfo const* oldCaptainNameData = sWorld->GetCharacterInfo(arena->GetCaptain());
|
||||
if (!oldCaptainNameData)
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
handler->PSendSysMessage(LANG_ARENA_CAPTAIN, arena->GetName().c_str(), arena->GetId(), oldCaptainNameData->m_name.c_str(), target->GetName().c_str());
|
||||
handler->PSendSysMessage(LANG_ARENA_CAPTAIN, arena->GetName().c_str(), arena->GetId(), oldCaptainNameData->Name.c_str(), target->GetName().c_str());
|
||||
if (handler->GetSession())
|
||||
TC_LOG_DEBUG("bg.arena", "GameMaster: %s [GUID: %u] promoted player: %s [GUID: %u] to leader of arena team \"%s\"[Id: %u]",
|
||||
handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUID().GetCounter(), target->GetName().c_str(), target->GetGUID().GetCounter(), arena->GetName().c_str(), arena->GetId());
|
||||
|
||||
@@ -226,7 +226,7 @@ public:
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_NAME_DATA);
|
||||
stmt->setUInt32(0, delInfo.guid.GetCounter());
|
||||
if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
|
||||
sWorld->AddCharacterNameData(delInfo.guid, delInfo.name, (*result)[2].GetUInt8(), (*result)[0].GetUInt8(), (*result)[1].GetUInt8(), (*result)[3].GetUInt8());
|
||||
sWorld->AddCharacterInfo(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)
|
||||
@@ -386,7 +386,7 @@ public:
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
sWorld->UpdateCharacterNameData(targetGuid, newName);
|
||||
sWorld->UpdateCharacterInfo(targetGuid, newName);
|
||||
|
||||
handler->PSendSysMessage(LANG_RENAME_PLAYER_WITH_NEW_NAME, playerOldName.c_str(), newName.c_str());
|
||||
|
||||
|
||||
Reference in new issue
Block a user