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 2174c5d7dd)
This commit is contained in:
treeston
2016-09-13 20:02:09 +02:00
committed by joschiwald
parent bd5669ec5e
commit e829af4c2b

View File

@@ -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.
*/
@@ -125,6 +125,20 @@ public:
ScheduleEvent(eventId, uint32(time.count()), group, phase);
}
/**
* @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.
@@ -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.
*/
@@ -148,6 +162,20 @@ public:
RescheduleEvent(eventId, uint32(time.count()), group, phase);
}
/**
* @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.
@@ -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)