Make staticlib in battle library an unique ptr.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
0125215007
commit
d746b3ecce
|
@ -18,7 +18,7 @@ export void CreatureLib_BattleLibrary_Destruct(const BattleLibrary* p) { delete
|
||||||
#define SIMPLE_GET_FUNC_SMART_PTR(type, name, returnType) \
|
#define SIMPLE_GET_FUNC_SMART_PTR(type, name, returnType) \
|
||||||
export returnType CreatureLib_##type##_##name(const type* p) { return p->name().operator->(); }
|
export returnType CreatureLib_##type##_##name(const type* p) { return p->name().operator->(); }
|
||||||
|
|
||||||
SIMPLE_GET_FUNC(BattleLibrary, GetStaticLib, const CreatureLib::Library::DataLibrary*);
|
SIMPLE_GET_FUNC_SMART_PTR(BattleLibrary, GetStaticLib, const CreatureLib::Library::DataLibrary*);
|
||||||
SIMPLE_GET_FUNC_SMART_PTR(BattleLibrary, GetStatCalculator, const BattleStatCalculator*);
|
SIMPLE_GET_FUNC_SMART_PTR(BattleLibrary, GetStatCalculator, const BattleStatCalculator*);
|
||||||
SIMPLE_GET_FUNC_SMART_PTR(BattleLibrary, GetDamageLibrary, const DamageLibrary*);
|
SIMPLE_GET_FUNC_SMART_PTR(BattleLibrary, GetDamageLibrary, const DamageLibrary*);
|
||||||
SIMPLE_GET_FUNC_SMART_PTR(BattleLibrary, GetMiscLibrary, const MiscLibrary*);
|
SIMPLE_GET_FUNC_SMART_PTR(BattleLibrary, GetMiscLibrary, const MiscLibrary*);
|
||||||
|
|
|
@ -15,8 +15,6 @@ BattleLibrary::BattleLibrary(const CreatureLib::Library::DataLibrary* staticLib,
|
||||||
AssertNotNull(_miscLibrary);
|
AssertNotNull(_miscLibrary);
|
||||||
}
|
}
|
||||||
|
|
||||||
BattleLibrary::~BattleLibrary() { delete _staticLib; }
|
|
||||||
|
|
||||||
const std::unique_ptr<const CreatureLib::Library::LibrarySettings>& BattleLibrary::GetSettings() const noexcept {
|
const std::unique_ptr<const CreatureLib::Library::LibrarySettings>& BattleLibrary::GetSettings() const noexcept {
|
||||||
return _staticLib->GetSettings();
|
return _staticLib->GetSettings();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
namespace CreatureLib::Battling {
|
namespace CreatureLib::Battling {
|
||||||
class BattleLibrary {
|
class BattleLibrary {
|
||||||
protected:
|
protected:
|
||||||
const Library::DataLibrary* _staticLib = nullptr;
|
std::unique_ptr<const Library::DataLibrary> _staticLib = nullptr;
|
||||||
std::unique_ptr<const BattleStatCalculator> _statCalculator = nullptr;
|
std::unique_ptr<const BattleStatCalculator> _statCalculator = nullptr;
|
||||||
std::unique_ptr<const DamageLibrary> _damageLibrary = nullptr;
|
std::unique_ptr<const DamageLibrary> _damageLibrary = nullptr;
|
||||||
std::unique_ptr<const ExperienceLibrary> _experienceLibrary = nullptr;
|
std::unique_ptr<const ExperienceLibrary> _experienceLibrary = nullptr;
|
||||||
|
@ -22,8 +22,8 @@ namespace CreatureLib::Battling {
|
||||||
BattleLibrary(const Library::DataLibrary* staticLib, BattleStatCalculator* statCalculator,
|
BattleLibrary(const Library::DataLibrary* staticLib, BattleStatCalculator* statCalculator,
|
||||||
DamageLibrary* damageLibrary, ExperienceLibrary* experienceLibrary,
|
DamageLibrary* damageLibrary, ExperienceLibrary* experienceLibrary,
|
||||||
ScriptResolver* scriptResolver, MiscLibrary* miscLibrary);
|
ScriptResolver* scriptResolver, MiscLibrary* miscLibrary);
|
||||||
~BattleLibrary();
|
~BattleLibrary() = default;
|
||||||
inline const Library::DataLibrary* GetStaticLib() const noexcept { return _staticLib; }
|
inline const std::unique_ptr<const Library::DataLibrary>& GetStaticLib() const noexcept { return _staticLib; }
|
||||||
|
|
||||||
[[nodiscard]] const std::unique_ptr<const Library::LibrarySettings>& GetSettings() const noexcept;
|
[[nodiscard]] const std::unique_ptr<const Library::LibrarySettings>& GetSettings() const noexcept;
|
||||||
[[nodiscard]] const std::unique_ptr<const Library::SpeciesLibrary>& GetSpeciesLibrary() const noexcept;
|
[[nodiscard]] const std::unique_ptr<const Library::SpeciesLibrary>& GetSpeciesLibrary() const noexcept;
|
||||||
|
|
Loading…
Reference in New Issue