Avoid rollover in _RyzomDay for low values

--HG--
branch : save_deposit_state_v2
hg/compatibility-develop
Guillaume Dupuy 8 years ago
parent e5e2ccf45c
commit a1fbc963a9

@ -85,13 +85,16 @@ namespace WEEKDAY
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;
uint32 totalTicks = gameCyle + _TickOffset;
uint32 days = totalTicks / ticksPerDay;
uint32 dayCycle = totalTicks - (days * ticksPerDay);
uint32 days = totalTicks / RYZOM_DAY_IN_TICKS;
uint32 dayCycle = totalTicks - (days * RYZOM_DAY_IN_TICKS);
// Avoid rollover for low amount of days
if(days >= RYZOM_START_SPRING)
days -= RYZOM_START_SPRING;
else
days = 0;
float hours = (float)dayCycle / ticksPerHour;
_RyzomDay = days;

Loading…
Cancel
Save