diff options
Diffstat (limited to 'src/server/game/Cache')
| -rw-r--r-- | src/server/game/Cache/CharacterCache.cpp | 14 | ||||
| -rw-r--r-- | src/server/game/Cache/CharacterCache.h | 2 |
2 files changed, 10 insertions, 6 deletions
diff --git a/src/server/game/Cache/CharacterCache.cpp b/src/server/game/Cache/CharacterCache.cpp index 20b0e1ffd9d..f424e5bd113 100644 --- a/src/server/game/Cache/CharacterCache.cpp +++ b/src/server/game/Cache/CharacterCache.cpp @@ -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; } /* diff --git a/src/server/game/Cache/CharacterCache.h b/src/server/game/Cache/CharacterCache.h index 186ffa1474c..cd4b18bffb8 100644 --- a/src/server/game/Cache/CharacterCache.h +++ b/src/server/game/Cache/CharacterCache.h @@ -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; |
