Question about Time_Info

Posted by Kelsid on Tue 13 Nov 2001 08:50 PM — 5 posts, 19,799 views.

USA #0
I had a quick question about time_info.hour:


Basically what Im trying to do, is stop the compression of time in the normal smaug code. Ive figured out where the time_info data is processed in db.c

the code is as follows:


    /*
     * Set time and weather.
     */
    {
	long lhour, lday, lmonth;

	log_string("Setting time and weather");

	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 % 12;
	time_info.year	= lmonth / 12;



Basically I want to make time flow with the current_time. I know the problems is either with the 1hour or time_info.hour variables.

Any suggestions would be welcome.


Thanks,
-Kelsid
Australia Forum Administrator #1
Probably the simplest thing is to adjust lhour before the calculations. I'm not sure what the compression is, but if it is 5 times, then dividing lhour by 5 should slow it down.

eg.


lhour /= 5;


Alternatively, get the current time and just stuff the hour, day and month into the appropriate variables (time_info.hour and so on).
USA #2
Thanks again Nick,


Actually.... Id rather go with the current_time, How would I get the hours, day, and month from current_time(to make them the time_info equivalants)?

Thanks again,


Kelsid
Australia Forum Administrator #3
I haven't tested it, but something like this:


struct tm *now_time;

now_time = localtime(&current_time);
time_info.min = now_time->tm_min;
time_info.hour = now_time->tm_hour;

// and so on

USA #4
Thanks for a point in the right direction Nick,


For Anyones info....


The problem I encountered was in update.c....

Had a bunch of small modifications there.

-Kelsid