Changeset - r16743:d5b704fe24fb
[Not reviewed]
master
0 1 0
rubidium - 14 years ago 2010-12-12 18:23:38
rubidium@openttd.org
(svn r21486) -Codechange: use TILE_AREA_LOOP for station expansion checks as well
1 file changed with 6 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/station_cmd.cpp
Show inline comments
 
@@ -81,14 +81,18 @@ bool IsHangar(TileIndex t)
 
 * @param st to 'return' the found station
 
 * @return Succeeded command (if zero or one station found) or failed command (for two or more stations found).
 
 */
 
template <class T>
 
CommandCost GetStationAround(TileArea ta, StationID closest_station, T **st)
 
{
 
	ta.tile -= TileDiffXY(1, 1);
 
	ta.w    += 2;
 
	ta.h    += 2;
 

	
 
	/* check around to see if there's any stations there */
 
	TILE_LOOP(tile_cur, ta.w + 2, ta.h + 2, ta.tile - TileDiffXY(1, 1)) {
 
	TILE_AREA_LOOP(tile_cur, ta) {
 
		if (IsTileType(tile_cur, MP_STATION)) {
 
			StationID t = GetStationIndex(tile_cur);
 

	
 
			if (closest_station == INVALID_STATION) {
 
				if (T::IsValidID(t)) closest_station = t;
 
			} else if (closest_station != t) {
 
@@ -937,13 +941,13 @@ CommandCost CanExpandRailStation(const B
 
		new_ta.w = max(TileX(cur_ta.tile) + cur_ta.w, TileX(new_ta.tile) + new_ta.w) - x;
 
		new_ta.h = max(TileY(cur_ta.tile) + cur_ta.h, TileY(new_ta.tile) + new_ta.h) - y;
 
		new_ta.tile = TileXY(x, y);
 
	} else {
 
		/* do not allow modifying non-uniform stations,
 
		 * the uniform-stations code wouldn't handle it well */
 
		TILE_LOOP(t, cur_ta.w, cur_ta.h, cur_ta.tile) {
 
		TILE_AREA_LOOP(t, cur_ta) {
 
			if (!st->TileBelongsToRailStation(t)) { // there may be adjoined station
 
				return_cmd_error(STR_ERROR_NONUNIFORM_STATIONS_DISALLOWED);
 
			}
 
		}
 

	
 
		/* check so the orientation is the same */
0 comments (0 inline, 0 general)