Reset on initialization in ScriptAggregator, fixes segfault when calling Reset on an empty Aggregator.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
@@ -32,17 +32,23 @@ namespace CreatureLib::Battling {
|
||||
}
|
||||
|
||||
public:
|
||||
ScriptAggregator(){};
|
||||
explicit ScriptAggregator(const ArbUt::List<ScriptWrapper>& scripts)
|
||||
: _scripts(scripts.RawData()), _size(scripts.Count()){};
|
||||
ScriptAggregator() {};
|
||||
|
||||
explicit ScriptAggregator(const ArbUt::List<ScriptWrapper> &scripts)
|
||||
: _scripts(scripts.RawData()), _size(scripts.Count()) {
|
||||
Reset();
|
||||
};
|
||||
|
||||
inline void Reset() {
|
||||
_index = 0;
|
||||
if (_scripts[_index].IsSet()) {
|
||||
_setIndex = -1;
|
||||
if (_size > 0) {
|
||||
if (_scripts[_index].IsSet()) {
|
||||
_setIndex = -1;
|
||||
}
|
||||
IncrementToNextNotNull(false);
|
||||
}
|
||||
IncrementToNextNotNull(false);
|
||||
}
|
||||
|
||||
inline bool HasNext() { return _index < _size; }
|
||||
|
||||
std::optional<ArbUt::BorrowedPtr<BattleScript>> GetNextNotNull() {
|
||||
@@ -54,13 +60,13 @@ namespace CreatureLib::Battling {
|
||||
}
|
||||
|
||||
ArbUt::BorrowedPtr<BattleScript> GetNext() {
|
||||
auto& current = _scripts[_index];
|
||||
auto ¤t = _scripts[_index];
|
||||
if (!current.IsSet()) {
|
||||
auto s = current.GetScript();
|
||||
IncrementToNextNotNull();
|
||||
return (*s);
|
||||
} else {
|
||||
auto& set = current.GetScriptSet()->GetIterator();
|
||||
auto &set = current.GetScriptSet()->GetIterator();
|
||||
auto v = set[_setIndex];
|
||||
IncrementToNextNotNull();
|
||||
return v;
|
||||
|
||||
Reference in New Issue
Block a user