Make SpeciesVariants smart pointers.
Some checks reported errors
continuous-integration/drone/push Build was killed

This commit is contained in:
2020-05-26 14:35:18 +02:00
parent 36208da2fb
commit 8418c814b4
6 changed files with 50 additions and 37 deletions

View File

@@ -7,10 +7,11 @@
using namespace CreatureLib;
Battling::Creature::Creature(const BattleLibrary* library, const borrowed_ptr<const Library::CreatureSpecies>& species,
const Library::SpeciesVariant* variant, uint8_t level, uint32_t experience, uint32_t uid,
Library::Gender gender, uint8_t coloring, const borrowed_ptr<const Library::Item> heldItem,
std::string nickname, const Library::TalentIndex& talent,
const List<LearnedAttack*>& attacks, bool allowedExperienceGain)
const borrowed_ptr<const Library::SpeciesVariant>& variant, uint8_t level,
uint32_t experience, uint32_t uid, Library::Gender gender, uint8_t coloring,
const borrowed_ptr<const Library::Item> heldItem, std::string nickname,
const Library::TalentIndex& talent, const List<LearnedAttack*>& attacks,
bool allowedExperienceGain)
: _library(library), _species(species), _variant(variant), _level(level), _experience(experience),
_uniqueIdentifier(uid), _gender(gender), _coloring(coloring), _heldItem(heldItem), _nickname(std::move(nickname)),
_talentIndex(talent), _hasOverridenTalent(false), _attacks(attacks),
@@ -191,7 +192,7 @@ borrowed_ptr<const Library::CreatureSpecies> Battling::Creature::GetDisplaySpeci
species = _species;
return species;
}
const Library::SpeciesVariant* Battling::Creature::GetDisplayVariant() const noexcept {
borrowed_ptr<const Library::SpeciesVariant> Battling::Creature::GetDisplayVariant() const noexcept {
auto variant = _displayVariant;
if (variant == nullptr)
variant = _variant;

View File

@@ -25,10 +25,10 @@ namespace CreatureLib::Battling {
const BattleLibrary* _library;
borrowed_ptr<const Library::CreatureSpecies> _species;
const Library::SpeciesVariant* _variant;
borrowed_ptr<const Library::SpeciesVariant> _variant;
borrowed_ptr<const Library::CreatureSpecies> _displaySpecies = nullptr;
const Library::SpeciesVariant* _displayVariant = nullptr;
borrowed_ptr<const Library::SpeciesVariant> _displayVariant = nullptr;
uint8_t _level;
uint32_t _experience;
@@ -65,9 +65,10 @@ namespace CreatureLib::Battling {
public:
Creature(const BattleLibrary* library, const borrowed_ptr<const Library::CreatureSpecies>& species,
const Library::SpeciesVariant* variant, uint8_t level, uint32_t experience, uint32_t uid,
Library::Gender gender, uint8_t coloring, const borrowed_ptr<const Library::Item> heldItem,
std::string nickname, const Library::TalentIndex& talent, const List<LearnedAttack*>& attacks,
const borrowed_ptr<const Library::SpeciesVariant>& variant, uint8_t level, uint32_t experience,
uint32_t uid, Library::Gender gender, uint8_t coloring,
const borrowed_ptr<const Library::Item> heldItem, std::string nickname,
const Library::TalentIndex& talent, const List<LearnedAttack*>& attacks,
bool allowedExperienceGain = true);
virtual ~Creature() {
@@ -84,7 +85,7 @@ namespace CreatureLib::Battling {
}
inline const borrowed_ptr<const Library::CreatureSpecies>& GetSpecies() const noexcept { return _species; }
inline const Library::SpeciesVariant* GetVariant() const noexcept { return _variant; }
inline const borrowed_ptr<const Library::SpeciesVariant>& GetVariant() const noexcept { return _variant; }
inline uint8_t GetLevel() const noexcept { return _level; }
inline uint32_t GetExperience() const noexcept { return _experience; }
inline Library::Gender GetGender() const noexcept { return _gender; }
@@ -137,7 +138,7 @@ namespace CreatureLib::Battling {
const List<LearnedAttack*>& GetAttacks() noexcept { return _attacks; }
borrowed_ptr<const Library::CreatureSpecies> GetDisplaySpecies() const noexcept;
const Library::SpeciesVariant* GetDisplayVariant() const noexcept;
borrowed_ptr<const Library::SpeciesVariant> GetDisplayVariant() const noexcept;
void SetDisplaySpecies(const borrowed_ptr<const Library::CreatureSpecies>& species) noexcept {
_displaySpecies = species;