src/openttd.cpp
branchNewGRF_ports
changeset 10994 cd9968b6f96b
parent 10991 d8811e327d12
equal deleted inserted replaced
10991:d8811e327d12 10994:cd9968b6f96b
   284  * Extract the resolution from the given string and store
   284  * Extract the resolution from the given string and store
   285  * it in the 'res' parameter.
   285  * it in the 'res' parameter.
   286  * @param res variable to store the resolution in.
   286  * @param res variable to store the resolution in.
   287  * @param s   the string to decompose.
   287  * @param s   the string to decompose.
   288  */
   288  */
   289 static void ParseResolution(int res[2], const char *s)
   289 static void ParseResolution(Dimension *res, const char *s)
   290 {
   290 {
   291 	const char *t = strchr(s, 'x');
   291 	const char *t = strchr(s, 'x');
   292 	if (t == NULL) {
   292 	if (t == NULL) {
   293 		ShowInfoF("Invalid resolution '%s'", s);
   293 		ShowInfoF("Invalid resolution '%s'", s);
   294 		return;
   294 		return;
   295 	}
   295 	}
   296 
   296 
   297 	res[0] = max(strtoul(s, NULL, 0), 64UL);
   297 	res->width  = max(strtoul(s, NULL, 0), 64UL);
   298 	res[1] = max(strtoul(t + 1, NULL, 0), 64UL);
   298 	res->height = max(strtoul(t + 1, NULL, 0), 64UL);
   299 }
   299 }
   300 
   300 
   301 static void InitializeDynamicVariables()
   301 static void InitializeDynamicVariables()
   302 {
   302 {
   303 	/* Dynamic stuff needs to be initialized somewhere... */
   303 	/* Dynamic stuff needs to be initialized somewhere... */
   375 int ttd_main(int argc, char *argv[])
   375 int ttd_main(int argc, char *argv[])
   376 {
   376 {
   377 	int i;
   377 	int i;
   378 	const char *optformat;
   378 	const char *optformat;
   379 	char musicdriver[32], sounddriver[32], videodriver[32], blitter[32];
   379 	char musicdriver[32], sounddriver[32], videodriver[32], blitter[32];
   380 	int resolution[2] = {0, 0};
   380 	Dimension resolution = {0, 0};
   381 	Year startyear = INVALID_YEAR;
   381 	Year startyear = INVALID_YEAR;
   382 	uint generation_seed = GENERATE_NEW_SEED;
   382 	uint generation_seed = GENERATE_NEW_SEED;
   383 	bool save_config = true;
   383 	bool save_config = true;
   384 #if defined(ENABLE_NETWORK)
   384 #if defined(ENABLE_NETWORK)
   385 	bool dedicated = false;
   385 	bool dedicated = false;
   440 			break;
   440 			break;
   441 		case 'l':
   441 		case 'l':
   442 			debuglog_conn = mgo.opt;
   442 			debuglog_conn = mgo.opt;
   443 			break;
   443 			break;
   444 #endif /* ENABLE_NETWORK */
   444 #endif /* ENABLE_NETWORK */
   445 		case 'r': ParseResolution(resolution, mgo.opt); break;
   445 		case 'r': ParseResolution(&resolution, mgo.opt); break;
   446 		case 't': startyear = atoi(mgo.opt); break;
   446 		case 't': startyear = atoi(mgo.opt); break;
   447 		case 'd': {
   447 		case 'd': {
   448 #if defined(WIN32)
   448 #if defined(WIN32)
   449 				CreateConsole();
   449 				CreateConsole();
   450 #endif
   450 #endif
   493 	/* override config? */
   493 	/* override config? */
   494 	if (!StrEmpty(musicdriver)) ttd_strlcpy(_ini_musicdriver, musicdriver, sizeof(_ini_musicdriver));
   494 	if (!StrEmpty(musicdriver)) ttd_strlcpy(_ini_musicdriver, musicdriver, sizeof(_ini_musicdriver));
   495 	if (!StrEmpty(sounddriver)) ttd_strlcpy(_ini_sounddriver, sounddriver, sizeof(_ini_sounddriver));
   495 	if (!StrEmpty(sounddriver)) ttd_strlcpy(_ini_sounddriver, sounddriver, sizeof(_ini_sounddriver));
   496 	if (!StrEmpty(videodriver)) ttd_strlcpy(_ini_videodriver, videodriver, sizeof(_ini_videodriver));
   496 	if (!StrEmpty(videodriver)) ttd_strlcpy(_ini_videodriver, videodriver, sizeof(_ini_videodriver));
   497 	if (!StrEmpty(blitter))     ttd_strlcpy(_ini_blitter, blitter, sizeof(_ini_blitter));
   497 	if (!StrEmpty(blitter))     ttd_strlcpy(_ini_blitter, blitter, sizeof(_ini_blitter));
   498 	if (resolution[0] != 0) { _cur_resolution[0] = resolution[0]; _cur_resolution[1] = resolution[1]; }
   498 	if (resolution.width != 0) { _cur_resolution = resolution; }
   499 	if (startyear != INVALID_YEAR) _settings_newgame.game_creation.starting_year = startyear;
   499 	if (startyear != INVALID_YEAR) _settings_newgame.game_creation.starting_year = startyear;
   500 	if (generation_seed != GENERATE_NEW_SEED) _settings_newgame.game_creation.generation_seed = generation_seed;
   500 	if (generation_seed != GENERATE_NEW_SEED) _settings_newgame.game_creation.generation_seed = generation_seed;
   501 
   501 
   502 	/* The width and height must be at least 1 pixel, this
   502 	/* The width and height must be at least 1 pixel, this
   503 	 * way all internal drawing routines work correctly. */
   503 	 * way all internal drawing routines work correctly. */
   504 	if (_cur_resolution[0] == 0) _cur_resolution[0] = 1;
   504 	if (_cur_resolution.width  <= 0) _cur_resolution.width  = 1;
   505 	if (_cur_resolution[1] == 0) _cur_resolution[1] = 1;
   505 	if (_cur_resolution.height <= 0) _cur_resolution.height = 1;
   506 
   506 
   507 #if defined(ENABLE_NETWORK)
   507 #if defined(ENABLE_NETWORK)
   508 	if (dedicated_host) snprintf(_settings_client.network.server_bind_ip, sizeof(_settings_client.network.server_bind_ip), "%s", dedicated_host);
   508 	if (dedicated_host) snprintf(_settings_client.network.server_bind_ip, sizeof(_settings_client.network.server_bind_ip), "%s", dedicated_host);
   509 	if (dedicated_port) _settings_client.network.server_port = dedicated_port;
   509 	if (dedicated_port) _settings_client.network.server_port = dedicated_port;
   510 	if (_dedicated_forks && !dedicated) _dedicated_forks = false;
   510 	if (_dedicated_forks && !dedicated) _dedicated_forks = false;