示例#1
0
    IPlatformEnvironment * SetupEnvironment()
    {
        utf8 userPath[MAX_PATH];
        platform_resolve_openrct_data_path();
        platform_resolve_user_data_path();
        platform_get_user_directory(userPath, NULL, sizeof(userPath));
        if (!platform_ensure_directory_exists(userPath))
        {
            Console::Error::WriteLine("Could not create user directory (do you have write access to your documents folder?)");
            return nullptr;
        }
        openrct2_set_exe_path();

        config_set_defaults();
        if (!config_open_default())
        {
            if (!config_find_or_browse_install_directory())
            {
                gConfigGeneral.last_run_version = String::Duplicate(OPENRCT2_VERSION);
                config_save_default();
                utf8 path[MAX_PATH];
                config_get_default_path(path, sizeof(path));
                Console::Error::WriteLine("An RCT2 install directory must be specified! Please edit \"game_path\" in %s.", path);
                return nullptr;
            }
            config_save_default();
        }

        if (!rct2_init_directories())
        {
            return nullptr;
        }
        if (!rct2_startup_checks())
        {
            return nullptr;
        }

        utf8 path[260];
        std::string basePaths[4];
        basePaths[(size_t)DIRBASE::RCT1] = String::ToStd(gConfigGeneral.rct1_path);
        basePaths[(size_t)DIRBASE::RCT2] = String::ToStd(gConfigGeneral.rct2_path);
        platform_get_openrct_data_path(path, sizeof(path));
        basePaths[(size_t)DIRBASE::OPENRCT2] = std::string(path);
        platform_get_user_directory(path, nullptr, sizeof(path));
        basePaths[(size_t)DIRBASE::USER] = std::string(path);

        IPlatformEnvironment * env = CreatePlatformEnvironment(basePaths);
        return env;
    }
示例#2
0
文件: rct2.c 项目: Aitchwing/OpenRCT2
int rct2_init()
{
	log_verbose("initialising game");

	RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, uint32) = 0;
	RCT2_GLOBAL(0x009AC310, char*) = RCT2_GLOBAL(RCT2_ADDRESS_CMDLINE, char*);
	get_system_time();
	util_srand((unsigned int)time(0));
	RCT2_GLOBAL(0x009DEA69, short) = RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_DAY, short);
	RCT2_GLOBAL(0x009DEA6B, short) = RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_MONTH, short);
	if (!rct2_init_directories())
		return 0;

	if (!rct2_startup_checks())
		return 0;

	config_reset_shortcut_keys();
	config_shortcut_keys_load();
	RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) = 0;
	// config_load();

	object_list_load();
	scenario_load_list();

	ride_list_item item = { 253, 0 };
	track_load_list(item);

	gfx_load_g1();
	gfx_load_g2();
	font_sprite_initialise_characters();
	if (!gOpenRCT2Headless) {
		platform_init();
		audio_init_ride_sounds_and_info();
	}
	viewport_init_all();
	news_item_init_queue();
	get_local_time();
	reset_park_entrances();
	user_string_clear_all();
	reset_sprite_list();
	ride_init_all();
	window_guest_list_init_vars_a();
	staff_reset_modes();
	map_init(150);
	park_init();
	if (!gOpenRCT2Headless)
		window_title_menu_open();
	date_reset();
	climate_reset(CLIMATE_COOL_AND_WET);
	scenery_set_default_placement_configuration();
	window_new_ride_init_vars();
	window_guest_list_init_vars_b();
	window_staff_list_init_vars();

	if (!gOpenRCT2Headless) {
		title_load();

		gfx_clear(RCT2_ADDRESS(RCT2_ADDRESS_SCREEN_DPI, rct_drawpixelinfo), 10);
	}

	log_verbose("initialising game finished");
	return 1;
}