MudOSa4DGD/
MudOSa4DGD/bin/
MudOSa4DGD/data/
MudOSa4DGD/doc/
MudOSa4DGD/doc/driver/
MudOSa4DGD/doc/efun/bitstrings/
MudOSa4DGD/doc/efun/command/
MudOSa4DGD/doc/efun/communication/
MudOSa4DGD/doc/efun/heart_beat/
MudOSa4DGD/doc/efun/interactive/
MudOSa4DGD/doc/efun/inventory/
MudOSa4DGD/doc/efun/living/
MudOSa4DGD/doc/efun/mappings/
MudOSa4DGD/doc/efun/strings/
MudOSa4DGD/doc/efun/uid/
MudOSa4DGD/doc/funs/
MudOSa4DGD/doc/language/
MudOSa4DGD/mudlib/dgd/doc/
MudOSa4DGD/mudlib/dgd/lib/include/dgd/
MudOSa4DGD/mudlib/dgd/lib/std/
MudOSa4DGD/mudlib/dgd/lib/sys/
MudOSa4DGD/mudlib/dgd/log/
MudOSa4DGD/mudlib/log/
MudOSa4DGD/mudlib/std/include/
MudOSa4DGD/mudlib/std/obj/
/*
 * shutdown.c
 *
 * SFUN: shutdown the mud
 *
 * (C) Frank Schmidt, Jesus@NorseMUD
 *
 */

#include <std.h>
#include <levels.h>

static varargs void shutdown(int exitcode) {
  object *usr;
  int i;

  if (DRIVER->query_driver_state()) {
    /* Driver managed to startup, perform deinitialization */
#if 0
    if (!DRIVER_PRIV() && (((file_name() != D_SHUTDOWN) && ((this_player() && 
	this_player()->query_level() < LESSER_GOD))) || !this_player())) {
      illegal();
      if (this_player()) {
	message("info", "\nDGD driver falls down boggling, while shutting d...\n", this_player());
	this_player()->__DESTROY_DEF();
      }
      /* we didn't shutdown the mud */
      return;
    }
    
    /* log the event */
    catch(log_file("SYSLOG", "shutdown: The mud is shutdown by " +
		   (this_player() ? (this_player()->query_real_name() + "(" +
				     file_name(this_player()) + ")") :
		    file_name()) + "\n"));
    
#endif

    /* last second actions before shutdown */
    for (i=a_sizeof(usr=users()); --i >= 0; )
      catch(usr[i]->save_me(1));

    /* notify users */
    catch(message("info", "\nDGD falls down boggling, while shutting d...\n", users()));
  }
    
  /* notify driver object */
  catch(DRIVER->do_shutdown(exitcode));

  /* Do It! */
  ::shutdown();
}