(svn r25221) -Fix: IsCompatibleTrainStationTile() is not a symmetric function. Clarify the parameters and fix the cases were they were swapped.

This commit is contained in:
frosch 2013-05-06 13:05:04 +00:00
parent 0278d192c6
commit 6631b9e5e3
2 changed files with 17 additions and 17 deletions

View File

@ -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;

View File

@ -364,25 +364,25 @@ static inline TrackBits GetRailStationTrackBits(TileIndex t)
}
/**
* 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);
}
/**