Example #1
0
__declspec(dllexport) int StartOpenRCT(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	print_launch_information();

	// Begin RCT2
	RCT2_GLOBAL(RCT2_ADDRESS_HINSTANCE, HINSTANCE) = hInstance;
	RCT2_GLOBAL(RCT2_ADDRESS_CMDLINE, LPSTR) = lpCmdLine;
	get_system_info();

	audio_init();
	audio_get_devices();
	RCT2_CALLPROC(0x0040502E); // get_dsound_devices()
	config_init();
	language_open(gGeneral_config.language);
	rct2_init();
	rct2_loop();
	osinterface_free();
	exit(0);

	return 0;
}
Example #2
0
bool openrct2_initialise()
{
	utf8 userPath[MAX_PATH];

	platform_resolve_user_data_path();
	platform_get_user_directory(userPath, NULL);
	if (!platform_ensure_directory_exists(userPath)) {
		log_fatal("Could not create user directory (do you have write access to your documents folder?)");
		return false;
	}

	if (!openrct2_setup_rct2_segment()) {
		log_fatal("Unable to load RCT2 data sector");
		return false;
	}

	openrct2_set_exe_path();

	config_set_defaults();
	if (!config_open_default()) {
		if (!config_find_or_browse_install_directory()) {
			log_fatal("An RCT2 install directory must be specified!");
			return false;
		}
	}

	gOpenRCT2ShowChangelog = true;
	if (gConfigGeneral.last_run_version != NULL && (strcmp(gConfigGeneral.last_run_version, OPENRCT2_VERSION) == 0))
		gOpenRCT2ShowChangelog = false;
	gConfigGeneral.last_run_version = OPENRCT2_VERSION;
	config_save_default();

	// TODO add configuration option to allow multiple instances
	// if (!gOpenRCT2Headless && !platform_lock_single_instance()) {
	// 	log_fatal("OpenRCT2 is already running.");
	// 	return false;
	// }

	get_system_info();
	if (!gOpenRCT2Headless) {
		audio_init();
		audio_get_devices();
	}
	if (!language_open(gConfigGeneral.language))
	{
		log_fatal("Failed to open language, exiting.");
		return false;
	}
	http_init();

	themes_set_default();
	themes_load_presets();
	title_sequences_set_default();
	title_sequences_load_presets();

	openrct2_setup_rct2_hooks();

	if (!rct2_init())
		return false;

	chat_init();

	openrct2_copy_original_user_files_over();

	// TODO move to audio initialise function
	if (str_is_null_or_empty(gConfigSound.device)) {
		Mixer_Init(NULL);
		RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) = 0;
	} else {
		Mixer_Init(gConfigSound.device);
		for (int i = 0; i < gAudioDeviceCount; i++) {
			if (strcmp(gAudioDevices[i].name, gConfigSound.device) == 0) {
				RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) = i;
			}
		}
	}

	return true;
}
Example #3
0
    bool openrct2_initialise()
    {
#ifndef DISABLE_NETWORK
        gHashCTX = EVP_MD_CTX_create();
        Guard::Assert(gHashCTX != nullptr, "EVP_MD_CTX_create failed");
#endif // DISABLE_NETWORK

        crash_init();

        // Sets up the environment OpenRCT2 is running in, e.g. directory paths
        OpenRCT2::_env = OpenRCT2::SetupEnvironment();
        if (OpenRCT2::_env == nullptr)
        {
            return false;
        }

        if (!rct2_interop_setup_segment())
        {
            log_fatal("Unable to load RCT2 data sector");
            return false;
        }

        if (gConfigGeneral.last_run_version != nullptr && String::Equals(gConfigGeneral.last_run_version, OPENRCT2_VERSION))
        {
            gOpenRCT2ShowChangelog = false;
        }
        else
        {
            gOpenRCT2ShowChangelog = true;
            gConfigGeneral.last_run_version = String::Duplicate(OPENRCT2_VERSION);
            config_save_default();
        }

        // TODO add configuration option to allow multiple instances
        // if (!gOpenRCT2Headless && !platform_lock_single_instance()) {
        // 	log_fatal("OpenRCT2 is already running.");
        // 	return false;
        // }

        IObjectRepository * objRepo = CreateObjectRepository(OpenRCT2::_env);
        ITrackDesignRepository * tdRepo = CreateTrackDesignRepository(OpenRCT2::_env);
        IScenarioRepository * scenarioRepo = CreateScenarioRepository(OpenRCT2::_env);

        if (!language_open(gConfigGeneral.language))
        {
            log_error("Failed to open configured language...");
            if (!language_open(LANGUAGE_ENGLISH_UK))
            {
                log_fatal("Failed to open fallback language...");
                return false;
            }
        }

        // TODO Ideally we want to delay this until we show the title so that we can
        //      still open the game window and draw a progress screen for the creation
        //      of the object cache.
        objRepo->LoadOrConstruct();

        // TODO Like objects, this can take a while if there are a lot of track designs
        //      its also really something really we might want to do in the background
        //      as its not required until the player wants to place a new ride.
        tdRepo->Scan();

        scenarioRepo->Scan();
        TitleSequenceManager::Scan();

        if (!gOpenRCT2Headless)
        {
            audio_init();
            audio_populate_devices();
        }

        http_init();
        theme_manager_initialise();

        rct2_interop_setup_hooks();

        if (!rct2_init())
        {
            return false;
        }

        chat_init();

        rct2_copy_original_user_files_over();
        return true;
    }