Changeset - r5049:c0ab8506ce5a
[Not reviewed]
master
0 1 0
peter1138 - 18 years ago 2006-11-07 15:25:07
peter1138@openttd.org
(svn r7099) -Fix (r4768): When changing the selected newstation type, ensure the station size chosen is permitted. If not, pick the first valid sizes.
1 file changed with 29 insertions and 0 deletions:
0 comments (0 inline, 0 general)
rail_gui.c
Show inline comments
 
@@ -631,6 +631,30 @@ static void HandleStationPlacement(TileI
 
			CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_AUTO | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION));
 
}
 

	
 
/* Check if the currently selected station size is allowed */
 
static void CheckSelectedSize(Window *w, const StationSpec *statspec)
 
{
 
	if (statspec == NULL || _railstation.dragdrop) return;
 

	
 
	if (HASBIT(statspec->disallowed_platforms, _railstation.numtracks - 1)) {
 
		RaiseWindowWidget(w, _railstation.numtracks + 4);
 
		_railstation.numtracks = 1;
 
		while (HASBIT(statspec->disallowed_platforms, _railstation.numtracks - 1)) {
 
			_railstation.numtracks++;
 
		}
 
		LowerWindowWidget(w, _railstation.numtracks + 4);
 
	}
 

	
 
	if (HASBIT(statspec->disallowed_lengths, _railstation.platlength - 1)) {
 
		RaiseWindowWidget(w, _railstation.platlength + 11);
 
		_railstation.platlength = 1;
 
		while (HASBIT(statspec->disallowed_lengths, _railstation.platlength - 1)) {
 
			_railstation.platlength++;
 
		}
 
		LowerWindowWidget(w, _railstation.platlength + 11);
 
	}
 
}
 

	
 
static void StationBuildWndProc(Window *w, WindowEvent *e)
 
{
 
	switch (e->event) {
 
@@ -824,6 +848,9 @@ static void StationBuildWndProc(Window *
 
				GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE) == 0) return;
 

	
 
			_railstation.station_type = y;
 

	
 
			CheckSelectedSize(w, statspec);
 

	
 
			SndPlayFx(SND_15_BEEP);
 
			SetWindowDirty(w);
 
			break;
 
@@ -837,6 +864,8 @@ static void StationBuildWndProc(Window *
 
			_railstation.station_type  = 0;
 
			_railstation.station_count = GetNumCustomStations(_railstation.station_class);
 

	
 
			CheckSelectedSize(w, GetCustomStationSpec(_railstation.station_class, _railstation.station_type));
 

	
 
			w->vscroll.count = _railstation.station_count;
 
			w->vscroll.pos   = _railstation.station_type;
 
		}
0 comments (0 inline, 0 general)