Resolve memory issue with Event Hooks.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
410487c86b
commit
db002c784f
|
@ -9,6 +9,7 @@ namespace CreatureLib::Battling {
|
||||||
|
|
||||||
class EventData {
|
class EventData {
|
||||||
public:
|
public:
|
||||||
|
virtual ~EventData() = default;
|
||||||
virtual EventDataKind GetKind() = 0;
|
virtual EventDataKind GetKind() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ namespace CreatureLib::Battling {
|
||||||
for (auto listener : _listeners) {
|
for (auto listener : _listeners) {
|
||||||
listener(eventData);
|
listener(eventData);
|
||||||
}
|
}
|
||||||
|
delete eventData;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace CreatureLib::Battling {
|
||||||
ChoiceQueue* _currentTurnQueue = nullptr;
|
ChoiceQueue* _currentTurnQueue = nullptr;
|
||||||
bool _hasEnded = false;
|
bool _hasEnded = false;
|
||||||
BattleResult _battleResult = BattleResult::Empty();
|
BattleResult _battleResult = BattleResult::Empty();
|
||||||
EventHook* _eventHook = new EventHook();
|
EventHook _eventHook = EventHook();
|
||||||
|
|
||||||
ScriptSet _volatile;
|
ScriptSet _volatile;
|
||||||
|
|
||||||
|
@ -74,8 +74,8 @@ namespace CreatureLib::Battling {
|
||||||
|
|
||||||
const std::vector<BattleSide*>& GetSides() const { return _sides; }
|
const std::vector<BattleSide*>& GetSides() const { return _sides; }
|
||||||
|
|
||||||
void RegisterEventListener(EVENT_HOOK_FUNC(listener)) { this->_eventHook->RegisterListener(listener); }
|
void RegisterEventListener(EVENT_HOOK_FUNC(listener)) { this->_eventHook.RegisterListener(listener); }
|
||||||
void TriggerEventListener(EventData* data) { this->_eventHook->TriggerEvent(data); }
|
void TriggerEventListener(EventData* data) { this->_eventHook.TriggerEvent(data); }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue