Avoid rollover in _RyzomDay for low values

--HG--
branch : save_deposit_state_v2
This commit is contained in:
Guillaume Dupuy 2017-04-10 01:56:44 +02:00
parent e5e2ccf45c
commit a1fbc963a9

View file

@ -85,13 +85,16 @@ namespace WEEKDAY
void CRyzomTime::updateRyzomClock(uint32 gameCyle) void CRyzomTime::updateRyzomClock(uint32 gameCyle)
{ {
static const uint32 ticksPerDay = (RYZOM_DAY_IN_HOUR * RYZOM_HOURS_IN_TICKS);
static const float ticksPerHour = (float)RYZOM_HOURS_IN_TICKS; static const float ticksPerHour = (float)RYZOM_HOURS_IN_TICKS;
uint32 totalTicks = gameCyle + _TickOffset; uint32 totalTicks = gameCyle + _TickOffset;
uint32 days = totalTicks / ticksPerDay; uint32 days = totalTicks / RYZOM_DAY_IN_TICKS;
uint32 dayCycle = totalTicks - (days * ticksPerDay); uint32 dayCycle = totalTicks - (days * RYZOM_DAY_IN_TICKS);
// Avoid rollover for low amount of days
if(days >= RYZOM_START_SPRING)
days -= RYZOM_START_SPRING; days -= RYZOM_START_SPRING;
else
days = 0;
float hours = (float)dayCycle / ticksPerHour; float hours = (float)dayCycle / ticksPerHour;
_RyzomDay = days; _RyzomDay = days;