diff --git a/solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp b/solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp index fef2e3e..00891b2 100644 --- a/solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp +++ b/solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include "./util.hpp" @@ -261,18 +261,27 @@ float SHA1_NGCFT1::iterate(float delta) { { // requested info timers std::vector timed_out; - _os.registry().view().each([delta, &timed_out](Object e, Components::ReRequestInfoTimer& rrit) { + _os.registry().view().each([delta, &timed_out](Object ov, Components::ReRequestInfoTimer& rrit) { rrit.timer += delta; // 15sec, TODO: config if (rrit.timer >= 15.f) { - timed_out.push_back(e); + timed_out.push_back(ov); } }); for (const auto e : timed_out) { // TODO: avoid dups - _queue_content_want_info.push_back(_os.objectHandle(e)); - _os.registry().remove(e); + for (const ObjectHandle it : _queue_content_want_info) { + assert(it != e); + } + + auto o = _os.objectHandle(e); + assert(!o.any_of()); + assert(!o.any_of()); + + _queue_content_want_info.push_back(o); + //_os.registry().remove(e); + o.remove(); // TODO: throw update? } } @@ -1209,16 +1218,34 @@ bool SHA1_NGCFT1::onEvent(const Events::NGCFT1_recv_message& e) { // HACK: assume the message sender has all o.get_or_emplace().others[c] = {true, {}}; + // TODO: queue info dl + // TODO: queue info/check if we already have info if (!o.all_of() && !o.all_of()) { - // TODO: check if already receiving - _queue_content_want_info.push_back(o); + bool in_info_want {false}; + for (const auto it : _queue_content_want_info) { + if (it == o) { + in_info_want = true; + break; + } + } + if (!in_info_want) { + // TODO: check if already receiving + _queue_content_want_info.push_back(o); + } + } else if (o.all_of()){ + // remove from info want + o.remove(); + + auto it = std::find(_queue_content_want_info.cbegin(), _queue_content_want_info.cend(), o); + if (it != _queue_content_want_info.cend()) { + _queue_content_want_info.erase(it); + } } // since public o.get_or_emplace().targets.emplace(c.get().parent); - // TODO: queue info dl - // TODO: queue info/check if we already have info + _os.throwEventUpdate(o); _rmm.throwEventConstruct(reg, new_msg_e);