Changeset - r14681:3d2babfe4327
[Not reviewed]
master
0 2 0
alberth - 15 years ago 2010-02-27 13:51:11
alberth@openttd.org
(svn r19273) -Codechange: Return station joining error message when error is detected.
2 files changed with 11 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/station_cmd.cpp
Show inline comments
 
@@ -80,10 +80,10 @@ bool IsHangar(TileIndex t)
 
 * @param ta the area to search over
 
 * @param closest_station the closest station found so far
 
 * @param st to 'return' the found station
 
 * @return false if more than one stations are found. True when zero or one are found.
 
 * @return Succeeded command (if zero or one station found) or failed command (for two or more stations found).
 
 */
 
template <class T>
 
bool GetStationAround(TileArea ta, StationID closest_station, T **st)
 
CommandCost GetStationAround(TileArea ta, StationID closest_station, T **st)
 
{
 
	/* 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)) {
 
@@ -93,13 +93,12 @@ bool GetStationAround(TileArea ta, Stati
 
			if (closest_station == INVALID_STATION) {
 
				if (T::IsValidID(t)) closest_station = t;
 
			} else if (closest_station != t) {
 
				_error_message = STR_ERROR_ADJOINS_MORE_THAN_ONE_EXISTING;
 
				return false;
 
				return_cmd_error(STR_ERROR_ADJOINS_MORE_THAN_ONE_EXISTING);
 
			}
 
		}
 
	}
 
	*st = (closest_station == INVALID_STATION) ? NULL : T::Get(closest_station);
 
	return true;
 
	return CommandCost();
 
}
 

	
 
/**
 
@@ -1031,7 +1030,8 @@ CommandCost FindJoiningBaseStation(Stati
 

	
 
	if (check_surrounding) {
 
		/* Make sure there are no similar stations around us. */
 
		if (!GetStationAround(ta, existing_station, st)) return CMD_ERROR;
 
		CommandCost ret = GetStationAround(ta, existing_station, st);
 
		if (ret.Failed()) return ret;
 
	}
 

	
 
	/* Distant join */
 
@@ -1137,6 +1137,7 @@ CommandCost CmdBuildRailStation(TileInde
 

	
 
	Station *st = NULL;
 
	CommandCost ret = FindJoiningStation(est, station_to_join, adjacent, new_location, &st);
 
	ret.SetGlobalErrorMessage();
 
	if (ret.Failed()) return ret;
 

	
 
	/* See if there is a deleted station close to us. */
 
@@ -1701,6 +1702,7 @@ CommandCost CmdBuildRoadStop(TileIndex t
 

	
 
	Station *st = NULL;
 
	ret = FindJoiningRoadStop(est, station_to_join, HasBit(p2, 5), roadstop_area, &st);
 
	ret.SetGlobalErrorMessage();
 
	if (ret.Failed()) return ret;
 

	
 
	/* Find a deleted station close to us */
 
@@ -2108,6 +2110,7 @@ CommandCost CmdBuildAirport(TileIndex ti
 

	
 
	Station *st = NULL;
 
	CommandCost ret = FindJoiningStation(INVALID_STATION, station_to_join, HasBit(p2, 0), TileArea(tile, w, h), &st);
 
	ret.SetGlobalErrorMessage();
 
	if (ret.Failed()) return ret;
 

	
 
	/* Distant join */
 
@@ -2354,6 +2357,7 @@ CommandCost CmdBuildDock(TileIndex tile,
 
	CommandCost ret = FindJoiningStation(INVALID_STATION, station_to_join, HasBit(p1, 0),
 
			TileArea(tile + ToTileIndexDiff(_dock_tileoffs_chkaround[direction]),
 
					_dock_w_chk[direction], _dock_h_chk[direction]), &st);
 
	ret.SetGlobalErrorMessage();
 
	if (ret.Failed()) return ret;
 

	
 
	/* Distant join */
src/waypoint_cmd.cpp
Show inline comments
 
@@ -253,6 +253,7 @@ CommandCost CmdBuildRailWaypoint(TileInd
 
	Waypoint *wp = NULL;
 
	TileArea new_location(TileArea(start_tile, width, height));
 
	CommandCost ret = FindJoiningWaypoint(est, station_to_join, adjacent, new_location, &wp);
 
	ret.SetGlobalErrorMessage();
 
	if (ret.Failed()) return ret;
 

	
 
	/* Check if there is an already existing, deleted, waypoint close to us that we can reuse. */
0 comments (0 inline, 0 general)