|
|
@ -175,6 +175,42 @@
|
|
|
|
#include "nel/misc/hierarchical_timer.h"
|
|
|
|
#include "nel/misc/hierarchical_timer.h"
|
|
|
|
inline uint32 saveGameCycleToSecond(NLMISC::TGameCycle tick)
|
|
|
|
inline uint32 saveGameCycleToSecond(NLMISC::TGameCycle tick)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// Evaluate the UTC of this event (with the current date of save). Suppose that 1 second==10 tick
|
|
|
|
|
|
|
|
// NB: result should be positive since no event should have been launched before 1970!
|
|
|
|
|
|
|
|
if (tick < CTickEventHandler::getGameCycle())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
NLMISC::TGameCycle tick_dt = CTickEventHandler::getGameCycle() - tick;
|
|
|
|
|
|
|
|
uint32 s_dt = tick_dt / 10;
|
|
|
|
|
|
|
|
return NLMISC::CTime::getSecondsSince1970() - s_dt;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
NLMISC::TGameCycle tick_dt = tick - CTickEventHandler::getGameCycle();
|
|
|
|
|
|
|
|
uint32 s_dt = tick_dt / 10;
|
|
|
|
|
|
|
|
return NLMISC::CTime::getSecondsSince1970() + s_dt;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
inline NLMISC::TGameCycle loadSecondToGameCycle(uint32 second)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (second < NLMISC::CTime::getSecondsSince1970())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
uint32 s_dt = NLMISC::CTime::getSecondsSince1970() - second;
|
|
|
|
|
|
|
|
NLMISC::TGameCycle tick_dt = s_dt * 10;
|
|
|
|
|
|
|
|
return CTickEventHandler::getGameCycle() - tick_dt;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
uint32 s_dt = second - NLMISC::CTime::getSecondsSince1970();
|
|
|
|
|
|
|
|
NLMISC::TGameCycle tick_dt = s_dt * 10;
|
|
|
|
|
|
|
|
return CTickEventHandler::getGameCycle() + tick_dt;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*inline uint32 saveGameCycleToSecond(NLMISC::TGameCycle tick)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sint32 dt = CTickEventHandler::getGameCycle() - tick;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Evaluate the UTC of this event (with the current date of save). Suppose that 1 second==10 tick
|
|
|
|
// Evaluate the UTC of this event (with the current date of save). Suppose that 1 second==10 tick
|
|
|
|
if (tick < CTickEventHandler::getGameCycle())
|
|
|
|
if (tick < CTickEventHandler::getGameCycle())
|
|
|
|
return NLMISC::CTime::getSecondsSince1970();
|
|
|
|
return NLMISC::CTime::getSecondsSince1970();
|
|
|
@ -190,7 +226,7 @@ inline NLMISC::TGameCycle loadSecondToGameCycle(uint32 second)
|
|
|
|
|
|
|
|
|
|
|
|
// Convert UTC of the event to game cycle. Suppose that 1 second==10 tick
|
|
|
|
// Convert UTC of the event to game cycle. Suppose that 1 second==10 tick
|
|
|
|
return CTickEventHandler::getGameCycle() + (second - NLMISC::CTime::getSecondsSince1970())*10;
|
|
|
|
return CTickEventHandler::getGameCycle() + (second - NLMISC::CTime::getSecondsSince1970())*10;
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// GameCycle property (saved as a UTC of the current game cycle, support server migration)
|
|
|
|
// GameCycle property (saved as a UTC of the current game cycle, support server migration)
|
|
|
|