Make BaseLibraries use shared_ptr.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -6,11 +6,13 @@
|
||||
|
||||
using namespace CreatureLib;
|
||||
|
||||
Battling::Creature::Creature(const BattleLibrary* library, const Library::CreatureSpecies* species,
|
||||
Battling::Creature::Creature(const BattleLibrary* library,
|
||||
const std::shared_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 Library::Item* heldItem,
|
||||
std::string nickname, const Library::TalentIndex& talent,
|
||||
const List<LearnedAttack*>& attacks, bool allowedExperienceGain)
|
||||
Library::Gender gender, uint8_t coloring,
|
||||
const std::shared_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),
|
||||
@@ -185,7 +187,7 @@ void Battling::Creature::AddExperience(uint32_t amount) {
|
||||
_experience = exp;
|
||||
_level = level;
|
||||
}
|
||||
const Library::CreatureSpecies* Battling::Creature::GetDisplaySpecies() const noexcept {
|
||||
std::shared_ptr<const Library::CreatureSpecies> Battling::Creature::GetDisplaySpecies() const noexcept {
|
||||
auto species = _displaySpecies;
|
||||
if (species == nullptr)
|
||||
species = _species;
|
||||
@@ -198,14 +200,14 @@ const Library::SpeciesVariant* Battling::Creature::GetDisplayVariant() const noe
|
||||
return variant;
|
||||
}
|
||||
void Battling::Creature::SetHeldItem(const ConstString& itemName) {
|
||||
const Library::Item* item;
|
||||
if (!_library->GetItemLibrary()->TryGet(itemName, item)) {
|
||||
std::shared_ptr<const Library::Item> item;
|
||||
if (!_library->GetItemLibrary()->TryGet(itemName.GetHash(), item)) {
|
||||
throw CreatureException("Item not found.");
|
||||
}
|
||||
_heldItem = item;
|
||||
}
|
||||
void Battling::Creature::SetHeldItem(uint32_t itemNameHash) {
|
||||
const Library::Item* item;
|
||||
std::shared_ptr<const Library::Item> item;
|
||||
if (!_library->GetItemLibrary()->TryGet(itemNameHash, item)) {
|
||||
throw CreatureException("Item not found.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user