Update char name data when create/delete char.

This commit is contained in:
megamage
2011-10-08 16:24:07 -04:00
parent 0bb86a3e97
commit 45de1f01e0
3 changed files with 15 additions and 5 deletions

View File

@@ -686,6 +686,7 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte
sLog->outDetail("Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), createInfo->Name.c_str(), newChar.GetGUIDLow());
sLog->outChar("Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), createInfo->Name.c_str(), newChar.GetGUIDLow());
sScriptMgr->OnPlayerCreate(&newChar);
sWorld->AddCharacterNameData(newChar.GetGUIDLow(), std::string(newChar.GetName()), newChar.getGender(), newChar.getRace(), newChar.getClass());
delete createInfo;
_charCreateCallback.SetParam(NULL);
@@ -741,6 +742,7 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket & recv_data)
sLog->outDetail("Account: %d (IP: %s) Delete Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), GUID_LOPART(guid));
sLog->outChar("Account: %d (IP: %s) Delete Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), GUID_LOPART(guid));
sScriptMgr->OnPlayerDelete(guid);
sWorld->DeleteCharaceterNameData(guid);
if (sLog->IsOutCharDump()) // optimize GetPlayerDump call
{

View File

@@ -2865,17 +2865,23 @@ void World::LoadCharacterNameData()
do
{
Field *fields = result->Fetch();
CharacterNameData& data = _characterNameDataMap[fields[0].GetUInt32()];
data.m_name = fields[1].GetString();
data.m_race = fields[2].GetUInt8();
data.m_gender = fields[3].GetUInt8();
data.m_class = fields[4].GetUInt8();
AddCharacterNameData(fields[0].GetUInt32(), fields[1].GetString(),
fields[3].GetUInt8() /*gender*/, fields[2].GetUInt8() /*race*/, fields[4].GetUInt8() /*class*/);
++count;
} while (result->NextRow());
sLog->outString("Loaded name data for %u characters", count);
}
void World::AddCharacterNameData(uint32 guid, const std::string& name, uint8 gender, uint8 race, uint8 playerClass)
{
CharacterNameData& data = _characterNameDataMap[guid];
data.m_name = name;
data.m_race = race;
data.m_gender = gender;
data.m_class = playerClass;
}
void World::UpdateCharacterNameData(uint32 guid, const std::string& name, uint8 gender, uint8 race)
{
std::map<uint32, CharacterNameData>::iterator itr = _characterNameDataMap.find(guid);

View File

@@ -740,7 +740,9 @@ class World
bool isEventKillStart;
const CharacterNameData* GetCharacterNameData(uint32 guid) const;
void AddCharacterNameData(uint32 guid, const std::string& name, uint8 gender, uint8 race, uint8 playerClass);
void UpdateCharacterNameData(uint32 guid, const std::string& name, uint8 gender, uint8 race = RACE_NONE);
void DeleteCharaceterNameData(uint32 guid) { _characterNameDataMap.erase(guid); }
uint32 GetCleaningFlags() const { return m_CleaningFlags; }
void SetCleaningFlags(uint32 flags) { m_CleaningFlags = flags; }