aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortreeston <treeston.mmoc@gmail.com>2016-09-13 20:02:09 +0200
committerjoschiwald <joschiwald.trinity@gmail.com>2017-02-26 20:02:15 +0100
commite829af4c2b8cbdfd38b00aafb4251b5255976b9b (patch)
treebb81c442bf2ceb7a79eb003b78b558fce7a48cc1
parentbd5669ec5ea48dc445fa3343b4aae484bb363d17 (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.
(cherry picked from commit 2174c5d7dd9669384b2e68b8b406a3173042d7d9)
-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 961d6765240..edcc7a64455 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)