I'm going through the ROM source code (db.c file, ROM 2.4) and I'm trying to figure out how ROM does its timing and I just don't understand how this code works...
/*
* Set time and weather.
*/
{
long lhour, lday, lmonth;
lhour = (current_time - 650336715)
/ (PULSE_TICK / PULSE_PER_SECOND);
time_info.hour = lhour % 24;
lday = lhour / 24;
time_info.day = lday % 35;
lmonth = lday / 35;
time_info.month = lmonth % 17;
time_info.year = lmonth / 17;
Okay -- what is the significance of 650336715? What exactly is the code that divides to get lhour doing? I'm not as concerned with the code below it, but an explanation of why 35 and 17 are used would be helpful too.
One last question -- what kind value is current_time? Is it the current time in seconds? In comm.c, it is defined as:
time_t current_time; /* time of this pulse */
and later it is defined as:
gettimeofday( &now_time, NULL );
current_time = (time_t) now_time.tv_sec;
Gettimeofday's function:
int gettimeofday( struct timeval *tp, void *tzp )
{
tp->tv_sec = time( NULL );
tp->tv_usec = 0;
}
Hope this helps. I'm just trying to get some clarification on what this code is doing and maybe some background help on how the time system works in ROM or any other text-based role playing game. I've heard the time in ROM is 2 hours = 1 year -- is this correct? How can this be changed or verified?
/*
* Set time and weather.
*/
{
long lhour, lday, lmonth;
lhour = (current_time - 650336715)
/ (PULSE_TICK / PULSE_PER_SECOND);
time_info.hour = lhour % 24;
lday = lhour / 24;
time_info.day = lday % 35;
lmonth = lday / 35;
time_info.month = lmonth % 17;
time_info.year = lmonth / 17;
Okay -- what is the significance of 650336715? What exactly is the code that divides to get lhour doing? I'm not as concerned with the code below it, but an explanation of why 35 and 17 are used would be helpful too.
One last question -- what kind value is current_time? Is it the current time in seconds? In comm.c, it is defined as:
time_t current_time; /* time of this pulse */
and later it is defined as:
gettimeofday( &now_time, NULL );
current_time = (time_t) now_time.tv_sec;
Gettimeofday's function:
int gettimeofday( struct timeval *tp, void *tzp )
{
tp->tv_sec = time( NULL );
tp->tv_usec = 0;
}
Hope this helps. I'm just trying to get some clarification on what this code is doing and maybe some background help on how the time system works in ROM or any other text-based role playing game. I've heard the time in ROM is 2 hours = 1 year -- is this correct? How can this be changed or verified?