mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(svn r14280) -Codechange: use IsRailWaypointTile() instead of IsTileType() and IsRailWaypoint() checks at several places
This commit is contained in:
parent
a527d237aa
commit
f503c7c99e
@ -244,8 +244,7 @@ static TileIndex FindRailStationEnd(TileIndex tile, TileIndexDiff delta, bool ch
|
|||||||
TileIndex new_tile = TILE_ADD(tile, delta);
|
TileIndex new_tile = TILE_ADD(tile, delta);
|
||||||
|
|
||||||
if (waypoint) {
|
if (waypoint) {
|
||||||
if (!IsTileType(new_tile, MP_RAILWAY)) break;
|
if (!IsRailWaypointTile(new_tile)) break;
|
||||||
if (!IsRailWaypoint(new_tile)) break;
|
|
||||||
if (check_axis && GetWaypointAxis(new_tile) != orig_axis) break;
|
if (check_axis && GetWaypointAxis(new_tile) != orig_axis) break;
|
||||||
} else {
|
} else {
|
||||||
if (!IsRailwayStationTile(new_tile)) break;
|
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 0x42: return GetTerrainType(tile) | (GetRailType(tile) << 8);
|
||||||
case 0x43: return st->owner; // Station owner
|
case 0x43: return st->owner; // Station owner
|
||||||
case 0x44:
|
case 0x44:
|
||||||
if (IsTileType(tile, MP_RAILWAY) && IsRailWaypoint(tile)) {
|
if (IsRailWaypointTile(tile)) {
|
||||||
return GetDepotWaypointReservation(tile) ? 7 : 4;
|
return GetDepotWaypointReservation(tile) ? 7 : 4;
|
||||||
} else {
|
} else {
|
||||||
return GetRailwayStationReservation(tile) ? 7 : 4; // PBS status
|
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.
|
/* Give owners to waypoints, based on rail tracks it is sitting on.
|
||||||
* If none is available, specify OWNER_NONE */
|
* If none is available, specify OWNER_NONE */
|
||||||
Waypoint *wp;
|
Waypoint *wp;
|
||||||
Owner owner;
|
|
||||||
FOR_ALL_WAYPOINTS(wp) {
|
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;
|
wp->owner = IsValidPlayerID(owner) ? owner : OWNER_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -318,10 +318,9 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check waypoint */
|
/* check waypoint */
|
||||||
if (IsTileType(tile, MP_RAILWAY) &&
|
if (IsRailWaypointTile(tile) &&
|
||||||
v->type == VEH_TRAIN &&
|
v->type == VEH_TRAIN &&
|
||||||
IsTileOwner(tile, _local_player) &&
|
IsTileOwner(tile, _local_player)) {
|
||||||
IsRailWaypoint(tile)) {
|
|
||||||
order.MakeGoToWaypoint(GetWaypointByTile(tile)->index);
|
order.MakeGoToWaypoint(GetWaypointByTile(tile)->index);
|
||||||
if (_settings_client.gui.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
|
if (_settings_client.gui.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
|
||||||
return order;
|
return order;
|
||||||
|
@ -82,6 +82,16 @@ static inline bool IsRailWaypoint(TileIndex t)
|
|||||||
return GetRailTileType(t) == RAIL_TILE_WAYPOINT;
|
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?
|
* Is this rail tile a rail depot?
|
||||||
* @param t the tile to get the information from
|
* @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?
|
* Is this tile rail tile and a rail depot?
|
||||||
* @param t the tile to get the information from
|
* @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
|
* @return true if and only if the tile is a rail depot
|
||||||
*/
|
*/
|
||||||
static inline bool IsRailDepotTile(TileIndex t)
|
static inline bool IsRailDepotTile(TileIndex t)
|
||||||
|
@ -309,8 +309,7 @@ CommandCost RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove)
|
|||||||
Waypoint *wp;
|
Waypoint *wp;
|
||||||
|
|
||||||
/* Make sure it's a waypoint */
|
/* Make sure it's a waypoint */
|
||||||
if (!IsTileType(tile, MP_RAILWAY) ||
|
if (!IsRailWaypointTile(tile) ||
|
||||||
!IsRailWaypoint(tile) ||
|
|
||||||
(!CheckTileOwnership(tile) && _current_player != OWNER_WATER) ||
|
(!CheckTileOwnership(tile) && _current_player != OWNER_WATER) ||
|
||||||
!EnsureNoVehicleOnGround(tile)) {
|
!EnsureNoVehicleOnGround(tile)) {
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
|
@ -55,7 +55,7 @@ static inline bool IsValidWaypointID(WaypointID index)
|
|||||||
*/
|
*/
|
||||||
static inline Waypoint *GetWaypointByTile(TileIndex tile)
|
static inline Waypoint *GetWaypointByTile(TileIndex tile)
|
||||||
{
|
{
|
||||||
assert(IsTileType(tile, MP_RAILWAY) && IsRailWaypoint(tile));
|
assert(IsRailWaypointTile(tile));
|
||||||
return GetWaypoint(GetWaypointIndex(tile));
|
return GetWaypoint(GetWaypointIndex(tile));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user