Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ Question about Time_Info
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Kelsid
USA (35 posts) Bio
|
| Date
| Tue 13 Nov 2001 08:50 PM (UTC) |
| Message
| 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 |
-Kelsid | | Top |
|
| Posted by
| Nick Gammon
Australia (23,165 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Tue 13 Nov 2001 09:23 PM (UTC) |
| Message
| 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). |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Kelsid
USA (35 posts) Bio
|
| Date
| Reply #2 on Tue 13 Nov 2001 09:45 PM (UTC) |
| Message
| 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 |
-Kelsid | | Top |
|
| Posted by
| Nick Gammon
Australia (23,165 posts) Bio
Forum Administrator |
| Date
| Reply #3 on Tue 13 Nov 2001 11:20 PM (UTC) |
| Message
| I haven't tested it, but something like this:
struct tm *now_time;
now_time = localtime(¤t_time);
time_info.min = now_time->tm_min;
time_info.hour = now_time->tm_hour;
// and so on
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Kelsid
USA (35 posts) Bio
|
| Date
| Reply #4 on Mon 26 Nov 2001 02:25 AM (UTC) |
| Message
| 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 |
-Kelsid | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
17,397 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top