aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2025-01-19 18:29:38 +0100
committerShauren <shauren.trinity@gmail.com>2025-01-19 18:29:38 +0100
commitcb4013efe67a875dc19ef3bcd5b8c142f5a131d6 (patch)
treeb00de9bbf536e78a915272fe791856087a999a9a /src
parent453ae0ab88eb7c64cb10f35302c337ec99e272b5 (diff)
Core/Misc: Added float chrono typedefs
Diffstat (limited to 'src')
-rw-r--r--src/common/Utilities/Duration.h22
-rw-r--r--src/server/game/Spells/Auras/SpellAuras.cpp6
-rw-r--r--src/server/scripts/Spells/spell_dh.cpp2
-rw-r--r--src/server/scripts/Spells/spell_evoker.cpp2
4 files changed, 17 insertions, 15 deletions
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 <http://www.gnu.org/licenses/>.
*/
-#ifndef _DURATION_H_
-#define _DURATION_H_
+#ifndef TRINITYCORE_DURATION_H
+#define TRINITYCORE_DURATION_H
#include <chrono>
/// Milliseconds shorthand typedef.
-typedef std::chrono::milliseconds Milliseconds;
+using Milliseconds = std::chrono::milliseconds;
+using FloatMilliseconds = std::chrono::duration<float, Milliseconds::period>;
/// Seconds shorthand typedef.
-typedef std::chrono::seconds Seconds;
+using Seconds = std::chrono::seconds;
+using FloatSeconds = std::chrono::duration<float, Seconds::period>;
/// Minutes shorthand typedef.
-typedef std::chrono::minutes Minutes;
+using Minutes = std::chrono::minutes;
+using FloatMinutes = std::chrono::duration<float, Minutes::period>;
/// Hours shorthand typedef.
-typedef std::chrono::hours Hours;
+using Hours = std::chrono::hours;
+using FloatHours = std::chrono::duration<float, Hours::period>;
/// 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 2a29366ae6d..3d7664f19b6 100644
--- a/src/server/game/Spells/Auras/SpellAuras.cpp
+++ b/src/server/game/Spells/Auras/SpellAuras.cpp
@@ -2010,15 +2010,13 @@ void Aura::TriggerProcOnEvent(uint32 procEffectMask, AuraApplication* aurApp, Pr
float Aura::CalcPPMProcChance(Unit* actor) const
{
- using FSeconds = std::chrono::duration<float, Seconds::period>;
-
// 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<FSeconds>(currentTime - m_lastProcAttemptTime).count(), 10.0f);
- float secondsSinceLastProc = std::min(std::chrono::duration_cast<FSeconds>(currentTime - m_lastProcSuccessTime).count(), 1000.0f);
+ float secondsSinceLastAttempt = std::min(duration_cast<FloatSeconds>(currentTime - m_lastProcAttemptTime).count(), 10.0f);
+ float secondsSinceLastProc = std::min(duration_cast<FloatSeconds>(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);
diff --git a/src/server/scripts/Spells/spell_dh.cpp b/src/server/scripts/Spells/spell_dh.cpp
index da84f70c52f..1b7b37adf13 100644
--- a/src/server/scripts/Spells/spell_dh.cpp
+++ b/src/server/scripts/Spells/spell_dh.cpp
@@ -971,7 +971,7 @@ struct at_dh_glaive_tempest : AreaTriggerAI
{
_scheduler.Schedule(0ms, [this](TaskContext task)
{
- std::chrono::duration<float> period = 500ms; // 500ms, affected by haste
+ FloatMilliseconds period = 500s; // 500ms, affected by haste
if (Unit* caster = at->GetCaster())
{
period *= *caster->m_unitData->ModHaste;
diff --git a/src/server/scripts/Spells/spell_evoker.cpp b/src/server/scripts/Spells/spell_evoker.cpp
index 7e371042134..82eb493dc04 100644
--- a/src/server/scripts/Spells/spell_evoker.cpp
+++ b/src/server/scripts/Spells/spell_evoker.cpp
@@ -384,7 +384,7 @@ struct at_evo_firestorm : AreaTriggerAI
_scheduler.Schedule(0ms, [this](TaskContext task)
{
- std::chrono::duration<float> period = 2s; // 2s, affected by haste
+ FloatMilliseconds period = 2s; // 2s, affected by haste
if (Unit* caster = at->GetCaster())
{
period *= *caster->m_unitData->ModCastingSpeed;