(svn r7951) -Backport from trunk (r7810, r7812): 0.5
authorDarkvater
Sun, 07 Jan 2007 12:13:57 +0000
branch0.5
changeset 5394 58afc8e5ff3e
parent 5393 55e249a41db4
child 5395 9443baf4f597
(svn r7951) -Backport from trunk (r7810, r7812):
- Building airport whose size exceeds max station spread-out caused assert. (r7810)
- rail station build window was not correctly updated after station_spread change (r7812)
rail_gui.c
station_cmd.c
--- a/rail_gui.c	Sun Jan 07 12:11:54 2007 +0000
+++ b/rail_gui.c	Sun Jan 07 12:13:57 2007 +0000
@@ -694,6 +694,7 @@
 		bool newstations = _railstation.newstations;
 		int y_offset;
 		DrawPixelInfo tmp_dpi, *old_dpi;
+		const StationSpec *statspec = newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL;
 
 		if (WP(w,def_d).close) return;
 
@@ -712,23 +713,14 @@
 		if (_station_show_coverage)
 			SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
 
-		/* Update buttons for correct spread value */
-		for (bits = _patches.station_spread; bits < 7; bits++) {
-			DisableWindowWidget(w, bits + 5);
-			DisableWindowWidget(w, bits + 12);
-		}
-
-		if (newstations) {
-			const StationSpec *statspec = GetCustomStationSpec(_railstation.station_class, _railstation.station_type);
-
-			for (bits = 0; bits < 7; bits++) {
-				if (statspec == NULL) {
-					EnableWindowWidget(w, bits +  5);
-					EnableWindowWidget(w, bits + 12);
-				} else {
-					SetWindowWidgetDisabledState(w, bits +  5, HASBIT(statspec->disallowed_platforms, bits));
-					SetWindowWidgetDisabledState(w, bits + 12, HASBIT(statspec->disallowed_lengths,   bits));
-				}
+		for (bits = 0; bits < 7; bits++) {
+			bool disable = bits >= _patches.station_spread;
+			if (statspec == NULL) {
+				SetWindowWidgetDisabledState(w, bits +  5, disable);
+				SetWindowWidgetDisabledState(w, bits + 12, disable);
+			} else {
+				SetWindowWidgetDisabledState(w, bits +  5, HASBIT(statspec->disallowed_platforms, bits) || disable);
+				SetWindowWidgetDisabledState(w, bits + 12, HASBIT(statspec->disallowed_lengths,   bits) || disable);
 			}
 		}
 
--- a/station_cmd.c	Sun Jan 07 12:11:54 2007 +0000
+++ b/station_cmd.c	Sun Jan 07 12:13:57 2007 +0000
@@ -1700,6 +1700,11 @@
 		if (st != NULL && st->facilities) st = NULL;
 	}
 
+	if (w > _patches.station_spread || h > _patches.station_spread) {
+		_error_message = STR_306C_STATION_TOO_SPREAD_OUT;
+		return CMD_ERROR;
+	}
+
 	if (st != NULL) {
 		if (st->owner != OWNER_NONE && st->owner != _current_player)
 			return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION);