Beispiel #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;
}
Beispiel #2
0
/**
 * A shared entry point to OpenRCT2. The command lines must be parsed before any further action is done. Invalid command lines
 * will then terminate before any initialisation has even been done.
 * @returns 1 if the game should run, otherwise 0.
 */
int cmdline_run(const char **argv, int argc)
{
	//
	int version = 0, headless = 0, verbose = 0, width = 0, height = 0, port = 0;
	char *server = NULL;
	char *userDataPath = NULL;

	argparse_option_t options[] = {
		OPT_HELP(),
		OPT_BOOLEAN('v', "version", &version, "show version information and exit"),
		OPT_BOOLEAN(0, "headless", &headless, "run OpenRCT2 headless"),
		OPT_BOOLEAN(0, "verbose", &verbose, "log verbose messages"),
		OPT_INTEGER('m', "mode", &sprite_mode, "the type of sprite conversion. 0 = default, 1 = simple closest pixel match, 2 = dithering"),
		OPT_STRING(0, "server", &server, "server to connect to"),
		OPT_INTEGER(0, "port", &port, "port"),
		OPT_STRING(0, "user-data-path", &userDataPath, "path to the user data directory (containing config.ini)"),
		OPT_END()
	};

	argparse_t argparse;
	argparse_init(&argparse, options, usage, 0);
	argc = argparse_parse(&argparse, argc, argv);

	if (version) {
		print_version();
		return 0;
	}

	if (headless)
		gOpenRCT2Headless = true;

	if (verbose)
		_log_levels[DIAGNOSTIC_LEVEL_VERBOSE] = 1;

	if (userDataPath != NULL) {
		safe_strncpy(gCustomUserDataPath, userDataPath, sizeof(gCustomUserDataPath));
	}

#ifndef DISABLE_NETWORK
	if (port != 0) {
		gNetworkStart = NETWORK_MODE_SERVER;
		gNetworkStartPort = port;
	}

	if (server != NULL) {
		gNetworkStart = NETWORK_MODE_CLIENT;
		safe_strncpy(gNetworkStartHost, server, sizeof(gNetworkStartHost));
	}
#endif // DISABLE_NETWORK

	if (argc != 0) {
		gExitCode = cmdline_call_action(argv, argc);
		if (gExitCode != 0) {
			return 0;
		}
	}

	// Headless mode requires a park to open
	if (gOpenRCT2Headless) {
		if (str_is_null_or_empty(gOpenRCT2StartupActionPath)) {
			printf("You must specify a park to open in headless mode.\n");
			gExitCode = -1;
			return 0;
		}
	}

	if (verbose) {
		print_launch_information();
	}
	return 1;
}