Make all individual scripts smart pointers.
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2020-06-02 13:43:44 +02:00
parent dba1275813
commit e4b9550efa
11 changed files with 48 additions and 58 deletions

View File

@@ -5,9 +5,9 @@ using namespace CreatureLib::Battling;
export uint8_t CreatureLib_ExecutingAttack_Construct(ExecutingAttack*& out, Creature* const* targets,
size_t targetCount, uint8_t numberHits, Creature* user,
LearnedAttack* attack, Script* script) {
Try(auto ls = ArbUt::List<ArbUt::BorrowedPtr<Creature>>(targetCount); for (size_t i = 0; i < targetCount; i++) {
ls.Append(targets[i]);
} out = new ExecutingAttack(ls, numberHits, user, attack, script);)
Try(auto ls = ArbUt::List<ArbUt::BorrowedPtr<Creature>>(targetCount);
for (size_t i = 0; i < targetCount; i++) { ls.Append(targets[i]); } auto s = std::unique_ptr<Script>(script);
out = new ExecutingAttack(ls, numberHits, user, attack, s);)
}
export void CreatureLib_ExecutingAttack_Destruct(ExecutingAttack* p) { delete p; }

View File

@@ -30,7 +30,7 @@ SIMPLE_GET_FUNC(AttackTurnChoice, GetKind, TurnChoiceKind)
export uint8_t CreatureLib_BaseTurnChoice_GetPriority(int8_t& out, AttackTurnChoice* p) { Try(out = p->GetPriority()); }
SIMPLE_GET_FUNC(AttackTurnChoice, GetAttackScript, Script*)
SIMPLE_GET_FUNC_SMART_PTR(AttackTurnChoice, GetAttackScript, Script*)
export uint8_t CreatureLib_BaseTurnChoice_GetTargetSideIndex(const AttackTurnChoice* p) {
return p->GetTarget().GetSideIndex();
}