Пример #1
0
void bye(void)
{
	channel_kill();
	tunnels_kill();
	net_exit();
	exit(0);
}
Пример #2
0
void void_exit( void )
{
	phys_exit();
	script_exit();
	net_exit();
	input_exit();
	audio_exit();
	video_exit();
	log_exit();
}
Пример #3
0
/**
 * Exit derrick.
 * @param s Signal number
 */
void derrick_exit(int s)
{
    /* Exit network monitoring */
    net_exit();

    /* Close log file */
    log_close();

    /* Point of no return  */
    exit(EXIT_SUCCESS);
}
Пример #4
0
void osd_exit(void)
{
    MAME32App.m_bIsInitialized = FALSE;
    MAME32App.m_bDone = FALSE;

    if (MAME32App.m_pFMSynth  != NULL) MAME32App.m_pFMSynth->exit();
    if (MAME32App.m_pTrak     != NULL) MAME32App.m_pTrak->exit();
    if (MAME32App.m_pJoystick != NULL) MAME32App.m_pJoystick->exit();
    if (MAME32App.m_pKeyboard != NULL) MAME32App.m_pKeyboard->exit();
    if (MAME32App.m_pSound    != NULL) MAME32App.m_pSound->exit();
    if (MAME32App.m_pDisplay  != NULL) MAME32App.m_pDisplay->exit();
#ifdef MAME_NET
    if (MAME32App.m_pNetwork  != NULL) net_exit( NET_QUIT_QUIT );
#endif /* MAME_NET */

    uclock_exit();

    if (IsWindow(MAME32App.m_hWnd))
        DestroyWindow(MAME32App.m_hWnd);
}
Пример #5
0
int osd_init()
{
    BOOL    bUseDirectDraw  = TRUE;
    BOOL    bUseWindow      = FALSE;
    BOOL    bNoSound        = FALSE;
    BOOL    bUseMIDASSound  = FALSE;
    BOOL    bUseDirectSound = FALSE;
    BOOL    bUseAIMouse     = FALSE;
    BOOL    bUseDIKeyboard  = FALSE;
    BOOL    bUseDIJoystick  = FALSE;
#ifdef MAME_NET
    BOOL    bUseNetwork     = FALSE;
#endif /* MAME_NET */
    BOOL    bDisplayInitialized  = FALSE;
    BOOL    bSoundInitialized    = FALSE;
    BOOL    bKeyboardInitialized = FALSE;
    BOOL    bJoystickInitialized = FALSE;
    BOOL    bTrakInitialized     = FALSE;
    BOOL    bFMSynthInitialized  = FALSE;
#ifdef MAME_NET
    BOOL    bNetworkInitialized  = FALSE;
#endif /* MAME_NET */

    options_type *options = GetPlayingGameOptions();

    if (options->is_window)
        bUseWindow = TRUE;

    if (options->is_window && !options->window_ddraw)
        bUseDirectDraw = FALSE;

    if (options->sound == SOUND_NONE)
        bNoSound = TRUE;

#ifndef NOMIDAS
    if (options->sound == SOUND_MIDAS)
        bUseMIDASSound = TRUE;
#endif

    if (options->sound == SOUND_DIRECT)
        bUseDirectSound = TRUE;

    if (options->use_ai_mouse)
        bUseAIMouse = TRUE;

    if (options->di_keyboard)
        bUseDIKeyboard = TRUE;

    if (options->di_joystick)
        bUseDIJoystick = TRUE;

#ifdef MAME_NET
    if (MAME32App.m_bUseNetwork)
        bUseNetwork = TRUE;

#endif /* MAME_NET */
   
    /*
        Set up.
    */
    MAME32App_init(options);

    if (bUseDirectDraw == FALSE)
        MAME32App.m_pDisplay = &GDIDisplay;
    else
    if (bUseWindow == TRUE)
        MAME32App.m_pDisplay = &GDIDisplay;/*&DDrawWindowDisplay;*/
    else
#if defined(MAME_DEBUG)
        /* don't do fullscreen debugging */
        MAME32App.m_pDisplay = &GDIDisplay;
#else
        MAME32App.m_pDisplay = &DDrawDisplay;
#endif

    if (bNoSound == TRUE)
        MAME32App.m_pSound = &NullSound;
    else
#ifndef NOMIDAS
    if (bUseMIDASSound == TRUE)
        MAME32App.m_pSound = &MIDASSound;
    else
#endif
    if (bUseDirectSound == TRUE)
        MAME32App.m_pSound = &DirectSound;

    MAME32App.m_pTrak = &Trak;

    MAME32App.m_bUseAIMouse = bUseAIMouse;

    if (bUseDIKeyboard == TRUE)
        MAME32App.m_pKeyboard = &DIKeyboard;
    else
        MAME32App.m_pKeyboard = &Keyboard;
    if (bUseDIJoystick == TRUE)
        MAME32App.m_pJoystick = &DIJoystick;
    else
        MAME32App.m_pJoystick = &Joystick;

    if (options->fm_ym3812)
    {
        if (OnNT())
            MAME32App.m_pFMSynth = &NTFMSynth;
        else
            MAME32App.m_pFMSynth = &FMSynth;
    }
    else
        MAME32App.m_pFMSynth = NULL;

#ifdef MAME_NET

#if 0
    if (bUseNetwork == TRUE )
	{
        MAME32App.m_pNetwork = &Network;
	}
    else
	{
        MAME32App.m_pNetwork = NULL;
	}

    /* TODO: show chat screen */
#endif
	/* init network thread */
    if (bUseNetwork)
    {
		if (net_game_init() != 0)
		{
            goto error;
		}
        else
		{
            bNetworkInitialized = TRUE;
		}
    }

	/* TODO: spin until chat screen says go */
#endif /* MAME_NET */

    MAME32App.m_hWnd = MAME32App.CreateMAMEWindow();

    if (IsWindow(MAME32App.m_hWnd) == FALSE)
        goto error;

    /* 
        Initialize everything.
    */
    uclock_init();
    if (MAME32App.m_pDisplay != NULL)
    {        
        if (MAME32App.m_pDisplay->init(options) != 0)
            goto error;
        else
            bDisplayInitialized = TRUE;
    }

    if (MAME32App.m_pSound != NULL)
    {
        if (MAME32App.m_pSound->init(options) != 0)
            goto error;
        else
            bSoundInitialized = TRUE;        
    }

    if (MAME32App.m_pKeyboard != NULL)
    {
        if (MAME32App.m_pKeyboard->init(options) != 0)
            goto error;
        else
            bKeyboardInitialized = TRUE;        
    }

    if (MAME32App.m_pJoystick != NULL)
    {
        if (MAME32App.m_pJoystick->init(options) != 0)
            goto error;
        else
            bJoystickInitialized = TRUE;
    }

    if (MAME32App.m_pTrak != NULL)
    {
        if (MAME32App.m_pTrak->init(options) != 0)
            goto error;
        else
            bTrakInitialized = TRUE;
    }

    if (MAME32App.m_pFMSynth != NULL)
    {
        if (MAME32App.m_pFMSynth->init(options) != 0)
            goto error;
        else
            bFMSynthInitialized = TRUE;
    }

    osd_set_mastervolume(- options->volume);
    return 0;

error:

    if (bFMSynthInitialized  == TRUE) MAME32App.m_pFMSynth->exit();
    if (bTrakInitialized     == TRUE) MAME32App.m_pTrak->exit();
    if (bJoystickInitialized == TRUE) MAME32App.m_pJoystick->exit();
    if (bKeyboardInitialized == TRUE) MAME32App.m_pKeyboard->exit();
    if (bSoundInitialized    == TRUE) MAME32App.m_pSound->exit();
    if (bDisplayInitialized  == TRUE) MAME32App.m_pDisplay->exit();
#ifdef MAME_NET
    //if (bNetInitialized)  osd_net_game_exit();
    if (MAME32App.m_pNetwork  != NULL) net_exit( NET_QUIT_ABRT );
#endif /* MAME_NET */
    uclock_exit();

    if (IsWindow(MAME32App.m_hWnd))
        DestroyWindow(MAME32App.m_hWnd);

    return 1;
}
Пример #6
0
int main(int argc, char* argv[])
{
	pid_t pid;
	
	parse_args(argc, argv);

	if (config_init(argv[1]) == -1) {
		BOOT_LOG(-1, "Failed to Parse File '%s'", argv[1]);
	}

	if (config_init("common.conf") == -1) {
			BOOT_LOG(-1, "Failed to Parse File '%s'", argv[1]);
	}

	daemon_start(argc, argv);
	load_bind_file();
	log_init_ex( config_get_strval("log_dir"),
				config_get_intval("log_level", log_lvl_trace),
				config_get_intval("log_size", 1<<30),
				config_get_intval("max_log_files", 0),
				config_get_strval("log_prefix") ,
				config_get_intval("log_save_next_file_interval_min", 0) );

    //Èç¹ûʹÓÃÔà´Ê¼ì²âÂß¼­£¬Ôò¿ªÆô¸¸½ø³ÌµÄÔà´Ê¸üÐÂÂß¼­.
    if (config_get_intval("tm_dirty_use_dirty_logical", 1) == 1) {
        if (tm_dirty_daemon( config_get_strval("tm_dirty_local_dirty_file_path"),
                    config_get_strval("tm_dirty_server_addr"),
                    config_get_intval("tm_dirty_update_cycle", 600),
                    NULL) == -1) {
            BOOT_LOG(-1, "FAILED TO RUN TM_DIRTY_DAEMON");
        }   
    }   

	net_init(MAXFDS, MAXFDS);

	bind_config_t* bc = get_bind_conf();
//--------------------------------
	net_start(config_get_strval("online_ip"), config_get_intval("online_port", 443), bc->configs);
//--------------------------------

//	bind_config_elem_t* bc_elem;
	int i = 0;
	for ( ; i != bc->bind_num; ++i ) {
		bind_config_elem_t* bc_elem = &(bc->configs[i]);
		shmq_create(bc_elem);

		if ( (pid = fork ()) < 0 ) {
			BOOT_LOG(-1, "fork child process");
		} else if (pid > 0) { //parent process
			close_shmq_pipe(bc, i, 0);
			do_add_conn(bc_elem->sendq.pipe_handles[0], PIPE_TYPE_FD, 0, bc_elem);
			//net_start(bc_elem->bind_ip, bc_elem->bind_port, bc_elem);
		} else { //child process
			run_worker_process(bc, i, i + 1);
		}
	}

	while (!stop) {
		net_loop(-1, PAGESIZE, 1);
	}

	net_exit();
	shmq_destroy(0, bc->bind_num);
	daemon_stop();

	return 0;
}