aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorUjp8LfXBJ6wCPR <github@lillecarl.com>2020-02-08 20:29:18 +0100
committerGitHub <noreply@github.com>2020-02-08 20:29:18 +0100
commit76831f1f467efe4aa26a38dc58c9eab2229bce71 (patch)
treef8b0090795ab5ccb4ac6546799a1f56ba302d97b /src
parentc574972cb2d000caacd155ddd32af425bed259ee (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/CoreAI/GameObjectAI.h2
-rw-r--r--src/server/game/AI/CreatureAI.h2
-rw-r--r--src/server/game/Cache/CharacterCache.cpp2
-rw-r--r--src/server/game/Cache/CharacterCache.h3
-rw-r--r--src/server/game/Handlers/CharacterHandler.cpp4
-rw-r--r--src/server/game/Scripting/ScriptReloadMgr.cpp4
6 files changed, 9 insertions, 8 deletions
diff --git a/src/server/game/AI/CoreAI/GameObjectAI.h b/src/server/game/AI/CoreAI/GameObjectAI.h
index 19be90eeead..218113fef20 100644
--- a/src/server/game/AI/CoreAI/GameObjectAI.h
+++ b/src/server/game/AI/CoreAI/GameObjectAI.h
@@ -52,7 +52,7 @@ class TC_GAME_API GameObjectAI
static int32 Permissible(GameObject const* go);
// Called when the dialog status between a player and the gameobject is requested.
- virtual Optional<QuestGiverStatus> GetDialogStatus(Player* /*player*/) { return boost::none; }
+ virtual Optional<QuestGiverStatus> GetDialogStatus(Player* /*player*/) { return {}; }
// Called when a player opens a gossip dialog with the gameobject.
virtual bool GossipHello(Player* /*player*/) { return false; }
diff --git a/src/server/game/AI/CreatureAI.h b/src/server/game/AI/CreatureAI.h
index 114bda4a6c9..0f9a7e5c817 100644
--- a/src/server/game/AI/CreatureAI.h
+++ b/src/server/game/AI/CreatureAI.h
@@ -192,7 +192,7 @@ class TC_GAME_API CreatureAI : public UnitAI
/// == Gossip system ================================
// Called when the dialog status between a player and the creature is requested.
- virtual Optional<QuestGiverStatus> GetDialogStatus(Player* /*player*/) { return boost::none; }
+ virtual Optional<QuestGiverStatus> GetDialogStatus(Player* /*player*/) { return {}; }
// Called when a player opens a gossip dialog with the creature.
virtual bool GossipHello(Player* /*player*/) { return false; }
diff --git a/src/server/game/Cache/CharacterCache.cpp b/src/server/game/Cache/CharacterCache.cpp
index b5be0e8c2b4..1835571b1e5 100644
--- a/src/server/game/Cache/CharacterCache.cpp
+++ b/src/server/game/Cache/CharacterCache.cpp
@@ -116,7 +116,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<uint8> gender /*= {}*/, Optional<uint8> 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 5fe884ef46b..201d5f1cc77 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 <string>
struct CharacterCacheEntry
@@ -46,7 +47,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);
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<uint8> gender = {}, Optional<uint8> race = {});
void UpdateCharacterLevel(ObjectGuid const& guid, uint8 level);
void UpdateCharacterAccountId(ObjectGuid const& guid, uint32 accountId);
void UpdateCharacterGuildId(ObjectGuid const& guid, ObjectGuid::LowType guildId);
diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp
index 9f54122d69f..b4a488d887f 100644
--- a/src/server/game/Handlers/CharacterHandler.cpp
+++ b/src/server/game/Handlers/CharacterHandler.cpp
@@ -1459,7 +1459,7 @@ void WorldSession::HandleCharCustomizeCallback(std::shared_ptr<CharacterCustomiz
CharacterDatabase.CommitTransaction(trans);
- sCharacterCache->UpdateCharacterData(customizeInfo->Guid, customizeInfo->Name, &customizeInfo->Gender);
+ sCharacterCache->UpdateCharacterData(customizeInfo->Guid, customizeInfo->Name, customizeInfo->Gender);
SendCharCustomize(RESPONSE_SUCCESS, customizeInfo.get());
@@ -1758,7 +1758,7 @@ void WorldSession::HandleCharFactionOrRaceChangeCallback(std::shared_ptr<Charact
trans->Append(stmt);
}
- sCharacterCache->UpdateCharacterData(factionChangeInfo->Guid, factionChangeInfo->Name, &factionChangeInfo->Gender, &factionChangeInfo->Race);
+ sCharacterCache->UpdateCharacterData(factionChangeInfo->Guid, factionChangeInfo->Name, factionChangeInfo->Gender, factionChangeInfo->Race);
if (oldRace != factionChangeInfo->Race)
{
diff --git a/src/server/game/Scripting/ScriptReloadMgr.cpp b/src/server/game/Scripting/ScriptReloadMgr.cpp
index 18f1135128e..4484ba0bf34 100644
--- a/src/server/game/Scripting/ScriptReloadMgr.cpp
+++ b/src/server/game/Scripting/ScriptReloadMgr.cpp
@@ -275,7 +275,7 @@ Optional<std::shared_ptr<ScriptModule>>
path.generic_string().c_str());
}
- return boost::none;
+ return {};
}
// Use RAII to release the library on failure.
@@ -302,7 +302,7 @@ Optional<std::shared_ptr<ScriptModule>>
TC_LOG_ERROR("scripts.hotswap", "Could not extract all required functions from the shared library \"%s\"!",
path.generic_string().c_str());
- return boost::none;
+ return {};
}
}