Login
User Name:

Password:



Register

Forgot your password?
do_owhere recursive
Author: Khonsu
Submitted by: Khonsu
Changes list / Addchange
Author: Khonsu
Submitted by: Khonsu
6Dragons mp3 sound pack
Author: Vladaar
Submitted by: Vladaar
AFKMud 2.2.3
Author: AFKMud Team
Submitted by: Samson
SWFOTEFUSS 1.5
Author: Various
Submitted by: Samson
Users Online
AhrefsBot, Bing

Members: 0
Guests: 33
Stats
Files
Topics
Posts
Members
Newest Member
489
3,792
19,646
597
Aileenutz

Today's Birthdays
There are no member birthdays today.
» SmaugMuds » Codebases » LoP Codebase » a couple newbie questions abo...
Forum Rules | Mark all | Recent Posts

a couple newbie questions about time
< Newer Topic :: Older Topic > lop1.40

Pages:<< prev 1 next >>
Post is unread #1 Jul 4, 2011 6:05 am   
Go to the top of the page
Go to the bottom of the page

rinlek
Fledgling
GroupMembers
Posts5
JoinedApr 30, 2011

 
i'm using lop 1.40 and i have 2 questions about time withing this code.

first, how do you slow down the time in game, i want to make my game so that 1 day real life is 2 days in game. the current setup goes way to fast. i've tried to play around with the code, but nothing i've done seems to work.

second, how do i adjust the system time the mud shows when you type time?

thanks for any help

Post is unread #2 Jul 4, 2011 9:55 am   
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,917
JoinedJul 26, 2005

 
To modify how fast the time is in the game take a look at the time_update in timeinfo.c it is called in update.c if you want to see how often it is called. If I was going to slow it down Id just add a new int that it counts up every time and just once in awhile for it allow it to get to the normal time_update.
I think it still more or less does stock smaug time updating which is about something like one day every 15 mins or so. Been quite awhile since I looked into it lol.

Well it uses the normal system time, but I tossed in something in comm.c in the main function to modify it a bit to show EDT.
   current_time = ( time_t ) now_time.tv_sec;
   current_time += ( time_t ) TIME_MODIFY; /* Increase it to EDT */

mud.h has this
#define TIME_MODIFY          0 /* Done in seconds, Modifies current_time to what you want the time displayed in */

So it isn't actually affecting it, but it gives you a way to modify it easier if needed. So if you want it to add an hour change TIME_MODIFY to 3600 (is 60*60) Hope that helps.

Post is unread #3 Jul 5, 2011 7:55 am   
Go to the top of the page
Go to the bottom of the page

rinlek
Fledgling
GroupMembers
Posts5
JoinedApr 30, 2011

 
i was able to adjust the system time thanks to what you posted remcon but i can't seem to find the spot in timeinfo.c or update.c to adjust the passage of time in game. would you be able to tell me what line to look at or show me the code i need to find please?

Post is unread #4 Jul 5, 2011 3:33 pm   
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,917
JoinedJul 26, 2005

 
Its the time_update function its only real function is to increase mud time. Ill post in example code later

Post is unread #5 Jul 5, 2011 7:05 pm   
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,917
JoinedJul 26, 2005

 
Found in timeinfo.c
/* update the time */
void time_update( void )
{
   AREA_DATA *pArea;
   DESCRIPTOR_DATA *d;
   WEATHER_DATA *weath;
   MONTH_DATA *month;
   DAY_DATA *day;
   char *hmessage;
   int mday = 0, mmonth = 0;

   switch( ++time_info.hour )
   {
      case 5:
      case 6:
      case 12:
      case 19:
      case 20:
         for( pArea = first_area; pArea; pArea = ( pArea == last_area ) ? first_build : pArea->next )
            get_time_echo( pArea->weather );

         for( d = first_descriptor; d; d = d->next )
         {
            if( d->connected == CON_PLAYING && is_outside( d->character ) && is_awake( d->character ) )
            {
               weath = d->character->in_room->area->weather;
               if( !weath->echo )
                  continue;
               set_char_color( weath->echo_color, d->character );
               send_to_char( weath->echo, d->character );
            }
         }
         break;

      case 24:
         time_info.hour = 0;
         time_info.day++;
         time_info.wday++;
         if( ( hmessage = show_holiday( ) ) )
         {
            for( d = first_descriptor; d; d = d->next )
            {
               if( d->connected == CON_PLAYING )
                  ch_printf( d->character, "%s\r\n", hmessage );
            }
         }
         break;
   }

   update_sunlight( );

   if( !( month = get_mdata( time_info.month ) ) )
   {
      bug( "%s: invalid month!!!!", __FUNCTION__ );
      return;
   }

   for( day = first_day; day; day = day->next )
      mday++;

   if( time_info.wday > mday )
      time_info.wday = 1;

   if( time_info.day > month->days )
   {
      time_info.day = 1;
      time_info.month++;
      give_interest( );
   }

   for( month = first_month; month; month = month->next )
      mmonth++;
 
   if( time_info.month > mmonth )
   {
      time_info.month = 1;
      time_info.year++;
   }

   /* Shouldn't be to bad to save it each update */
   save_timeinfo( );
}

The ++time_info.hour is where it is increasing the hour on the mud and it does so everytime time_update is called. You have a few different things you can do but the easiest way is to just change the amount of time time_info.hour is updated or you can even add in another part in time like mins and just up a min each time it is called and then update the mud hour every so many mins till you find the time you like. Just watch how fast the hours go by and if you went with 2 mins before an hour passed then it would be an hour passing half as fast. etc.... Let me know the kind of way you want to go with it and if you need some extra help I'll help out.

Another way is changing in update.c
find
   if( --pulse_point <= 0 )
   {
      pulse_point = number_range( ( int )( PULSE_TICK * 0.75 ), ( int )( PULSE_TICK * 1.25 ) );

      auth_update( );  /* Gorog */
      time_update( );
      weather_update( );
      char_update( );
      obj_update( );
   }

change it to this
   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( );
   }

   {
      static int pulse_slowtime;

      if( --pulse_slowtime <= 0 )
      {
         pulse_slowtime = number_range( ( int )( PULSE_TICK * 1.75 ), ( int )( PULSE_TICK * 2.25 ) );
         time_update( );
      }
   }

for example that is. You can change the multiplying or just go with some other range etc....

Post is unread #6 Jul 10, 2011 7:51 am   
Go to the top of the page
Go to the bottom of the page

rinlek
Fledgling
GroupMembers
Posts5
JoinedApr 30, 2011

 
this is what i was looking for, thanks for the help remcon. your a life saver.

btw lop is one of the best codebases i've seen.

Post is unread #7 Jul 10, 2011 5:40 pm   
Go to the top of the page
Go to the bottom of the page

dbna2
Sorcerer
GroupMembers
Posts600
JoinedDec 3, 2008

 
Yeah LOP is a really good codebase. Plus Remcon is really helpful. I like the fact that he took alot of the broken systems and fixed them up. I use alot of things from his codebase in my own. I also plan on using LOP as a base for a naruto or bleach mud when I finish the current project I am working on.

Post is unread #8 Jul 10, 2011 9:57 pm   
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,917
JoinedJul 26, 2005

 
Thanks, glad it is being enjoyed in part or in whole. :)

Pages:<< prev 1 next >>