aboutsummaryrefslogtreecommitdiff
path: root/src/common/Utilities/EventMap.h
diff options
context:
space:
mode:
authortreeston <treeston.mmoc@gmail.com>2016-09-13 20:02:09 +0200
committertreeston <treeston.mmoc@gmail.com>2016-09-13 20:02:09 +0200
commit2174c5d7dd9669384b2e68b8b406a3173042d7d9 (patch)
treee063e2600292581383d8b78ec15375de09556ff1 /src/common/Utilities/EventMap.h
parent0f7efc86d066ed614fa7b192da81c48d586f8b85 (diff)
Common/Utilities: More std::chrono overloads for EventMap. Specifying 2 std::chrono types now gives you a random (to milliseconds) time in that interval (inclusive) for (Re)ScheduleEvent.
Diffstat (limited to 'src/common/Utilities/EventMap.h')
-rw-r--r--src/common/Utilities/EventMap.h34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/common/Utilities/EventMap.h b/src/common/Utilities/EventMap.h
index 6a314a9e633..a2fe985c6f9 100644
--- a/src/common/Utilities/EventMap.h
+++ b/src/common/Utilities/EventMap.h
@@ -116,7 +116,7 @@ public:
* @name ScheduleEvent
* @brief Creates new event entry in map.
* @param eventId The id of the new event.
- * @param time The time in milliseconds as std::chrono::duration until the event occurs.
+ * @param time The time until the event occurs as std::chrono type.
* @param group The group which the event is associated to. Has to be between 1 and 8. 0 means it has no group.
* @param phase The phase in which the event can occur. Has to be between 1 and 8. 0 means it can occur in all phases.
*/
@@ -129,6 +129,20 @@ public:
* @name ScheduleEvent
* @brief Creates new event entry in map.
* @param eventId The id of the new event.
+ * @param minTime The minimum time until the event occurs as std::chrono type.
+ * @param maxTime The maximum time until the event occurs as std::chrono type.
+ * @param group The group which the event is associated to. Has to be between 1 and 8. 0 means it has no group.
+ * @param phase The phase in which the event can occur. Has to be between 1 and 8. 0 means it can occur in all phases.
+ */
+ void ScheduleEvent(uint32 eventId, Milliseconds const& minTime, Milliseconds const& maxTime, uint32 group = 0, uint32 phase = 0)
+ {
+ ScheduleEvent(eventId, urand(uint32(minTime.count()), uint32(maxTime.count())), group, phase);
+ }
+
+ /**
+ * @name ScheduleEvent
+ * @brief Creates new event entry in map.
+ * @param eventId The id of the new event.
* @param time The time in milliseconds until the event occurs.
* @param group The group which the event is associated to. Has to be between 1 and 8. 0 means it has no group.
* @param phase The phase in which the event can occur. Has to be between 1 and 8. 0 means it can occur in all phases.
@@ -139,7 +153,7 @@ public:
* @name RescheduleEvent
* @brief Cancels the given event and reschedules it.
* @param eventId The id of the event.
- * @param time The time in milliseconds as std::chrono::duration until the event occurs.
+ * @param time The time until the event occurs as std::chrono type.
* @param group The group which the event is associated to. Has to be between 1 and 8. 0 means it has no group.
* @param phase The phase in which the event can occur. Has to be between 1 and 8. 0 means it can occur in all phases.
*/
@@ -152,6 +166,20 @@ public:
* @name RescheduleEvent
* @brief Cancels the given event and reschedules it.
* @param eventId The id of the event.
+ * @param minTime The minimum time until the event occurs as std::chrono type.
+ * @param maxTime The maximum time until the event occurs as std::chrono type.
+ * @param group The group which the event is associated to. Has to be between 1 and 8. 0 means it has no group.
+ * @param phase The phase in which the event can occur. Has to be between 1 and 8. 0 means it can occur in all phases.
+ */
+ void RescheduleEvent(uint32 eventId, Milliseconds const& minTime, Milliseconds const& maxTime, uint32 group = 0, uint32 phase = 0)
+ {
+ RescheduleEvent(eventId, urand(uint32(minTime.count()), uint32(maxTime.count())), group, phase);
+ }
+
+ /**
+ * @name RescheduleEvent
+ * @brief Cancels the given event and reschedules it.
+ * @param eventId The id of the event.
* @param time The time in milliseconds until the event occurs.
* @param group The group which the event is associated to. Has to be between 1 and 8. 0 means it has no group.
* @param phase The phase in which the event can occur. Has to be between 1 and 8. 0 means it can occur in all phases.
@@ -223,7 +251,7 @@ public:
/**
* @name DelayEvents
- * @brief Delays all events in the map. If delay is greater than or equal internal timer, delay will be 0.
+ * @brief Delays all events in the map. If delay is greater than or equal internal timer, delay will be equal to internal timer.
* @param delay Amount of delay.
*/
void DelayEvents(uint32 delay)