mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 01:09:50 +00:00
Avoid rollover in _RyzomDay for low values
--HG-- branch : save_deposit_state_v2
This commit is contained in:
parent
e5e2ccf45c
commit
a1fbc963a9
1 changed files with 7 additions and 4 deletions
|
@ -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);
|
||||||
days -= RYZOM_START_SPRING;
|
// Avoid rollover for low amount of days
|
||||||
|
if(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;
|
||||||
|
|
Loading…
Reference in a new issue