06 Oct, 2006, Celest wrote in the 1st comment:
Votes: 0
Im rather new to coding, but im getting a grasp of it here and there. However i wanted to know how I could tweak the do_restart code in smaug to allow for a global countdown. Ie. 5 minutes to countdown. (a minute passes) 4 minutes to countdown etc. Would anyone be able to point me in the right direction of what kind of time functions or commands I should be using or elaborate on how I could accomplish this. Any help would be much appreciated.Thank you in advance.
06 Oct, 2006, Conner wrote in the 2nd comment:
Votes: 0
In update.c, find reboot_check and change
static char *tmsg[] = { "You feel the ground shake as the end comes near!",
"Lightning crackles in the sky above!",
"Crashes of thunder sound across the land!",
"The sky has suddenly turned midnight black.",
"You notice the life forms around you slowly dwindling away.",
"The seas across the lands have turned frigid.",
"The aura of magic that surrounds the Lands seems slightly unstable.",
"You sense a change in the magical forces surrounding you."
to whatever messages you want it to use instead and then change
static const int times[] = { 60, 120, 180, 240, 300, 600, 900, 1800 };
to the number of seconds to send out each of those respective messages to instead of the default which you can see is 1 minute, 2 minutes, 3 minutes, 4 minutes, 5 minutes, 10 minutes, 15 minutes, and 30 minutes prior to the reboot.

Otherwise, it's already in there for you to do a global announcement at those intervals.
06 Oct, 2006, kiasyn wrote in the 3rd comment:
Votes: 0
he means teh reboot command, not the automatic reboot
06 Oct, 2006, Conner wrote in the 4th comment:
Votes: 0
Doesn't the reboot command still call the same reboot_check function to do the global countdown announcements as the automatic reboot?

And, if it doesn't, why couldn't you just copy the relevant portions from reboot_check to do_reboot?
06 Oct, 2006, kiasyn wrote in the 5th comment:
Votes: 0
it doesn't, and you probably couldn't. one way to do it would be to set reboot_time (or whatever variable it is in stock) to current_time+<timer in seconds>
06 Oct, 2006, Celest wrote in the 6th comment:
Votes: 0
Yes, I am wanting to do this with the manual reboot/restart /not/ the automatic process. I have looked at both codes, one for the auto and one for the manual. Theres not really anything there that could be transferred over from what I can tell, though i could be wrong as well. Would i have to tie in tmsg and some kind of time subroutine into the manual restart function and opener? And how ould i incorporated the different messaged in an order sequence since the auto one seems to choose the message strings at random.
06 Oct, 2006, kiasyn wrote in the 7th comment:
Votes: 0
the auto one actually does follow order.. you could make another global variable, bool manual_restart, and do what i said above, updating reboot_time (or next best) so that its when you want to reboot, and change the messages based on manual_restart.
06 Oct, 2006, Guest wrote in the 8th comment:
Votes: 0
You might want to take a peek at how afkmud does the reboots. We took out all of the automated stuff a long time ago and replaced it with a timed system like what you want.
16 Oct, 2006, Justice wrote in the 9th comment:
Votes: 0
Personally, I'd modify the existing reboot code to handle this. All you need to do is update do_reboot to update the boot time. You can look at the "time" argument for do_set_boot_time for information on how to do this. You may wish to add a flag that makes it use an alternative set of messages.

The other option is to write your own delay code. In which case you need to write a handler and put it in update_handler in update.c. This would need to compare either the current time, or the current pulse against the reboot and should have an exit case when no reboot time is set.

For reference:

check_reboot in update.c
if( new_boot_time_t <= current_time )

if( auction->item )
snprintf( buf, MAX_STRING_LENGTH, "Sale of %s has been stopped by mud.", auction->item->short_descr );
talk_auction( buf );
obj_to_char( auction->item, auction->seller );
auction->item = NULL;
if( auction->buyer && auction->buyer != auction->seller )
auction->buyer->gold += auction->bet;
send_to_char( "Your money has been returned.\r\n", auction->buyer );
echo_to_all( AT_YELLOW, "You are forced from these realms by a strong "
"magical presence\r\nas life here is reconstructed.", ECHOTAR_ALL );
log_string( "Automatic Reboot" );
for( vch = first_char; vch; vch = vch->next )
if( !IS_NPC( vch ) )
save_char_obj( vch );
mud_down = TRUE;

do_reboot in act_wiz.c
if( auction->item )
do_auction( ch, "stop" );
snprintf( buf, MAX_STRING_LENGTH, "Reboot by %s.", ch->name );
do_echo( ch, buf );

if( !str_cmp( argument, "and sort skill table" ) )
sort_skill_table( );
save_skill_table( );

* Save all characters before booting.
if( str_cmp( argument, "nosave" ) )
for( vch = first_char; vch; vch = vch->next )
if( !IS_NPC( vch ) )
save_char_obj( vch );

mud_down = TRUE;

game_loop in comm.c
while( !mud_down )

You'll notice that both of these do basically the same thing. They stop any auctions, save the players and optionally for reboot… game state… and set "mud_down" to true. The primary game loop exits then exits on it's next pass.