From 3b071727c3b7d8756e46dde6c9af7f27ae1c1130 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Fri, 4 Sep 2020 15:10:24 +0100 Subject: [PATCH] Properly use the extra delay in all cases --- src/timer_base.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/timer_base.cpp b/src/timer_base.cpp index d5235fd..ac3a2b3 100644 --- a/src/timer_base.cpp +++ b/src/timer_base.cpp @@ -27,15 +27,15 @@ namespace duck { namespace { [[gnu::pure]] - unsigned long time_interval (const oro::Header& header) { - return header.retry_after / header.rate_limit; + unsigned long time_interval (const oro::Header& header, double extra) { + return header.retry_after / header.rate_limit + extra; } - oro::Timestamp calc_next_update (const oro::Header& header) { + oro::Timestamp calc_next_update (const oro::Header& header, double extra) { oro::Timestamp ret; ret.ts = std::chrono::time_point_cast(std::chrono::system_clock::now()) + - std::chrono::seconds(time_interval(header)); + std::chrono::seconds(time_interval(header, extra)); return ret; } @@ -75,7 +75,7 @@ void TimerBase::on_timer() { } void TimerBase::set_next_timer (const oro::Header& header) { - const unsigned long next_timer = time_interval(header) + m_extra_delay; + const unsigned long next_timer = time_interval(header, m_extra_delay); std::cout << "Next timer in " << next_timer << " secs\n"; this->set_timer(static_cast(next_timer)); } @@ -96,19 +96,19 @@ oro::OriginsDB& TimerBase::db() { } void TimerBase::update_db (const oro::Shops& shops, const oro::Header& header) { - db().update(shops, calc_next_update(header)); + db().update(shops, calc_next_update(header, m_extra_delay)); } void TimerBase::update_db (const oro::Items& items, const oro::Header& header) { - db().update(items, calc_next_update(header)); + db().update(items, calc_next_update(header, m_extra_delay)); } void TimerBase::update_db (const oro::Icons& icons, const oro::Header& header) { - db().update(icons, calc_next_update(header)); + db().update(icons, calc_next_update(header, m_extra_delay)); } void TimerBase::update_db (const oro::Creators& creators, const oro::Header& header) { - db().update(creators, calc_next_update(header)); + db().update(creators, calc_next_update(header, m_extra_delay)); } } //namespace duck