From cdd1ac992f9a5511efc50817a429908400c89e9d Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Mon, 11 Nov 2019 20:04:59 +0100 Subject: [PATCH] Fix build on Linux. --- src/Battling/ScriptHandling/ScriptAggregator.hpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) 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)