diff --git a/CInterface/Battling/EventData.cpp b/CInterface/Battling/EventData.cpp index 48b0f3e..99f16a0 100644 --- a/CInterface/Battling/EventData.cpp +++ b/CInterface/Battling/EventData.cpp @@ -2,7 +2,7 @@ #include "../Core.hpp" using namespace CreatureLib::Battling; -export void CreatureLib_EventData_Destruct(const EventData* p) { delete p; } +DESTRUCTOR(EventData); SIMPLE_GET_FUNC(EventData, GetKind, EventDataKind); @@ -10,15 +10,29 @@ BORROWED_GET_FUNC(DamageEvent, GetCreature, Creature*); SIMPLE_GET_FUNC(DamageEvent, GetDamageSource, DamageSource); SIMPLE_GET_FUNC(DamageEvent, GetOriginalHealth, uint32_t); SIMPLE_GET_FUNC(DamageEvent, GetNewHealth, uint32_t); -export void CreatureLib_DamageEvent_Destruct(const DamageEvent* p) { delete p; } +DESTRUCTOR(DamageEvent); BORROWED_GET_FUNC(HealEvent, GetCreature, Creature*); SIMPLE_GET_FUNC(HealEvent, GetOriginalHealth, uint32_t); SIMPLE_GET_FUNC(HealEvent, GetNewHealth, uint32_t); -export void CreatureLib_HealEvent_Destruct(const HealEvent* p) { delete p; } +DESTRUCTOR(HealEvent); BORROWED_GET_FUNC(FaintEvent, GetCreature, Creature*); -export void CreatureLib_FaintEvent_Destruct(const FaintEvent* p) { delete p; } +DESTRUCTOR(FaintEvent); + +BORROWED_GET_FUNC(SwitchEvent, GetNewCreature, Creature*); +export uint8_t CreatureLib_SwitchEvent_GetSide(const SwitchEvent* p) { return p->GetIndex().GetSideIndex(); } +export uint8_t CreatureLib_SwitchEvent_GetIndex(const SwitchEvent* p) { return p->GetIndex().GetCreatureIndex(); } +DESTRUCTOR(SwitchEvent); + +DESTRUCTOR(TurnStartEvent); + +DESTRUCTOR(TurnEndEvent); + +BORROWED_GET_FUNC(ExperienceGainEvent, GetCreature, Creature*); +SIMPLE_GET_FUNC(ExperienceGainEvent, GetPreviousExperience, uint32_t); +SIMPLE_GET_FUNC(ExperienceGainEvent, GetNewExperience, uint32_t); +DESTRUCTOR(ExperienceGainEvent); export const char* CreatureLib_DisplayTextEvent_GetText(const DisplayTextEvent* p) { return p->GetText().c_str(); } export void CreatureLib_DisplayTextEvent_Destruct(const DisplayTextEvent* p) { delete p; } diff --git a/CInterface/Core.hpp b/CInterface/Core.hpp index a12c6d4..1fcfdc5 100644 --- a/CInterface/Core.hpp +++ b/CInterface/Core.hpp @@ -37,5 +37,7 @@ public: export returnType CreatureLib_##type##_##name(const type* p) { return p->name().GetRaw(); } #define SMART_GET_FUNC(type, name, returnType) \ export returnType CreatureLib_##type##_##name(const type* p) { return p->name().get(); } +#define DESTRUCTOR(type) \ + export void CreatureLib_##type##_Destruct(const type* p) { delete p; } #endif // CREATURELIB_CORE_HPP