(svn r14280) -Codechange: use IsRailWaypointTile() instead of IsTileType() and IsRailWaypoint() checks at several places

pull/155/head
smatz 16 years ago
parent 80631f4a45
commit ff7e0b2586

@ -244,8 +244,7 @@ static TileIndex FindRailStationEnd(TileIndex tile, TileIndexDiff delta, bool ch
TileIndex new_tile = TILE_ADD(tile, delta);
if (waypoint) {
if (!IsTileType(new_tile, MP_RAILWAY)) break;
if (!IsRailWaypoint(new_tile)) break;
if (!IsRailWaypointTile(new_tile)) break;
if (check_axis && GetWaypointAxis(new_tile) != orig_axis) break;
} else {
if (!IsRailwayStationTile(new_tile)) break;
@ -407,7 +406,7 @@ static uint32 StationGetVariable(const ResolverObject *object, byte variable, by
case 0x42: return GetTerrainType(tile) | (GetRailType(tile) << 8);
case 0x43: return st->owner; // Station owner
case 0x44:
if (IsTileType(tile, MP_RAILWAY) && IsRailWaypoint(tile)) {
if (IsRailWaypointTile(tile)) {
return GetDepotWaypointReservation(tile) ? 7 : 4;
} else {
return GetRailwayStationReservation(tile) ? 7 : 4; // PBS status

@ -2539,9 +2539,8 @@ bool AfterLoadGame()
/* Give owners to waypoints, based on rail tracks it is sitting on.
* If none is available, specify OWNER_NONE */
Waypoint *wp;
Owner owner;
FOR_ALL_WAYPOINTS(wp) {
owner = (IsTileType(wp->xy, MP_RAILWAY) && IsRailWaypoint(wp->xy) ? GetTileOwner(wp->xy) : OWNER_NONE);
Owner owner = (IsRailWaypointTile(wp->xy) ? GetTileOwner(wp->xy) : OWNER_NONE);
wp->owner = IsValidPlayerID(owner) ? owner : OWNER_NONE;
}
}

@ -318,10 +318,9 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
}
/* check waypoint */
if (IsTileType(tile, MP_RAILWAY) &&
if (IsRailWaypointTile(tile) &&
v->type == VEH_TRAIN &&
IsTileOwner(tile, _local_player) &&
IsRailWaypoint(tile)) {
IsTileOwner(tile, _local_player)) {
order.MakeGoToWaypoint(GetWaypointByTile(tile)->index);
if (_settings_client.gui.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
return order;

@ -82,6 +82,16 @@ static inline bool IsRailWaypoint(TileIndex t)
return GetRailTileType(t) == RAIL_TILE_WAYPOINT;
}
/**
* Is this tile rail tile and a rail waypoint?
* @param t the tile to get the information from
* @return true if and only if the tile is a rail waypoint
*/
static inline bool IsRailWaypointTile(TileIndex t)
{
return IsTileType(t, MP_RAILWAY) && IsRailWaypoint(t);
}
/**
* Is this rail tile a rail depot?
* @param t the tile to get the information from
@ -96,7 +106,6 @@ static inline bool IsRailDepot(TileIndex t)
/**
* Is this tile rail tile and a rail depot?
* @param t the tile to get the information from
* @pre IsTileType(t, MP_RAILWAY)
* @return true if and only if the tile is a rail depot
*/
static inline bool IsRailDepotTile(TileIndex t)

@ -309,8 +309,7 @@ CommandCost RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove)
Waypoint *wp;
/* Make sure it's a waypoint */
if (!IsTileType(tile, MP_RAILWAY) ||
!IsRailWaypoint(tile) ||
if (!IsRailWaypointTile(tile) ||
(!CheckTileOwnership(tile) && _current_player != OWNER_WATER) ||
!EnsureNoVehicleOnGround(tile)) {
return CMD_ERROR;

@ -55,7 +55,7 @@ static inline bool IsValidWaypointID(WaypointID index)
*/
static inline Waypoint *GetWaypointByTile(TileIndex tile)
{
assert(IsTileType(tile, MP_RAILWAY) && IsRailWaypoint(tile));
assert(IsRailWaypointTile(tile));
return GetWaypoint(GetWaypointIndex(tile));
}

Loading…
Cancel
Save