Make LearnedAttack of Creature a smart pointer.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-05-31 17:26:39 +02:00
parent a7069a5960
commit ff181204ae
8 changed files with 25 additions and 21 deletions

View File

@@ -3,6 +3,7 @@
#include <Arbutils/Collections/List.hpp>
#include <Arbutils/Memory/BorrowedPtr.hpp>
#include <Arbutils/Memory/UniquePtrList.hpp>
#include "../../Library/ClampedStatisticSet.hpp"
#include "../../Library/CreatureData/CreatureSpecies.hpp"
#include "../../Library/Items/Item.hpp"
@@ -52,7 +53,7 @@ namespace CreatureLib::Battling {
ArbUt::CaseInsensitiveConstString _overridenTalentName = ""_cnc;
std::unordered_set<Creature*> _seenOpponents = {};
ArbUt::List<LearnedAttack*> _attacks;
ArbUt::UniquePtrList<LearnedAttack> _attacks;
bool _allowedExperienceGain;
Script* _status = nullptr;
@@ -66,13 +67,10 @@ namespace CreatureLib::Battling {
const ArbUt::BorrowedPtr<const Library::SpeciesVariant>& variant, uint8_t level, uint32_t experience,
uint32_t uid, Library::Gender gender, uint8_t coloring,
const ArbUt::BorrowedPtr<const Library::Item> heldItem, std::string nickname,
const Library::TalentIndex& talent, const ArbUt::List<LearnedAttack*>& attacks,
const Library::TalentIndex& talent, const std::vector<LearnedAttack*>& attacks,
bool allowedExperienceGain = true);
virtual ~Creature() {
for (auto attack : _attacks) {
delete attack;
}
delete _activeTalent;
delete _status;
};
@@ -135,7 +133,7 @@ namespace CreatureLib::Battling {
void RemoveVolatileScript(Script* script);
bool HasVolatileScript(const ArbUt::CaseInsensitiveConstString& name) const;
const ArbUt::List<LearnedAttack*>& GetAttacks() noexcept { return _attacks; }
const ArbUt::UniquePtrList<LearnedAttack>& GetAttacks() noexcept { return _attacks; }
ArbUt::BorrowedPtr<const Library::CreatureSpecies> GetDisplaySpecies() const noexcept;
ArbUt::BorrowedPtr<const Library::SpeciesVariant> GetDisplayVariant() const noexcept;