From 54d64860348be2307266a17d7af44bef5b128bbf Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 19 Jan 2025 18:29:38 +0100 Subject: Core/Misc: Added float chrono typedefs (cherry picked from commit cb4013efe67a875dc19ef3bcd5b8c142f5a131d6) # Conflicts: # src/server/scripts/Spells/spell_dh.cpp # src/server/scripts/Spells/spell_evoker.cpp --- src/common/Utilities/Duration.h | 22 +++++++++++++--------- src/server/game/Spells/Auras/SpellAuras.cpp | 6 ++---- 2 files changed, 15 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/common/Utilities/Duration.h b/src/common/Utilities/Duration.h index f506467abda..8ad5be0a10b 100644 --- a/src/common/Utilities/Duration.h +++ b/src/common/Utilities/Duration.h @@ -15,22 +15,26 @@ * with this program. If not, see . */ -#ifndef _DURATION_H_ -#define _DURATION_H_ +#ifndef TRINITYCORE_DURATION_H +#define TRINITYCORE_DURATION_H #include /// Milliseconds shorthand typedef. -typedef std::chrono::milliseconds Milliseconds; +using Milliseconds = std::chrono::milliseconds; +using FloatMilliseconds = std::chrono::duration; /// Seconds shorthand typedef. -typedef std::chrono::seconds Seconds; +using Seconds = std::chrono::seconds; +using FloatSeconds = std::chrono::duration; /// Minutes shorthand typedef. -typedef std::chrono::minutes Minutes; +using Minutes = std::chrono::minutes; +using FloatMinutes = std::chrono::duration; /// Hours shorthand typedef. -typedef std::chrono::hours Hours; +using Hours = std::chrono::hours; +using FloatHours = std::chrono::duration; /// time_point shorthand typedefs typedef std::chrono::steady_clock::time_point TimePoint; @@ -39,9 +43,9 @@ typedef std::chrono::system_clock::time_point SystemTimePoint; /// Makes std::chrono_literals globally available. using namespace std::chrono_literals; -constexpr std::chrono::hours operator""_days(unsigned long long days) +constexpr std::chrono::days operator""_days(unsigned long long days) { - return std::chrono::hours(days * 24h); + return std::chrono::days(days); } -#endif // _DURATION_H_ +#endif // TRINITYCORE_DURATION_H diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index 7afc63628dc..7572a80a377 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -2013,15 +2013,13 @@ void Aura::TriggerProcOnEvent(uint32 procEffectMask, AuraApplication* aurApp, Pr float Aura::CalcPPMProcChance(Unit* actor) const { - using FSeconds = std::chrono::duration; - // Formula see http://us.battle.net/wow/en/forum/topic/8197741003#1 float ppm = m_spellInfo->CalcProcPPM(actor, GetCastItemLevel()); float averageProcInterval = 60.0f / ppm; TimePoint currentTime = GameTime::Now(); - float secondsSinceLastAttempt = std::min(std::chrono::duration_cast(currentTime - m_lastProcAttemptTime).count(), 10.0f); - float secondsSinceLastProc = std::min(std::chrono::duration_cast(currentTime - m_lastProcSuccessTime).count(), 1000.0f); + float secondsSinceLastAttempt = std::min(duration_cast(currentTime - m_lastProcAttemptTime).count(), 10.0f); + float secondsSinceLastProc = std::min(duration_cast(currentTime - m_lastProcSuccessTime).count(), 1000.0f); float chance = std::max(1.0f, 1.0f + ((secondsSinceLastProc / averageProcInterval - 1.5f) * 3.0f)) * ppm * secondsSinceLastAttempt / 60.0f; RoundToInterval(chance, 0.0f, 1.0f); -- cgit v1.2.3