Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
 parse description bug
Yesterday, 10:08 pm
By Remcon
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
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
LOP 1.45
Author: Remcon
Submitted by: Remcon
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
Users Online
CommonCrawl, Yandex, Yahoo!

Members: 0
Guests: 9
Stats
Files
Topics
Posts
Members
Newest Member
477
3,706
19,240
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » SmaugFUSS » Weather Message Frequency
Forum Rules | Mark all | Recent Posts

Weather Message Frequency
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 May 11, 2008, 7:51 am
Go to the top of the page
Go to the bottom of the page

whisperedecho
Apprentice
GroupMembers
Posts58
JoinedMay 9, 2008

Hi.

I've noticed that the weather message frequency tends to be a little high. Eventually, I'm planning on adding in a code snippet so that users can turn the messages on/off in the config section. However, I was wondering how I would go about setting the frequency of the messages so they wouldn't pop up so often? I know I have to edit the WeatherMessage section in the weather.c file but I'm not sure exactly what to put in to adjust the frequency.

Any help?
       
Post is unread #2 May 11, 2008, 3:50 pm   Last edited May 11, 2008, 3:59 pm by Llarn
Go to the top of the page
Go to the bottom of the page

Llarn
Apprentice
GroupMembers
Posts63
JoinedNov 25, 2007

There are cooler ways of doing this, namely finding a spot
in update_handler that updates less frequently, but this is what I did.

in weathermessage function or whatever it's called of weather.c

short chance;

chance = number_range( 1, 10);

if ( chance > 5 )

{

The whole guts of weathermessage function besides the last bracket goes here.

}

You can also add the config for weathermessages by just making a plr_flag for it or something just like plr_flag for afk.
       
Post is unread #3 May 11, 2008, 4:00 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

I just gave weather it's own update cycle at 1.5 times the calendar update.
       
Post is unread #4 May 11, 2008, 4:23 pm
Go to the top of the page
Go to the bottom of the page

whisperedecho
Apprentice
GroupMembers
Posts58
JoinedMay 9, 2008

Ok, thanks very much!! :-)
       
Post is unread #5 May 14, 2008, 2:22 pm   Last edited May 14, 2008, 2:22 pm by whisperedecho
Go to the top of the page
Go to the bottom of the page

whisperedecho
Apprentice
GroupMembers
Posts58
JoinedMay 9, 2008

Llarn said:

You can also add the config for weathermessages by just making a plr_flag for it or something just like plr_flag for afk.


How would I go about adding the playerflag? I tried adding it with the rest of them but I kept on getting compile errors when I tried to compile. Is there a guide somewhere that would explain what code to add?
       
Post is unread #6 May 14, 2008, 5:02 pm   Last edited May 14, 2008, 5:21 pm by Llarn
Go to the top of the page
Go to the bottom of the page

Llarn
Apprentice
GroupMembers
Posts63
JoinedNov 25, 2007

A good guide is looking where PLR_AFK is and doing the same thing with your new flag.

If your using linux which you should be with smaugfuss you can use the grep command
grep PLR_AFK *.c this will show the config function you will have to add your flag here.
grep PLR_AFK *.h should point to mud.h
grep afk *.c -> which should point to build.c where you need to include your new flag

Course in messageweather function you'd put a check something like if player is PLR_NOWEATHER
no message.

A pitfall to avoid is not making sure your flags match from mud.h and build.c

       
Post is unread #7 May 15, 2008, 2:11 am   Last edited May 15, 2008, 2:41 am by whisperedecho
Go to the top of the page
Go to the bottom of the page

whisperedecho
Apprentice
GroupMembers
Posts58
JoinedMay 9, 2008

Kayle said:

I just gave weather it's own update cycle at 1.5 times the calendar update.


I found the WeatherUpdate function in update.c but how did you set it so that it updates at 1.5 times the calendar update?

I tried moving the WeatherUpdate() function up above char_calendar_update to see if that will slow down the weather messages.

EDIT:
Nevermind, I figured out how to slow it down. I basically did this:
if( --pulse_point <= 0 )
   {
      pulse_point = number_range( ( int )( PULSE_TICK * 0.5 ), ( int )( PULSE_TICK * 2.00 ) );

      UpdateWeather(  ); /* New Weather Updater -Kayle */
   }
       
Post is unread #8 May 15, 2008, 2:29 am
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

The easiest way to explain it is to just show you. Here's my update_handler function, well, my old one. In the current version of my base I'm working on I don't have one, but that's beside the point.

void update_handler( void )
{
   static int pulse_mobile;
   static int pulse_violence;
   static int pulse_point;
   static int pulse_second;
   static int pulse_spell;
   static int pulse_area;
   static int pulse_time;
   static int pulse_weather;
   struct timeval sttime;
   struct timeval etime;

   if( timechar )
   {
      set_char_color( AT_PLAIN, timechar );
      send_to_char( "Starting update timer.\r\n", timechar );
      gettimeofday( &sttime, NULL );
   }

   if( --pulse_area <= 0 )
   {
      pulse_area = sysdata.pulsearea;
      task_update(  );
   }

   if( --pulse_mobile <= 0 )
   {
      pulse_mobile = sysdata.pulsemobile;
      mobile_update(  );
   }

   if( --pulse_violence <= 0 )
      pulse_violence = sysdata.pulseviolence;

   if( --pulse_spell <= 0 )
   {
      pulse_spell = sysdata.pulsespell;
      spell_update(  );
   }

   if( --pulse_weather <= 0 )
   {
	   pulse_weather = sysdata.pulseweather;
	   UpdateWeather(  ); /* New Weather Updater -Kayle */
   }

   if( --pulse_time <= 0 )
   {
      pulse_time = sysdata.pulsecalendar;
	  
      char_calendar_update(  );
	  time_update(  ); 
   }

   if( --pulse_point <= 0 )
   {
      pulse_point = number_range( ( int )( sysdata.pulsetick * 0.75 ), ( int )( sysdata.pulsetick * 1.25 ) );
	
      auth_update(  );  /* Gorog */
      hint_update(  );
      char_update(  );
      obj_update(  );
      clear_vrooms(  ); /* remove virtual rooms */
   }

   if( --pulse_second <= 0 )
   {
      pulse_second = sysdata.pulsepersec;
      char_check(  );
      check_dns(  );
   }

   if( --auction->pulse <= 0 )
   {
      auction->pulse = sysdata.auctionseconds;
      auction_update(  );
   }

   mpsleep_update(  );  /* Check for sleeping mud progs -rkb */
   tele_update(  );
   aggr_update(  );
   obj_act_update(  );
   room_act_update(  );
   clean_obj_queue(  ); /* dispose of extracted objects */
   clean_char_queue(  );   /* dispose of dead mobs/quitting chars */
   run_events( current_time );
   if( timechar )
   {
      gettimeofday( &etime, NULL );
      set_char_color( AT_PLAIN, timechar );
      send_to_char( "Update timing complete.\r\n", timechar );
      subtract_times( &etime, &sttime );
      ch_printf( timechar, "Timing took %ld.%06ld seconds.\r\n", ( time_t ) etime.tv_sec, ( time_t ) etime.tv_usec );
      timechar = NULL;
   }
   tail_chain(  );
   return;
}


Then to go along with that.

Act_wiz.c Update_timers

void update_timers( void )
{
   sysdata.pulsetick = sysdata.secpertick * sysdata.pulsepersec;
   sysdata.pulseviolence = 3 * sysdata.pulsepersec;
   sysdata.pulsespell = sysdata.pulseviolence;
   sysdata.pulsemobile = 4 * sysdata.pulsepersec;
   sysdata.pulsecalendar = 4 * sysdata.pulsetick;
   sysdata.pulseweather = 6 * sysdata.pulsetick;
   sysdata.pulsearea = 60 * sysdata.pulsepersec;
   return;
}


Dunno if I that helps much but maybe it does.
       
Post is unread #9 May 15, 2008, 2:43 am
Go to the top of the page
Go to the bottom of the page

whisperedecho
Apprentice
GroupMembers
Posts58
JoinedMay 9, 2008

Ah, awesome!

I had just set up something temporarily (see my edit to my last post above). Thanks, that will help me out!
       
Post is unread #10 May 15, 2008, 2:56 am
Go to the top of the page
Go to the bottom of the page

whisperedecho
Apprentice
GroupMembers
Posts58
JoinedMay 9, 2008

I got compiler errors when I tried making the changes you specified above so I had to revert back to my temporary fix.
       
Post is unread #11 May 15, 2008, 3:22 am
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

You'll have to add entries to the system_data struct to account for pulseweather.

You're also not going to want to use that update_handler exactly, just compare yours to mine, See what yours does, and what mine does.


as for your temporary fix, you're not going to want to use pulse_point, as that will mess with some updates a little lower and will end up slowing a lot of things down not just weather.

You could even do something like:
 
   if( --pulse_weather <= 0 )
   {
	   pulse_weather = number_range( ( int )( PULSE_TICK * 0.5 ), ( int )( PULSE_TICK * 2.00 ) );
	   UpdateWeather(  ); /* New Weather Updater -Kayle */
   }


and then add a:
static int pulse_weather;

at the top with the rest of them.
       
Post is unread #12 May 15, 2008, 7:18 am
Go to the top of the page
Go to the bottom of the page

whisperedecho
Apprentice
GroupMembers
Posts58
JoinedMay 9, 2008

Ok thanks. What exactly does pulse point do anyway? Is it like a timer for when things are supposed to be updated?
       
Post is unread #13 May 15, 2008, 7:51 am
Go to the top of the page
Go to the bottom of the page

whisperedecho
Apprentice
GroupMembers
Posts58
JoinedMay 9, 2008


Kayle said:

You'll have to add entries to the system_data struct to account for pulseweather.

You're also not going to want to use that update_handler exactly, just compare yours to mine, See what yours does, and what mine does.


as for your temporary fix, you're not going to want to use pulse_point, as that will mess with some updates a little lower and will end up slowing a lot of things down not just weather.

You could even do something like:
 
   if( --pulse_weather <= 0 )
   {
	   pulse_weather = number_range( ( int )( PULSE_TICK * 0.5 ), ( int )( PULSE_TICK * 2.00 ) );
	   UpdateWeather(  ); /* New Weather Updater -Kayle */
   }


and then add a:
static int pulse_weather;

at the top with the rest of them.


Thanks Kayle!!! It works perfectly! :grinning:
       
Post is unread #14 May 16, 2008, 1:26 am
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

it's just the generic secondary update timer. the primary updates fire everytime update_handler is called, pulse_point ends up zeroing out every other update_handler call if I recall.
       
Pages:<< prev 1 next >>