Enable pedantic errors
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Deukhoofd 2022-04-02 12:33:26 +02:00
parent 4bb353e75b
commit 842d708996
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
39 changed files with 447 additions and 413 deletions

View File

@ -2,87 +2,89 @@
#include "../Core.hpp"
using namespace CreatureLib::Battling;
export u8 CreatureLib_Battle_Construct(Battle*& out, const BattleLibrary* library, BattleParty* partyArr[],
size_t numberOfParties, bool canFlee, u8 numberOfSides, u8 creaturesPerSide,
uint_fast32_t randomSeed) {
export_func u8 CreatureLib_Battle_Construct(Battle*& out, const BattleLibrary* library, BattleParty* partyArr[],
size_t numberOfParties, bool canFlee, u8 numberOfSides, u8 creaturesPerSide,
uint_fast32_t randomSeed) {
Try(ArbUt::List<BattleParty*> parties(partyArr, partyArr + numberOfParties);
out = new Battle(library, parties, canFlee, numberOfSides, creaturesPerSide, randomSeed);)
}
export void CreatureLib_Battle_Destruct(const Battle* p) { delete p; }
export_func void CreatureLib_Battle_Destruct(const Battle* p) { delete p; }
export const BattleLibrary* CreatureLib_Battle_GetLibrary(const Battle* p) { return p->GetLibrary().GetRaw(); }
export u8 CreatureLib_Battle_CanUse(bool& out, Battle* p, BaseTurnChoice* turnChoice) {
export_func const BattleLibrary* CreatureLib_Battle_GetLibrary(const Battle* p) { return p->GetLibrary().GetRaw(); }
export_func u8 CreatureLib_Battle_CanUse(bool& out, Battle* p, BaseTurnChoice* turnChoice) {
Try(out = p->CanUse(turnChoice);)
}
export u8 CreatureLib_Battle_TrySetChoice(bool& out, Battle* p, BaseTurnChoice* turnChoice) {
export_func u8 CreatureLib_Battle_TrySetChoice(bool& out, Battle* p, BaseTurnChoice* turnChoice) {
Try(out = p->TrySetChoice(turnChoice);)
}
export bool CreatureLib_Battle_CanFlee(const Battle* p) { return p->CanFlee(); }
export u8 CreatureLib_Battle_CheckChoicesSetAndRun(Battle* p) { Try(p->CheckChoicesSetAndRun();) }
export u32 CreatureLib_Battle_GetCurrentTurn(Battle* p) { return p->GetCurrentTurn(); }
export u32 CreatureLib_Battle_GetCreaturesPerSide(Battle* p) { return p->GetCreaturesPerSide(); }
export_func bool CreatureLib_Battle_CanFlee(const Battle* p) { return p->CanFlee(); }
export_func u8 CreatureLib_Battle_CheckChoicesSetAndRun(Battle* p) { Try(p->CheckChoicesSetAndRun();) }
export_func u32 CreatureLib_Battle_GetCurrentTurn(Battle* p) { return p->GetCurrentTurn(); }
export_func u32 CreatureLib_Battle_GetCreaturesPerSide(Battle* p) { return p->GetCreaturesPerSide(); }
export ChoiceQueue* CreatureLib_Battle_GetCurrentTurnQueue(const Battle* p) {
export_func ChoiceQueue* CreatureLib_Battle_GetCurrentTurnQueue(const Battle* p) {
return p->GetCurrentTurnQueue().GetRaw();
}
export BattleRandom* CreatureLib_Battle_GetRandom(Battle* p) { return p->GetRandom(); }
export u8 CreatureLib_Battle_CreatureInField(bool& out, const Battle* p, Creature* c) {
export_func BattleRandom* CreatureLib_Battle_GetRandom(Battle* p) { return p->GetRandom(); }
export_func u8 CreatureLib_Battle_CreatureInField(bool& out, const Battle* p, Creature* c) {
Try(out = p->CreatureInField(c);)
}
export u8 CreatureLib_Battle_GetCreature(Creature*& out, const Battle* p, u8 side, u8 target) {
export_func u8 CreatureLib_Battle_GetCreature(Creature*& out, const Battle* p, u8 side, u8 target) {
Try(out = p->GetCreature(side, target).GetValue();)
}
export u8 CreatureLib_Battle_ForceRecall(Battle* p, u8 side, u8 target) { Try(p->ForceRecall(side, target);) }
export u8 CreatureLib_Battle_SwitchCreature(Battle* p, u8 side, u8 target, Creature* c) {
export_func u8 CreatureLib_Battle_ForceRecall(Battle* p, u8 side, u8 target) { Try(p->ForceRecall(side, target);) }
export_func u8 CreatureLib_Battle_SwitchCreature(Battle* p, u8 side, u8 target, Creature* c) {
Try(p->SwitchCreature(side, target, c);)
}
export u8 CreatureLib_Battle_CanSlotBeFilled(bool& out, const Battle* p, u8 side, u8 target) {
export_func u8 CreatureLib_Battle_CanSlotBeFilled(bool& out, const Battle* p, u8 side, u8 target) {
Try(out = p->CanSlotBeFilled(side, target);)
}
export u8 CreatureLib_Battle_ValidateBattleState(Battle* p) { Try(p->ValidateBattleState();) }
export bool CreatureLib_Battle_HasEnded(const Battle* p) { return p->HasEnded(); }
export_func u8 CreatureLib_Battle_ValidateBattleState(Battle* p) { Try(p->ValidateBattleState();) }
export_func bool CreatureLib_Battle_HasEnded(const Battle* p) { return p->HasEnded(); }
export bool CreatureLib_Battle_HasConclusiveResult(const Battle* p) { return p->GetResult().IsConclusiveResult(); }
export bool CreatureLib_Battle_GetWinningSide(const Battle* p) { return p->GetResult().GetWinningSide(); }
export_func bool CreatureLib_Battle_HasConclusiveResult(const Battle* p) { return p->GetResult().IsConclusiveResult(); }
export_func bool CreatureLib_Battle_GetWinningSide(const Battle* p) { return p->GetResult().GetWinningSide(); }
export size_t CreatureLib_Battle_GetSidesCount(const Battle* p) { return p->GetSides().Count(); }
export BattleSide* const* CreatureLib_Battle_GetSides(const Battle* p) { return p->GetSides().RawData(); }
export_func size_t CreatureLib_Battle_GetSidesCount(const Battle* p) { return p->GetSides().Count(); }
export_func BattleSide* const* CreatureLib_Battle_GetSides(const Battle* p) { return p->GetSides().RawData(); }
export size_t CreatureLib_Battle_GetPartiesCount(const Battle* p) { return p->GetParties().Count(); }
export BattleParty* const* CreatureLib_Battle_GetParties(const Battle* p) {
export_func size_t CreatureLib_Battle_GetPartiesCount(const Battle* p) { return p->GetParties().Count(); }
export_func BattleParty* const* CreatureLib_Battle_GetParties(const Battle* p) {
return reinterpret_cast<BattleParty* const*>(p->GetParties().RawData());
}
export BattleScript* CreatureLib_Battle_GetVolatileScript(Battle* p, const char* key) {
export_func BattleScript* CreatureLib_Battle_GetVolatileScript(Battle* p, const char* key) {
auto v = p->GetVolatileScript(ArbUt::StringView::CalculateHash(key));
if (!v.HasValue()) {
return nullptr;
}
return v.GetValue();
}
export u8 CreatureLib_Battle_AddVolatileScriptByName(Battle* p, const char* key) {
export_func u8 CreatureLib_Battle_AddVolatileScriptByName(Battle* p, const char* key) {
Try(p->AddVolatileScript(ArbUt::StringView(key));)
}
export u8 CreatureLib_Battle_AddVolatileScript(Battle* p, BattleScript* script) { Try(p->AddVolatileScript(script);) }
export_func u8 CreatureLib_Battle_AddVolatileScript(Battle* p, BattleScript* script) {
Try(p->AddVolatileScript(script);)
}
export u8 CreatureLib_Battle_RemoveVolatileScript(Battle* p, const char* key) {
export_func u8 CreatureLib_Battle_RemoveVolatileScript(Battle* p, const char* key) {
Try(p->RemoveVolatileScript(ArbUt::StringView::CalculateHash(key));)
}
export u8 CreatureLib_Battle_RemoveVolatileScriptWithScript(Battle* p, BattleScript* script) {
export_func u8 CreatureLib_Battle_RemoveVolatileScriptWithScript(Battle* p, BattleScript* script) {
Try(p->RemoveVolatileScript(script);)
}
export bool CreatureLib_Battle_HasVolatileScript(Battle* p, const char* key) {
export_func bool CreatureLib_Battle_HasVolatileScript(Battle* p, const char* key) {
return p->HasVolatileScript(ArbUt::StringView::CalculateHash(key));
}
export u8 CreatureLib_Battle_RegisterEventListener(Battle* p, void (*func)(const EventData*)) {
export_func u8 CreatureLib_Battle_RegisterEventListener(Battle* p, void (*func)(const EventData*)) {
Try(p->RegisterEventListener(func);)
}
export const HistoryHolder* CreatureLib_Battle_GetHistory(Battle* p) { return p->GetHistory(); }
export_func const HistoryHolder* CreatureLib_Battle_GetHistory(Battle* p) { return p->GetHistory(); }
export u8 CreatureLib_Battle_EndBattle(Battle* p) { Try(p->EndBattle()) }
export u8 CreatureLib_Battle_ClearBattle(Battle* p) { Try(p->ClearBattle()) }
export_func u8 CreatureLib_Battle_EndBattle(Battle* p) { Try(p->EndBattle()) }
export_func u8 CreatureLib_Battle_ClearBattle(Battle* p) { Try(p->ClearBattle()) }
SIMPLE_GET_FUNC(Battle, GetLastTurnTimeMicroseconds, long);

View File

@ -2,16 +2,16 @@
#include "../Core.hpp"
using namespace CreatureLib::Battling;
export u8 CreatureLib_BattleLibrary_Construct(const BattleLibrary*& out,
const CreatureLib::Library::DataLibrary* staticLib,
BattleStatCalculator* statCalculator, DamageLibrary* damageLibrary,
ExperienceLibrary* experienceLibrary, ScriptResolver* scriptResolver,
MiscLibrary* miscLibrary) {
export_func u8 CreatureLib_BattleLibrary_Construct(const BattleLibrary*& out,
const CreatureLib::Library::DataLibrary* staticLib,
BattleStatCalculator* statCalculator, DamageLibrary* damageLibrary,
ExperienceLibrary* experienceLibrary, ScriptResolver* scriptResolver,
MiscLibrary* miscLibrary) {
Try(out = new BattleLibrary(staticLib, statCalculator, damageLibrary, experienceLibrary, scriptResolver,
miscLibrary);)
}
export void CreatureLib_BattleLibrary_Destruct(const BattleLibrary* p) { delete p; }
export_func void CreatureLib_BattleLibrary_Destruct(const BattleLibrary* p) { delete p; }
SMART_GET_FUNC(BattleLibrary, GetStaticLib, const CreatureLib::Library::DataLibrary*);
SMART_GET_FUNC(BattleLibrary, GetStatCalculator, const BattleStatCalculator*);

View File

@ -4,17 +4,19 @@ using namespace CreatureLib::Battling;
// Note that creatureIndices should be twice the size of numberOfIndices, and have index of side, index of creature on
// side, one after the other.
export u8 CreatureLib_BattleParty_Construct(BattleParty*& out, CreatureParty* p, u8 creatureIndices[],
size_t numberOfIndices) {
export_func u8 CreatureLib_BattleParty_Construct(BattleParty*& out, CreatureParty* p, u8 creatureIndices[],
size_t numberOfIndices) {
Try(ArbUt::List<CreatureIndex> indices(numberOfIndices); for (size_t i = 0; i < numberOfIndices; i++) {
indices.Append(CreatureIndex(creatureIndices[i * 2], creatureIndices[i * 2 + 1]));
} out = new BattleParty(p, indices);)
}
export void CreatureLib_BattleParty_Destruct(const BattleParty* p) { delete p; }
export_func void CreatureLib_BattleParty_Destruct(const BattleParty* p) { delete p; }
BORROWED_GET_FUNC(BattleParty, GetParty, CreatureParty*);
export u8 CreatureLib_BattleParty_IsResponsibleForIndex(bool& out, const BattleParty* p, u8 side, u8 creature) {
export_func u8 CreatureLib_BattleParty_IsResponsibleForIndex(bool& out, const BattleParty* p, u8 side, u8 creature) {
Try(out = p->IsResponsibleForIndex(side, creature);)
}
export bool CreatureLib_BattleParty_HasCreaturesNotInField(const BattleParty* p) { return p->HasCreaturesNotInField(); }
export_func bool CreatureLib_BattleParty_HasCreaturesNotInField(const BattleParty* p) {
return p->HasCreaturesNotInField();
}

View File

@ -2,17 +2,19 @@
#include "../Core.hpp"
using namespace CreatureLib::Battling;
export BattleRandom* CreatureLib_BattleRandom_Construct() { return new BattleRandom(); }
export BattleRandom* CreatureLib_BattleRandom_ConstructWithSeed(uint_fast32_t seed) { return new BattleRandom(seed); }
export_func BattleRandom* CreatureLib_BattleRandom_Construct() { return new BattleRandom(); }
export_func BattleRandom* CreatureLib_BattleRandom_ConstructWithSeed(uint_fast32_t seed) {
return new BattleRandom(seed);
}
export void CreatureLib_BattleRandom_Destruct(BattleRandom* p) { delete p; }
export_func void CreatureLib_BattleRandom_Destruct(BattleRandom* p) { delete p; }
export i8 CreatureLib_BattleRandom_EffectChance(bool& out, BattleRandom* p, float chance, ExecutingAttack* attack,
Creature* target) {
export_func i8 CreatureLib_BattleRandom_EffectChance(bool& out, BattleRandom* p, float chance, ExecutingAttack* attack,
Creature* target) {
Try(out = p->EffectChance(chance, attack, target);)
}
export i32 CreatureLib_BattleRandom_Get(BattleRandom* p) { return p->Get(); }
export i32 CreatureLib_BattleRandom_GetMax(BattleRandom* p, i32 max) { return p->Get(max); }
export i32 CreatureLib_BattleRandom_GetMinMax(BattleRandom* p, i32 min, i32 max) { return p->Get(min, max); }
export uint_fast32_t CreatureLib_BattleRandom_GetSeed(BattleRandom* p) { return p->GetSeed(); }
export_func i32 CreatureLib_BattleRandom_Get(BattleRandom* p) { return p->Get(); }
export_func i32 CreatureLib_BattleRandom_GetMax(BattleRandom* p, i32 max) { return p->Get(max); }
export_func i32 CreatureLib_BattleRandom_GetMinMax(BattleRandom* p, i32 min, i32 max) { return p->Get(min, max); }
export_func uint_fast32_t CreatureLib_BattleRandom_GetSeed(BattleRandom* p) { return p->GetSeed(); }

View File

@ -2,94 +2,94 @@
#include "../Core.hpp"
using namespace CreatureLib::Battling;
export void CreatureLib_Script_Destruct(BattleScript* p) { delete p; }
export_func void CreatureLib_Script_Destruct(BattleScript* p) { delete p; }
export u8 CreatureLib_Script_Stack(BattleScript* p) { Try(p->Stack()); }
export u8 CreatureLib_Script_OnRemove(BattleScript* p) { Try(p->OnRemove()); }
export const char* CreatureLib_Script_GetName(BattleScript* p) { return p->GetName().c_str(); }
export_func u8 CreatureLib_Script_Stack(BattleScript* p) { Try(p->Stack()); }
export_func u8 CreatureLib_Script_OnRemove(BattleScript* p) { Try(p->OnRemove()); }
export_func const char* CreatureLib_Script_GetName(BattleScript* p) { return p->GetName().c_str(); }
export u8 CreatureLib_Script_OnBeforeTurn(BattleScript* p, const BaseTurnChoice* choice) {
export_func u8 CreatureLib_Script_OnBeforeTurn(BattleScript* p, const BaseTurnChoice* choice) {
Try(p->OnBeforeTurn(choice));
}
export u8 CreatureLib_Script_ChangeAttack(BattleScript* p, AttackTurnChoice* choice, const char*& outAttack) {
export_func u8 CreatureLib_Script_ChangeAttack(BattleScript* p, AttackTurnChoice* choice, const char*& outAttack) {
Try(auto sv = ArbUt::StringView(outAttack); p->ChangeAttack(choice, &sv); outAttack = sv.c_str(););
}
export u8 CreatureLib_Script_PreventAttack(BattleScript* p, ExecutingAttack* attack, bool* outResult) {
export_func u8 CreatureLib_Script_PreventAttack(BattleScript* p, ExecutingAttack* attack, bool* outResult) {
Try(p->PreventAttack(attack, outResult));
}
export u8 CreatureLib_Script_FailAttack(BattleScript* p, ExecutingAttack* attack, bool* outResult) {
export_func u8 CreatureLib_Script_FailAttack(BattleScript* p, ExecutingAttack* attack, bool* outResult) {
Try(p->FailAttack(attack, outResult));
}
export u8 CreatureLib_Script_StopBeforeAttack(BattleScript* p, ExecutingAttack* attack, bool* outResult) {
export_func u8 CreatureLib_Script_StopBeforeAttack(BattleScript* p, ExecutingAttack* attack, bool* outResult) {
Try(p->StopBeforeAttack(attack, outResult));
}
export u8 CreatureLib_Script_OnBeforeAttack(BattleScript* p, ExecutingAttack* attack) {
export_func u8 CreatureLib_Script_OnBeforeAttack(BattleScript* p, ExecutingAttack* attack) {
Try(p->OnBeforeAttack(attack));
}
export u8 CreatureLib_Script_FailIncomingAttack(BattleScript* p, ExecutingAttack* attack, Creature* target,
bool* outResult) {
export_func u8 CreatureLib_Script_FailIncomingAttack(BattleScript* p, ExecutingAttack* attack, Creature* target,
bool* outResult) {
Try(p->FailIncomingAttack(attack, target, outResult));
}
export u8 CreatureLib_Script_IsInvulnerable(BattleScript* p, ExecutingAttack* attack, Creature* target,
bool* outResult) {
export_func u8 CreatureLib_Script_IsInvulnerable(BattleScript* p, ExecutingAttack* attack, Creature* target,
bool* outResult) {
Try(p->IsInvulnerable(attack, target, outResult));
}
export u8 CreatureLib_Script_OnAttackMiss(BattleScript* p, ExecutingAttack* attack, Creature* target) {
export_func u8 CreatureLib_Script_OnAttackMiss(BattleScript* p, ExecutingAttack* attack, Creature* target) {
Try(p->OnAttackMiss(attack, target));
}
export u8 CreatureLib_Script_ChangeAttackType(BattleScript* p, ExecutingAttack* attack, Creature* target, u8 hitNumber,
u8* outType) {
export_func u8 CreatureLib_Script_ChangeAttackType(BattleScript* p, ExecutingAttack* attack, Creature* target,
u8 hitNumber, u8* outType) {
Try(p->ChangeAttackType(attack, target, hitNumber, outType))
}
export u8 CreatureLib_Script_OverrideBasePower(BattleScript* p, ExecutingAttack* attack, Creature* target, u8 hitNumber,
u8* basePower) {
export_func u8 CreatureLib_Script_OverrideBasePower(BattleScript* p, ExecutingAttack* attack, Creature* target,
u8 hitNumber, u8* basePower) {
Try(p->OverrideBasePower(attack, target, hitNumber, basePower));
}
export u8 CreatureLib_Script_ChangeDamageStatsUser(BattleScript* p, ExecutingAttack* attack, Creature* target,
u8 hitNumber, Creature** statsUser) {
export_func u8 CreatureLib_Script_ChangeDamageStatsUser(BattleScript* p, ExecutingAttack* attack, Creature* target,
u8 hitNumber, Creature** statsUser) {
Try(p->ChangeDamageStatsUser(attack, target, hitNumber, statsUser));
}
export u8 CreatureLib_Script_BypassDefensiveStat(BattleScript* p, ExecutingAttack* attack, Creature* target,
u8 hitNumber, bool* bypass) {
export_func u8 CreatureLib_Script_BypassDefensiveStat(BattleScript* p, ExecutingAttack* attack, Creature* target,
u8 hitNumber, bool* bypass) {
Try(p->BypassDefensiveStat(attack, target, hitNumber, bypass));
}
export u8 CreatureLib_Script_BypassOffensiveStat(BattleScript* p, ExecutingAttack* attack, Creature* target,
u8 hitNumber, bool* bypass) {
export_func u8 CreatureLib_Script_BypassOffensiveStat(BattleScript* p, ExecutingAttack* attack, Creature* target,
u8 hitNumber, bool* bypass) {
Try(p->BypassOffensiveStat(attack, target, hitNumber, bypass));
}
export u8 CreatureLib_Script_ModifyStatModifier(BattleScript* p, ExecutingAttack* attack, Creature* target,
u8 hitNumber, float* modifier) {
export_func u8 CreatureLib_Script_ModifyStatModifier(BattleScript* p, ExecutingAttack* attack, Creature* target,
u8 hitNumber, float* modifier) {
Try(p->ModifyStatModifier(attack, target, hitNumber, modifier));
}
export u8 CreatureLib_Script_ModifyDamageModifier(BattleScript* p, ExecutingAttack* attack, Creature* target,
u8 hitNumber, float* modifier) {
export_func u8 CreatureLib_Script_ModifyDamageModifier(BattleScript* p, ExecutingAttack* attack, Creature* target,
u8 hitNumber, float* modifier) {
Try(p->ModifyDamageModifier(attack, target, hitNumber, modifier));
}
export u8 CreatureLib_Script_OverrideDamage(BattleScript* p, ExecutingAttack* attack, Creature* target, u8 hitNumber,
u32* damage) {
export_func u8 CreatureLib_Script_OverrideDamage(BattleScript* p, ExecutingAttack* attack, Creature* target,
u8 hitNumber, u32* damage) {
Try(p->OverrideDamage(attack, target, hitNumber, damage));
}
export u8 CreatureLib_Script_PreventSecondaryEffects(BattleScript* p, ExecutingAttack* attack, Creature* target,
u8 hitNumber, bool* outResult) {
export_func u8 CreatureLib_Script_PreventSecondaryEffects(BattleScript* p, ExecutingAttack* attack, Creature* target,
u8 hitNumber, bool* outResult) {
Try(p->PreventSecondaryEffects(attack, target, hitNumber, outResult));
}
export u8 CreatureLib_Script_OnSecondaryEffect(BattleScript* p, ExecutingAttack* attack, Creature* target,
u8 hitNumber) {
export_func u8 CreatureLib_Script_OnSecondaryEffect(BattleScript* p, ExecutingAttack* attack, Creature* target,
u8 hitNumber) {
Try(p->OnSecondaryEffect(attack, target, hitNumber));
}
export u8 CreatureLib_Script_OnAfterHits(BattleScript* p, ExecutingAttack* attack, Creature* target) {
export_func u8 CreatureLib_Script_OnAfterHits(BattleScript* p, ExecutingAttack* attack, Creature* target) {
Try(p->OnAfterHits(attack, target));
}
export u8 CreatureLib_Script_PreventSelfSwitch(BattleScript* p, const SwitchTurnChoice* choice, bool* outResult) {
export_func u8 CreatureLib_Script_PreventSelfSwitch(BattleScript* p, const SwitchTurnChoice* choice, bool* outResult) {
Try(p->PreventSelfSwitch(choice, outResult));
}
export u8 CreatureLib_Script_ModifyEffectChance(BattleScript* p, const ExecutingAttack* attack, Creature* target,
float* chance) {
export_func u8 CreatureLib_Script_ModifyEffectChance(BattleScript* p, const ExecutingAttack* attack, Creature* target,
float* chance) {
Try(p->ModifyEffectChance(attack, target, chance));
}
export u8 CreatureLib_Script_ModifyIncomingEffectChance(BattleScript* p, const ExecutingAttack* attack,
Creature* target, float* chance) {
export_func u8 CreatureLib_Script_ModifyIncomingEffectChance(BattleScript* p, const ExecutingAttack* attack,
Creature* target, float* chance) {
Try(p->ModifyIncomingEffectChance(attack, target, chance));
}

View File

@ -2,66 +2,68 @@
#include "../Core.hpp"
using namespace CreatureLib::Battling;
export BattleSide* CreatureLib_BattleSide_Construct(u8 index, Battle* battle, u8 creaturesPerSide) {
export_func BattleSide* CreatureLib_BattleSide_Construct(u8 index, Battle* battle, u8 creaturesPerSide) {
return new BattleSide(index, battle, creaturesPerSide);
}
export void CreatureLib_BattleSide_Destruct(BattleSide* p) { delete p; }
export_func void CreatureLib_BattleSide_Destruct(BattleSide* p) { delete p; }
export Battle* CreatureLib_BattleSide_GetBattle(BattleSide* p) { return p->GetBattle(); }
export bool CreatureLib_BattleSide_AllChoicesSet(BattleSide* p) { return p->AllChoicesSet(); }
export_func Battle* CreatureLib_BattleSide_GetBattle(BattleSide* p) { return p->GetBattle(); }
export_func bool CreatureLib_BattleSide_AllChoicesSet(BattleSide* p) { return p->AllChoicesSet(); }
export u8 CreatureLib_BattleSide_AllPossibleSlotsFilled(bool& out, BattleSide* p) {
export_func u8 CreatureLib_BattleSide_AllPossibleSlotsFilled(bool& out, BattleSide* p) {
Try(out = p->AllPossibleSlotsFilled());
}
export u8 CreatureLib_BattleSide_SetChoice(BattleSide* p, BaseTurnChoice* choice) { Try(p->SetChoice(choice);) }
export_func u8 CreatureLib_BattleSide_SetChoice(BattleSide* p, BaseTurnChoice* choice) { Try(p->SetChoice(choice);) }
export void CreatureLib_BattleSide_ResetChoices(BattleSide* p) { p->ResetChoices(); }
export_func void CreatureLib_BattleSide_ResetChoices(BattleSide* p) { p->ResetChoices(); }
export u8 CreatureLib_BattleSide_SetCreature(BattleSide* p, Creature* creature, u8 index) {
export_func u8 CreatureLib_BattleSide_SetCreature(BattleSide* p, Creature* creature, u8 index) {
Try(p->SetCreature(creature, index));
}
export u8 CreatureLib_BattleSide_GetCreature(Creature*& out, BattleSide* p, u8 index) {
export_func u8 CreatureLib_BattleSide_GetCreature(Creature*& out, BattleSide* p, u8 index) {
Try(out = p->GetCreature(index).GetValue());
}
export u8 CreatureLib_BattleSide_GetSideIndex(BattleSide* p) { return p->GetSideIndex(); }
export u8 CreatureLib_BattleSide_GetCreatureIndex(u8& out, BattleSide* p, Creature* c) {
export_func u8 CreatureLib_BattleSide_GetSideIndex(BattleSide* p) { return p->GetSideIndex(); }
export_func u8 CreatureLib_BattleSide_GetCreatureIndex(u8& out, BattleSide* p, Creature* c) {
Try(out = p->GetCreatureIndex(c));
}
export u8 CreatureLib_BattleSide_MarkSlotAsUnfillable(BattleSide* p, Creature* c) { Try(p->MarkSlotAsUnfillable(c)); }
export_func u8 CreatureLib_BattleSide_MarkSlotAsUnfillable(BattleSide* p, Creature* c) {
Try(p->MarkSlotAsUnfillable(c));
}
export bool CreatureLib_BattleSide_IsDefeated(BattleSide* p) { return p->IsDefeated(); }
export bool CreatureLib_BattleSide_HasFled(BattleSide* p) { return p->HasFled(); }
export void CreatureLib_BattleSide_MarkAsFled(BattleSide* p) { p->MarkAsFled(); }
export_func bool CreatureLib_BattleSide_IsDefeated(BattleSide* p) { return p->IsDefeated(); }
export_func bool CreatureLib_BattleSide_HasFled(BattleSide* p) { return p->HasFled(); }
export_func void CreatureLib_BattleSide_MarkAsFled(BattleSide* p) { p->MarkAsFled(); }
export u8 CreatureLib_BattleSide_SwapPositions(u8& out, BattleSide* p, u8 a, u8 b) {
export_func u8 CreatureLib_BattleSide_SwapPositions(u8& out, BattleSide* p, u8 a, u8 b) {
Try(out = p->SwapPositions(a, b);)
}
export BattleScript* CreatureLib_BattleSide_GetVolatileScript(BattleSide* p, const char* key) {
export_func BattleScript* CreatureLib_BattleSide_GetVolatileScript(BattleSide* p, const char* key) {
auto v = p->GetVolatileScript(ArbUt::StringView::CalculateHash(key));
if (!v.HasValue()) {
return nullptr;
}
return v.GetValue();
}
export u8 CreatureLib_BattleSide_AddVolatileScriptByName(BattleSide* p, const char* key) {
export_func u8 CreatureLib_BattleSide_AddVolatileScriptByName(BattleSide* p, const char* key) {
Try(p->AddVolatileScript(ArbUt::StringView(key));)
}
export u8 CreatureLib_BattleSide_AddVolatileScript(BattleSide* p, BattleScript* script) {
export_func u8 CreatureLib_BattleSide_AddVolatileScript(BattleSide* p, BattleScript* script) {
Try(p->AddVolatileScript(script);)
}
export u8 CreatureLib_BattleSide_RemoveVolatileScript(BattleSide* p, const char* key) {
export_func u8 CreatureLib_BattleSide_RemoveVolatileScript(BattleSide* p, const char* key) {
Try(p->RemoveVolatileScript(ArbUt::StringView::CalculateHash(key));)
}
export u8 CreatureLib_BattleSide_RemoveVolatileScriptWithScript(BattleSide* p, BattleScript* script) {
export_func u8 CreatureLib_BattleSide_RemoveVolatileScriptWithScript(BattleSide* p, BattleScript* script) {
Try(p->RemoveVolatileScript(script);)
}
export bool CreatureLib_BattleSide_HasVolatileScript(BattleSide* p, const char* key) {
export_func bool CreatureLib_BattleSide_HasVolatileScript(BattleSide* p, const char* key) {
return p->HasVolatileScript(ArbUt::StringView::CalculateHash(key));
}

View File

@ -2,16 +2,19 @@
#include "../Core.hpp"
using namespace CreatureLib::Battling;
export const BattleStatCalculator* CreatureLib_BattleStatCalculator_Construct() { return new BattleStatCalculator(); }
export_func const BattleStatCalculator* CreatureLib_BattleStatCalculator_Construct() {
return new BattleStatCalculator();
}
export void CreatureLib_BattleStatCalculator_Destruct(const BattleStatCalculator* p) { delete p; }
export_func void CreatureLib_BattleStatCalculator_Destruct(const BattleStatCalculator* p) { delete p; }
export u8 CreatureLib_BattleStatCalculator_CalculateFlatStat(u32& out, const BattleStatCalculator* p,
Creature* creature, CreatureLib::Library::Statistic stat) {
export_func u8 CreatureLib_BattleStatCalculator_CalculateFlatStat(u32& out, const BattleStatCalculator* p,
Creature* creature,
CreatureLib::Library::Statistic stat) {
Try(out = p->CalculateFlatStat(creature, stat);)
}
export u8 CreatureLib_BattleStatCalculator_CalculateBoostedStat(u32& out, const BattleStatCalculator* p,
Creature* creature,
CreatureLib::Library::Statistic stat) {
export_func u8 CreatureLib_BattleStatCalculator_CalculateBoostedStat(u32& out, const BattleStatCalculator* p,
Creature* creature,
CreatureLib::Library::Statistic stat) {
Try(out = p->CalculateBoostedStat(creature, stat);)
}

View File

@ -2,13 +2,13 @@
#include "../Core.hpp"
using namespace CreatureLib::Battling;
export u8 CreatureLib_Creature_Construct(Creature*& out, const BattleLibrary* library,
const CreatureLib::Library::CreatureSpecies* species,
const CreatureLib::Library::SpeciesVariant* variant, level_int_t level,
u32 experience, u32 uid, CreatureLib::Library::Gender gender, u8 coloring,
const CreatureLib::Library::Item* heldItem, const char* nickname,
bool secretTalent, u8 talent, LearnedAttack* attacks[], size_t attacksNum,
bool allowedExperienceGain) {
export_func u8 CreatureLib_Creature_Construct(Creature*& out, const BattleLibrary* library,
const CreatureLib::Library::CreatureSpecies* species,
const CreatureLib::Library::SpeciesVariant* variant, level_int_t level,
u32 experience, u32 uid, CreatureLib::Library::Gender gender, u8 coloring,
const CreatureLib::Library::Item* heldItem, const char* nickname,
bool secretTalent, u8 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,
@ -17,19 +17,19 @@ export u8 CreatureLib_Creature_Construct(Creature*& out, const BattleLibrary* li
CreatureLib::Library::TalentIndex(secretTalent, talent), attacksVec, allowedExperienceGain);)
};
export void CreatureLib_Creature_Destruct(const Creature* p) { delete p; }
export_func void CreatureLib_Creature_Destruct(const Creature* p) { delete p; }
export u8 CreatureLib_Creature_Initialize(Creature* p) { Try(p->Initialize();) }
export_func u8 CreatureLib_Creature_Initialize(Creature* p) { Try(p->Initialize();) }
BORROWED_GET_FUNC(Creature, GetLibrary, const CreatureLib::Battling::BattleLibrary*);
BORROWED_GET_FUNC(Creature, GetSpecies, const CreatureLib::Library::CreatureSpecies*);
BORROWED_GET_FUNC(Creature, GetVariant, const CreatureLib::Library::SpeciesVariant*);
export u8 CreatureLib_Creature_ChangeSpecies(Creature* p, const CreatureLib::Library::CreatureSpecies* species,
const CreatureLib::Library::SpeciesVariant* variant) {
export_func u8 CreatureLib_Creature_ChangeSpecies(Creature* p, const CreatureLib::Library::CreatureSpecies* species,
const CreatureLib::Library::SpeciesVariant* variant) {
Try(p->ChangeSpecies(species, variant);)
}
export u8 CreatureLib_Creature_ChangeVariant(Creature* p, const CreatureLib::Library::SpeciesVariant* variant) {
export_func u8 CreatureLib_Creature_ChangeVariant(Creature* p, const CreatureLib::Library::SpeciesVariant* variant) {
Try(p->ChangeVariant(variant);)
}
@ -39,104 +39,111 @@ SIMPLE_GET_FUNC(Creature, GetUniqueIdentifier, u32);
SIMPLE_GET_FUNC(Creature, GetGender, CreatureLib::Library::Gender);
SIMPLE_GET_FUNC(Creature, GetColoring, u8);
export bool CreatureLib_Creature_HasHeldItem(const Creature* p, const char* name) {
export_func bool CreatureLib_Creature_HasHeldItem(const Creature* p, const char* name) {
return p->HasHeldItem(ArbUt::StringView(name));
}
export bool CreatureLib_Creature_HasHeldItemWithHash(const Creature* p, u32 hash) { return p->HasHeldItem(hash); }
export_func bool CreatureLib_Creature_HasHeldItemWithHash(const Creature* p, u32 hash) { return p->HasHeldItem(hash); }
OPTIONAL_GET_FUNC(Creature, GetHeldItem, const CreatureLib::Library::Item*);
export u8 CreatureLib_Creature_SetHeldItem(Creature* p, const char* name) {
export_func u8 CreatureLib_Creature_SetHeldItem(Creature* p, const char* name) {
Try(p->SetHeldItem(ArbUt::StringView(name));)
}
export u8 CreatureLib_Creature_SetHeldItemWithHash(Creature* p, u32 hash) { Try(p->SetHeldItem(hash);) }
export void CreatureLib_Creature_SetHeldItemFromItem(Creature* p, const CreatureLib::Library::Item* item) {
export_func u8 CreatureLib_Creature_SetHeldItemWithHash(Creature* p, u32 hash) { Try(p->SetHeldItem(hash);) }
export_func void CreatureLib_Creature_SetHeldItemFromItem(Creature* p, const CreatureLib::Library::Item* item) {
return p->SetHeldItem(ArbUt::BorrowedPtr<const CreatureLib::Library::Item>(item));
}
SIMPLE_GET_FUNC(Creature, GetCurrentHealth, u32);
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) {
export_func const char* CreatureLib_Creature_GetNickname(Creature* p) {
auto s = p->GetNickname();
if (s.has_value()) {
return p->GetNickname().value().data();
}
return "";
}
export void CreatureLib_Creature_SetNickname(Creature* p, const char* nickname) { p->SetNickname(nickname); }
export bool CreatureLib_Creature_HasType(Creature* p, u8 type) { return p->HasType(type); }
export size_t CreatureLib_Creature_GetTypeCount(Creature* p) { return p->GetTypes().size(); }
export const u8* CreatureLib_Creature_GetTypes(Creature* p) { return p->GetTypes().data(); }
export_func void CreatureLib_Creature_SetNickname(Creature* p, const char* nickname) { p->SetNickname(nickname); }
export_func bool CreatureLib_Creature_HasType(Creature* p, u8 type) { return p->HasType(type); }
export_func size_t CreatureLib_Creature_GetTypeCount(Creature* p) { return p->GetTypes().size(); }
export_func const u8* CreatureLib_Creature_GetTypes(Creature* p) { return p->GetTypes().data(); }
SIMPLE_GET_FUNC(Creature, GetMaxHealth, u32);
export u8 CreatureLib_Creature_ChangeLevelBy(Creature* p, i8 level) { Try(p->ChangeLevelBy(level);) }
export u8 CreatureLib_Creature_Damage(Creature* p, u32 damage, DamageSource source) { Try(p->Damage(damage, source);) }
export u8 CreatureLib_Creature_Heal(Creature* p, u32 health, bool canRevive) { Try(p->Heal(health, canRevive);) }
export u8 CreatureLib_Creature_RestoreAllAttackUses(Creature* p) { Try(p->RestoreAllAttackUses();) }
export_func u8 CreatureLib_Creature_ChangeLevelBy(Creature* p, i8 level) { Try(p->ChangeLevelBy(level);) }
export_func u8 CreatureLib_Creature_Damage(Creature* p, u32 damage, DamageSource source) {
Try(p->Damage(damage, source);)
}
export_func u8 CreatureLib_Creature_Heal(Creature* p, u32 health, bool canRevive) { Try(p->Heal(health, canRevive);) }
export_func u8 CreatureLib_Creature_RestoreAllAttackUses(Creature* p) { Try(p->RestoreAllAttackUses();) }
export bool CreatureLib_Creature_GetRealTalentIsSecret(const Creature* p) { return p->GetRealTalent().IsSecret(); }
export bool CreatureLib_Creature_GetRealTalentIndex(const Creature* p) { return p->GetRealTalent().GetIndex(); }
export_func bool CreatureLib_Creature_GetRealTalentIsSecret(const Creature* p) { return p->GetRealTalent().IsSecret(); }
export_func bool CreatureLib_Creature_GetRealTalentIndex(const Creature* p) { return p->GetRealTalent().GetIndex(); }
export u8 CreatureLib_Creature_GetActiveTalent(const Creature* p, const CreatureLib::Library::Talent*& out) {
export_func u8 CreatureLib_Creature_GetActiveTalent(const Creature* p, const CreatureLib::Library::Talent*& out) {
Try(out = p->GetActiveTalent().GetRaw();)
}
export u8 CreatureLib_Creature_OverrideActiveTalent(Creature* p, const char* talent) {
export_func u8 CreatureLib_Creature_OverrideActiveTalent(Creature* p, const char* talent) {
Try(p->OverrideActiveTalent(ArbUt::StringView(talent));)
}
export u8 CreatureLib_Creature_AddExperience(Creature* p, u32 experience) { Try(p->AddExperience(experience);) }
export u8 CreatureLib_Creature_ClearVolatileScripts(Creature* p) { Try(p->ClearVolatileScripts();) }
export u8 CreatureLib_Creature_AddVolatileScriptByName(Creature* p, const char* scriptName) {
export_func u8 CreatureLib_Creature_AddExperience(Creature* p, u32 experience) { Try(p->AddExperience(experience);) }
export_func u8 CreatureLib_Creature_ClearVolatileScripts(Creature* p) { Try(p->ClearVolatileScripts();) }
export_func u8 CreatureLib_Creature_AddVolatileScriptByName(Creature* p, const char* scriptName) {
Try(p->AddVolatileScript(ArbUt::StringView(scriptName));)
}
export u8 CreatureLib_Creature_AddVolatileScript(Creature* p, BattleScript* script) {
export_func u8 CreatureLib_Creature_AddVolatileScript(Creature* p, BattleScript* script) {
Try(p->AddVolatileScript(script);)
}
export u8 CreatureLib_Creature_RemoveVolatileScriptByName(Creature* p, const char* scriptName) {
export_func u8 CreatureLib_Creature_RemoveVolatileScriptByName(Creature* p, const char* scriptName) {
Try(p->RemoveVolatileScript(ArbUt::StringView(scriptName));)
}
export u8 CreatureLib_Creature_RemoveVolatileScript(Creature* p, BattleScript* script) {
export_func u8 CreatureLib_Creature_RemoveVolatileScript(Creature* p, BattleScript* script) {
Try(p->RemoveVolatileScript(script);)
}
export bool CreatureLib_Creature_HasVolatileScript(Creature* p, const char* scriptName) {
export_func bool CreatureLib_Creature_HasVolatileScript(Creature* p, const char* scriptName) {
return p->HasVolatileScript(ArbUt::StringView(scriptName));
}
export size_t CreatureLib_Creature_GetAttacksCount(Creature* p) { return p->GetAttacks().Count(); }
export LearnedAttack* const* CreatureLib_Creature_GetAttacks(Creature* p) { return p->GetAttacks().RawData(); }
export bool CreatureLib_Creature_HasAttack(Creature* p, const char* scriptName) {
export_func size_t CreatureLib_Creature_GetAttacksCount(Creature* p) { return p->GetAttacks().Count(); }
export_func LearnedAttack* const* CreatureLib_Creature_GetAttacks(Creature* p) { return p->GetAttacks().RawData(); }
export_func bool CreatureLib_Creature_HasAttack(Creature* p, const char* scriptName) {
return p->HasAttack(ArbUt::StringView(scriptName));
}
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) {
export_func void CreatureLib_Creature_SetDisplaySpecies(Creature* p,
const CreatureLib::Library::CreatureSpecies* species) {
return p->SetDisplaySpecies(ArbUt::BorrowedPtr<const CreatureLib::Library::CreatureSpecies>(species));
}
export void CreatureLib_Creature_SetDisplayVariant(Creature* p, const CreatureLib::Library::SpeciesVariant* variant) {
export_func void CreatureLib_Creature_SetDisplayVariant(Creature* p,
const CreatureLib::Library::SpeciesVariant* variant) {
return p->SetDisplayVariant(variant);
}
export bool CreatureLib_Creature_AllowedExperienceGain(Creature* p) { return p->AllowedExperienceGain(); }
export void CreatureLib_Creature_SetAllowedExperienceGain(Creature* p, bool b) { p->SetAllowedExperienceGain(b); }
export_func bool CreatureLib_Creature_AllowedExperienceGain(Creature* p) { return p->AllowedExperienceGain(); }
export_func void CreatureLib_Creature_SetAllowedExperienceGain(Creature* p, bool b) { p->SetAllowedExperienceGain(b); }
export void CreatureLib_Creature_ChangeStatBoost(Creature* p, CreatureLib::Library::Statistic stat, i8 diffAmount) {
export_func void CreatureLib_Creature_ChangeStatBoost(Creature* p, CreatureLib::Library::Statistic stat,
i8 diffAmount) {
p->ChangeStatBoost(stat, diffAmount);
}
export u32 CreatureLib_Creature_GetFlatStat(Creature* p, CreatureLib::Library::Statistic stat) {
export_func u32 CreatureLib_Creature_GetFlatStat(Creature* p, CreatureLib::Library::Statistic stat) {
return p->GetFlatStat(stat);
}
export u32 CreatureLib_Creature_GetBoostedStat(Creature* p, CreatureLib::Library::Statistic stat) {
export_func u32 CreatureLib_Creature_GetBoostedStat(Creature* p, CreatureLib::Library::Statistic stat) {
return p->GetBoostedStat(stat);
}
export u32 CreatureLib_Creature_GetBaseStat(Creature* p, CreatureLib::Library::Statistic stat) {
export_func u32 CreatureLib_Creature_GetBaseStat(Creature* p, CreatureLib::Library::Statistic stat) {
return p->GetBaseStat(stat);
}
export i8 CreatureLib_Creature_GetStatBoost(Creature* p, CreatureLib::Library::Statistic stat) {
export_func i8 CreatureLib_Creature_GetStatBoost(Creature* p, CreatureLib::Library::Statistic stat) {
return p->GetStatBoost(stat);
}
SIMPLE_GET_FUNC(Creature, GetAvailableAttackSlot, u8);
export u8 CreatureLib_Creature_AddAttack(Creature* p, LearnedAttack* attack) { Try(p->AddAttack(attack);) }
export u8 CreatureLib_Creature_ReplaceAttack(Creature* p, size_t index, LearnedAttack* attack) {
export_func u8 CreatureLib_Creature_AddAttack(Creature* p, LearnedAttack* attack) { Try(p->AddAttack(attack);) }
export_func u8 CreatureLib_Creature_ReplaceAttack(Creature* p, size_t index, LearnedAttack* attack) {
Try(p->ReplaceAttack(index, attack);)
}
export u8 CreatureLib_Creature_SwapAttack(Creature* p, size_t a, size_t b) { Try(p->SwapAttacks(a, b);) }
export_func u8 CreatureLib_Creature_SwapAttack(Creature* p, size_t a, size_t b) { Try(p->SwapAttacks(a, b);) }
export u8 CreatureLib_Creature_SetStatus(Creature* p, const char* name) { Try(p->SetStatus(ArbUt::StringView(name))); };
export u8 CreatureLib_Creature_ClearStatus(Creature* p) { Try(p->ClearStatus()); };
export const char* CreatureLib_Creature_GetStatusName(Creature* p) { return p->GetStatusName().c_str(); }
export_func u8 CreatureLib_Creature_SetStatus(Creature* p, const char* name) {
Try(p->SetStatus(ArbUt::StringView(name)));
};
export_func u8 CreatureLib_Creature_ClearStatus(Creature* p) { Try(p->ClearStatus()); };
export_func const char* CreatureLib_Creature_GetStatusName(Creature* p) { return p->GetStatusName().c_str(); }

View File

@ -2,28 +2,28 @@
#include "../Core.hpp"
using namespace CreatureLib::Battling;
export CreatureParty* CreatureLib_CreatureParty_ConstructWithSize(size_t size) { return new CreatureParty(size); }
export CreatureParty* CreatureLib_CreatureParty_ConstructFromArray(Creature* creatures[], size_t size) {
export_func CreatureParty* CreatureLib_CreatureParty_ConstructWithSize(size_t size) { return new CreatureParty(size); }
export_func CreatureParty* CreatureLib_CreatureParty_ConstructFromArray(Creature* creatures[], size_t size) {
return new CreatureParty(ArbUt::List<Creature*>(creatures, creatures + size));
}
export void CreatureLib_CreatureParty_Destruct(const CreatureParty* p) { delete p; }
export_func void CreatureLib_CreatureParty_Destruct(const CreatureParty* p) { delete p; }
export u8 CreatureLib_CreatureParty_GetAtIndex(Creature*& out, const CreatureParty* p, size_t index) {
export_func u8 CreatureLib_CreatureParty_GetAtIndex(Creature*& out, const CreatureParty* p, size_t index) {
Try(out = p->GetAtIndex(index).GetValue();)
}
export u8 CreatureLib_CreatureParty_Switch(CreatureParty* p, size_t a, size_t b) { Try(p->Switch(a, b);) }
export u8 CreatureLib_CreatureParty_PackParty(CreatureParty* p) { Try(p->PackParty();) }
export_func u8 CreatureLib_CreatureParty_Switch(CreatureParty* p, size_t a, size_t b) { Try(p->Switch(a, b);) }
export_func u8 CreatureLib_CreatureParty_PackParty(CreatureParty* p) { Try(p->PackParty();) }
export u8 CreatureLib_CreatureParty_SwapInto(Creature*& out, CreatureParty* p, size_t index, Creature* creature) {
export_func u8 CreatureLib_CreatureParty_SwapInto(Creature*& out, CreatureParty* p, size_t index, Creature* creature) {
Try(out = p->SwapInto(index, creature);)
}
export bool CreatureLib_CreatureParty_HasAvailableCreatures(const CreatureParty* p) {
export_func bool CreatureLib_CreatureParty_HasAvailableCreatures(const CreatureParty* p) {
return p->HasAvailableCreatures();
}
export size_t CreatureLib_CreatureParty_GetLength(const CreatureParty* p) { return p->GetLength(); }
export_func size_t CreatureLib_CreatureParty_GetLength(const CreatureParty* p) { return p->GetLength(); }
export Creature* const* CreatureLib_CreatureParty_GetParty(CreatureParty* p) { return p->GetParty().RawData(); }
export_func Creature* const* CreatureLib_CreatureParty_GetParty(CreatureParty* p) { return p->GetParty().RawData(); }

View File

@ -2,25 +2,27 @@
#include "../Core.hpp"
using namespace CreatureLib::Battling;
export const DamageLibrary* CreatureLib_DamageLibrary_Construct() { return new DamageLibrary(); }
export_func const DamageLibrary* CreatureLib_DamageLibrary_Construct() { return new DamageLibrary(); }
export void CreatureLib_DamageLibrary_Destruct(const DamageLibrary* p) { delete p; }
export_func void CreatureLib_DamageLibrary_Destruct(const DamageLibrary* p) { delete p; }
export u8 CreatureLib_DamageLibrary_GetDamage(u32& out, const DamageLibrary* p, ExecutingAttack* attack,
Creature* target, u8 hitIndex, ExecutingAttack::HitData* hitData) {
export_func u8 CreatureLib_DamageLibrary_GetDamage(u32& out, const DamageLibrary* p, ExecutingAttack* attack,
Creature* target, u8 hitIndex, ExecutingAttack::HitData* hitData) {
Try(out = p->GetDamage(attack, target, hitIndex, *hitData);)
}
export u8 CreatureLib_DamageLibrary_GetBasePower(u8& out, const DamageLibrary* p, ExecutingAttack* attack,
Creature* target, u8 hitIndex, ExecutingAttack::HitData* hitData) {
Try(out = p->GetBasePower(attack, target, hitIndex, *hitData);)
}
export u8 CreatureLib_DamageLibrary_GetStatModifier(float& out, const DamageLibrary* p, ExecutingAttack* attack,
Creature* target, u8 hitIndex, ExecutingAttack::HitData* hitData) {
Try(out = p->GetStatModifier(attack, target, hitIndex, *hitData);)
}
export u8 CreatureLib_DamageLibrary_GetDamageModifier(float& out, const DamageLibrary* p, ExecutingAttack* attack,
export_func u8 CreatureLib_DamageLibrary_GetBasePower(u8& out, const DamageLibrary* p, ExecutingAttack* attack,
Creature* target, u8 hitIndex,
ExecutingAttack::HitData* hitData) {
Try(out = p->GetBasePower(attack, target, hitIndex, *hitData);)
}
export_func u8 CreatureLib_DamageLibrary_GetStatModifier(float& out, const DamageLibrary* p, ExecutingAttack* attack,
Creature* target, u8 hitIndex,
ExecutingAttack::HitData* hitData) {
Try(out = p->GetStatModifier(attack, target, hitIndex, *hitData);)
}
export_func u8 CreatureLib_DamageLibrary_GetDamageModifier(float& out, const DamageLibrary* p, ExecutingAttack* attack,
Creature* target, u8 hitIndex,
ExecutingAttack::HitData* hitData) {
Try(out = p->GetDamageModifier(attack, target, hitIndex, *hitData);)
}

View File

@ -21,8 +21,8 @@ BORROWED_GET_FUNC(FaintEvent, GetCreature, Creature*);
DESTRUCTOR(FaintEvent);
BORROWED_GET_FUNC(SwitchEvent, GetNewCreature, Creature*);
export u8 CreatureLib_SwitchEvent_GetSide(const SwitchEvent* p) { return p->GetIndex().GetSideIndex(); }
export u8 CreatureLib_SwitchEvent_GetIndex(const SwitchEvent* p) { return p->GetIndex().GetCreatureIndex(); }
export_func u8 CreatureLib_SwitchEvent_GetSide(const SwitchEvent* p) { return p->GetIndex().GetSideIndex(); }
export_func u8 CreatureLib_SwitchEvent_GetIndex(const SwitchEvent* p) { return p->GetIndex().GetCreatureIndex(); }
DESTRUCTOR(SwitchEvent);
DESTRUCTOR(TurnStartEvent);
@ -48,8 +48,8 @@ DESTRUCTOR(ChangeVariantEvent);
BORROWED_GET_FUNC(AttackUseEvent, GetAttack, const ExecutingAttack*);
DESTRUCTOR(AttackUseEvent);
export const char* CreatureLib_DisplayTextEvent_GetText(const DisplayTextEvent* p) { return p->GetText().c_str(); }
export void CreatureLib_DisplayTextEvent_Destruct(const DisplayTextEvent* p) { delete p; }
export_func const char* CreatureLib_DisplayTextEvent_GetText(const DisplayTextEvent* p) { return p->GetText().c_str(); }
export_func void CreatureLib_DisplayTextEvent_Destruct(const DisplayTextEvent* p) { delete p; }
BORROWED_GET_FUNC(ChangeStatBoostEvent, GetCreature, const Creature*);
SIMPLE_GET_FUNC(ChangeStatBoostEvent, GetStatistic, CreatureLib::Library::Statistic);

View File

@ -2,39 +2,41 @@
#include "../Core.hpp"
using namespace CreatureLib::Battling;
export u8 CreatureLib_ExecutingAttack_Construct(ExecutingAttack*& out, Creature* const* targets, size_t targetCount,
u8 numberHits, Creature* user, LearnedAttack* attack,
CreatureLib::Library::AttackData* attackData, BattleScript* script) {
export_func u8 CreatureLib_ExecutingAttack_Construct(ExecutingAttack*& out, Creature* const* targets,
size_t targetCount, u8 numberHits, Creature* user,
LearnedAttack* attack,
CreatureLib::Library::AttackData* attackData,
BattleScript* script) {
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<BattleScript>(script);
out = new ExecutingAttack(ls, numberHits, user, attack, attackData, s);)
}
export void CreatureLib_ExecutingAttack_Destruct(ExecutingAttack* p) { delete p; }
export_func void CreatureLib_ExecutingAttack_Destruct(ExecutingAttack* p) { delete p; }
SIMPLE_GET_FUNC(ExecutingAttack, GetNumberOfHits, u8);
export u8 CreatureLib_ExecutingAttack_GetHitData(ExecutingAttack::HitData*& out, ExecutingAttack* p, Creature* target,
u8 hit) {
export_func u8 CreatureLib_ExecutingAttack_GetHitData(ExecutingAttack::HitData*& out, ExecutingAttack* p,
Creature* target, u8 hit) {
Try(out = &p->GetHitData(target, hit);)
}
export bool CreatureLib_ExecutingAttack_IsCreatureTarget(ExecutingAttack* p, Creature* target) {
export_func bool CreatureLib_ExecutingAttack_IsCreatureTarget(ExecutingAttack* p, Creature* target) {
return p->IsCreatureTarget(target);
}
export u8 CreatureLib_ExecutingAttack_GetTargetCount(ExecutingAttack* p) { return p->GetTargetCount(); }
export const Creature* const* CreatureLib_ExecutingAttack_GetTargets(ExecutingAttack* p) {
export_func u8 CreatureLib_ExecutingAttack_GetTargetCount(ExecutingAttack* p) { return p->GetTargetCount(); }
export_func const Creature* const* CreatureLib_ExecutingAttack_GetTargets(ExecutingAttack* p) {
return reinterpret_cast<const Creature* const*>(p->GetTargets().RawData());
}
export Creature* CreatureLib_ExecutingAttack_GetUser(ExecutingAttack* p) { return p->GetUser().GetRaw(); }
export LearnedAttack* CreatureLib_ExecutingAttack_GetAttack(ExecutingAttack* p) { return p->GetAttack().GetRaw(); }
export const CreatureLib::Library::AttackData* CreatureLib_ExecutingAttack_GetUseAttack(ExecutingAttack* p) {
export_func Creature* CreatureLib_ExecutingAttack_GetUser(ExecutingAttack* p) { return p->GetUser().GetRaw(); }
export_func LearnedAttack* CreatureLib_ExecutingAttack_GetAttack(ExecutingAttack* p) { return p->GetAttack().GetRaw(); }
export_func const CreatureLib::Library::AttackData* CreatureLib_ExecutingAttack_GetUseAttack(ExecutingAttack* p) {
return p->GetUseAttack().GetRaw();
}
#define HITDATA_GET_FUNC(name, returnType) \
export returnType CreatureLib_HitData##_##name(const ExecutingAttack::HitData* p) { return p->name(); }
export_func returnType CreatureLib_HitData##_##name(const ExecutingAttack::HitData* p) { return p->name(); }
HITDATA_GET_FUNC(IsCritical, bool);
HITDATA_GET_FUNC(GetBasePower, u8);
@ -43,7 +45,7 @@ HITDATA_GET_FUNC(GetDamage, u32);
HITDATA_GET_FUNC(GetType, u8);
#define HITDATA_SET_FUNC(name, type) \
export void CreatureLib_HitData##_##name(ExecutingAttack::HitData* p, type val) { p->name(val); }
export_func void CreatureLib_HitData##_##name(ExecutingAttack::HitData* p, type val) { p->name(val); }
HITDATA_SET_FUNC(SetCritical, bool);
HITDATA_SET_FUNC(SetBasePower, u8);

View File

@ -2,12 +2,12 @@
#include "../Core.hpp"
using namespace CreatureLib::Battling;
export const ExperienceLibrary* CreatureLib_ExperienceLibrary_Construct() { return new ExperienceLibrary(); }
export_func const ExperienceLibrary* CreatureLib_ExperienceLibrary_Construct() { return new ExperienceLibrary(); }
export void CreatureLib_ExperienceLibrary_Destruct(const ExperienceLibrary* p) { delete p; }
export_func void CreatureLib_ExperienceLibrary_Destruct(const ExperienceLibrary* p) { delete p; }
export u8 CreatureLib_ExperienceLibrary_HandleExperienceGain(const ExperienceLibrary* p, Creature* faintedMon,
Creature* opponents[], size_t opponentsCount) {
export_func u8 CreatureLib_ExperienceLibrary_HandleExperienceGain(const ExperienceLibrary* p, Creature* faintedMon,
Creature* opponents[], size_t opponentsCount) {
Try(auto set = std::unordered_set<ArbUt::BorrowedPtr<Creature>>(opponentsCount);
for (size_t i = 0; i < opponentsCount;
i++) { set.insert(opponents[i]); } p->HandleExperienceGain(faintedMon, set);)

View File

@ -3,23 +3,23 @@
#include "../Core.hpp"
using namespace CreatureLib::Battling;
export const HistoryElement* CreatureLib_HistoryHandler_GetTopElement(const HistoryHolder* p) {
export_func const HistoryElement* CreatureLib_HistoryHandler_GetTopElement(const HistoryHolder* p) {
return p->GetTopElement().GetValue();
}
export const HistoryElement* CreatureLib_HistoryHandler_GetLastUsedAttack(const HistoryHolder* p) {
export_func const HistoryElement* CreatureLib_HistoryHandler_GetLastUsedAttack(const HistoryHolder* p) {
return p->GetLastUsedAttack().GetValue();
}
export const HistoryElement* CreatureLib_HistoryHandler_GetLastDamageOnTarget(const HistoryHolder* p,
const Creature* c) {
export_func const HistoryElement* CreatureLib_HistoryHandler_GetLastDamageOnTarget(const HistoryHolder* p,
const Creature* c) {
return p->GetLastDamageOnTarget(c).GetValue();
}
export HistoryElementKind CreatureLib_HistoryElement_GetKind(const HistoryElement* p) { return p->GetKind(); }
export const HistoryElement* CreatureLib_HistoryElement_GetPrevious(const HistoryElement* p) {
export_func HistoryElementKind CreatureLib_HistoryElement_GetKind(const HistoryElement* p) { return p->GetKind(); }
export_func const HistoryElement* CreatureLib_HistoryElement_GetPrevious(const HistoryElement* p) {
return p->GetPrevious().GetValue();
}
export const ExecutingAttack* CreatureLib_AttackUseHistory_GetAttack(const AttackUseHistory* p) {
export_func const ExecutingAttack* CreatureLib_AttackUseHistory_GetAttack(const AttackUseHistory* p) {
return p->GetAttack().GetRaw();
}

View File

@ -2,17 +2,19 @@
#include "../Core.hpp"
using namespace CreatureLib::Battling;
export void CreatureLib_ItemUseScript_Destruct(ItemUseScript* p) { delete p; }
export u8 CreatureLib_ItemUseScript_IsItemUsable(ItemUseScript* p, u8& out) { Try(out = p->IsItemUsable()) }
export u8 CreatureLib_ItemUseScript_IsCreatureUseItem(ItemUseScript* p, u8& out) { Try(out = p->IsCreatureUseItem()) }
export_func void CreatureLib_ItemUseScript_Destruct(ItemUseScript* p) { delete p; }
export_func u8 CreatureLib_ItemUseScript_IsItemUsable(ItemUseScript* p, u8& out) { Try(out = p->IsItemUsable()) }
export_func u8 CreatureLib_ItemUseScript_IsCreatureUseItem(ItemUseScript* p, u8& out) {
Try(out = p->IsCreatureUseItem())
}
export u8 CreatureLib_ItemUseScript_IsUseValidForCreature(ItemUseScript* p, Creature* creature, u8& out) {
export_func u8 CreatureLib_ItemUseScript_IsUseValidForCreature(ItemUseScript* p, Creature* creature, u8& out) {
Try(out = p->IsUseValidForCreature(creature))
}
export u8 CreatureLib_ItemUseScript_IsHoldable(ItemUseScript* p, u8& out) { Try(out = p->IsHoldable()) }
export_func u8 CreatureLib_ItemUseScript_IsHoldable(ItemUseScript* p, u8& out) { Try(out = p->IsHoldable()) }
export u8 CreatureLib_ItemUseScript_OnUse(ItemUseScript* p, Battle* battle) { Try(p->OnUse(battle)) }
export u8 CreatureLib_ItemUseScript_OnCreatureUse(ItemUseScript* p, Creature* creature, bool isBattle) {
export_func u8 CreatureLib_ItemUseScript_OnUse(ItemUseScript* p, Battle* battle) { Try(p->OnUse(battle)) }
export_func u8 CreatureLib_ItemUseScript_OnCreatureUse(ItemUseScript* p, Creature* creature, bool isBattle) {
Try(p->OnCreatureUse(creature, isBattle))
}

View File

@ -2,19 +2,19 @@
#include "../Core.hpp"
using namespace CreatureLib::Battling;
export u8 CreatureLib_LearnedAttack_Construct(LearnedAttack*& out, const CreatureLib::Library::AttackData* attack,
u8 maxUses, AttackLearnMethod learnMethod) {
export_func u8 CreatureLib_LearnedAttack_Construct(LearnedAttack*& out, const CreatureLib::Library::AttackData* attack,
u8 maxUses, AttackLearnMethod learnMethod) {
Try(out = new LearnedAttack(ArbUt::BorrowedPtr<const CreatureLib::Library::AttackData>(attack), maxUses,
learnMethod);)
}
export void CreatureLib_LearnedAttack_Destruct(LearnedAttack* p) { delete p; }
export_func void CreatureLib_LearnedAttack_Destruct(LearnedAttack* p) { delete p; }
BORROWED_GET_FUNC(LearnedAttack, GetAttack, const CreatureLib::Library::AttackData*);
SIMPLE_GET_FUNC(LearnedAttack, GetMaxUses, u8);
SIMPLE_GET_FUNC(LearnedAttack, GetRemainingUses, u8);
SIMPLE_GET_FUNC(LearnedAttack, GetLearnMethod, AttackLearnMethod);
export bool CreatureLib_LearnedAttack_TryUse(LearnedAttack* p, u8 uses) { return p->TryUse(uses); }
export void CreatureLib_LearnedAttack_DecreaseUses(LearnedAttack* p, u8 uses) { p->DecreaseUses(uses); }
export void CreatureLib_LearnedAttack_RestoreUses(LearnedAttack* p, u8 uses) { p->RestoreUses(uses); }
export void CreatureLib_LearnedAttack_RestoreAllUses(LearnedAttack* p) { p->RestoreAllUses(); }
export_func bool CreatureLib_LearnedAttack_TryUse(LearnedAttack* p, u8 uses) { return p->TryUse(uses); }
export_func void CreatureLib_LearnedAttack_DecreaseUses(LearnedAttack* p, u8 uses) { p->DecreaseUses(uses); }
export_func void CreatureLib_LearnedAttack_RestoreUses(LearnedAttack* p, u8 uses) { p->RestoreUses(uses); }
export_func void CreatureLib_LearnedAttack_RestoreAllUses(LearnedAttack* p) { p->RestoreAllUses(); }

View File

@ -2,18 +2,18 @@
#include "../Core.hpp"
using namespace CreatureLib::Battling;
export MiscLibrary* CreatureLib_MiscLibrary_Construct() { return new MiscLibrary(); }
export_func MiscLibrary* CreatureLib_MiscLibrary_Construct() { return new MiscLibrary(); }
export void CreatureLib_MiscLibrary_Destruct(const MiscLibrary* p) { delete p; }
export_func void CreatureLib_MiscLibrary_Destruct(const MiscLibrary* p) { delete p; }
export u8 CreatureLib_MiscLibrary_IsCritical(bool& out, MiscLibrary* p, ExecutingAttack* attack, Creature* target,
u8 hit) {
export_func u8 CreatureLib_MiscLibrary_IsCritical(bool& out, MiscLibrary* p, ExecutingAttack* attack, Creature* target,
u8 hit) {
Try(out = p->IsCritical(attack, target, hit);)
};
export u8 CreatureLib_MiscLibrary_CanFlee(bool& out, MiscLibrary* p, FleeTurnChoice* switchChoice) {
export_func u8 CreatureLib_MiscLibrary_CanFlee(bool& out, MiscLibrary* p, FleeTurnChoice* switchChoice) {
Try(out = p->CanFlee(switchChoice);)
};
export u8 CreatureLib_MiscLibrary_ReplacementAttack(BaseTurnChoice*& out, MiscLibrary* p, Creature* user, u8 sideTarget,
u8 creatureTarget) {
export_func u8 CreatureLib_MiscLibrary_ReplacementAttack(BaseTurnChoice*& out, MiscLibrary* p, Creature* user,
u8 sideTarget, u8 creatureTarget) {
Try(out = p->ReplacementAttack(user, CreatureIndex(sideTarget, creatureTarget));)
};

View File

@ -2,19 +2,19 @@
#include "../Core.hpp"
using namespace CreatureLib::Battling;
export ScriptResolver* CreatureLib_ScriptResolver_Construct() { return new ScriptResolver(); }
export_func ScriptResolver* CreatureLib_ScriptResolver_Construct() { return new ScriptResolver(); }
export void CreatureLib_ScriptResolver_Destruct(const ScriptResolver* p) { delete p; }
export_func void CreatureLib_ScriptResolver_Destruct(const ScriptResolver* p) { delete p; }
export u8 CreatureLib_ScriptResolver_Initialize(ScriptResolver* p, BattleLibrary* library) {
export_func u8 CreatureLib_ScriptResolver_Initialize(ScriptResolver* p, BattleLibrary* library) {
Try(p->Initialize(library);)
};
export u8 CreatureLib_ScriptResolver_LoadScript(BattleScript*& out, ScriptResolver* p, void* owner,
ScriptCategory category, const char* scriptName) {
export_func u8 CreatureLib_ScriptResolver_LoadScript(BattleScript*& out, ScriptResolver* p, void* owner,
ScriptCategory category, const char* scriptName) {
Try(out = p->LoadScript(owner, category, ArbUt::StringView(scriptName));)
};
export u8 CreatureLib_ScriptResolver_LoadItemScript(ItemUseScript*& out, ScriptResolver* p,
const CreatureLib::Library::Item* item) {
export_func u8 CreatureLib_ScriptResolver_LoadItemScript(ItemUseScript*& out, ScriptResolver* p,
const CreatureLib::Library::Item* item) {
Try(out = p->LoadItemScript(item);)
};

View File

@ -5,19 +5,19 @@
#include "../Core.hpp"
using namespace CreatureLib::Battling;
export AttackTurnChoice* CreatureLib_AttackTurnChoice_Construct(Creature* user, LearnedAttack* attack, u8 sideIndex,
u8 targetIndex) {
export_func AttackTurnChoice* CreatureLib_AttackTurnChoice_Construct(Creature* user, LearnedAttack* attack,
u8 sideIndex, u8 targetIndex) {
return new AttackTurnChoice(user, attack, CreatureIndex(sideIndex, targetIndex));
}
export void CreatureLib_AttackTurnChoice_Destruct(AttackTurnChoice* p) { delete p; }
export FleeTurnChoice* CreatureLib_FleeTurnChoice_Construct(Creature* user) { return new FleeTurnChoice(user); }
export void CreatureLib_FleeTurnChoice_Destruct(AttackTurnChoice* p) { delete p; }
export PassTurnChoice* CreatureLib_PassTurnChoice_Construct(Creature* user) { return new PassTurnChoice(user); }
export void CreatureLib_PassTurnChoice_Destruct(AttackTurnChoice* p) { delete p; }
export SwitchTurnChoice* CreatureLib_SwitchTurnChoice_Construct(Creature* user, Creature* newCreature) {
export_func void CreatureLib_AttackTurnChoice_Destruct(AttackTurnChoice* p) { delete p; }
export_func FleeTurnChoice* CreatureLib_FleeTurnChoice_Construct(Creature* user) { return new FleeTurnChoice(user); }
export_func void CreatureLib_FleeTurnChoice_Destruct(AttackTurnChoice* p) { delete p; }
export_func PassTurnChoice* CreatureLib_PassTurnChoice_Construct(Creature* user) { return new PassTurnChoice(user); }
export_func void CreatureLib_PassTurnChoice_Destruct(AttackTurnChoice* p) { delete p; }
export_func SwitchTurnChoice* CreatureLib_SwitchTurnChoice_Construct(Creature* user, Creature* newCreature) {
return new SwitchTurnChoice(user, newCreature);
}
export void CreatureLib_SwitchTurnChoice_Destruct(AttackTurnChoice* p) { delete p; }
export_func void CreatureLib_SwitchTurnChoice_Destruct(AttackTurnChoice* p) { delete p; }
SIMPLE_GET_FUNC(BaseTurnChoice, GetKind, TurnChoiceKind)
BORROWED_GET_FUNC(BaseTurnChoice, GetUser, Creature*)
@ -25,13 +25,13 @@ BORROWED_GET_FUNC(BaseTurnChoice, GetUser, Creature*)
BORROWED_GET_FUNC(AttackTurnChoice, GetAttack, LearnedAttack*)
SIMPLE_GET_FUNC(AttackTurnChoice, GetKind, TurnChoiceKind)
export u8 CreatureLib_AttackTurnChoice_GetPriority(i8& out, AttackTurnChoice* p) { Try(out = p->GetPriority()); }
export_func u8 CreatureLib_AttackTurnChoice_GetPriority(i8& out, AttackTurnChoice* p) { Try(out = p->GetPriority()); }
SMART_GET_FUNC(AttackTurnChoice, GetAttackScript, BattleScript*)
export u8 CreatureLib_AttackTurnChoice_GetTargetSideIndex(const AttackTurnChoice* p) {
export_func u8 CreatureLib_AttackTurnChoice_GetTargetSideIndex(const AttackTurnChoice* p) {
return p->GetTarget().GetSideIndex();
}
export u8 CreatureLib_AttackTurnChoice_GetTargetCreatureIndex(const AttackTurnChoice* p) {
export_func u8 CreatureLib_AttackTurnChoice_GetTargetCreatureIndex(const AttackTurnChoice* p) {
return p->GetTarget().GetCreatureIndex();
}

View File

@ -3,5 +3,7 @@
std::string ExceptionHandler::_creatureLibLastException = "";
std::string ExceptionHandler::_creatureLibLastExceptionStacktrace = "Unset";
export const char* CreatureLib_C_GetLastException() { return ExceptionHandler::GetLastException(); }
export const char* CreatureLib_C_GetLastExceptionStacktrace() { return ExceptionHandler::GetLastExceptionStacktrace(); }
export_func const char* CreatureLib_C_GetLastException() { return ExceptionHandler::GetLastException(); }
export_func const char* CreatureLib_C_GetLastExceptionStacktrace() {
return ExceptionHandler::GetLastExceptionStacktrace();
}

View File

@ -7,7 +7,7 @@
#include <sstream>
#include <string>
#include "../src/Defines.hpp"
#define export extern "C" [[maybe_unused]]
#define export_func extern "C" [[maybe_unused]]
#define CreatureLibException 2;
@ -47,18 +47,18 @@ public:
}
#define SIMPLE_GET_FUNC(type, name, returnType) \
export returnType CreatureLib_##type##_##name(const type* p) { return p->name(); }
export_func 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(); }
export_func 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) { \
export_func 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(); }
export_func returnType CreatureLib_##type##_##name(const type* p) { return p->name().get(); }
#define DESTRUCTOR(type) \
export void CreatureLib_##type##_Destruct(const type* p) { delete p; }
export_func void CreatureLib_##type##_Destruct(const type* p) { delete p; }
#endif // CREATURELIB_CORE_HPP

View File

@ -2,11 +2,11 @@
#include "../Core.hpp"
using namespace CreatureLib::Library;
export u8 CreatureLib_AttackData_Construct(AttackData*& out, const char* name, u8 type, AttackCategory category,
u8 power, u8 accuracy, u8 baseUsage, AttackTarget target, i8 priority,
float effectChance, const char* effectName,
EffectParameter* effectParameters[], size_t effectParameterCount,
const char* flags[], size_t flagsCount) {
export_func u8 CreatureLib_AttackData_Construct(AttackData*& out, const char* name, u8 type, AttackCategory category,
u8 power, u8 accuracy, u8 baseUsage, AttackTarget target, i8 priority,
float effectChance, const char* effectName,
EffectParameter* effectParameters[], size_t effectParameterCount,
const char* flags[], size_t flagsCount) {
Try({
std::unordered_set<u32> conversedFlags(flagsCount);
for (size_t i = 0; i < flagsCount; i++) {
@ -24,9 +24,9 @@ export u8 CreatureLib_AttackData_Construct(AttackData*& out, const char* name, u
})
};
export void CreatureLib_AttackData_Destruct(const AttackData* p) { delete p; }
export_func void CreatureLib_AttackData_Destruct(const AttackData* p) { delete p; }
export const char* CreatureLib_AttackData_GetName(const AttackData* p) { return p->GetName().c_str(); }
export_func const char* CreatureLib_AttackData_GetName(const AttackData* p) { return p->GetName().c_str(); }
SIMPLE_GET_FUNC(AttackData, GetType, u8);
SIMPLE_GET_FUNC(AttackData, GetCategory, AttackCategory);
SIMPLE_GET_FUNC(AttackData, GetBasePower, u8);
@ -35,16 +35,16 @@ SIMPLE_GET_FUNC(AttackData, GetBaseUsages, u8);
SIMPLE_GET_FUNC(AttackData, GetTarget, AttackTarget);
SIMPLE_GET_FUNC(AttackData, GetPriority, i8);
export bool CreatureLib_AttackData_HasSecondaryEffect(const AttackData* p) { return p->HasSecondaryEffect(); }
export_func bool CreatureLib_AttackData_HasSecondaryEffect(const AttackData* p) { return p->HasSecondaryEffect(); }
export float CreatureLib_AttackData_GetSecondaryEffectChance(const AttackData* p) {
export_func float CreatureLib_AttackData_GetSecondaryEffectChance(const AttackData* p) {
return p->GetSecondaryEffect()->GetChance();
}
export const char* CreatureLib_AttackData_GetSecondaryEffectName(const AttackData* p) {
export_func const char* CreatureLib_AttackData_GetSecondaryEffectName(const AttackData* p) {
return p->GetSecondaryEffect()->GetEffectName().c_str();
}
export bool CreatureLib_AttackData_HasFlag(const AttackData* p, const char* key) {
export_func bool CreatureLib_AttackData_HasFlag(const AttackData* p, const char* key) {
return p->HasFlag(ArbUt::StringView::CalculateHash(key));
}

View File

@ -4,10 +4,10 @@
using namespace CreatureLib::Library;
export u8 CreatureLib_AttackLibrary_Construct(AttackLibrary*& library, size_t initialCapacity = 32) {
export_func u8 CreatureLib_AttackLibrary_Construct(AttackLibrary*& library, size_t initialCapacity = 32) {
Try(library = new AttackLibrary(initialCapacity);)
};
export void CreatureLib_AttackLibrary_Destruct(const AttackLibrary* p) { delete p; }
export_func void CreatureLib_AttackLibrary_Destruct(const AttackLibrary* p) { delete p; }
BASELIBRARY(CreatureLib_AttackLibrary, AttackLibrary, AttackData);

View File

@ -1,19 +1,21 @@
#include "../Core.hpp"
#define BASELIBRARY(simpleName, fullname, returnType) \
export u8 simpleName##_Insert(fullname* p, const char* name, returnType* t) { \
export_func u8 simpleName##_Insert(fullname* p, const char* name, returnType* t) { \
Try(p->Insert(ArbUt::StringView::CalculateHash(name), t);) \
} \
\
export u8 simpleName##_InsertWithHash(fullname* p, u32 hashedKey, returnType* t) { Try(p->Insert(hashedKey, t);) } \
export_func u8 simpleName##_InsertWithHash(fullname* p, u32 hashedKey, returnType* t) { \
Try(p->Insert(hashedKey, t);) \
} \
\
export u8 simpleName##_Delete(fullname* p, const char* name) { \
export_func u8 simpleName##_Delete(fullname* p, const char* name) { \
Try(p->Delete(ArbUt::StringView::CalculateHash(name));) \
} \
\
export u8 simpleName##_DeleteWithHash(fullname* p, u32 hashedKey) { Try(p->Delete(hashedKey);) } \
export_func u8 simpleName##_DeleteWithHash(fullname* p, u32 hashedKey) { Try(p->Delete(hashedKey);) } \
\
export bool simpleName##_TryGet(fullname* p, const char* name, const returnType*& out) { \
export_func bool simpleName##_TryGet(fullname* p, const char* name, const returnType*& out) { \
ArbUt::BorrowedPtr<const returnType> o; \
auto v = p->TryGet(ArbUt::StringView::CalculateHash(name)); \
if (!v.has_value()) { \
@ -25,7 +27,7 @@
} \
} \
\
export bool simpleName##_TryGetWithHash(fullname* p, u32 hashedKey, const returnType*& out) { \
export_func bool simpleName##_TryGetWithHash(fullname* p, u32 hashedKey, const returnType*& out) { \
ArbUt::BorrowedPtr<const returnType> o; \
auto v = p->TryGet(hashedKey); \
if (!v.has_value()) { \
@ -37,15 +39,15 @@
} \
} \
\
export u8 simpleName##_Get(fullname* p, const char* name, const returnType*& out) { \
export_func u8 simpleName##_Get(fullname* p, const char* name, const returnType*& out) { \
Try(out = p->Get(ArbUt::StringView::CalculateHash(name)).GetRaw();) \
} \
\
export u8 simpleName##_GetWithHash(fullname* p, u32 hashedKey, const returnType*& out) { \
export_func u8 simpleName##_GetWithHash(fullname* p, u32 hashedKey, const returnType*& out) { \
Try(out = p->Get(hashedKey).GetRaw();) \
} \
\
export size_t simpleName##_GetCount(fullname* p) { return p->GetCount(); } \
export u8 simpleName##_GetAtIndex(fullname* p, size_t index, const returnType*& out) { \
export_func size_t simpleName##_GetCount(fullname* p) { return p->GetCount(); } \
export_func u8 simpleName##_GetAtIndex(fullname* p, size_t index, const returnType*& out) { \
Try(out = p->GetAtIndex(index).GetRaw();) \
}

View File

@ -2,10 +2,10 @@
#include "../Core.hpp"
using namespace CreatureLib::Library;
export u8 CreatureLib_CreatureSpecies_Construct(CreatureSpecies*& out, u16 id, const char* name,
SpeciesVariant* defaultVariant, float genderRatio,
const char* growthRate, u8 captureRate, const char* flags[],
size_t flagsCount) {
export_func u8 CreatureLib_CreatureSpecies_Construct(CreatureSpecies*& out, u16 id, const char* name,
SpeciesVariant* defaultVariant, float genderRatio,
const char* growthRate, u8 captureRate, const char* flags[],
size_t flagsCount) {
Try(std::unordered_set<u32> conversedFlags(flagsCount);
for (size_t i = 0; i < flagsCount; i++) { conversedFlags.insert(ArbUt::StringView::CalculateHash(flags[i])); }
@ -14,31 +14,31 @@ export u8 CreatureLib_CreatureSpecies_Construct(CreatureSpecies*& out, u16 id, c
ArbUt::StringView(growthRate), captureRate, conversedFlags);)
}
export void CreatureLib_CreatureSpecies_Destruct(const CreatureSpecies* p) { delete p; }
export_func void CreatureLib_CreatureSpecies_Destruct(const CreatureSpecies* p) { delete p; }
SIMPLE_GET_FUNC(CreatureSpecies, GetId, u16);
SIMPLE_GET_FUNC(CreatureSpecies, GetGenderRate, float);
SIMPLE_GET_FUNC(CreatureSpecies, GetCaptureRate, u8);
export const char* CreatureLib_CreatureSpecies_GetName(const CreatureSpecies* p) { return p->GetName().c_str(); }
export const char* CreatureLib_CreatureSpecies_GetGrowthRate(const CreatureSpecies* p) {
export_func const char* CreatureLib_CreatureSpecies_GetName(const CreatureSpecies* p) { return p->GetName().c_str(); }
export_func const char* CreatureLib_CreatureSpecies_GetGrowthRate(const CreatureSpecies* p) {
return p->GetGrowthRate().c_str();
}
export bool CreatureLib_CreatureSpecies_HasVariant(const CreatureSpecies* p, const char* name) {
export_func bool CreatureLib_CreatureSpecies_HasVariant(const CreatureSpecies* p, const char* name) {
return p->HasVariant(ArbUt::StringView::CalculateHash(name));
}
export bool CreatureLib_CreatureSpecies_HasVariantWithHash(const CreatureSpecies* p, u32 hash) {
export_func bool CreatureLib_CreatureSpecies_HasVariantWithHash(const CreatureSpecies* p, u32 hash) {
return p->HasVariant(hash);
}
export bool CreatureLib_CreatureSpecies_TryGetVariant(const CreatureSpecies* p, const char* name,
const SpeciesVariant*& out) {
export_func bool CreatureLib_CreatureSpecies_TryGetVariant(const CreatureSpecies* p, const char* name,
const SpeciesVariant*& out) {
auto res = p->TryGetVariant(ArbUt::StringView::CalculateHash(name));
if (!res.has_value())
return false;
out = res.value();
return true;
}
export bool CreatureLib_CreatureSpecies_TryGetVariantWithHash(const CreatureSpecies* p, u32 hash,
const SpeciesVariant*& out) {
export_func bool CreatureLib_CreatureSpecies_TryGetVariantWithHash(const CreatureSpecies* p, u32 hash,
const SpeciesVariant*& out) {
auto res = p->TryGetVariant(hash);
if (!res.has_value())
return false;
@ -46,28 +46,28 @@ export bool CreatureLib_CreatureSpecies_TryGetVariantWithHash(const CreatureSpec
return true;
}
export u8 CreatureLib_CreatureSpecies_GetVariant(const SpeciesVariant*& out, const CreatureSpecies* p,
const char* name) {
export_func u8 CreatureLib_CreatureSpecies_GetVariant(const SpeciesVariant*& out, const CreatureSpecies* p,
const char* name) {
Try(out = p->GetVariant(ArbUt::StringView::CalculateHash(name)).GetRaw();)
}
export u8 CreatureLib_CreatureSpecies_GetVariantWithHash(const SpeciesVariant*& out, const CreatureSpecies* p,
u32 hash) {
export_func u8 CreatureLib_CreatureSpecies_GetVariantWithHash(const SpeciesVariant*& out, const CreatureSpecies* p,
u32 hash) {
Try(out = p->GetVariant(hash).GetRaw();)
}
export u8 CreatureLib_CreatureSpecies_SetVariant(CreatureSpecies* p, const char* name, SpeciesVariant* variant) {
export_func u8 CreatureLib_CreatureSpecies_SetVariant(CreatureSpecies* p, const char* name, SpeciesVariant* variant) {
Try(p->SetVariant(ArbUt::StringView(name), variant);)
}
export Gender CreatureLib_CreatureSpecies_GetRandomGender(CreatureSpecies* p, ArbUt::Random* random) {
export_func Gender CreatureLib_CreatureSpecies_GetRandomGender(CreatureSpecies* p, ArbUt::Random* random) {
return p->GetRandomGender(*random);
}
export size_t CreatureLib_CreatureSpecies_GetVariantsCount(CreatureSpecies* p) {
export_func size_t CreatureLib_CreatureSpecies_GetVariantsCount(CreatureSpecies* p) {
return p->GetVariantsIterator().Count();
}
export const SpeciesVariant* const* CreatureLib_CreatureSpecies_GetVariants(CreatureSpecies* p) {
export_func const SpeciesVariant* const* CreatureLib_CreatureSpecies_GetVariants(CreatureSpecies* p) {
return reinterpret_cast<const SpeciesVariant* const*>(p->GetVariantsIterator().RawData());
}
export bool CreatureLib_CreatureSpecies_HasFlag(const CreatureSpecies* p, const char* key) {
export_func bool CreatureLib_CreatureSpecies_HasFlag(const CreatureSpecies* p, const char* key) {
return p->HasFlag(ArbUt::StringView::CalculateHash(key));
}

View File

@ -2,13 +2,14 @@
#include "../Core.hpp"
using namespace CreatureLib::Library;
export u8 CreatureLib_DataLibrary_Construct(const DataLibrary*& out, LibrarySettings* settings, SpeciesLibrary* species,
AttackLibrary* attacks, ItemLibrary* items, GrowthRateLibrary* growthRates,
TypeLibrary* typeLibrary, TalentLibrary* talentLibrary) {
export_func u8 CreatureLib_DataLibrary_Construct(const DataLibrary*& out, LibrarySettings* settings,
SpeciesLibrary* species, AttackLibrary* attacks, ItemLibrary* items,
GrowthRateLibrary* growthRates, TypeLibrary* typeLibrary,
TalentLibrary* talentLibrary) {
Try(out = new DataLibrary(settings, species, attacks, items, growthRates, typeLibrary, talentLibrary);)
}
export void CreatureLib_DataLibrary_Destruct(const DataLibrary* p) { delete p; }
export_func void CreatureLib_DataLibrary_Destruct(const DataLibrary* p) { delete p; }
SMART_GET_FUNC(DataLibrary, GetSettings, const LibrarySettings*);
SMART_GET_FUNC(DataLibrary, GetSpeciesLibrary, const SpeciesLibrary*);

View File

@ -2,18 +2,18 @@
#include "../Core.hpp"
using namespace CreatureLib::Library;
export EffectParameter* CreatureLib_EffectParameter_FromBool(bool b) { return new EffectParameter(b); }
export EffectParameter* CreatureLib_EffectParameter_FromInt(i64 i) { return new EffectParameter(i); }
export EffectParameter* CreatureLib_EffectParameter_FromFloat(float f) { return new EffectParameter(f); }
export EffectParameter* CreatureLib_EffectParameter_FromString(const char* c) {
export_func EffectParameter* CreatureLib_EffectParameter_FromBool(bool b) { return new EffectParameter(b); }
export_func EffectParameter* CreatureLib_EffectParameter_FromInt(i64 i) { return new EffectParameter(i); }
export_func EffectParameter* CreatureLib_EffectParameter_FromFloat(float f) { return new EffectParameter(f); }
export_func EffectParameter* CreatureLib_EffectParameter_FromString(const char* c) {
return new EffectParameter(ArbUt::StringView(c));
}
export void CreatureLib_EffectParameter_Destruct(const EffectParameter* p) { delete p; }
export EffectParameterType CreatureLib_EffectParameter_GetType(const EffectParameter* p) { return p->GetType(); }
export u8 CreatureLib_EffectParameter_AsBool(const EffectParameter* p, bool& out) { Try(out = p->AsBool();) }
export u8 CreatureLib_EffectParameter_AsInt(const EffectParameter* p, i64& out) { Try(out = p->AsInt();) }
export u8 CreatureLib_EffectParameter_AsFloat(const EffectParameter* p, float& out) { Try(out = p->AsFloat();) }
export u8 CreatureLib_EffectParameter_AsString(const EffectParameter* p, const char*& out) {
export_func void CreatureLib_EffectParameter_Destruct(const EffectParameter* p) { delete p; }
export_func EffectParameterType CreatureLib_EffectParameter_GetType(const EffectParameter* p) { return p->GetType(); }
export_func u8 CreatureLib_EffectParameter_AsBool(const EffectParameter* p, bool& out) { Try(out = p->AsBool();) }
export_func u8 CreatureLib_EffectParameter_AsInt(const EffectParameter* p, i64& out) { Try(out = p->AsInt();) }
export_func u8 CreatureLib_EffectParameter_AsFloat(const EffectParameter* p, float& out) { Try(out = p->AsFloat();) }
export_func u8 CreatureLib_EffectParameter_AsString(const EffectParameter* p, const char*& out) {
Try(out = p->AsString().c_str();)
}

View File

@ -4,24 +4,24 @@
#include "../Core.hpp"
using namespace CreatureLib::Library;
export GrowthRate* CreatureLib_LookupGrowthRate_Construct(u32 experiencePerLevel[], size_t count) {
export_func GrowthRate* CreatureLib_LookupGrowthRate_Construct(u32 experiencePerLevel[], size_t count) {
ArbUt::List<u32> exp(experiencePerLevel, experiencePerLevel + count);
return new LookupGrowthRate(exp);
};
export u8 CreatureLib_ExternGrowthRate_Construct(GrowthRate*& out, level_int_t (*calcLevel)(u32),
u32 (*calcExperience)(level_int_t)) {
export_func u8 CreatureLib_ExternGrowthRate_Construct(GrowthRate*& out, level_int_t (*calcLevel)(u32),
u32 (*calcExperience)(level_int_t)) {
Try(out = new ExternGrowthRate(calcLevel, calcExperience);)
};
export void CreatureLib_GrowthRate_Destruct(const GrowthRate* p) { delete p; }
export void CreatureLib_LookupGrowthRate_Destruct(const LookupGrowthRate* p) { delete p; }
export void CreatureLib_ExternGrowthRate_Destruct(const ExternGrowthRate* p) { delete p; }
export_func void CreatureLib_GrowthRate_Destruct(const GrowthRate* p) { delete p; }
export_func void CreatureLib_LookupGrowthRate_Destruct(const LookupGrowthRate* p) { delete p; }
export_func void CreatureLib_ExternGrowthRate_Destruct(const ExternGrowthRate* p) { delete p; }
export u8 CreatureLib_GrowthRate_CalculateLevel(level_int_t& out, const GrowthRate* p, u32 experience) {
export_func u8 CreatureLib_GrowthRate_CalculateLevel(level_int_t& out, const GrowthRate* p, u32 experience) {
Try(out = p->CalculateLevel(experience);)
}
export u8 CreatureLib_GrowthRate_CalculateExperience(u32& out, const GrowthRate* p, level_int_t level) {
export_func u8 CreatureLib_GrowthRate_CalculateExperience(u32& out, const GrowthRate* p, level_int_t level) {
Try(out = p->CalculateExperience(level);)
}

View File

@ -2,36 +2,36 @@
#include "../Core.hpp"
using namespace CreatureLib::Library;
export GrowthRateLibrary* CreatureLib_GrowthRateLibrary_Construct(size_t initialCapacity) {
export_func GrowthRateLibrary* CreatureLib_GrowthRateLibrary_Construct(size_t initialCapacity) {
return new GrowthRateLibrary(initialCapacity);
}
export void CreatureLib_GrowthRateLibrary_Destruct(GrowthRateLibrary* p) { delete p; }
export_func void CreatureLib_GrowthRateLibrary_Destruct(GrowthRateLibrary* p) { delete p; }
export u8 CreatureLib_GrowthRateLibrary_CalculateLevel(level_int_t& out, GrowthRateLibrary* library,
const char* growthRate, u32 experience) {
export_func u8 CreatureLib_GrowthRateLibrary_CalculateLevel(level_int_t& out, GrowthRateLibrary* library,
const char* growthRate, u32 experience) {
Try(out = library->CalculateLevel(ArbUt::StringView::CalculateHash(growthRate), experience);)
}
export u8 CreatureLib_GrowthRateLibrary_CalculateLevelWithHash(level_int_t& out, GrowthRateLibrary* library,
u32 growthRateHash, u32 experience) {
export_func u8 CreatureLib_GrowthRateLibrary_CalculateLevelWithHash(level_int_t& out, GrowthRateLibrary* library,
u32 growthRateHash, u32 experience) {
Try(out = library->CalculateLevel(growthRateHash, experience);)
}
export u8 CreatureLib_GrowthRateLibrary_CalculateExperience(u32& out, GrowthRateLibrary* library,
const char* growthRate, level_int_t level) {
export_func u8 CreatureLib_GrowthRateLibrary_CalculateExperience(u32& out, GrowthRateLibrary* library,
const char* growthRate, level_int_t level) {
Try(out = library->CalculateExperience(ArbUt::StringView::CalculateHash(growthRate), level);)
}
export u8 CreatureLib_GrowthRateLibrary_CalculateExperienceWithHash(u32& out, GrowthRateLibrary* library,
u32 growthRateHash, level_int_t level) {
export_func u8 CreatureLib_GrowthRateLibrary_CalculateExperienceWithHash(u32& out, GrowthRateLibrary* library,
u32 growthRateHash, level_int_t level) {
Try(out = library->CalculateExperience(growthRateHash, level);)
}
export u8 CreatureLib_GrowthRateLibrary_AddGrowthRate(GrowthRateLibrary* library, const char* growthRateName,
GrowthRate* growthRate) {
export_func u8 CreatureLib_GrowthRateLibrary_AddGrowthRate(GrowthRateLibrary* library, const char* growthRateName,
GrowthRate* growthRate) {
Try(library->AddGrowthRate(ArbUt::StringView::CalculateHash(growthRateName), growthRate);)
}
export u8 CreatureLib_GrowthRateLibrary_AddGrowthRateWithHash(GrowthRateLibrary* library, u32 growthRateHash,
GrowthRate* growthRate) {
export_func u8 CreatureLib_GrowthRateLibrary_AddGrowthRateWithHash(GrowthRateLibrary* library, u32 growthRateHash,
GrowthRate* growthRate) {
Try(library->AddGrowthRate(growthRateHash, growthRate);)
}

View File

@ -2,12 +2,12 @@
#include "../Core.hpp"
using namespace CreatureLib::Library;
export Item* CreatureLib_Item_Construct(const char* name, ItemCategory category, BattleItemCategory battleCategory,
i32 price, const char* effectName, EffectParameter* effectParameters[],
size_t effectParameterCount, const char* battleTriggerEffectName,
EffectParameter* battleTriggerEffectParameters[],
size_t battleTriggerEffectParameterCount, const char* flags[],
size_t flagsCount) {
export_func Item* CreatureLib_Item_Construct(const char* name, ItemCategory category, BattleItemCategory battleCategory,
i32 price, const char* effectName, EffectParameter* effectParameters[],
size_t effectParameterCount, const char* battleTriggerEffectName,
EffectParameter* battleTriggerEffectParameters[],
size_t battleTriggerEffectParameterCount, const char* flags[],
size_t flagsCount) {
std::unordered_set<u32> conversedFlags(flagsCount);
for (size_t i = 0; i < flagsCount; i++) {
conversedFlags.insert(ArbUt::StringView::CalculateHash(flags[i]));
@ -24,13 +24,13 @@ export Item* CreatureLib_Item_Construct(const char* name, ItemCategory category,
conversedFlags);
};
export void CreatureLib_Item_Destruct(const Item* p) { delete p; }
export_func void CreatureLib_Item_Destruct(const Item* p) { delete p; }
export const char* CreatureLib_Item_GetName(const Item* p) { return p->GetName().c_str(); }
export_func const char* CreatureLib_Item_GetName(const Item* p) { return p->GetName().c_str(); }
SIMPLE_GET_FUNC(Item, GetCategory, ItemCategory);
SIMPLE_GET_FUNC(Item, GetBattleCategory, BattleItemCategory);
SIMPLE_GET_FUNC(Item, GetPrice, i32);
export bool CreatureLib_Item_HasFlag(const Item* p, const char* key) {
export_func bool CreatureLib_Item_HasFlag(const Item* p, const char* key) {
return p->HasFlag(ArbUt::StringView::CalculateHash(key));
}

View File

@ -3,10 +3,10 @@
#include "BaseLibrary.cpp"
using namespace CreatureLib::Library;
export const ItemLibrary* CreatureLib_ItemLibrary_Construct(size_t initialCapacity = 32) {
export_func const ItemLibrary* CreatureLib_ItemLibrary_Construct(size_t initialCapacity = 32) {
return new ItemLibrary(initialCapacity);
};
export void CreatureLib_ItemLibrary_Destruct(const ItemLibrary* p) { delete p; }
export_func void CreatureLib_ItemLibrary_Destruct(const ItemLibrary* p) { delete p; }
BASELIBRARY(CreatureLib_ItemLibrary, ItemLibrary, Item);

View File

@ -2,31 +2,31 @@
#include "../Core.hpp"
using namespace CreatureLib::Library;
export u8 CreatureLib_LearnableAttacks_Construct(LearnableAttacks*& out, size_t levelAttackCapacity) {
export_func u8 CreatureLib_LearnableAttacks_Construct(LearnableAttacks*& out, size_t levelAttackCapacity) {
Try(out = new LearnableAttacks(levelAttackCapacity);)
};
export void CreatureLib_LearnableAttacks_Destruct(LearnableAttacks* p) { delete p; }
export_func void CreatureLib_LearnableAttacks_Destruct(LearnableAttacks* p) { delete p; }
export void CreatureLib_LearnableAttacks_AddLevelAttack(LearnableAttacks* p, level_int_t level,
const AttackData* attack) {
export_func void CreatureLib_LearnableAttacks_AddLevelAttack(LearnableAttacks* p, level_int_t level,
const AttackData* attack) {
p->AddLevelAttack(level, attack);
}
export const AttackData* const* CreatureLib_LearnableAttacks_GetAttacksForLevel(LearnableAttacks* p, u8 level) {
export_func const AttackData* const* CreatureLib_LearnableAttacks_GetAttacksForLevel(LearnableAttacks* p, u8 level) {
return reinterpret_cast<const AttackData* const*>(p->GetAttacksForLevel(level).RawData());
}
export bool CreatureLib_LearnableAttacks_HasAttacksForLevel(LearnableAttacks* p, u8 level) {
export_func bool CreatureLib_LearnableAttacks_HasAttacksForLevel(LearnableAttacks* p, u8 level) {
return p->HasAttacksForLevel(level);
}
export size_t CreatureLib_LearnableAttacks_GetAttacksForLevelCount(LearnableAttacks* p, u8 level) {
export_func size_t CreatureLib_LearnableAttacks_GetAttacksForLevelCount(LearnableAttacks* p, u8 level) {
return p->GetAttacksForLevel(level).Count();
}
export size_t CreatureLib_LearnableAttacks_GetDistinctLevelAttacksCount(LearnableAttacks* p) {
export_func size_t CreatureLib_LearnableAttacks_GetDistinctLevelAttacksCount(LearnableAttacks* p) {
return p->GetDistinctLevelAttacks().Count();
}
export const AttackData* const* CreatureLib_LearnableAttacks_GetDistinctLevelAttacks(LearnableAttacks* p) {
export_func const AttackData* const* CreatureLib_LearnableAttacks_GetDistinctLevelAttacks(LearnableAttacks* p) {
return reinterpret_cast<const AttackData* const*>(p->GetDistinctLevelAttacks().RawData());
}

View File

@ -2,11 +2,11 @@
#include "../Core.hpp"
using namespace CreatureLib::Library;
export const LibrarySettings* CreatureLib_LibrarySettings_Construct(u8 maximalLevel, u8 maximalMoves) {
export_func const LibrarySettings* CreatureLib_LibrarySettings_Construct(u8 maximalLevel, u8 maximalMoves) {
return new LibrarySettings(maximalLevel, maximalMoves);
}
export void CreatureLib_LibrarySettings_Destruct(const LibrarySettings* p) { delete p; }
export_func void CreatureLib_LibrarySettings_Destruct(const LibrarySettings* p) { delete p; }
SIMPLE_GET_FUNC(LibrarySettings, GetMaximalLevel, level_int_t);
SIMPLE_GET_FUNC(LibrarySettings, GetMaximalAttacks, u8);

View File

@ -3,14 +3,14 @@
#include "BaseLibrary.cpp"
using namespace CreatureLib::Library;
export const SpeciesLibrary* CreatureLib_SpeciesLibrary_Construct(size_t initialCapacity = 32) {
export_func const SpeciesLibrary* CreatureLib_SpeciesLibrary_Construct(size_t initialCapacity = 32) {
return new SpeciesLibrary(initialCapacity);
};
export void CreatureLib_SpeciesLibrary_Destruct(const SpeciesLibrary* p) { delete p; }
export_func void CreatureLib_SpeciesLibrary_Destruct(const SpeciesLibrary* p) { delete p; }
BASELIBRARY(CreatureLib_SpeciesLibrary, SpeciesLibrary, CreatureSpecies);
export const CreatureSpecies* CreatureLib_SpeciesLibrary_GetById(const SpeciesLibrary* p, u16 id) {
export_func const CreatureSpecies* CreatureLib_SpeciesLibrary_GetById(const SpeciesLibrary* p, u16 id) {
return p->GetById(id).GetRaw();
}

View File

@ -3,7 +3,7 @@
using namespace CreatureLib::Library;
export SpeciesVariant* CreatureLib_SpeciesVariant_Construct(
export_func SpeciesVariant* CreatureLib_SpeciesVariant_Construct(
const char* name, float height, float weight, u32 baseExperience, u8 types[], size_t typeLength, u16 baseHealth,
u16 baseAttack, u16 baseDefense, u16 baseMagicalAttack, u16 baseMagicalDefense, u16 baseSpeed,
const Talent* talents[], size_t talentsLength, const Talent* secretTalents[], size_t secretTalentsLength,
@ -30,28 +30,28 @@ export SpeciesVariant* CreatureLib_SpeciesVariant_Construct(
talentsWrapped, secretTalentsWrapped, attacks, conversedFlags);
}
export void CreatureLib_SpeciesVariant_Destruct(SpeciesVariant* p) { delete p; }
export_func void CreatureLib_SpeciesVariant_Destruct(SpeciesVariant* p) { delete p; }
export const char* CreatureLib_SpeciesVariant_GetName(SpeciesVariant* p) { return p->GetName().c_str(); }
export_func const char* CreatureLib_SpeciesVariant_GetName(SpeciesVariant* p) { return p->GetName().c_str(); }
SIMPLE_GET_FUNC(SpeciesVariant, GetHeight, float);
SIMPLE_GET_FUNC(SpeciesVariant, GetWeight, float);
SIMPLE_GET_FUNC(SpeciesVariant, GetBaseExperience, u32);
SIMPLE_GET_FUNC(SpeciesVariant, GetTypeCount, size_t);
export u8 CreatureLib_SpeciesVariant_GetType(SpeciesVariant* p, size_t index) { return p->GetType(index); }
export u16 CreatureLib_SpeciesVariant_GetStatistic(SpeciesVariant* p, CreatureLib::Library::Statistic stat) {
export_func u8 CreatureLib_SpeciesVariant_GetType(SpeciesVariant* p, size_t index) { return p->GetType(index); }
export_func u16 CreatureLib_SpeciesVariant_GetStatistic(SpeciesVariant* p, CreatureLib::Library::Statistic stat) {
return p->GetStatistic(stat);
}
SIMPLE_GET_FUNC(SpeciesVariant, GetTalentCount, size_t);
SIMPLE_GET_FUNC(SpeciesVariant, GetSecretTalentCount, size_t);
export u8 CreatureLib_SpeciesVariant_GetTalent(SpeciesVariant* p, bool secret, u8 index, const Talent*& out) {
export_func u8 CreatureLib_SpeciesVariant_GetTalent(SpeciesVariant* p, bool secret, u8 index, const Talent*& out) {
Try(out = p->GetTalent(TalentIndex(secret, index)).GetRaw();)
}
export const LearnableAttacks* CreatureLib_SpeciesVariant_GetLearnableAttacks(SpeciesVariant* p) {
export_func const LearnableAttacks* CreatureLib_SpeciesVariant_GetLearnableAttacks(SpeciesVariant* p) {
return p->GetLearnableAttacks().GetRaw();
}
export u8 CreatureLib_SpeciesVariant_GetRandomTalent(SpeciesVariant* p, ArbUt::Random* rand) {
export_func u8 CreatureLib_SpeciesVariant_GetRandomTalent(SpeciesVariant* p, ArbUt::Random* rand) {
return p->GetRandomTalent(*rand).GetIndex();
}
export bool CreatureLib_SpeciesVariant_HasFlag(const SpeciesVariant* p, const char* key) {
export_func bool CreatureLib_SpeciesVariant_HasFlag(const SpeciesVariant* p, const char* key) {
return p->HasFlag(ArbUt::StringView::CalculateHash(key));
}

View File

@ -2,16 +2,16 @@
#include "../Core.hpp"
using namespace CreatureLib::Library;
export Talent* CreatureLib_Talent_Construct(const char* name, const char* effect, EffectParameter* effectParameters[],
size_t effectParameterCount) {
export_func Talent* CreatureLib_Talent_Construct(const char* name, const char* effect,
EffectParameter* effectParameters[], size_t effectParameterCount) {
ArbUt::List<EffectParameter*> effectParameterList(effectParameterCount);
for (size_t i = 0; i < effectParameterCount; i++) {
effectParameterList.Append(effectParameters[i]);
}
return new Talent(ArbUt::StringView(name), ArbUt::StringView(effect), effectParameterList);
}
export void CreatureLib_Talent_Destruct(const Talent* p) { delete p; }
export_func void CreatureLib_Talent_Destruct(const Talent* p) { delete p; }
export const char* CreatureLib_Talent_GetName(const Talent* talent) { return talent->GetName().c_str(); }
export_func const char* CreatureLib_Talent_GetName(const Talent* talent) { return talent->GetName().c_str(); }
export const char* CreatureLib_Talent_GetEffect(const Talent* talent) { return talent->GetEffect().c_str(); }
export_func const char* CreatureLib_Talent_GetEffect(const Talent* talent) { return talent->GetEffect().c_str(); }

View File

@ -4,10 +4,10 @@
using namespace CreatureLib::Library;
export u8 CreatureLib_TalentLibrary_Construct(TalentLibrary*& library, size_t initialCapacity = 32) {
export_func u8 CreatureLib_TalentLibrary_Construct(TalentLibrary*& library, size_t initialCapacity = 32) {
Try(library = new TalentLibrary(initialCapacity);)
};
export void CreatureLib_TalentLibrary_Destruct(const TalentLibrary* p) { delete p; }
export_func void CreatureLib_TalentLibrary_Destruct(const TalentLibrary* p) { delete p; }
BASELIBRARY(CreatureLib_TalentLibrary, TalentLibrary, Talent);

View File

@ -2,31 +2,32 @@
#include "../Core.hpp"
using namespace CreatureLib::Library;
export TypeLibrary* CreatureLib_TypeLibrary_Construct(size_t initialCapacity) {
export_func TypeLibrary* CreatureLib_TypeLibrary_Construct(size_t initialCapacity) {
return new TypeLibrary(initialCapacity);
};
export void CreatureLib_TypeLibrary_Destruct(const TypeLibrary* p) { delete p; }
export_func void CreatureLib_TypeLibrary_Destruct(const TypeLibrary* p) { delete p; }
export u8 CreatureLib_TypeLibrary_GetTypeId(u8& out, const TypeLibrary* p, const char* type) {
export_func u8 CreatureLib_TypeLibrary_GetTypeId(u8& out, const TypeLibrary* p, const char* type) {
Try(out = p->GetTypeId(ArbUt::StringView(type));)
}
export u8 CreatureLib_TypeLibrary_RegisterType(u8& out, TypeLibrary* p, const char* type) {
export_func u8 CreatureLib_TypeLibrary_RegisterType(u8& out, TypeLibrary* p, const char* type) {
Try(out = p->RegisterType(ArbUt::StringView(type));)
}
export u8 CreatureLib_TypeLibrary_SetEffectiveness(TypeLibrary* p, u8 attacking, u8 defensive, float effectiveness) {
export_func u8 CreatureLib_TypeLibrary_SetEffectiveness(TypeLibrary* p, u8 attacking, u8 defensive,
float effectiveness) {
Try(p->SetEffectiveness(attacking, defensive, effectiveness);)
}
export u8 CreatureLib_TypeLibrary_GetSingleEffectiveness(float& out, TypeLibrary* p, u8 attacking, u8 defensive) {
export_func u8 CreatureLib_TypeLibrary_GetSingleEffectiveness(float& out, TypeLibrary* p, u8 attacking, u8 defensive) {
Try(out = p->GetSingleEffectiveness(attacking, defensive);)
}
export u8 CreatureLib_TypeLibrary_GetEffectiveness(float& out, TypeLibrary* p, u8 attacking, u8 defensive[],
size_t defensiveCount) {
export_func u8 CreatureLib_TypeLibrary_GetEffectiveness(float& out, TypeLibrary* p, u8 attacking, u8 defensive[],
size_t defensiveCount) {
Try(out = p->GetEffectiveness(attacking, std::vector<u8>(defensive, defensive + defensiveCount));)
}
export u8 CreatureLib_TypeLibrary_GetTypeName(const char*& out, TypeLibrary* p, u8 type) {
export_func u8 CreatureLib_TypeLibrary_GetTypeName(const char*& out, TypeLibrary* p, u8 type) {
Try(out = p->GetTypeName(type).c_str();)
}

View File

@ -5,7 +5,7 @@ include(CPM.cmake)
project(CreatureLib)
# Enable all warnings, and make them error when occurring.
add_compile_options(-Wall -Wextra -Werror)
add_compile_options(-Wall -Wextra -Werror -pedantic-errors)
# We like new stuff, so set the c++ standard to c++20.
set(CMAKE_CXX_STANDARD 20)
@ -55,6 +55,10 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_link_options(-fuse-ld=lld)
# Only warn for unknown sanitizers. This error is not major enough to error on.
add_compile_options(-Wno-error=unknown-sanitizers)
# Ignore pedantic nullability extension warning, as we only use this for clang specifically
add_compile_options(-Wno-nullability-extension)
# As far as I can tell this is an invalid pedantic warning since C++ 20. Empty variadic macro arguments is completely legal.
add_compile_options(-Wno-gnu-zero-variadic-macro-arguments)
endif ()
if (LEVEL_SIZE STREQUAL "8")