From 91a0fbbd7145d6fb966231689c369d641da06f9b Mon Sep 17 00:00:00 2001 From: Ujp8LfXBJ6wCPR Date: Sat, 8 Feb 2020 20:29:18 +0100 Subject: Use boost::optional and boost::none instead of smelly pointer (#24134) * Remove bad pointer usage from CharacterCache Use TrinityCore Option type instead which is intended for this purpose. (Wrapper around boost::option until C++17 bump is finalised) * Unify codestyle regarding TC optional type Based upon advice from @Shauren (cherry picked from commit 76831f1f467efe4aa26a38dc58c9eab2229bce71) --- src/server/game/Cache/CharacterCache.cpp | 2 +- src/server/game/Cache/CharacterCache.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src/server/game/Cache') diff --git a/src/server/game/Cache/CharacterCache.cpp b/src/server/game/Cache/CharacterCache.cpp index aea05434410..fa55d2a8235 100644 --- a/src/server/game/Cache/CharacterCache.cpp +++ b/src/server/game/Cache/CharacterCache.cpp @@ -117,7 +117,7 @@ void CharacterCache::DeleteCharacterCacheEntry(ObjectGuid const& guid, std::stri _characterCacheByNameStore.erase(name); } -void CharacterCache::UpdateCharacterData(ObjectGuid const& guid, std::string const& name, uint8* gender /*= nullptr*/, uint8* race /*= nullptr*/) +void CharacterCache::UpdateCharacterData(ObjectGuid const& guid, std::string const& name, Optional gender /*= {}*/, Optional race /*= {}*/) { auto itr = _characterCacheStore.find(guid); if (itr == _characterCacheStore.end()) diff --git a/src/server/game/Cache/CharacterCache.h b/src/server/game/Cache/CharacterCache.h index a9a872da837..74feef11e35 100644 --- a/src/server/game/Cache/CharacterCache.h +++ b/src/server/game/Cache/CharacterCache.h @@ -20,6 +20,7 @@ #include "Define.h" #include "ObjectGuid.h" +#include "Optional.h" #include struct CharacterCacheEntry @@ -47,7 +48,7 @@ class TC_GAME_API CharacterCache void AddCharacterCacheEntry(ObjectGuid const& guid, uint32 accountId, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level, bool isDeleted); 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 UpdateCharacterData(ObjectGuid const& guid, std::string const& name, Optional gender = {}, Optional race = {}); void UpdateCharacterGender(ObjectGuid const& guid, uint8 gender); void UpdateCharacterLevel(ObjectGuid const& guid, uint8 level); void UpdateCharacterAccountId(ObjectGuid const& guid, uint32 accountId); -- cgit v1.2.3