aboutsummaryrefslogtreecommitdiff
path: root/src/common/Utilities/EventMap.cpp
diff options
context:
space:
mode:
authorCarbenium <carbenium@outlook.com>2020-07-25 17:59:34 +0200
committerPeter Keresztes Schmidt <carbenium@outlook.com>2020-07-26 23:20:11 +0200
commit4470b9122379dc846b322a441951a03913912b71 (patch)
tree308db08b04862d72c067ace4641c58b569982697 /src/common/Utilities/EventMap.cpp
parente877f988d1c4e1361612f3d5c4ebe915f746aee5 (diff)
Core/EventMap: Unify semantics of DelayEvents
DelayEvents(Milliseconds delay) had different semantics than DelayEvents(Milliseconds delay, uint32 group). The first method delayed the events only in the case the internal timer already ticked at least for the amount of delay. In contrast the latter method delayed events regardless of the internal timer value. Use the latter semantics for DelayEvents(Milliseconds delay) as well which makes the outcome more predictable. Adapt tests accordingly.
Diffstat (limited to 'src/common/Utilities/EventMap.cpp')
-rw-r--r--src/common/Utilities/EventMap.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/common/Utilities/EventMap.cpp b/src/common/Utilities/EventMap.cpp
index de3400b403f..8e09d21ed6d 100644
--- a/src/common/Utilities/EventMap.cpp
+++ b/src/common/Utilities/EventMap.cpp
@@ -94,7 +94,16 @@ uint32 EventMap::ExecuteEvent()
void EventMap::DelayEvents(Milliseconds delay)
{
- _time = delay < _time - _time.min() ? _time - delay : TimePoint::min();
+ if (Empty())
+ return;
+
+ EventStore delayed = std::move(_eventMap);
+ for (EventStore::iterator itr = delayed.begin(); itr != delayed.end();)
+ {
+ EventStore::node_type node = delayed.extract(itr++);
+ node.key() = node.key() + delay;
+ _eventMap.insert(_eventMap.end(), std::move(node));
+ }
}
void EventMap::DelayEvents(Milliseconds delay, uint32 group)