Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
Bug in get_exp_worth( )
Oct 10, 2017, 1:26 am
By GatewaySysop
Bug in do_drag( )
Oct 8, 2017, 12:40 am
By GatewaySysop
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Beastmaster 6D sound files
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl, Yandex, Bing, Google, Yahoo!, Majestic-12

Members: 0
Guests: 5
Stats
Files
Topics
Posts
Members
Newest Member
476
3,704
19,231
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » SWR FUSS » MUD Time
Forum Rules | Mark all | Recent Posts

MUD Time
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Nov 12, 2008, 10:33 am
Go to the top of the page
Go to the bottom of the page

Krylan
Fledgling
GroupMembers
Posts39
JoinedApr 14, 2005

I have decided I'd like to change the time on my SWR FUSS to reflect that of real life time. Meaning a 24 hour day on the MUD and the likes, however I do not want to affect timers and the likes. Just the time system and the weather system. Anybody have any idea how I would go about doing this? I'm rather clueless on this one...


       
Post is unread #2 Dec 1, 2008, 5:54 pm
Go to the top of the page
Go to the bottom of the page

chaoscayne
Fledgling
GroupMembers
Posts15
JoinedNov 29, 2008

well I know it falls under "Set time and weather." in db.c
Not exactly sure how it's doing that math with the way it's set up.

here is the time code that I have -
/*
* 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 % 17;
time_info.year = lmonth / 17;

if ( time_info.hour < 5 ) weather_info.sunlight = SUN_DARK;
else if ( time_info.hour < 6 ) weather_info.sunlight = SUN_RISE;
else if ( time_info.hour < 19 ) weather_info.sunlight = SUN_LIGHT;
else if ( time_info.hour < 20 ) weather_info.sunlight = SUN_SET;
else weather_info.sunlight = SUN_DARK;

weather_info.change = 0;
weather_info.mmhg = 960;
if ( time_info.month >= 7 && time_info.month <=12 )
weather_info.mmhg += number_range( 1, 50 );
else
weather_info.mmhg += number_range( 1, 80 );

if ( weather_info.mmhg <= 980 ) weather_info.sky = SKY_LIGHTNING;
else if ( weather_info.mmhg <= 1000 ) weather_info.sky = SKY_RAINING;
else if ( weather_info.mmhg <= 1020 ) weather_info.sky = SKY_CLOUDY;
else weather_info.sky = SKY_CLOUDLESS;

}
**Pulse Code
#define PULSE_PER_SECOND 4
#define PULSE_MINUTE ( 60 * PULSE_PER_SECOND)
#define PULSE_TICK ( 70 * PULSE_PER_SECOND)

The bolded part is what has me confused.....
was looking to do something similar, but not drop it all the way down to 1_MUD_day = 1_RL_day, more along the lines of 3_MUD_day = 1_RL_day

if i'm reading this right....with my current settings I have 240 pulses per RL minute and 14,400 pulses per RL hour
       
Post is unread #3 Dec 2, 2008, 8:37 pm
Go to the top of the page
Go to the bottom of the page

Keberus
Conjurer
GroupFUSS Project Team
Posts341
JoinedJun 4, 2005

Davidhaley put it well in a post on the gammon forums:

current_time is the number of seconds since the Epoch, which is typically Jan-01-1970 00:00.


A quick google search I came across a wikipedia reference to the Epoch related to Linux/Unix machines:

Unix time, or POSIX time, is a system for describing points in time, defined as the number of seconds elapsed since midnight Coordinated Universal Time (UTC) of January 1, 1970, not counting leap seconds. It is widely used not only on Unix-like operating systems but also in many other computing systems. It is neither a linear representation of time nor a true representation of UTC (though it is frequently mistaken for both) as the times it represents are UTC but it has no way of representing UTC leap seconds (e.g. 1998-12-31 23:59:60).


Which was interesting enough to find out, I remembered something about it from classes but this really brought it back home. Kinda cool to know.
       
Post is unread #4 Dec 3, 2008, 1:34 am
Go to the top of the page
Go to the bottom of the page

chaoscayne
Fledgling
GroupMembers
Posts15
JoinedNov 29, 2008

it is a good bit of information. . .but still leaves me a little confused on how to disect it to make it so only 3 days pass in the game for ever real day. I even scoured through the code in other files to find references to it. Currently time is passing at 1 mud hour for every 1.1 - 1.3 real minutes
       
Post is unread #5 Dec 3, 2008, 7:51 am
Go to the top of the page
Go to the bottom of the page

David Haley
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007

If you want three game days to pass for one real day, you want one game day for eight hours. That means that you want three game hours for every real hour. That means that you want one game hour every twenty minutes. If you have x pulses per minute, you want to advance the hour every 20*x pulses.

Or, you can look at it this way. Since you have this:

lhour = (current_time - 650336715)
/ (PULSE_TICK / PULSE_PER_SECOND); 


And:
#define PULSE_PER_SECOND     4
#define PULSE_MINUTE              ( 60 * PULSE_PER_SECOND)
#define PULSE_TICK   ( 70 * PULSE_PER_SECOND) 


This means that lhour is advances by one every 70 seconds. Because: lhour = number of seconds / ( (70/PPS) / PPS) = number of seconds / 70

So, since we saw above that you want one game hour for every 20 minutes, or 1200 seconds, you want:

lhour = number of seconds / 1200

where number of seconds = current_time - (whatever that number is)


I would not recommend messing too much with the pulse values themselves as that will change everything else too (like combat speed, effect durations, ...). Changing the the above lhour calculation lets you change the passage of clock time, but doesn't affect game time.
       
Post is unread #6 Dec 3, 2008, 4:51 pm
Go to the top of the page
Go to the bottom of the page

chaoscayne
Fledgling
GroupMembers
Posts15
JoinedNov 29, 2008

well i changed the line of code to

	lhour		= (current_time - 650336715) / 1200;


and game hours are still rolling by at about 1.2 minutes each so I'm still a bit confused. I understand what your trying to say....but i played with the numbers a bit to try to actually change it, tried * 1200 instead but still same result. . .each game hour passes at 1.2 minutes each.

       
Post is unread #7 Dec 3, 2008, 7:20 pm
Go to the top of the page
Go to the bottom of the page

Keberus
Conjurer
GroupFUSS Project Team
Posts341
JoinedJun 4, 2005

As far as when to update the hour of the mud, *I think* you really need to look at update.c.

in update_handler you should see something like this:
   if( --pulse_point <= 0 )
   {
      pulse_point = number_range( ( int )( PULSE_TICK * 0.75 ), ( int )( PULSE_TICK * 1.25 ) );

      auth_update(  );  /* Gorog */
      time_update(  );  /* If looking for slower passing time, move this to just above char_calendar_update(  ); */


Which seems to mathmatically make pulse point between 52.5 seconds and 87.5 seconds anyways notice that time_update() is called.

here is a snippet from time_update in update.c
/*
 * update the time
 */
void time_update( void )
{
   DESCRIPTOR_DATA *d;
   int n;
   const char *echo; /* echo string */
   int echo_color;   /* color for the echo */

   n = number_bits( 2 );
   echo = NULL;
   echo_color = AT_GREY;

   ++time_info.hour;


notice how time_info.hour is updated here with the ++ incrementor.

So I think the way to actually change how the hour is updated would be to change the pulse value thats related to it.

In update.c, function update_handler find:
   static int pulse_time;


and under it add:
   static int pulse_update_time;


then find:
   if( --pulse_point <= 0 )
   {
      pulse_point = number_range( ( int )( PULSE_TICK * 0.75 ), ( int )( PULSE_TICK * 1.25 ) );

      auth_update(  );  /* Gorog */
      time_update(  );  /* If looking for slower passing time, move this to just above char_calendar_update(  ); */
      UpdateWeather(  ); /* New Weather Updater -Kayle */
      hint_update(  );
      char_update(  );
      obj_update(  );
      clear_vrooms(  ); /* remove virtual rooms */
   }


and change to:
   if( --pulse_point <= 0 )
   {
      pulse_point = number_range( ( int )( PULSE_TICK * 0.75 ), ( int )( PULSE_TICK * 1.25 ) );

      auth_update(  );  /* Gorog */
      UpdateWeather(  ); /* New Weather Updater -Kayle */
      hint_update(  );
      char_update(  );
      obj_update(  );
      clear_vrooms(  ); /* remove virtual rooms */
   }


and under it add:
   if( --pulse_update_time <= 0 )
   {
      //PPS * 60 gives you 1 min, * 20 gives you 20 min
      pulse_update_time = ( PULSE_PER_SECOND * 60 * 20);
      time_update(  );  /* If looking for slower passing time, move this to just above char_calendar_update(  ); */
   }


Let me know if that works or doesn't.

Later,
KeB
       
Post is unread #8 Dec 3, 2008, 7:45 pm   Last edited Dec 3, 2008, 7:53 pm by chaoscayne
Go to the top of the page
Go to the bottom of the page

chaoscayne
Fledgling
GroupMembers
Posts15
JoinedNov 29, 2008

that code actually doesn't exist in update.c, period, well....not the time_update part......just not there anywhere in file

This is the only and closest reference to time_update i could find....
act_wiz.c,
struct tm *update_time ( struct tm *old_time )
{
   time_t time;

   time = mktime(old_time); 
   return localtime(&time);
}


Did find this thou that is close to what you were saying but not exactly...looks like the weather command is what is adjusting the hours
/*
 * Update the weather.
 */
void weather_update( void )
{
    char buf[MAX_STRING_LENGTH];
    DESCRIPTOR_DATA *d;
    int diff;
    sh_int AT_TEMP = AT_PLAIN;

    buf[0] = '\0';

    switch ( ++time_info.hour )
    {
    case  5:
	weather_info.sunlight = SUN_LIGHT;
	strcat( buf, "The day has begun." );
        AT_TEMP = AT_YELLOW;
	break;

    case  6:
	weather_info.sunlight = SUN_RISE;
	strcat( buf, "The sun rises in the east." );
        AT_TEMP = AT_ORANGE;
	break;

    case 12:
        weather_info.sunlight = SUN_LIGHT;
        strcat( buf, "It's noon." ); 
        AT_TEMP = AT_YELLOW;
   	break;
	
    case 19:
	weather_info.sunlight = SUN_SET;
	strcat( buf, "The sun slowly disappears in the west." );
        AT_TEMP = AT_BLOOD;
  	break;

    case 20:
	weather_info.sunlight = SUN_DARK;
	strcat( buf, "The night has begun." );
        AT_TEMP = AT_DGREY;
	break;

    case 24:
	time_info.hour = 0;
	time_info.day++;
	break;
    }

    if ( time_info.day   >= 30 )
    {
	time_info.day = 0;
	time_info.month++;
    }

    if ( time_info.month >= 17 )
    {
	time_info.month = 0;
	time_info.year++;
    }

    if ( buf[0] != '\0' )
    {
	for ( d = first_descriptor; d; d = d->next )
	{
	    if ( d->connected == CON_PLAYING
	    &&   IS_OUTSIDE(d->character)
	    &&   IS_AWAKE(d->character)
	    &&   d->character->in_room
	    &&   d->character->in_room->sector_type != SECT_UNDERWATER
	    &&   d->character->in_room->sector_type != SECT_OCEANFLOOR 
	    &&   d->character->in_room->sector_type != SECT_UNDERGROUND ) 
		act( AT_TEMP, buf, d->character, 0, 0, TO_CHAR );
	}
        buf[0] = '\0';
    }
       
Post is unread #9 Dec 3, 2008, 7:53 pm   Last edited Dec 3, 2008, 7:55 pm by Keberus
Go to the top of the page
Go to the bottom of the page

Keberus
Conjurer
GroupFUSS Project Team
Posts341
JoinedJun 4, 2005

Ah sorry, your using swrip, not smaugfuss.

in that case in update.c function update_handler find
  static int pulse_time;


and under it add:
   static int pulse_update_time;


then find:
    if ( --pulse_point    <= 0 )
    {
        pulse_point     = number_range( (int) ( PULSE_TICK * 0.75 ), (int) (PULSE_TICK * 1.25) );

        /*auth_update     ( );*/                        /* Gorog */
        weather_update  ( );
        char_update     ( );
        obj_update      ( );
        clear_vrooms    ( );                    /* remove virtual rooms */
    }


change it to:
    if ( --pulse_point    <= 0 )
    {
        pulse_point     = number_range( (int) ( PULSE_TICK * 0.75 ), (int) (PULSE_TICK * 1.25) );

        /*auth_update     ( );*/                        /* Gorog */
        char_update     ( );
        obj_update      ( );
        clear_vrooms    ( );                    /* remove virtual rooms */
    }


under it add:
   if( --pulse_update_time <= 0 )
   {
      //PPS * 60 gives you 1 min, * 20 gives you 20 min
      pulse_update_time = ( PULSE_PER_SECOND * 60 * 20);
      weather_update();
   }


for proof heres a snippet of weather_update from swrip2.0
/*
 * Update the weather.
 */
void weather_update( void )
{
    char buf[MAX_STRING_LENGTH];
    DESCRIPTOR_DATA *d;
    int diff;
    sh_int AT_TEMP = AT_PLAIN;

    buf[0] = '\0';

    switch ( ++time_info.hour )


Notice the time_info.time_info.hour is incremented there.

All, I'm really having you do is create a new timer with a different value, and making weather_update get called a lot less, but since weater_update updates the hour, i figure its all good.

Anyways, sorry for the mixup.

Let me know how it goes.
->KeB
       
Post is unread #10 Dec 3, 2008, 8:10 pm   Last edited Dec 3, 2008, 8:18 pm by chaoscayne
Go to the top of the page
Go to the bottom of the page

chaoscayne
Fledgling
GroupMembers
Posts15
JoinedNov 29, 2008

it seems to be working now. . .got to let it run awhile to test it. . . .appreciate the help. Will let you know if it goes wonky again. Now to dig into the combat system to convert it back over to a d20 system, or at least one with new EVC (Evasion Class) for defense and AC for damage asorbtion %
       
Post is unread #11 Dec 4, 2008, 7:40 am
Go to the top of the page
Go to the bottom of the page

David Haley
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007

I think that the initial code we were looking at -- the lhour stuff -- might be only for setting the initial time.
       
Post is unread #12 Dec 4, 2008, 6:17 pm
Go to the top of the page
Go to the bottom of the page

chaoscayne
Fledgling
GroupMembers
Posts15
JoinedNov 29, 2008

I'm going to have to agree, after it ran over night it seems to have stayed on the 1 hour for every 20 minutes
       
Pages:<< prev 1 next >>