diff src/openttd.cpp @ 9533:176a9fe1018f draft

(svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions
author smatz <smatz@openttd.org>
date Mon, 16 Jun 2008 19:38:41 +0000 (2008-06-16)
parents 47924a4b2ad4
children 67791dec09fd
line wrap: on
line diff
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -285,7 +285,7 @@
  * @param res variable to store the resolution in.
  * @param s   the string to decompose.
  */
-static void ParseResolution(int res[2], const char *s)
+static void ParseResolution(Dimension *res, const char *s)
 {
 	const char *t = strchr(s, 'x');
 	if (t == NULL) {
@@ -293,8 +293,8 @@
 		return;
 	}
 
-	res[0] = max(strtoul(s, NULL, 0), 64UL);
-	res[1] = max(strtoul(t + 1, NULL, 0), 64UL);
+	res->width  = max(strtoul(s, NULL, 0), 64UL);
+	res->height = max(strtoul(t + 1, NULL, 0), 64UL);
 }
 
 static void InitializeDynamicVariables()
@@ -379,7 +379,7 @@
 	int i;
 	const char *optformat;
 	char musicdriver[32], sounddriver[32], videodriver[32], blitter[32];
-	int resolution[2] = {0, 0};
+	Dimension resolution = {0, 0};
 	Year startyear = INVALID_YEAR;
 	uint generation_seed = GENERATE_NEW_SEED;
 	bool save_config = true;
@@ -444,7 +444,7 @@
 			debuglog_conn = mgo.opt;
 			break;
 #endif /* ENABLE_NETWORK */
-		case 'r': ParseResolution(resolution, mgo.opt); break;
+		case 'r': ParseResolution(&resolution, mgo.opt); break;
 		case 't': startyear = atoi(mgo.opt); break;
 		case 'd': {
 #if defined(WIN32)
@@ -497,14 +497,14 @@
 	if (!StrEmpty(sounddriver)) ttd_strlcpy(_ini_sounddriver, sounddriver, sizeof(_ini_sounddriver));
 	if (!StrEmpty(videodriver)) ttd_strlcpy(_ini_videodriver, videodriver, sizeof(_ini_videodriver));
 	if (!StrEmpty(blitter))     ttd_strlcpy(_ini_blitter, blitter, sizeof(_ini_blitter));
-	if (resolution[0] != 0) { _cur_resolution[0] = resolution[0]; _cur_resolution[1] = resolution[1]; }
+	if (resolution.width != 0) { _cur_resolution = resolution; }
 	if (startyear != INVALID_YEAR) _settings_newgame.game_creation.starting_year = startyear;
 	if (generation_seed != GENERATE_NEW_SEED) _settings_newgame.game_creation.generation_seed = generation_seed;
 
 	/* The width and height must be at least 1 pixel, this
 	 * way all internal drawing routines work correctly. */
-	if (_cur_resolution[0] == 0) _cur_resolution[0] = 1;
-	if (_cur_resolution[1] == 0) _cur_resolution[1] = 1;
+	if (_cur_resolution.width  <= 0) _cur_resolution.width  = 1;
+	if (_cur_resolution.height <= 0) _cur_resolution.height = 1;
 
 #if defined(ENABLE_NETWORK)
 	if (dedicated_host) snprintf(_settings_client.network.server_bind_ip, sizeof(_settings_client.network.server_bind_ip), "%s", dedicated_host);