Make HeldItem OptionalBorrowedPtr.
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
2020-12-12 13:40:30 +01:00
parent a01e22ad89
commit 4367d1f5cf
4 changed files with 13 additions and 12 deletions

View File

@@ -10,10 +10,11 @@ export uint8_t CreatureLib_Creature_Construct(Creature*& out, const BattleLibrar
const char* nickname, bool secretTalent, uint8_t talent,
LearnedAttack* attacks[], size_t attacksNum, bool allowedExperienceGain) {
Try(auto attacksVec = std::vector<LearnedAttack*>(attacks, attacks + (attacksNum * sizeof(LearnedAttack*)));
out = new Creature(library, ArbUt::BorrowedPtr<const CreatureLib::Library::CreatureSpecies>(species), variant,
level, experience, uid, gender, coloring,
ArbUt::BorrowedPtr<const CreatureLib::Library::Item>(heldItem), std::string(nickname),
CreatureLib::Library::TalentIndex(secretTalent, talent), attacksVec, allowedExperienceGain);)
out =
new Creature(library, ArbUt::BorrowedPtr<const CreatureLib::Library::CreatureSpecies>(species), variant,
level, experience, uid, gender, coloring,
ArbUt::OptionalBorrowedPtr<const CreatureLib::Library::Item>(heldItem), std::string(nickname),
CreatureLib::Library::TalentIndex(secretTalent, talent), attacksVec, allowedExperienceGain);)
};
export void CreatureLib_Creature_Destruct(const Creature* p) { delete p; }
@@ -42,7 +43,7 @@ export bool CreatureLib_Creature_HasHeldItem(const Creature* p, const char* name
return p->HasHeldItem(ArbUt::StringView(name));
}
export bool CreatureLib_Creature_HasHeldItemWithHash(const Creature* p, uint32_t hash) { return p->HasHeldItem(hash); }
BORROWED_GET_FUNC(Creature, GetHeldItem, const CreatureLib::Library::Item*);
OPTIONAL_GET_FUNC(Creature, GetHeldItem, const CreatureLib::Library::Item*);
export uint8_t CreatureLib_Creature_SetHeldItem(Creature* p, const char* name) {
Try(p->SetHeldItem(ArbUt::StringView(name));)
}