mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Misc: Pass std::chrono types by value everywhere.
(cherry picked from commit 2ef9d301f0)
This commit is contained in:
@@ -33,7 +33,7 @@ void EventMap::SetPhase(uint8 phase)
|
||||
_phase = uint8(1 << (phase - 1));
|
||||
}
|
||||
|
||||
void EventMap::ScheduleEvent(uint32 eventId, Milliseconds const& minTime, Milliseconds const& maxTime, uint32 group /*= 0*/, uint8 phase /*= 0*/)
|
||||
void EventMap::ScheduleEvent(uint32 eventId, Milliseconds minTime, Milliseconds maxTime, uint32 group /*= 0*/, uint8 phase /*= 0*/)
|
||||
{
|
||||
ScheduleEvent(eventId, urand(uint32(minTime.count()), uint32(maxTime.count())), group, phase);
|
||||
}
|
||||
@@ -49,7 +49,7 @@ void EventMap::ScheduleEvent(uint32 eventId, uint32 time, uint32 group /*= 0*/,
|
||||
_eventMap.insert(EventStore::value_type(_time + time, eventId));
|
||||
}
|
||||
|
||||
void EventMap::RescheduleEvent(uint32 eventId, Milliseconds const& minTime, Milliseconds const& maxTime, uint32 group /*= 0*/, uint8 phase /*= 0*/)
|
||||
void EventMap::RescheduleEvent(uint32 eventId, Milliseconds minTime, Milliseconds maxTime, uint32 group /*= 0*/, uint8 phase /*= 0*/)
|
||||
{
|
||||
RescheduleEvent(eventId, urand(uint32(minTime.count()), uint32(maxTime.count())), group, phase);
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public:
|
||||
* @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& time, uint32 group = 0, uint8 phase = 0)
|
||||
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group = 0, uint8 phase = 0)
|
||||
{
|
||||
ScheduleEvent(eventId, uint32(time.count()), group, phase);
|
||||
}
|
||||
@@ -134,7 +134,7 @@ public:
|
||||
* @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, uint8 phase = 0);
|
||||
void ScheduleEvent(uint32 eventId, Milliseconds minTime, Milliseconds maxTime, uint32 group = 0, uint8 phase = 0);
|
||||
|
||||
/**
|
||||
* @name ScheduleEvent
|
||||
@@ -154,7 +154,7 @@ public:
|
||||
* @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& time, uint32 group = 0, uint8 phase = 0)
|
||||
void RescheduleEvent(uint32 eventId, Milliseconds time, uint32 group = 0, uint8 phase = 0)
|
||||
{
|
||||
RescheduleEvent(eventId, uint32(time.count()), group, phase);
|
||||
}
|
||||
@@ -168,7 +168,7 @@ public:
|
||||
* @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, uint8 phase = 0);
|
||||
void RescheduleEvent(uint32 eventId, Milliseconds minTime, Milliseconds maxTime, uint32 group = 0, uint8 phase = 0);
|
||||
|
||||
/**
|
||||
* @name RescheduleEvent
|
||||
@@ -189,7 +189,7 @@ public:
|
||||
* @brief Repeats the mostly recently executed event.
|
||||
* @param time Time until in milliseconds as std::chrono::duration the event occurs.
|
||||
*/
|
||||
void Repeat(Milliseconds const& time)
|
||||
void Repeat(Milliseconds time)
|
||||
{
|
||||
Repeat(uint32(time.count()));
|
||||
}
|
||||
@@ -210,7 +210,7 @@ public:
|
||||
* @param minTime Minimum time as std::chrono::duration until the event occurs.
|
||||
* @param maxTime Maximum time as std::chrono::duration until the event occurs.
|
||||
*/
|
||||
void Repeat(Milliseconds const& minTime, Milliseconds const& maxTime)
|
||||
void Repeat(Milliseconds minTime, Milliseconds maxTime)
|
||||
{
|
||||
Repeat(uint32(minTime.count()), uint32(maxTime.count()));
|
||||
}
|
||||
@@ -235,7 +235,7 @@ public:
|
||||
* @brief Delays all events in the map. If delay is greater than or equal internal timer, delay will be 0.
|
||||
* @param delay Amount of delay in ms as std::chrono::duration.
|
||||
*/
|
||||
void DelayEvents(Milliseconds const& delay)
|
||||
void DelayEvents(Milliseconds delay)
|
||||
{
|
||||
DelayEvents(uint32(delay.count()));
|
||||
}
|
||||
@@ -256,7 +256,7 @@ public:
|
||||
* @param delay Amount of delay in ms as std::chrono::duration.
|
||||
* @param group Group of the events.
|
||||
*/
|
||||
void DelayEvents(Milliseconds const& delay, uint32 group)
|
||||
void DelayEvents(Milliseconds delay, uint32 group)
|
||||
{
|
||||
DelayEvents(uint32(delay.count()), group);
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ class TC_COMMON_API EventProcessor
|
||||
void Update(uint32 p_time);
|
||||
void KillAllEvents(bool force);
|
||||
void AddEvent(BasicEvent* event, uint64 e_time, bool set_addtime = true);
|
||||
void AddEventAtOffset(BasicEvent* event, Milliseconds const& offset) { AddEvent(event, CalculateTime(offset.count())); }
|
||||
void AddEventAtOffset(BasicEvent* event, Milliseconds offset) { AddEvent(event, CalculateTime(offset.count())); }
|
||||
void ModifyEventTime(BasicEvent* event, uint64 newTime);
|
||||
uint64 CalculateTime(uint64 t_offset) const { return m_time + t_offset; }
|
||||
std::multimap<uint64, BasicEvent*> const& GetEvents() const { return m_events; }
|
||||
|
||||
@@ -62,7 +62,7 @@ float frand(float min, float max)
|
||||
return float(GetRng()->Random() * (max - min) + min);
|
||||
}
|
||||
|
||||
Milliseconds randtime(Milliseconds const& min, Milliseconds const& max)
|
||||
Milliseconds randtime(Milliseconds min, Milliseconds max)
|
||||
{
|
||||
long long diff = max.count() - min.count();
|
||||
ASSERT(diff >= 0);
|
||||
|
||||
@@ -35,7 +35,7 @@ TC_COMMON_API uint32 urandms(uint32 min, uint32 max);
|
||||
TC_COMMON_API uint32 rand32();
|
||||
|
||||
/* Return a random time in the range min..max (up to millisecond precision). Only works for values where millisecond difference is a valid uint32. */
|
||||
TC_COMMON_API Milliseconds randtime(Milliseconds const& min, Milliseconds const& max);
|
||||
TC_COMMON_API Milliseconds randtime(Milliseconds min, Milliseconds max);
|
||||
|
||||
/* Return a random number in the range min..max */
|
||||
TC_COMMON_API float frand(float min, float max);
|
||||
|
||||
@@ -802,7 +802,7 @@ void AuctionHouseMgr::Update()
|
||||
++itr;
|
||||
}
|
||||
|
||||
_playerThrottleObjectsCleanupTime = now + Hours(1);
|
||||
_playerThrottleObjectsCleanupTime = now + 1h;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2271,7 +2271,7 @@ void Creature::Respawn(bool force)
|
||||
|
||||
}
|
||||
|
||||
void Creature::ForcedDespawn(uint32 timeMSToDespawn, Seconds const& forceRespawnTimer)
|
||||
void Creature::ForcedDespawn(uint32 timeMSToDespawn, Seconds forceRespawnTimer)
|
||||
{
|
||||
if (timeMSToDespawn)
|
||||
{
|
||||
@@ -2323,7 +2323,7 @@ void Creature::ForcedDespawn(uint32 timeMSToDespawn, Seconds const& forceRespawn
|
||||
}
|
||||
}
|
||||
|
||||
void Creature::DespawnOrUnsummon(uint32 msTimeToDespawn /*= 0*/, Seconds const& forceRespawnTimer /*= 0*/)
|
||||
void Creature::DespawnOrUnsummon(uint32 msTimeToDespawn /*= 0*/, Seconds forceRespawnTimer /*= 0*/)
|
||||
{
|
||||
if (TempSummon* summon = ToTempSummon())
|
||||
summon->UnSummon(msTimeToDespawn);
|
||||
|
||||
@@ -258,8 +258,8 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
|
||||
|
||||
void RemoveCorpse(bool setSpawnTime = true, bool destroyForNearbyPlayers = true);
|
||||
|
||||
void DespawnOrUnsummon(uint32 msTimeToDespawn = 0, Seconds const& forceRespawnTime = Seconds(0));
|
||||
void DespawnOrUnsummon(Milliseconds const& time, Seconds const& forceRespawnTime = Seconds(0)) { DespawnOrUnsummon(uint32(time.count()), forceRespawnTime); }
|
||||
void DespawnOrUnsummon(uint32 msTimeToDespawn = 0, Seconds forceRespawnTime = 0s);
|
||||
void DespawnOrUnsummon(Milliseconds time, Seconds forceRespawnTime = 0s) { DespawnOrUnsummon(uint32(time.count()), forceRespawnTime); }
|
||||
|
||||
time_t const& GetRespawnTime() const { return m_respawnTime; }
|
||||
time_t GetRespawnTimeEx() const;
|
||||
@@ -423,7 +423,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
|
||||
bool CanAlwaysSee(WorldObject const* obj) const override;
|
||||
|
||||
private:
|
||||
void ForcedDespawn(uint32 timeMSToDespawn = 0, Seconds const& forceRespawnTimer = Seconds(0));
|
||||
void ForcedDespawn(uint32 timeMSToDespawn = 0, Seconds forceRespawnTimer = 0s);
|
||||
bool CheckNoGrayAggroConfig(uint32 playerLevel, uint32 creatureLevel) const; // No aggro from gray creatures
|
||||
|
||||
// Waypoint path
|
||||
@@ -468,7 +468,7 @@ class TC_GAME_API AssistDelayEvent : public BasicEvent
|
||||
class TC_GAME_API ForcedDespawnDelayEvent : public BasicEvent
|
||||
{
|
||||
public:
|
||||
ForcedDespawnDelayEvent(Creature& owner, Seconds const& respawnTimer) : BasicEvent(), m_owner(owner), m_respawnTimer(respawnTimer) { }
|
||||
ForcedDespawnDelayEvent(Creature& owner, Seconds respawnTimer) : BasicEvent(), m_owner(owner), m_respawnTimer(respawnTimer) { }
|
||||
bool Execute(uint64 e_time, uint32 p_time) override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -965,7 +965,7 @@ void GameObject::AddUniqueUse(Player* player)
|
||||
m_unique_users.insert(player->GetGUID());
|
||||
}
|
||||
|
||||
void GameObject::DespawnOrUnsummon(Milliseconds const& delay, Seconds const& forceRespawnTime)
|
||||
void GameObject::DespawnOrUnsummon(Milliseconds delay, Seconds forceRespawnTime)
|
||||
{
|
||||
if (delay > 0ms)
|
||||
{
|
||||
|
||||
@@ -164,7 +164,7 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject>
|
||||
void SetSpawnedByDefault(bool b) { m_spawnedByDefault = b; }
|
||||
uint32 GetRespawnDelay() const { return m_respawnDelayTime; }
|
||||
void Refresh();
|
||||
void DespawnOrUnsummon(Milliseconds const& delay = 0ms, Seconds const& forceRespawnTime = 0s);
|
||||
void DespawnOrUnsummon(Milliseconds delay = 0ms, Seconds forceRespawnTime = 0s);
|
||||
void Delete();
|
||||
void SendGameObjectDespawn();
|
||||
void getFishLoot(Loot* loot, Player* loot_owner);
|
||||
|
||||
@@ -542,7 +542,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
|
||||
Scenario* GetScenario() const;
|
||||
|
||||
TempSummon* SummonCreature(uint32 entry, Position const& pos, TempSummonType despawnType = TEMPSUMMON_MANUAL_DESPAWN, uint32 despawnTime = 0, uint32 vehId = 0, uint32 spellId = 0, ObjectGuid privateObjectOwner = ObjectGuid::Empty);
|
||||
TempSummon* SummonCreature(uint32 entry, Position const& pos, TempSummonType despawnType, Milliseconds const& despawnTime, uint32 vehId = 0, uint32 spellId = 0, ObjectGuid privateObjectOwner = ObjectGuid::Empty) { return SummonCreature(entry, pos, despawnType, uint32(despawnTime.count()), vehId, spellId, privateObjectOwner); }
|
||||
TempSummon* SummonCreature(uint32 entry, Position const& pos, TempSummonType despawnType, Milliseconds despawnTime, uint32 vehId = 0, uint32 spellId = 0, ObjectGuid privateObjectOwner = ObjectGuid::Empty) { return SummonCreature(entry, pos, despawnType, uint32(despawnTime.count()), vehId, spellId, privateObjectOwner); }
|
||||
TempSummon* SummonCreature(uint32 entry, float x, float y, float z, float o = 0, TempSummonType despawnType = TEMPSUMMON_MANUAL_DESPAWN, uint32 despawnTime = 0, ObjectGuid privateObjectOwner = ObjectGuid::Empty);
|
||||
GameObject* SummonGameObject(uint32 entry, Position const& pos, QuaternionData const& rot, uint32 respawnTime /* s */, GOSummonType summonType = GO_SUMMON_TIMED_OR_CORPSE_DESPAWN);
|
||||
GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, QuaternionData const& rot, uint32 respawnTime /* s */);
|
||||
|
||||
@@ -41,6 +41,7 @@ ScriptReloadMgr* ScriptReloadMgr::instance()
|
||||
#include "Config.h"
|
||||
#include "GitRevision.h"
|
||||
#include "CryptoHash.h"
|
||||
#include "Duration.h"
|
||||
#include "Log.h"
|
||||
#include "MPSCQueue.h"
|
||||
#include "Regex.h"
|
||||
@@ -1035,7 +1036,7 @@ private:
|
||||
// Wait for the current build job to finish, if the job finishes in time
|
||||
// evaluate it and continue with the next one.
|
||||
if (_build_job->GetProcess()->GetFutureResult().
|
||||
wait_for(std::chrono::seconds(0)) == std::future_status::ready)
|
||||
wait_for(0s) == std::future_status::ready)
|
||||
ProcessReadyBuildJob();
|
||||
else
|
||||
return; // Return when the job didn't finish in time
|
||||
|
||||
@@ -893,13 +893,13 @@ void WorldSession::ProcessQueryCallbacks()
|
||||
_queryProcessor.ProcessReadyCallbacks();
|
||||
_transactionCallbacks.ProcessReadyCallbacks();
|
||||
|
||||
if (_realmAccountLoginCallback.valid() && _realmAccountLoginCallback.wait_for(std::chrono::seconds(0)) == std::future_status::ready &&
|
||||
_accountLoginCallback.valid() && _accountLoginCallback.wait_for(std::chrono::seconds(0)) == std::future_status::ready)
|
||||
if (_realmAccountLoginCallback.valid() && _realmAccountLoginCallback.wait_for(0s) == std::future_status::ready &&
|
||||
_accountLoginCallback.valid() && _accountLoginCallback.wait_for(0s) == std::future_status::ready)
|
||||
InitializeSessionCallback(static_cast<LoginDatabaseQueryHolder*>(_realmAccountLoginCallback.get()),
|
||||
static_cast<CharacterDatabaseQueryHolder*>(_accountLoginCallback.get()));
|
||||
|
||||
//! HandlePlayerLoginOpcode
|
||||
if (_charLoginCallback.valid() && _charLoginCallback.wait_for(std::chrono::seconds(0)) == std::future_status::ready)
|
||||
if (_charLoginCallback.valid() && _charLoginCallback.wait_for(0s) == std::future_status::ready)
|
||||
HandlePlayerLogin(reinterpret_cast<LoginQueryHolder*>(_charLoginCallback.get()));
|
||||
|
||||
if (_charEnumCallback.valid() && _charEnumCallback.wait_for(std::chrono::seconds(0)) == std::future_status::ready)
|
||||
|
||||
@@ -167,7 +167,7 @@ public:
|
||||
void SetupGroundPhase()
|
||||
{
|
||||
events.SetPhase(PHASE_GROUND);
|
||||
events.ScheduleEvent(EVENT_CLEAVE, Seconds(0), Seconds(15), GROUP_GROUND);
|
||||
events.ScheduleEvent(EVENT_CLEAVE, 0s, Seconds(15), GROUP_GROUND);
|
||||
events.ScheduleEvent(EVENT_TAIL_SWEEP, Seconds(4), Seconds(23), GROUP_GROUND);
|
||||
events.ScheduleEvent(EVENT_BELLOWING_ROAR, Seconds(48), GROUP_GROUND);
|
||||
events.ScheduleEvent(EVENT_CHARRED_EARTH, Seconds(12), Seconds(18), GROUP_GROUND);
|
||||
|
||||
@@ -386,12 +386,12 @@ public:
|
||||
_assassinCount = 6;
|
||||
_guardianCount = 2;
|
||||
_venomancerCount = 2;
|
||||
events.ScheduleEvent(EVENT_DARTER, Seconds(0), 0, PHASE_SUBMERGE);
|
||||
events.ScheduleEvent(EVENT_DARTER, 0s, 0, PHASE_SUBMERGE);
|
||||
break;
|
||||
}
|
||||
_petCount = _guardianCount + _venomancerCount;
|
||||
if (_assassinCount)
|
||||
events.ScheduleEvent(EVENT_ASSASSIN, Seconds(0), 0, PHASE_SUBMERGE);
|
||||
events.ScheduleEvent(EVENT_ASSASSIN, 0s, 0, PHASE_SUBMERGE);
|
||||
if (_guardianCount)
|
||||
events.ScheduleEvent(EVENT_GUARDIAN, Seconds(4), 0, PHASE_SUBMERGE);
|
||||
if (_venomancerCount)
|
||||
|
||||
@@ -103,7 +103,7 @@ class boss_faerlina : public CreatureScript
|
||||
summons.DoZoneInCombat();
|
||||
events.ScheduleEvent(EVENT_POISON, randtime(Seconds(10), Seconds(15)));
|
||||
events.ScheduleEvent(EVENT_FIRE, randtime(Seconds(6), Seconds(18)));
|
||||
events.ScheduleEvent(EVENT_FRENZY, Minutes(1)+randtime(Seconds(0), Seconds(20)));
|
||||
events.ScheduleEvent(EVENT_FRENZY, Minutes(1)+randtime(0s, Seconds(20)));
|
||||
}
|
||||
|
||||
void Reset() override
|
||||
@@ -173,7 +173,7 @@ class boss_faerlina : public CreatureScript
|
||||
{
|
||||
DoCast(SPELL_FRENZY);
|
||||
Talk(EMOTE_FRENZY);
|
||||
events.Repeat(Minutes(1) + randtime(Seconds(0), Seconds(20)));
|
||||
events.Repeat(Minutes(1) + randtime(0s, Seconds(20)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -528,7 +528,7 @@ class boss_gothik : public CreatureScript
|
||||
break;
|
||||
case EVENT_RESUME_ATTACK:
|
||||
me->SetReactState(REACT_AGGRESSIVE);
|
||||
events.ScheduleEvent(EVENT_BOLT, Seconds(0), 0, PHASE_TWO);
|
||||
events.ScheduleEvent(EVENT_BOLT, 0s, 0, PHASE_TWO);
|
||||
// return to the start of this method so victim side etc is re-evaluated
|
||||
return UpdateAI(0u); // tail recursion for efficiency
|
||||
case EVENT_BOLT:
|
||||
|
||||
@@ -182,7 +182,7 @@ class boss_sapphiron : public CreatureScript
|
||||
me->CastSpell(me, SPELL_FROST_AURA, true);
|
||||
|
||||
events.SetPhase(PHASE_GROUND);
|
||||
events.ScheduleEvent(EVENT_CHECK_RESISTS, Seconds(0));
|
||||
events.ScheduleEvent(EVENT_CHECK_RESISTS, 0s);
|
||||
events.ScheduleEvent(EVENT_BERSERK, Minutes(15));
|
||||
EnterPhaseGround(true);
|
||||
}
|
||||
@@ -207,7 +207,7 @@ class boss_sapphiron : public CreatureScript
|
||||
void MovementInform(uint32 /*type*/, uint32 id) override
|
||||
{
|
||||
if (id == 1)
|
||||
events.ScheduleEvent(EVENT_LIFTOFF, Seconds(0), 0, PHASE_FLIGHT);
|
||||
events.ScheduleEvent(EVENT_LIFTOFF, 0s, 0, PHASE_FLIGHT);
|
||||
}
|
||||
|
||||
void DoAction(int32 param) override
|
||||
|
||||
@@ -223,7 +223,7 @@ class boss_erekem : public CreatureScript
|
||||
task.Repeat(Seconds(8), Seconds(13));
|
||||
});
|
||||
|
||||
scheduler.Schedule(Seconds(0), [this](TaskContext task)
|
||||
scheduler.Schedule(0s, [this](TaskContext task)
|
||||
{
|
||||
for (uint32 i = DATA_EREKEM_GUARD_1; i <= DATA_EREKEM_GUARD_2; ++i)
|
||||
{
|
||||
|
||||
@@ -586,7 +586,7 @@ class npc_azure_saboteur : public CreatureScript
|
||||
{
|
||||
if (type == EFFECT_MOTION_TYPE && pointId == POINT_INTRO)
|
||||
{
|
||||
_scheduler.Schedule(Seconds(0), [this](TaskContext task)
|
||||
_scheduler.Schedule(0s, [this](TaskContext task)
|
||||
{
|
||||
me->CastSpell(me, SPELL_SHIELD_DISRUPTION, false);
|
||||
|
||||
|
||||
@@ -1459,7 +1459,7 @@ public:
|
||||
switch (me->GetEntry())
|
||||
{
|
||||
case NPC_ENRAGED_WATER_SPIRIT:
|
||||
_events.ScheduleEvent(EVENT_ENRAGED_WATER_SPIRIT, Seconds(0), Seconds(1));
|
||||
_events.ScheduleEvent(EVENT_ENRAGED_WATER_SPIRIT, 0s, Seconds(1));
|
||||
break;
|
||||
case NPC_ENRAGED_FIRE_SPIRIT:
|
||||
if (!me->GetAura(SPELL_FEL_FIRE_AURA))
|
||||
|
||||
Reference in New Issue
Block a user