feat(util): add CGameTime::GameTimeSetMinutesPerSecond

This commit is contained in:
fallenoak 2026-01-29 08:46:57 -06:00
parent 6e7c267d3e
commit 53b26169f3
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
2 changed files with 20 additions and 1 deletions

View File

@ -1,6 +1,20 @@
#include "util/time/CGameTime.hpp"
#include "common/Time.hpp"
float CGameTime::GameTimeSetMinutesPerSecond(float minutesPerSec) {
float oldMinutesPerSec = this->m_gameMinutesPerRealSecond;
if (minutesPerSec > CGameTime::MAX_SPEED) {
minutesPerSec = CGameTime::MAX_SPEED;
} else if (minutesPerSec < CGameTime::MIN_SPEED) {
minutesPerSec = CGameTime::MIN_SPEED;
}
this->m_gameMinutesPerRealSecond = minutesPerSec;
return oldMinutesPerSec;
}
void CGameTime::GameTimeSetTime(const WowTime& time, bool shouldTick) {
WowTime biasTime = time;

View File

@ -5,7 +5,12 @@
class CGameTime : public WowTime {
public:
// Public static variables
static constexpr float MIN_SPEED = 1.0f / 60.0f;
static constexpr float MAX_SPEED = 60.0f;
// Public member functions
float GameTimeSetMinutesPerSecond(float minutesPerSec);
void GameTimeSetTime(const WowTime& time, bool shouldTick);
void GameTimeUpdate(float elapsedSec);
@ -15,7 +20,7 @@ class CGameTime : public WowTime {
int32_t m_timeBias = 0;
int32_t m_dateBias = 0;
uint32_t m_gameMinutesElapsed = 0;
float m_gameMinutesPerRealSecond = 1.0f / 60.0f;
float m_gameMinutesPerRealSecond = MIN_SPEED;
float m_gameMinutesThisTick = 0.0f;
uint32_t m_timeDifferential = 0;
uint32_t m_lastTickMinute = 0;