Overhaul memory model to new Arbutils memory.
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
@@ -31,7 +31,7 @@ export uint8_t CreatureLib_Battle_CreatureInField(bool& out, const Battle* p, Cr
|
||||
Try(out = p->CreatureInField(c);)
|
||||
}
|
||||
export uint8_t CreatureLib_Battle_GetCreature(Creature*& out, const Battle* p, uint8_t side, uint8_t target) {
|
||||
Try(out = p->GetCreature(side, target).GetRaw();)
|
||||
Try(out = p->GetCreature(side, target).GetValue();)
|
||||
}
|
||||
|
||||
export uint8_t CreatureLib_Battle_ForceRecall(Battle* p, uint8_t side, uint8_t target) {
|
||||
@@ -58,7 +58,11 @@ export BattleParty* const* CreatureLib_Battle_GetParties(const Battle* p) {
|
||||
}
|
||||
|
||||
export Script* CreatureLib_Battle_GetVolatileScript(Battle* p, const char* key) {
|
||||
return p->GetVolatileScript(ArbUt::StringView::CalculateHash(key)).GetRaw();
|
||||
auto v = p->GetVolatileScript(ArbUt::StringView::CalculateHash(key));
|
||||
if (!v.has_value()) {
|
||||
return nullptr;
|
||||
}
|
||||
return v.value();
|
||||
}
|
||||
export uint8_t CreatureLib_Battle_AddVolatileScriptByName(Battle* p, const char* key) {
|
||||
Try(p->AddVolatileScript(ArbUt::StringView(key));)
|
||||
|
||||
@@ -23,7 +23,7 @@ export uint8_t CreatureLib_BattleSide_SetCreature(BattleSide* p, Creature* creat
|
||||
}
|
||||
|
||||
export uint8_t CreatureLib_BattleSide_GetCreature(Creature*& out, BattleSide* p, uint8_t index) {
|
||||
Try(out = p->GetCreature(index).GetRaw());
|
||||
Try(out = p->GetCreature(index).GetValue());
|
||||
}
|
||||
|
||||
export uint8_t CreatureLib_BattleSide_GetSideIndex(BattleSide* p) { return p->GetSideIndex(); }
|
||||
|
||||
@@ -51,8 +51,8 @@ export void CreatureLib_Creature_SetHeldItemFromItem(Creature* p, const Creature
|
||||
return p->SetHeldItem(ArbUt::BorrowedPtr<const CreatureLib::Library::Item>(item));
|
||||
}
|
||||
SIMPLE_GET_FUNC(Creature, GetCurrentHealth, uint32_t);
|
||||
BORROWED_GET_FUNC(Creature, GetBattle, Battle*);
|
||||
BORROWED_GET_FUNC(Creature, GetBattleSide, BattleSide*);
|
||||
OPTIONAL_GET_FUNC(Creature, GetBattle, Battle*);
|
||||
OPTIONAL_GET_FUNC(Creature, GetBattleSide, BattleSide*);
|
||||
SIMPLE_GET_FUNC(Creature, IsOnBattleField, bool);
|
||||
export const char* CreatureLib_Creature_GetNickname(Creature* p) { return p->GetNickname().data(); }
|
||||
export bool CreatureLib_Creature_HasType(Creature* p, uint8_t type) { return p->HasType(type); }
|
||||
@@ -101,8 +101,8 @@ export LearnedAttack* const* CreatureLib_Creature_GetAttacks(Creature* p) { retu
|
||||
export bool CreatureLib_Creature_HasAttack(Creature* p, const char* scriptName) {
|
||||
return p->HasAttack(ArbUt::StringView(scriptName));
|
||||
}
|
||||
BORROWED_GET_FUNC(Creature, GetDisplaySpecies, const CreatureLib::Library::CreatureSpecies*);
|
||||
BORROWED_GET_FUNC(Creature, GetDisplayVariant, const CreatureLib::Library::SpeciesVariant*);
|
||||
OPTIONAL_GET_FUNC(Creature, GetDisplaySpecies, const CreatureLib::Library::CreatureSpecies*);
|
||||
OPTIONAL_GET_FUNC(Creature, GetDisplayVariant, const CreatureLib::Library::SpeciesVariant*);
|
||||
export void CreatureLib_Creature_SetDisplaySpecies(Creature* p, const CreatureLib::Library::CreatureSpecies* species) {
|
||||
return p->SetDisplaySpecies(ArbUt::BorrowedPtr<const CreatureLib::Library::CreatureSpecies>(species));
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ export CreatureParty* CreatureLib_CreatureParty_ConstructFromArray(Creature* cre
|
||||
export void CreatureLib_CreatureParty_Destruct(const CreatureParty* p) { delete p; }
|
||||
|
||||
export uint8_t CreatureLib_CreatureParty_GetAtIndex(Creature*& out, const CreatureParty* p, size_t index) {
|
||||
Try(out = p->GetAtIndex(index).GetRaw();)
|
||||
Try(out = p->GetAtIndex(index).GetValue();)
|
||||
}
|
||||
|
||||
export uint8_t CreatureLib_CreatureParty_Switch(CreatureParty* p, size_t a, size_t b) { Try(p->Switch(a, b);) }
|
||||
|
||||
@@ -5,7 +5,7 @@ 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);
|
||||
Try(auto ls = ArbUt::List<ArbUt::OptionalBorrowedPtr<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);)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,11 @@ export const HistoryElement* CreatureLib_HistoryHandler_GetTopElement(const Hist
|
||||
return p->GetTopElement().GetRaw();
|
||||
}
|
||||
export const HistoryElement* CreatureLib_HistoryHandler_GetLastUsedAttack(const HistoryHolder* p) {
|
||||
return p->GetLastUsedAttack().GetRaw();
|
||||
auto res = p->GetLastUsedAttack();
|
||||
if (res.has_value()) {
|
||||
return res.value();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
export HistoryElementKind CreatureLib_HistoryElement_GetKind(const HistoryElement* p) { return p->GetKind(); }
|
||||
|
||||
@@ -37,4 +37,4 @@ export uint8_t CreatureLib_AttackTurnChoice_GetTargetCreatureIndex(const AttackT
|
||||
return p->GetTarget().GetCreatureIndex();
|
||||
}
|
||||
|
||||
BORROWED_GET_FUNC(SwitchTurnChoice, GetNewCreature, Creature*)
|
||||
OPTIONAL_GET_FUNC(SwitchTurnChoice, GetNewCreature, Creature*)
|
||||
@@ -50,6 +50,12 @@ public:
|
||||
export returnType CreatureLib_##type##_##name(const type* p) { return p->name(); }
|
||||
#define BORROWED_GET_FUNC(type, name, returnType) \
|
||||
export returnType CreatureLib_##type##_##name(const type* p) { return p->name().GetRaw(); }
|
||||
#define OPTIONAL_GET_FUNC(type, name, returnType) \
|
||||
export returnType CreatureLib_##type##_##name(const type* p) { \
|
||||
if (p->name().HasValue()) \
|
||||
return p->name().GetValue(); \
|
||||
return nullptr; \
|
||||
}
|
||||
#define SMART_GET_FUNC(type, name, returnType) \
|
||||
export returnType CreatureLib_##type##_##name(const type* p) { return p->name().get(); }
|
||||
#define DESTRUCTOR(type) \
|
||||
|
||||
Reference in New Issue
Block a user