Time?

Posted by Malti on Fri 13 Jul 2007 09:24 PM — 6 posts, 24,298 views.

USA #0
Okay so here is the deal. A normal hour in the mud is roughly (or exactly) 60 seconds. How do I extend the hour to 5 minutes persay? I know the hour gets updated in weather_update which gets called in update.c from do_update or whatever. Can I see it so that this gets called every 5 pulses or so? Any suggestions/codes would be appreciated. Thanks
United Kingdom #1
I think your after the code in db.c


      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;


If im correct... an hour is a day. So there for changing the 24 to a smaller number, should reduce the speed of time passing by...

Hope its what you want.
USA #2
I think that's the code to set up the initial time. I think you want to be looking at update.c -- every tick increment, it decides whether or not it is time to increment the various clocks like in-game hours, days, months...
USA #3
It is in update.c, i am well aware. However, I do not know how to extand it from updating every pulse/tick which I believe is every minute? Any help is greatly appreciated. Thanks
USA #4
Well, if you go to update_handler, you'll see that when pulse_point gets to zero it calls a bunch of functions like time_update, which adds an hour to the clock. It also resets pulse_point to be PULSE_TICK plus or minus a little noise.

If you want to make hours longer, you have several options:

- You can make everything about hours take longer, in which case you would increase PULSE_TICK (you'd have to work out the math to figure out what value to use depending on how long you want it to last; look at pulse/second and tick/second etc.)

- You can leave char updates, weather etc. at the current frequency (~1 minute) and only have the hours take longer; that's a little harder and you will need another counter for that.
USA #5
mud.h:
#define PULSE_TIME (PULSE_PER_SECOND * 3)

update.c:
void update_handler() ----
if (--pulse_time <= 0)
{
pulse_time = (PULSE_TIME/6);
time_update();
}

void time_update() ----
time_info.minute++ >= 60

I do not remember how stock smaug is setup, as i changed mine quite some time ago. But essentially this setup gives me 1 mud minute every 1.5 seconds, making that 1 mud hour every 90 seconds. But the pulse_time variable in update_handler is what will be controlling your mud time. i recommend not changing the define in mud.h, as i recall it messed things up considerably, can't remember what happened though.