From 715da7432087a94a20e76502911c0639220fd815 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 7 Mar 2021 12:39:15 +0100 Subject: [PATCH] Make Effect field in Item OptionalUniquePtr. Signed-off-by: Deukhoofd --- src/Library/Items/Item.cpp | 8 +++++--- src/Library/Items/Item.hpp | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Library/Items/Item.cpp b/src/Library/Items/Item.cpp index dc1501f..5f36675 100644 --- a/src/Library/Items/Item.cpp +++ b/src/Library/Items/Item.cpp @@ -7,7 +7,7 @@ namespace CreatureLib::Library { BattleItemCategory _battleCategory; int32_t _price; - std::unique_ptr _effect = nullptr; + ArbUt::OptionalUniquePtr _effect = nullptr; std::unordered_set _flags; public: @@ -20,7 +20,7 @@ namespace CreatureLib::Library { inline ItemCategory GetCategory() const noexcept { return _category; } inline BattleItemCategory GetBattleCategory() const noexcept { return _battleCategory; } inline int32_t GetPrice() const noexcept { return _price; } - inline const std::unique_ptr& GetEffect() const noexcept { return _effect; } + inline const ArbUt::OptionalUniquePtr& GetEffect() const noexcept { return _effect; } inline bool HasFlag(const ArbUt::BasicStringView& flag) const noexcept { return this->_flags.contains(flag); } inline bool HasFlag(uint32_t flag) const noexcept { return this->_flags.contains(flag); } @@ -34,7 +34,9 @@ namespace CreatureLib::Library { ItemCategory Item::GetCategory() const noexcept { return _impl->GetCategory(); } BattleItemCategory Item::GetBattleCategory() const noexcept { return _impl->GetBattleCategory(); } int32_t Item::GetPrice() const noexcept { return _impl->GetPrice(); } - const std::unique_ptr& Item::GetEffect() const noexcept { return _impl->GetEffect(); } + const ArbUt::OptionalUniquePtr& Item::GetEffect() const noexcept { + return _impl->GetEffect(); + } bool Item::HasFlag(const ArbUt::BasicStringView& flag) const noexcept { return _impl->HasFlag(flag); } bool Item::HasFlag(uint32_t flag) const noexcept { return _impl->HasFlag(flag); } diff --git a/src/Library/Items/Item.hpp b/src/Library/Items/Item.hpp index 90870bc..e95ccfd 100644 --- a/src/Library/Items/Item.hpp +++ b/src/Library/Items/Item.hpp @@ -23,7 +23,7 @@ namespace CreatureLib::Library { BattleItemCategory GetBattleCategory() const noexcept; int32_t GetPrice() const noexcept; - const std::unique_ptr& GetEffect() const noexcept; + const ArbUt::OptionalUniquePtr& GetEffect() const noexcept; bool HasFlag(const ArbUt::BasicStringView& flag) const noexcept; bool HasFlag(uint32_t flag) const noexcept; };