Example #1
0
void
mainloop(void)
{
    extern int game_is_being_shut_down;
    struct task *current_task;
    struct timeval tv;
    double task_start;

#ifdef SUPER_SNOOP
    read_snoop_file();
#endif
    (void) printf("Setting up ipc.\n");
    (void)fflush(stdout);
    prepare_ipc();
    (void) signal(SIGFPE, sigfpe_handler);

    while (!game_is_being_shut_down) {
	while (task_head.next == &task_head) {
	    set_current_time();
	    deliver_signals();
	    call_out(&tv);	    
	    if (task_head.next != &task_head)
		tv.tv_sec = tv.tv_usec = 0;
	    nd_select(&tv);
	    check_for_slow_shut_down();
	}
	set_current_time();
	current_task = task_head.next;
	remove_task(current_task);
	runtask(current_task);
	task_start = current_time;
	set_current_time();
	update_runq_av((num_tasks + 1.0) * (current_time - task_start));

	/* process callouts and IO */
	deliver_signals();
	if (task_head.next != &task_head ||
	    current_task->next == current_task) {
	    tv.tv_sec = tv.tv_usec = 0;
	    call_out(NULL);
        } else 
	    call_out(&tv);
	if (task_head.next != &task_head ||
	    current_task->next == current_task)
	    tv.tv_sec = tv.tv_usec = 0;
	nd_select(&tv);
	check_for_slow_shut_down();
	
	if (current_task->next == current_task)
	    append_task(current_task); /* reschedule the task */
	else
	    free(current_task);
    }
    shutdowngame();
}
Example #2
0
void tod_manager::set_new_current_times(const int new_current_turn_number)
{
	set_current_time(calculate_current_time(times_.size(), new_current_turn_number, currentTime_));
	for (area_time_of_day& area : areas_) {
		set_current_time(calculate_current_time(
			area.times.size(),
			new_current_turn_number,
			area.currentTime),
			area);
	}
}
Example #3
0
int slpt_time_tick(void) {
	unsigned int delta;
	struct timeval timeval;
	struct timezone timezone;
	static int otime = 0;
	static int otimezone = -1000000;

	/* get system time */
	assert(!gettimeofday(&timeval, &timezone));

	/* we want rise to next second when [new_sec >= old_sec + 0.95]
	 * error range is : [0 --- 0.1 sec]
	 */
	if ((timeval.tv_sec == otime) &&
		(timezone.tz_minuteswest == otimezone)) {
		delta = 1000000 - timeval.tv_usec;
		pr_debug("%s time: %lu.%lu\n",
				 delta <= ((100 / 2) * 1000) ? "take" : "skip", timeval.tv_sec, timeval.tv_usec);
		if (delta <= ((100 / 2) * 1000)) {
			timeval.tv_sec += 1;
			timeval.tv_usec = 0;
		} else {
			return 0;
		}
	}

	otime = timeval.tv_sec;
	otimezone = timezone.tz_minuteswest;

	set_current_time(timeval.tv_sec - (timezone.tz_minuteswest * 60));

	return 1;
}
Example #4
0
void validate_decoder_sequence(struct decoder_event *ev, int num) {
  int i;
  for (i = 0; i < num; ++i) {
    if (ev[i].t0) {
      config.decoder.last_t0 = ev[i].time;
      config.decoder.needs_decoding_t0 = 1;
    }
    if (ev[i].t1) {
      config.decoder.last_t1 = ev[i].time;
      config.decoder.needs_decoding_t1 = 1;
    }

    set_current_time(ev[i].time);
    config.decoder.decode(&config.decoder);
    ck_assert_msg(config.decoder.state == ev[i].state, 
        "expected event at %d: (%d, %d). Got (%d, %d)",
        ev[i].time, ev[i].state, ev[i].valid, 
        config.decoder.state, config.decoder.valid);
    if (!ev[i].valid) {
      ck_assert_msg(config.decoder.loss == ev[i].reason,
      "reason mismatch at %d: %d. Got %d",
      ev[i].time, ev[i].reason, config.decoder.loss);
    }
  }
}
Example #5
0
void msm6242_device::device_start()
{
	m_out_int_handler.resolve();

	// let's call the timer callback every tick
	m_timer = timer_alloc(TIMER_RTC_CALLBACK);
	m_timer->adjust(attotime::zero);

	// get real time from system
	set_current_time(machine());

	// set up registers
	m_tick = 0;
	m_irq_flag = 0;
	m_irq_type = 0;

	// TODO: skns writes 0x4 to D then expects E == 6 and F == 4, perhaps those are actually saved in the RTC CMOS?
	m_reg[0] = 0;
	m_reg[1] = 0x6;
	m_reg[2] = 0x4;

	// save states
	save_item(NAME(m_reg));
	save_item(NAME(m_irq_flag));
	save_item(NAME(m_irq_type));
	save_item(NAME(m_tick));
	save_item(NAME(m_last_update_time));
}
Example #6
0
void mm58167_device::device_reset()
{
	set_current_time(machine());

	m_regs[R_CTL_STATUS] = 0;	// not busy
	m_milliseconds = 0;
}
Example #7
0
void mdb_t::set_mdb_timestamp ( time_t timestamp )
{
    if ( m_ok )
    {
        set_current_time ( timestamp );
    }
}
Example #8
0
void msm6242_device::device_start()
{
	const msm6242_interface *intf = reinterpret_cast<const msm6242_interface *>(static_config());
	if (intf != NULL)
		m_res_out_int_func.resolve(intf->m_out_int_func, *this);

	// let's call the timer callback every tick
	m_timer = timer_alloc(TIMER_RTC_CALLBACK);
	m_timer->adjust(attotime::zero);

	// get real time from system
	set_current_time(machine());

	// set up registers
	m_tick = 0;
	m_irq_flag = 0;
	m_irq_type = 0;

	// TODO: skns writes 0x4 to D then expects E == 6 and F == 4, perhaps those are actually saved in the RTC CMOS?
	m_reg[0] = 0;
	m_reg[1] = 0x6;
	m_reg[2] = 0x4;

	// save states
	save_item(NAME(m_reg));
	save_item(NAME(m_irq_flag));
	save_item(NAME(m_irq_type));
	save_item(NAME(m_tick));
	save_item(NAME(m_last_update_time));
}
Example #9
0
void rp5c01_device::device_reset()
{
	memset(m_reg, 0, sizeof(m_reg));
	memset(m_ram, 0, sizeof(m_ram));

	// 24 hour mode
	m_reg[MODE01][REGISTER_12_24_SELECT] = 1;

	if (m_battery_backed && clock() > 0)
		set_current_time(machine());
}
Example #10
0
} END_TEST

START_TEST(check_tfi_decoder_syncloss_expire) {
  prepare_decoder(FORD_TFI);
  validate_decoder_sequence(tfi_startup_events, 6);
  ck_assert_int_eq(config.decoder.expiration, 162500);

  set_current_time(170000);
  check_handle_decoder_expire(&config.decoder);
  ck_assert_int_eq(0, config.decoder.current_triggers_rpm);
  ck_assert_int_eq(0, config.decoder.valid);
  ck_assert_int_eq(DECODER_EXPIRED, config.decoder.loss);
} END_TEST
Example #11
0
void upd1990a_device::device_start()
{
	(void)m_variant;
	// resolve callbacks
	m_write_data.resolve_safe();
	m_write_tp.resolve_safe();

	// initialize
	set_current_time(machine());

	for (int i = 0; i < 7; i++)
		m_shift_reg[i] = 0;

	m_oe = 0;
	m_cs = 0;
	m_stb = 0;
	m_data_in = 0;
	m_data_out = 0;
	m_c = 0;
	m_clk = 0;
	m_tp = 0;
	m_c_unlatched = 0;
	m_testmode = false;

	// allocate timers
	m_timer_clock = timer_alloc(TIMER_CLOCK);
	m_timer_clock->adjust(attotime::from_hz(clock() / 32768.0), 0, attotime::from_hz(clock() / 32768.0)); // 1 second on XTAL_32_768kHz
	m_timer_tp = timer_alloc(TIMER_TP);
	m_timer_data_out = timer_alloc(TIMER_DATA_OUT);
	m_timer_test_mode = timer_alloc(TIMER_TEST_MODE);

	// state saving
	save_item(NAME(m_time_counter));
	save_item(NAME(m_shift_reg));
	save_item(NAME(m_oe));
	save_item(NAME(m_cs));
	save_item(NAME(m_stb));
	save_item(NAME(m_data_in));
	save_item(NAME(m_data_out));
	save_item(NAME(m_c));
	save_item(NAME(m_clk));
	save_item(NAME(m_tp));
	save_item(NAME(m_c_unlatched));
	save_item(NAME(m_testmode));
}
Example #12
0
void *timer_thread ( void * )
{
    int timerfd = timerfd_create (CLOCK_REALTIME, 0);
    if ( timerfd == - 1 )
    {
        return NULL;
    }

    struct itimerspec tv;
    memset (&tv, 0, sizeof (tv ));

    tv.it_value.tv_sec = 1;
    tv.it_interval.tv_sec = 1;

    if ( timerfd_settime (timerfd, 0, &tv, NULL) == - 1 )
        return NULL;

    struct pollfd pfd;
    pfd.fd = timerfd;
    pfd.events = POLLIN;

    int ret;
    uint64_t val;

    while ( is_running )
    {
        ret = poll (&pfd, 1, - 1);
        if ( ret == - 1 )
        {
            if ( errno == EINTR )
            {
                continue;
            }
            continue;
        }
        if ( pfd.revents & POLLIN )
        {
            read (timerfd, &val, sizeof (val ));
            set_current_time ();
        }
    }
    close (timerfd);
    return NULL;
}
Example #13
0
static void clock_handler(const int fd, const short which, void *arg) {
  struct timeval t;
  static bool initialized = false;
  
  if (initialized) {
    /* only delete the event if it's actually there. */
    evtimer_del(&clockevent);
  } else {
    initialized = true;
  }

  t.tv_sec = 1;
  t.tv_usec = 0;
  evtimer_set(&clockevent, clock_handler, 0);
  event_base_set(main_base, &clockevent);
  evtimer_add(&clockevent, &t);

  set_current_time();
  if (clock_callback)
    clock_callback(current_time);
}
Example #14
0
void hd64610_device::device_reset()
{
	set_current_time(machine());
}
Example #15
0
void tod_manager::set_current_time(int time, int area_index) {
	assert(area_index < static_cast<int>(areas_.size()));
	set_current_time(time, areas_[area_index]);
}
Example #16
0
void msm58321_device::device_reset()
{
	set_current_time(machine());
}
Example #17
0
int 
main(int argc, char **argv)
{
    extern int game_is_being_shut_down;
    int i, new_mudlib = 0;
    char *p;
    struct svalue *ret;
    extern struct svalue catch_value;
    extern void init_cfuns(void);
    struct gdexception exception_frame;

    (void)setlinebuf(stdout);

    const0.type = T_NUMBER; const0.u.number = 0;
    const1.type = T_NUMBER; const1.u.number = 1;
    constempty.type = T_FUNCTION; constempty.u.func = &funcempty;
    funcempty.funtype = FUN_EMPTY;
    catch_value = const0;
    
    /*
     * Check that the definition of EXTRACT_UCHAR() is correct.
     */
    p = (char *)&i;
    *p = -10;
    if (EXTRACT_UCHAR(p) != 0x100 - 10)
    {
	(void)fprintf(stderr, "Bad definition of EXTRACT_UCHAR() in config.h.\n");
	exit(1);
    }
    set_current_time();
#ifdef PROFILE_LPC
    set_profile_timebase(60.0); /* One minute */
#endif

#ifdef DRAND48
    srand48((long)current_time);
#else
#ifdef RANDOM
    srandom(current_time);
#else
#error No random generator specified!\n
#endif /* RANDOM */
#endif /* DRAND48 */

#if RESERVED_SIZE > 0
    reserved_area = malloc(RESERVED_SIZE);
#endif
    init_tasks();
    query_load_av();
    init_num_args();
    init_machine();
    init_cfuns();

    /*
     * Set up the signal handling.
     */
    init_signals();

    /*
     * The flags are parsed twice !
     * The first time, we only search for the -m flag, which specifies
     * another mudlib, and the D-flags, so that they will be available
     * when compiling master.c.
     */
    for (i = 1; i < argc; i++)
    {
	if (atoi(argv[i]))
	    port_number = atoi(argv[i]);
	else if (argv[i][0] != '-')
	    continue;
	switch(argv[i][1])
	{
	case 'D':
	    if (argv[i][2]) { /* Amylaar : allow flags to be passed down to
				 the LPC preprocessor */
		struct lpc_predef_s *tmp;
		
		tmp = (struct lpc_predef_s *)
		    xalloc(sizeof(struct lpc_predef_s));
		if (!tmp)
		    fatal("xalloc failed\n");
		tmp->flag = string_copy(argv[i]+2);
		tmp->next = lpc_predefs;
		lpc_predefs = tmp;
		continue;
	    }
	    (void)fprintf(stderr, "Illegal flag syntax: %s\n", argv[i]);
	    exit(1);
	    /* NOTREACHED */
	case 'N':
	    no_ip_demon++; continue;
	case 'm':
	    if (chdir(argv[i]+2) == -1)
	    {
	        (void)fprintf(stderr, "Bad mudlib directory: %s\n", argv[i]+2);
		exit(1);
	    }
	    new_mudlib = 1;
	    break;
	}
    }

    if (!new_mudlib && chdir(MUD_LIB) == -1) {
        (void)fprintf(stderr, "Bad mudlib directory: %s\n", MUD_LIB);
	exit(1);
    }

    if (setjmp(exception_frame.e_context))
    {
	clear_state();
	add_message("Anomaly in the fabric of world space.\n");
    } 
    else
    {
	exception_frame.e_exception = NULL;
	exception_frame.e_catch = 0;
	exception = &exception_frame;
	auto_ob = 0;
	master_ob = 0;
	
	if ((auto_ob = load_object("secure/auto", 1, 0, 0)) != NULL)
	{
	    add_ref(auto_ob, "main");
	    auto_ob->prog->flags |= PRAGMA_RESIDENT;
	}

	get_simul_efun();
	master_ob = load_object("secure/master", 1, 0, 0);
	if (master_ob)
	{
	    /*
	     * Make sure master_ob is never made a dangling pointer.
	     * Look at apply_master_ob() for more details.
	     */
	    add_ref(master_ob, "main");
	    master_ob->prog->flags |= PRAGMA_RESIDENT;
            resolve_master_fkntab();
	    create_object(master_ob);
            load_parse_information();
	    clear_state();
	}
    }
    exception = NULL;
    if (auto_ob == 0) 
    {
	(void)fprintf(stderr, "The file secure/auto must be loadable.\n");
	exit(1);
    }
    if (master_ob == 0) 
    {
	(void)fprintf(stderr, "The file secure/master must be loadable.\n");
	exit(1);
    }
    set_inc_list(apply_master_ob(M_DEFINE_INCLUDE_DIRS, 0));
    {
	struct svalue* ret1;

	ret1 = apply_master_ob(M_PREDEF_DEFINES, 0);
	if (ret1 && ret1->type == T_POINTER)
	{
	    int ii;
	    struct lpc_predef_s *tmp;

	    for (ii = 0; ii < ret1->u.vec->size; ii++)
		if (ret1->u.vec->item[ii].type == T_STRING)
		{
		    tmp = (struct lpc_predef_s *)
			xalloc(sizeof(struct lpc_predef_s));
		    tmp->flag = string_copy(ret1->u.vec->item[ii].u.string);
		    tmp->next = lpc_predefs;
		    lpc_predefs = tmp;
		}
	}
    }
    for (i = 1; i < argc; i++)
    {
	if (atoi(argv[i]))
	    ;
	else if (argv[i][0] != '-')
	{
	    (void)fprintf(stderr, "Bad argument %s\n", argv[i]);
	    exit(1);
	}
	else 
	{
	    /*
	     * Look at flags. -m has already been tested.
	     */
	    switch(argv[i][1])
	    {
	    case 'f':
		push_string(argv[i]+2, STRING_MSTRING);
		(void)apply_master_ob(M_FLAG, 1);
		if (game_is_being_shut_down)
		{
		    (void)fprintf(stderr, "Shutdown by master object.\n");
		    exit(0);
		}
		continue;
	    case 'e':
		e_flag++; continue;
	    case 'O':
		warnobsoleteflag++; continue;
	    case 'D':
		continue;
	    case 'N':
		continue;
	    case 'm':
		continue;
	    case 'd':
		d_flag = atoi(argv[i] + 2);
		continue;
	    case 'c':
		comp_flag++; continue;
	    case 'l':
		unlimited++;
		continue;
	    case 't':
		t_flag++; continue;
	    case 'S':
		s_flag++; 
		mudstatus_set(1, -1, -1); /* Statistics, default limits */
		continue;
	    case 'u':
#ifdef CATCH_UDP_PORT
		udp_port = atoi (&argv[i][2]);
#endif
		continue;
	    case 'p':
#ifdef SERVICE_PORT
		service_port = atoi (&argv[i][2]);
#endif
		continue;
	    case 'y':
#ifdef YYDEBUG
		yydebug = 1;
#endif
		continue;
	    default:
		(void)fprintf(stderr, "Unknown flag: %s\n", argv[i]);
		exit(1);
	    }
	}
    }

    /*
     * See to it that the mud name is always defined in compiled files
     */
    ret = apply_master_ob(M_GET_MUD_NAME, 0);

    if (ret && ret->type == T_STRING)
    {
	struct lpc_predef_s *tmp;
		
	tmp = (struct lpc_predef_s *)
	    xalloc(sizeof(struct lpc_predef_s));
	if (!tmp) 
	    fatal("xalloc failed\n");
	tmp->flag = string_copy(ret->u.string);
	tmp->next = lpc_predefs;
	lpc_predefs = tmp;
    }

    ret = apply_master_ob(M_GET_VBFC_OBJECT, 0);
    if (ret && ret->type == T_OBJECT)
    {
	vbfc_object = ret->u.ob;
	INCREF(vbfc_object->ref);
    }
    else
	vbfc_object = 0;

    if (game_is_being_shut_down)
	exit(1);

    if (!t_flag)
	init_call_out();

    preload_objects(e_flag);
    (void)apply_master_ob(M_FINAL_BOOT, 0);
    

    mainloop();
    /* backend(); */

    return 0;
}
Example #18
0
void tod_manager::set_current_time(int time, const std::string& area_id) {
	for (area_time_of_day& area : areas_) {
		if (area.id == area_id)
			set_current_time(time, area);
	}
}
Example #19
0
void rp5c15_device::device_reset()
{
	set_current_time(machine());
}
Example #20
0
istream & single_star::scan_star_story(istream& s)
{
    char input_line[MAX_INPUT_LINE_LENGTH];

    cerr << "\n\nUsing single_star_io version of scan_star_story()...\n\n";

    while(get_line(s,input_line), strcmp(END_STAR, input_line)){
	char keyword[MAX_INPUT_LINE_LENGTH];
	const char *val = getequals(input_line, keyword);

	if (val) {
	    real number;
	    if(0){   // trick to keep the if() statement, for the else below
	    }else if(!strcmp("Type",keyword)){
		char str_tpe[MAX_INPUT_LINE_LENGTH];
		sscanf(val,"%s",str_tpe);

	    }else if(!strcmp("Class",keyword)){
		char str_cls[MAX_INPUT_LINE_LENGTH];
		sscanf(val,"%s",str_cls);

	    }else if(!strcmp("T_cur",keyword)){
		set_current_time( strtod(val,NULL) );

	    }else if(!strcmp("T_rel",keyword)){
		set_relative_age( strtod(val,NULL) );

	    }else if(!strcmp("M_rel",keyword)){
		set_relative_mass( strtod(val,NULL) );

	    }else if(!strcmp("M_env",keyword)){
		set_envelope_mass( strtod(val,NULL) );

	    }else if(!strcmp("M_core",keyword)){
		set_core_mass( strtod(val,NULL) );

	    }else if(!strcmp("M_COcore",keyword)){
		set_COcore_mass( strtod(val,NULL) );

	    }else if(!strcmp("T_eff",keyword)){
		number = strtod(val,NULL);
		/* XXX ignore value?? */

	    }else if(!strcmp("L_eff",keyword)){
		set_luminosity( strtod(val,NULL) );

	    }else if(!strcmp("P_rot",keyword)){           // experimental extra 
	  					          // information for 
		set_rotation_period( strtod(val,NULL) );  // radio pulsars.

	    } else if(!strcmp("B_fld",keyword)){
		set_magnetic_field( strtod(val,NULL) );

	    }else{
		add_story_line(star_story, input_line);
	    }
	}
    }

    //if(current_time<=0) current_time = relative_age;
    return s;
}
Example #21
0
void upd1990a_rtc_device::device_reset()
{
	set_current_time(machine());
}
Example #22
0
/*
 * The start_boot() in master.c is supposed to return an array of files to load.
 * The array returned by apply() will be freed at next call of apply(),
 * which means that the ref count has to be incremented to protect against
 * deallocation.
 *
 * The master object is asked to do the actual loading.
 */
void 
preload_objects(int eflag)
{
    struct gdexception exception_frame;
    struct vector *prefiles;
    struct svalue *ret = NULL;
    volatile int ix;

    set_current_time();


    if (setjmp(exception_frame.e_context)) 
    {
	clear_state();
	(void)add_message("Error in start_boot() in master_ob.\n");
	exception = NULL;
	return;
    }
    else
    {
	exception_frame.e_exception = NULL;
	exception_frame.e_catch = 0;
	exception = &exception_frame;
	push_number(eflag);
	ret = apply_master_ob(M_START_BOOT, 1);
    }

    if ((ret == 0) || (ret->type != T_POINTER))
	return;
    else
	prefiles = ret->u.vec;

    if ((prefiles == 0) || (prefiles->size < 1))
	return;

    INCREF(prefiles->ref); /* Otherwise it will be freed next sapply */

    ix = -1;
    if (setjmp(exception_frame.e_context)) 
    {
	clear_state();
	(void)add_message("Anomaly in the fabric of world space.\n");
    }

    while (++ix < prefiles->size) 
    {
        set_current_time();
	if (s_flag)
	    reset_mudstatus();
	eval_cost = 0;
	push_svalue(&(prefiles->item[ix]));
	(void)apply_master_ob(M_PRELOAD_BOOT, 1);
	if (s_flag)
	    print_mudstatus(prefiles->item[ix].u.string, eval_cost,
			    get_millitime(), get_processtime());
	tmpclean();
    }
    free_vector(prefiles);
    exception = NULL;
    set_current_time();
}
Example #23
0
int 
main(int argc, char **argv)
{
    extern int game_is_being_shut_down;
    char *p;
    int i = 0;
    struct svalue *ret;
    extern struct svalue catch_value;
    extern void init_cfuns(void);
    struct gdexception exception_frame;

    (void)setlinebuf(stdout);

    parse_args(argc, argv);
    
    const0.type = T_NUMBER; const0.u.number = 0;
    const1.type = T_NUMBER; const1.u.number = 1;
    constempty.type = T_FUNCTION; constempty.u.func = &funcempty;
    funcempty.funtype = FUN_EMPTY;
    catch_value = const0;
    
    /*
     * Check that the definition of EXTRACT_UCHAR() is correct.
     */
    p = (char *)&i;
    *p = -10;
    if (EXTRACT_UCHAR(p) != 0x100 - 10)
    {
	(void)fprintf(stderr, "Bad definition of EXTRACT_UCHAR() in config.h.\n");
	exit(1);
    }
    set_current_time();

#ifdef PROFILE_LPC
    set_profile_timebase(60.0); /* One minute */
#endif

#if RESERVED_SIZE > 0
    reserved_area = malloc(RESERVED_SIZE);
#endif

    init_random();
    init_tasks();
    query_load_av();
    init_num_args();
    init_machine();
    init_cfuns();
    init_hash();

    /*
     * Set up the signal handling.
     */
    init_signals();

    if (chdir(mudlib_path) == -1) {
        (void)fprintf(stderr, "Bad mudlib directory: %s\n", MUD_LIB);
	exit(1);
    }

    if (setjmp(exception_frame.e_context))
    {
	clear_state();
	add_message("Anomaly in the fabric of world space.\n");
    } 
    else
    {
	exception_frame.e_exception = NULL;
	exception_frame.e_catch = 0;
	exception = &exception_frame;
	auto_ob = 0;
	master_ob = 0;
	
	if ((auto_ob = load_object("secure/auto", 1, 0, 0)) != NULL)
	{
	    add_ref(auto_ob, "main");
	    auto_ob->prog->flags |= PRAGMA_RESIDENT;
	}

	get_simul_efun();
	master_ob = load_object("secure/master", 1, 0, 0);
	if (master_ob)
	{
	    /*
	     * Make sure master_ob is never made a dangling pointer.
	     * Look at apply_master_ob() for more details.
	     */
	    add_ref(master_ob, "main");
	    master_ob->prog->flags |= PRAGMA_RESIDENT;
            resolve_master_fkntab();
	    create_object(master_ob);
            load_parse_information();
	    clear_state();
	}
    }
    exception = NULL;
    if (auto_ob == 0) 
    {
	(void)fprintf(stderr, "The file secure/auto must be loadable.\n");
	exit(1);
    }
    if (master_ob == 0) 
    {
	(void)fprintf(stderr, "The file secure/master must be loadable.\n");
	exit(1);
    }
    set_inc_list(apply_master_ob(M_DEFINE_INCLUDE_DIRS, 0));
    
    {
	struct svalue* ret1;

	ret1 = apply_master_ob(M_PREDEF_DEFINES, 0);
	if (ret1 && ret1->type == T_POINTER)
	{
	    int ii;

	    for (ii = 0; ii < ret1->u.vec->size; ii++)
		if (ret1->u.vec->item[ii].type == T_STRING)
		{
                    add_pre_define(ret1->u.vec->item[ii].u.string);
		}
	}
    }

    if (flag != NULL)
    {
        printf("Applying driver flag: %s\n", flag);
        push_string(flag, STRING_MSTRING);
        (void)apply_master_ob(M_FLAG, 1);

        if (game_is_being_shut_down)
        {
            (void)fprintf(stderr, "Shutdown by master object.\n");
            exit(0);
        }
    }

    /*
     * See to it that the mud name is always defined in compiled files
     */
    ret = apply_master_ob(M_GET_MUD_NAME, 0);

    if (ret && ret->type == T_STRING)
    {
	struct lpc_predef_s *tmp;
		
	tmp = (struct lpc_predef_s *)
	    xalloc(sizeof(struct lpc_predef_s));
	if (!tmp) 
	    fatal("xalloc failed\n");
	tmp->flag = string_copy(ret->u.string);
	tmp->next = lpc_predefs;
	lpc_predefs = tmp;
    }

    ret = apply_master_ob(M_GET_VBFC_OBJECT, 0);
    if (ret && ret->type == T_OBJECT)
    {
	vbfc_object = ret->u.ob;
	INCREF(vbfc_object->ref);
    }
    else
	vbfc_object = 0;

    if (game_is_being_shut_down)
	exit(1);

    init_call_out();
    preload_objects(e_flag);
    (void)apply_master_ob(M_FINAL_BOOT, 0);
    
    mainloop();

    return 0;
}