Update to latest Arbutils, use new integer defines

This commit is contained in:
2022-03-23 13:56:45 +01:00
parent 52127f6555
commit 3cc19de61f
102 changed files with 687 additions and 742 deletions

View File

@@ -4,7 +4,7 @@
#include <Arbutils/Enum.hpp>
namespace CreatureLib::Battling {
ENUM(EventDataKind, uint8_t, Damage, Heal, Faint, Switch, TurnStart, TurnEnd, ExperienceGain, Miss, DisplayText,
ENUM(EventDataKind, u8, Damage, Heal, Faint, Switch, TurnStart, TurnEnd, ExperienceGain, Miss, DisplayText,
ChangeSpecies, ChangeVariant, AttackUse, ChangeStatBoost, Fail, Swap, StatusChange)
}

View File

@@ -21,7 +21,7 @@ namespace CreatureLib::Battling {
std::vector<EventHookFunc> _listeners;
size_t _offset;
size_t _capacity;
uint8_t* _memory = nullptr;
u8* _memory = nullptr;
static constexpr size_t initialSize = 2048;
static constexpr size_t stepSize = 1024;
@@ -32,7 +32,7 @@ namespace CreatureLib::Battling {
if (ptr == nullptr) {
THROW("Out of memory.");
}
_memory = static_cast<uint8_t*>(ptr);
_memory = static_cast<u8*>(ptr);
}
EventHook(const EventHook&) = delete;
EventHook& operator=(const EventHook&) = delete;
@@ -52,9 +52,9 @@ namespace CreatureLib::Battling {
if (newPtr == nullptr) {
THROW("Out of memory.");
}
_memory = static_cast<uint8_t*>(newPtr);
_memory = static_cast<u8*>(newPtr);
}
uint8_t* ptr = _memory + _offset;
u8* ptr = _memory + _offset;
T* event = new (ptr) T(args...);
_offset += sizeof(T);
for (const auto& listener : _listeners) {

View File

@@ -7,19 +7,19 @@ namespace CreatureLib::Battling {
class ChangeStatBoostEvent final : public EventData {
const ArbUt::BorrowedPtr<Creature> _creature;
const CreatureLib::Library::Statistic _statistic;
const int8_t _oldValue;
const int8_t _newValue;
const i8 _oldValue;
const i8 _newValue;
public:
ChangeStatBoostEvent(const ArbUt::BorrowedPtr<Creature>& creature, CreatureLib::Library::Statistic statistic,
int8_t oldValue, int8_t newValue) noexcept
i8 oldValue, i8 newValue) noexcept
: _creature(creature), _statistic(statistic), _oldValue(oldValue), _newValue(newValue) {}
EventDataKind GetKind() const noexcept override { return EventDataKind ::ChangeStatBoost; }
const ArbUt::BorrowedPtr<Creature>& GetCreature() const noexcept { return _creature; }
CreatureLib::Library::Statistic GetStatistic() const noexcept { return _statistic; }
int8_t GetOldValue() const noexcept { return _oldValue; }
int8_t GetNewValue() const noexcept { return _newValue; }
i8 GetOldValue() const noexcept { return _oldValue; }
i8 GetNewValue() const noexcept { return _newValue; }
};
}

View File

@@ -6,17 +6,17 @@ namespace CreatureLib::Battling {
class DamageEvent final : public EventData {
ArbUt::BorrowedPtr<Creature> _creature;
DamageSource _damageSource;
uint32_t _originalHealth;
uint32_t _newHealth;
u32 _originalHealth;
u32 _newHealth;
public:
DamageEvent(Creature* c, DamageSource s, uint32_t oHealth, uint32_t newHealth) noexcept
DamageEvent(Creature* c, DamageSource s, u32 oHealth, u32 newHealth) noexcept
: _creature(c), _damageSource(s), _originalHealth(oHealth), _newHealth(newHealth) {}
EventDataKind GetKind() const noexcept override { return EventDataKind ::Damage; }
const ArbUt::BorrowedPtr<Creature>& GetCreature() const noexcept { return _creature; }
DamageSource GetDamageSource() const noexcept { return _damageSource; }
uint32_t GetOriginalHealth() const noexcept { return _originalHealth; }
uint32_t GetNewHealth() const noexcept { return _newHealth; }
u32 GetOriginalHealth() const noexcept { return _originalHealth; }
u32 GetNewHealth() const noexcept { return _newHealth; }
};
}

View File

@@ -5,16 +5,16 @@
namespace CreatureLib::Battling {
class ExperienceGainEvent final : public EventData {
ArbUt::BorrowedPtr<Creature> _creature;
uint32_t _previousExperience;
uint32_t _newExperience;
u32 _previousExperience;
u32 _newExperience;
public:
ExperienceGainEvent(const ArbUt::BorrowedPtr<Creature>& creature, uint32_t previousExp, uint32_t newExp)
ExperienceGainEvent(const ArbUt::BorrowedPtr<Creature>& creature, u32 previousExp, u32 newExp)
: _creature(creature), _previousExperience(previousExp), _newExperience(newExp) {}
EventDataKind GetKind() const noexcept override { return EventDataKind ::ExperienceGain; }
const ArbUt::BorrowedPtr<Creature>& GetCreature() const noexcept { return _creature; }
uint32_t GetPreviousExperience() const noexcept { return _previousExperience; }
uint32_t GetNewExperience() const noexcept { return _newExperience; }
u32 GetPreviousExperience() const noexcept { return _previousExperience; }
u32 GetNewExperience() const noexcept { return _newExperience; }
};
}

View File

@@ -5,16 +5,16 @@
namespace CreatureLib::Battling {
class HealEvent final : public EventData {
ArbUt::BorrowedPtr<Creature> _creature;
uint32_t _originalHealth;
uint32_t _newHealth;
u32 _originalHealth;
u32 _newHealth;
public:
HealEvent(ArbUt::BorrowedPtr<Creature> c, uint32_t oHealth, uint32_t newHealth) noexcept
HealEvent(ArbUt::BorrowedPtr<Creature> c, u32 oHealth, u32 newHealth) noexcept
: _creature(c), _originalHealth(oHealth), _newHealth(newHealth) {}
EventDataKind GetKind() const noexcept override { return EventDataKind ::Heal; }
const ArbUt::BorrowedPtr<Creature>& GetCreature() const noexcept { return _creature; }
uint32_t GetOriginalHealth() const noexcept { return _originalHealth; }
uint32_t GetNewHealth() const noexcept { return _newHealth; }
u32 GetOriginalHealth() const noexcept { return _originalHealth; }
u32 GetNewHealth() const noexcept { return _newHealth; }
};
}