diff --git a/src/Battling/ScriptHandling/ScriptAggregator.hpp b/src/Battling/ScriptHandling/ScriptAggregator.hpp index b9a47fe..2466600 100644 --- a/src/Battling/ScriptHandling/ScriptAggregator.hpp +++ b/src/Battling/ScriptHandling/ScriptAggregator.hpp @@ -10,19 +10,17 @@ namespace CreatureLib::Battling{ class ScriptAggregator{ - __gnu_cxx::__normal_iterator> _selfIterator; - __gnu_cxx::__normal_iterator> _selfEnd; + std::vector _scripts; + int _index = 0; bool _isSetSet = false; std::__detail::_Node_const_iterator, false, true> _setIterator; std::__detail::_Node_const_iterator, false, true> _setEnd; public: - ScriptAggregator(std::vector scripts){ - _selfIterator = scripts.begin(); - _selfEnd = scripts.end(); + ScriptAggregator(std::vector scripts) : _scripts(std::move(scripts)){ }; bool HasNext(){ - return _selfIterator != _selfEnd || (_isSetSet && _setIterator != _setEnd); + return _index < _scripts.size() || (_isSetSet && _setIterator != _setEnd); } Script* GetNext(){ @@ -39,10 +37,10 @@ namespace CreatureLib::Battling{ } return s; } - if (_selfIterator == _selfEnd) + if (_index >= _scripts.size()) return nullptr; - auto next = *_selfIterator; - _selfIterator++; + auto next = _scripts[_index]; + _index++; if (!next.IsSet()){ auto scriptPtr = next.GetScript(); if (scriptPtr == nullptr)