mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Players: Fixed CharacterCache by-name storage holding data for deleted characters
This commit is contained in:
@@ -107,7 +107,8 @@ void CharacterCache::AddCharacterCacheEntry(ObjectGuid const& guid, uint32 accou
|
||||
data.IsDeleted = isDeleted;
|
||||
|
||||
// Fill Name to Guid Store
|
||||
_characterCacheByNameStore[name] = &data;
|
||||
if (!isDeleted)
|
||||
_characterCacheByNameStore[name] = &data;
|
||||
}
|
||||
|
||||
void CharacterCache::DeleteCharacterCacheEntry(ObjectGuid const& guid, std::string const& name)
|
||||
@@ -186,16 +187,19 @@ void CharacterCache::UpdateCharacterArenaTeamId(ObjectGuid const& guid, uint8 sl
|
||||
itr->second.ArenaTeamId[slot] = arenaTeamId;
|
||||
}
|
||||
|
||||
void CharacterCache::UpdateCharacterInfoDeleted(ObjectGuid const& guid, bool deleted, std::string const* name /*=nullptr*/)
|
||||
void CharacterCache::UpdateCharacterInfoDeleted(ObjectGuid const& guid, bool deleted, std::string const& name /*=nullptr*/)
|
||||
{
|
||||
auto itr = _characterCacheStore.find(guid);
|
||||
if (itr == _characterCacheStore.end())
|
||||
return;
|
||||
|
||||
itr->second.IsDeleted = deleted;
|
||||
if (deleted)
|
||||
_characterCacheByNameStore.erase(itr->second.Name);
|
||||
else
|
||||
_characterCacheByNameStore[name] = &itr->second;
|
||||
|
||||
if (name)
|
||||
itr->second.Name = *name;
|
||||
itr->second.Name = name;
|
||||
itr->second.IsDeleted = deleted;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -55,7 +55,7 @@ class TC_GAME_API CharacterCache
|
||||
void UpdateCharacterAccountId(ObjectGuid const& guid, uint32 accountId);
|
||||
void UpdateCharacterGuildId(ObjectGuid const& guid, ObjectGuid::LowType guildId);
|
||||
void UpdateCharacterArenaTeamId(ObjectGuid const& guid, uint8 slot, uint32 arenaTeamId);
|
||||
void UpdateCharacterInfoDeleted(ObjectGuid const& guid, bool deleted, std::string const* name = nullptr);
|
||||
void UpdateCharacterInfoDeleted(ObjectGuid const& guid, bool deleted, std::string const& name);
|
||||
|
||||
bool HasCharacterCacheEntry(ObjectGuid const& guid) const;
|
||||
CharacterCacheEntry const* GetCharacterCacheByGuid(ObjectGuid const& guid) const;
|
||||
|
||||
@@ -4276,7 +4276,7 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_DELETE_INFO);
|
||||
stmt->setUInt64(0, guid);
|
||||
trans->Append(stmt);
|
||||
sCharacterCache->UpdateCharacterInfoDeleted(playerguid, true);
|
||||
sCharacterCache->UpdateCharacterInfoDeleted(playerguid, true, "");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -2797,7 +2797,7 @@ void WorldSession::HandleCharUndeleteOpcode(WorldPackets::Character::UndeleteCha
|
||||
loginStmt->setUInt32(0, GetBattlenetAccountId());
|
||||
LoginDatabase.Execute(loginStmt);
|
||||
|
||||
sCharacterCache->UpdateCharacterInfoDeleted(undeleteInfo->CharacterGuid, false, &undeleteInfo->Name);
|
||||
sCharacterCache->UpdateCharacterInfoDeleted(undeleteInfo->CharacterGuid, false, undeleteInfo->Name);
|
||||
|
||||
SendUndeleteCharacterResponse(CHARACTER_UNDELETE_RESULT_OK, undeleteInfo.get());
|
||||
}));
|
||||
|
||||
@@ -231,7 +231,7 @@ public:
|
||||
stmt->setUInt64(2, delInfo.guid.GetCounter());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
sCharacterCache->UpdateCharacterInfoDeleted(delInfo.guid, false, &delInfo.name);
|
||||
sCharacterCache->UpdateCharacterInfoDeleted(delInfo.guid, false, delInfo.name);
|
||||
}
|
||||
|
||||
static bool HandleCharacterTitlesCommand(ChatHandler* handler, Optional<PlayerIdentifier> player)
|
||||
|
||||
Reference in New Issue
Block a user