File diff r5507:004ffecfe27d → r5508:5023c41fcac4
src/openttd.c
Show inline comments
 
@@ -155,13 +155,13 @@ static void showhelp(void)
 
		"  -t year             = Set starting year\n"
 
		"  -d [[fac=]lvl[,...]]= Debug mode\n"
 
		"  -e                  = Start Editor\n"
 
		"  -g [savegame]       = Start new/save game immediately\n"
 
		"  -G seed             = Set random seed\n"
 
		"  -n [ip:port#player] = Start networkgame\n"
 
		"  -D                  = Start dedicated server\n"
 
		"  -D [ip][:port]      = Start dedicated server\n"
 
#if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(WIN32)
 
		"  -f                  = Fork into the background (dedicated only)\n"
 
#endif
 
		"  -i                  = Force to use the DOS palette\n"
 
		"                          (use this if you see a lot of pink)\n"
 
		"  -c config_file      = Use 'config_file' instead of 'openttd.cfg'\n"
 
@@ -333,12 +333,14 @@ int ttd_main(int argc, char *argv[])
 
	Year startyear = INVALID_YEAR;
 
	uint generation_seed = GENERATE_NEW_SEED;
 
	bool dedicated = false;
 
	bool network   = false;
 
	bool save_config = true;
 
	char *network_conn = NULL;
 
	char *dedicated_host = NULL;
 
	uint16 dedicated_port = 0;
 

	
 
	musicdriver[0] = sounddriver[0] = videodriver[0] = 0;
 

	
 
	_game_mode = GM_MENU;
 
	_switch_mode = SM_MENU;
 
	_switch_mode_errorstr = INVALID_STRING_ID;
 
@@ -346,13 +348,13 @@ int ttd_main(int argc, char *argv[])
 
	_config_file = NULL;
 

	
 
	// The last param of the following function means this:
 
	//   a letter means: it accepts that param (e.g.: -h)
 
	//   a ':' behind it means: it need a param (e.g.: -m<driver>)
 
	//   a '::' behind it means: it can optional have a param (e.g.: -d<debug>)
 
	optformat = "m:s:v:hDn::eit:d::r:g::G:c:x"
 
	optformat = "m:s:v:hD::n::eit:d::r:g::G:c:x"
 
#if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(WIN32)
 
		"f"
 
#endif
 
	;
 

	
 
	MyGetOptInit(&mgo, argc-1, argv+1, optformat);
 
@@ -363,12 +365,22 @@ int ttd_main(int argc, char *argv[])
 
		case 'v': ttd_strlcpy(videodriver, mgo.opt, sizeof(videodriver)); break;
 
		case 'D':
 
			strcpy(musicdriver, "null");
 
			strcpy(sounddriver, "null");
 
			strcpy(videodriver, "dedicated");
 
			dedicated = true;
 
			if (mgo.opt != NULL)
 
			{
 
				/* Use the existing method for parsing (openttd -n).
 
				 * However, we do ignore the #player part. */
 
				const char *temp = NULL;
 
				const char *port = NULL;
 
				ParseConnectionString(&temp, &port, mgo.opt);
 
				if (*mgo.opt != '\0') dedicated_host = mgo.opt;
 
				if (port != NULL) dedicated_port = atoi(port);
 
			}
 
			break;
 
		case 'f': _dedicated_forks = true; break;
 
		case 'n':
 
			network = true;
 
			network_conn = mgo.opt; // optional IP parameter, NULL if unset
 
			break;
 
@@ -418,12 +430,14 @@ int ttd_main(int argc, char *argv[])
 
	if (sounddriver[0]) ttd_strlcpy(_ini_sounddriver, sounddriver, sizeof(_ini_sounddriver));
 
	if (videodriver[0]) ttd_strlcpy(_ini_videodriver, videodriver, sizeof(_ini_videodriver));
 
	if (resolution[0]) { _cur_resolution[0] = resolution[0]; _cur_resolution[1] = resolution[1]; }
 
	if (startyear != INVALID_YEAR) _patches_newgame.starting_year = startyear;
 
	if (generation_seed != GENERATE_NEW_SEED) _patches_newgame.generation_seed = generation_seed;
 

	
 
	if (dedicated_host) snprintf(_network_server_bind_ip_host, NETWORK_HOSTNAME_LENGTH, "%s", dedicated_host);
 
	if (dedicated_port) _network_server_port = dedicated_port;
 
	if (_dedicated_forks && !dedicated) _dedicated_forks = false;
 

	
 
	// enumerate language files
 
	InitializeLanguagePacks();
 

	
 
	// initialize screenshot formats