Changeset - r20221:18f1214f9d5d
[Not reviewed]
master
0 2 0
frosch - 11 years ago 2013-05-06 13:05:04
frosch@openttd.org
(svn r25221) -Fix: IsCompatibleTrainStationTile() is not a symmetric function. Clarify the parameters and fix the cases were they were swapped.
2 files changed with 17 insertions and 17 deletions:
0 comments (0 inline, 0 general)
src/newgrf_station.cpp
Show inline comments
 
@@ -73,8 +73,8 @@ struct ETileArea : TileArea {
 
				Axis axis = GetRailStationAxis(tile);
 
				TileIndexDiff delta = TileOffsByDiagDir(AxisToDiagDir(axis));
 

	
 
				for (end = tile; IsRailStationTile(end + delta) && IsCompatibleTrainStationTile(tile, end + delta); end += delta) { /* Nothing */ }
 
				for (start = tile; IsRailStationTile(start - delta) && IsCompatibleTrainStationTile(tile, start - delta); start -= delta) { /* Nothing */ }
 
				for (end = tile; IsRailStationTile(end + delta) && IsCompatibleTrainStationTile(end + delta, tile); end += delta) { /* Nothing */ }
 
				for (start = tile; IsRailStationTile(start - delta) && IsCompatibleTrainStationTile(start - delta, tile); start -= delta) { /* Nothing */ }
 

	
 
				this->tile = start;
 
				this->w = TileX(end) - TileX(start) + 1;
src/station_map.h
Show inline comments
 
@@ -364,25 +364,25 @@ static inline TrackBits GetRailStationTr
 
}
 

	
 
/**
 
 * Check if tile is compatible with a railstation tile. The two tiles
 
 * are compatible if all of the following are true:
 
 * \li both tiles are rail station tiles
 
 * \li the railtype of \a t1 is compatible with the railtype of \a t2
 
 * \li the tracks on \a t1 and \a t2 are in the same direction
 
 * Check if a tile is a valid continuation to a railstation tile.
 
 * The tile \a test_tile is a valid continuation to \a station_tile, if all of the following are true:
 
 * \li \a test_tile is a rail station tile
 
 * \li the railtype of \a test_tile is compatible with the railtype of \a station_tile
 
 * \li the tracks on \a test_tile and \a station_tile are in the same direction
 
 * \li both tiles belong to the same station
 
 * \li \a t1 is not blocked (@see IsStationTileBlocked)
 
 * @param t1 First tile to compare
 
 * @param t2 Second tile to compare
 
 * @pre IsRailStationTile(t2)
 
 * \li \a test_tile is not blocked (@see IsStationTileBlocked)
 
 * @param test_tile Tile to test
 
 * @param station_tile Station tile to compare with
 
 * @pre IsRailStationTile(station_tile)
 
 * @return true if the two tiles are compatible
 
 */
 
static inline bool IsCompatibleTrainStationTile(TileIndex t1, TileIndex t2)
 
static inline bool IsCompatibleTrainStationTile(TileIndex test_tile, TileIndex station_tile)
 
{
 
	assert(IsRailStationTile(t2));
 
	return IsRailStationTile(t1) && IsCompatibleRail(GetRailType(t1), GetRailType(t2)) &&
 
			GetRailStationAxis(t1) == GetRailStationAxis(t2) &&
 
			GetStationIndex(t1) == GetStationIndex(t2) &&
 
			!IsStationTileBlocked(t1);
 
	assert(IsRailStationTile(station_tile));
 
	return IsRailStationTile(test_tile) && IsCompatibleRail(GetRailType(test_tile), GetRailType(station_tile)) &&
 
			GetRailStationAxis(test_tile) == GetRailStationAxis(station_tile) &&
 
			GetStationIndex(test_tile) == GetStationIndex(station_tile) &&
 
			!IsStationTileBlocked(test_tile);
 
}
 

	
 
/**
0 comments (0 inline, 0 general)