aboutsummaryrefslogtreecommitdiff
path: root/src/common/Utilities/EventMap.cpp
diff options
context:
space:
mode:
authorCarbenium <carbenium@outlook.com>2020-07-25 17:59:34 +0200
committerShauren <shauren.trinity@gmail.com>2022-01-24 00:01:25 +0100
commita5d85deceda576bfa8231d0a703024d13df1ff88 (patch)
tree0bade2c99c732b23edafd2aec127c121ace508f0 /src/common/Utilities/EventMap.cpp
parent5512eb2f8f09efe730ab2f997af7e7130d1e90f5 (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. (cherry picked from commit 4470b9122379dc846b322a441951a03913912b71)
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 e4a1b447579..d2ff65a14c5 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)