(svn r16939) -Codechange: s/RailwayStation/RailStation/ to unify the way it's written.

This commit is contained in:
rubidium 2009-07-24 11:47:12 +00:00
parent 2c6b5237f6
commit cf38a5bee6
18 changed files with 80 additions and 79 deletions

View File

@ -38,7 +38,7 @@
{ {
if (!::IsValidTile(tile)) return false; if (!::IsValidTile(tile)) return false;
return ::IsRailwayStationTile(tile); return ::IsRailStationTile(tile);
} }
/* static */ bool AIRail::IsRailWaypointTile(TileIndex tile) /* static */ bool AIRail::IsRailWaypointTile(TileIndex tile)

View File

@ -54,8 +54,8 @@ struct ETileArea : TileArea {
Axis axis = GetRailStationAxis(tile); Axis axis = GetRailStationAxis(tile);
TileIndexDiff delta = TileOffsByDiagDir(AxisToDiagDir(axis)); TileIndexDiff delta = TileOffsByDiagDir(AxisToDiagDir(axis));
for (end = tile; IsRailwayStationTile(end + delta) && IsCompatibleTrainStationTile(tile, end + delta); end += delta) { /* Nothing */ } for (end = tile; IsRailStationTile(end + delta) && IsCompatibleTrainStationTile(tile, end + delta); end += delta) { /* Nothing */ }
for (start = tile; IsRailwayStationTile(start - delta) && IsCompatibleTrainStationTile(tile, start - delta); start -= delta) { /* Nothing */ } for (start = tile; IsRailStationTile(start - delta) && IsCompatibleTrainStationTile(tile, start - delta); start -= delta) { /* Nothing */ }
this->tile = start; this->tile = start;
this->w = TileX(end) - TileX(start) + 1; this->w = TileX(end) - TileX(start) + 1;

View File

@ -480,8 +480,8 @@ static void ClearPathReservation(const PathNode *start, const PathNode *end)
{ {
bool first_run = true; bool first_run = true;
for (; start != end; start = start->parent) { for (; start != end; start = start->parent) {
if (IsRailwayStationTile(start->node.tile) && first_run) { if (IsRailStationTile(start->node.tile) && first_run) {
SetRailwayStationPlatformReservation(start->node.tile, TrackdirToExitdir(start->node.direction), false); SetRailStationPlatformReservation(start->node.tile, TrackdirToExitdir(start->node.direction), false);
} else { } else {
UnreserveRailTrack(start->node.tile, TrackdirToTrack(start->node.direction)); UnreserveRailTrack(start->node.tile, TrackdirToTrack(start->node.direction));
} }
@ -512,7 +512,7 @@ static void NPFSaveTargetData(AyStar *as, OpenListNode *current)
ftd->node = target->node; ftd->node = target->node;
/* If the target is a station skip to platform end. */ /* If the target is a station skip to platform end. */
if (IsRailwayStationTile(target->node.tile)) { if (IsRailStationTile(target->node.tile)) {
DiagDirection dir = TrackdirToExitdir(target->node.direction); DiagDirection dir = TrackdirToExitdir(target->node.direction);
uint len = Station::GetByTile(target->node.tile)->GetPlatformLength(target->node.tile, dir); uint len = Station::GetByTile(target->node.tile)->GetPlatformLength(target->node.tile, dir);
TileIndex end_tile = TILE_ADD(target->node.tile, (len - 1) * TileOffsByDiagDir(dir)); TileIndex end_tile = TILE_ADD(target->node.tile, (len - 1) * TileOffsByDiagDir(dir));
@ -520,8 +520,8 @@ static void NPFSaveTargetData(AyStar *as, OpenListNode *current)
/* Update only end tile, trackdir of a station stays the same. */ /* Update only end tile, trackdir of a station stays the same. */
ftd->node.tile = end_tile; ftd->node.tile = end_tile;
if (!IsWaitingPositionFree(v, end_tile, target->node.direction, _settings_game.pf.forbid_90_deg)) return; if (!IsWaitingPositionFree(v, end_tile, target->node.direction, _settings_game.pf.forbid_90_deg)) return;
SetRailwayStationPlatformReservation(target->node.tile, dir, true); SetRailStationPlatformReservation(target->node.tile, dir, true);
SetRailwayStationReservation(target->node.tile, false); SetRailStationReservation(target->node.tile, false);
} else { } else {
if (!IsWaitingPositionFree(v, target->node.tile, target->node.direction, _settings_game.pf.forbid_90_deg)) return; if (!IsWaitingPositionFree(v, target->node.tile, target->node.direction, _settings_game.pf.forbid_90_deg)) return;
} }

View File

@ -41,21 +41,21 @@ TrackBits GetReservedTrackbits(TileIndex t)
/** /**
* Set the reservation for a complete station platform. * Set the reservation for a complete station platform.
* @pre IsRailwayStationTile(start) * @pre IsRailStationTile(start)
* @param start starting tile of the platform * @param start starting tile of the platform
* @param dir the direction in which to follow the platform * @param dir the direction in which to follow the platform
* @param b the state the reservation should be set to * @param b the state the reservation should be set to
*/ */
void SetRailwayStationPlatformReservation(TileIndex start, DiagDirection dir, bool b) void SetRailStationPlatformReservation(TileIndex start, DiagDirection dir, bool b)
{ {
TileIndex tile = start; TileIndex tile = start;
TileIndexDiff diff = TileOffsByDiagDir(dir); TileIndexDiff diff = TileOffsByDiagDir(dir);
assert(IsRailwayStationTile(start)); assert(IsRailStationTile(start));
assert(GetRailStationAxis(start) == DiagDirToAxis(dir)); assert(GetRailStationAxis(start) == DiagDirToAxis(dir));
do { do {
SetRailwayStationReservation(tile, b); SetRailStationReservation(tile, b);
MarkTileDirtyByTile(tile); MarkTileDirtyByTile(tile);
tile = TILE_ADD(tile, diff); tile = TILE_ADD(tile, diff);
} while (IsCompatibleTrainStationTile(tile, start)); } while (IsCompatibleTrainStationTile(tile, start));
@ -100,7 +100,7 @@ bool TryReserveRailTrack(TileIndex tile, Track t)
case MP_STATION: case MP_STATION:
if (HasStationRail(tile) && !HasStationReservation(tile)) { if (HasStationRail(tile) && !HasStationReservation(tile)) {
SetRailwayStationReservation(tile, true); SetRailStationReservation(tile, true);
MarkTileDirtyByTile(tile); // some GRFs need redraw after reserving track MarkTileDirtyByTile(tile); // some GRFs need redraw after reserving track
return true; return true;
} }
@ -151,7 +151,7 @@ bool TryReserveRailTrack(TileIndex tile, Track t)
case MP_STATION: case MP_STATION:
if (HasStationRail(tile)) { if (HasStationRail(tile)) {
SetRailwayStationReservation(tile, false); SetRailStationReservation(tile, false);
MarkTileDirtyByTile(tile); MarkTileDirtyByTile(tile);
} }
break; break;
@ -295,7 +295,7 @@ Train *GetTrainForReservation(TileIndex tile, Track track)
if (ftoti.best != NULL) return ftoti.best; if (ftoti.best != NULL) return ftoti.best;
/* Special case for stations: check the whole platform for a vehicle. */ /* Special case for stations: check the whole platform for a vehicle. */
if (IsRailwayStationTile(ftoti.res.tile)) { if (IsRailStationTile(ftoti.res.tile)) {
TileIndexDiff diff = TileOffsByDiagDir(TrackdirToExitdir(ReverseTrackdir(ftoti.res.trackdir))); TileIndexDiff diff = TileOffsByDiagDir(TrackdirToExitdir(ReverseTrackdir(ftoti.res.trackdir)));
for (TileIndex st_tile = ftoti.res.tile + diff; IsCompatibleTrainStationTile(st_tile, ftoti.res.tile); st_tile += diff) { for (TileIndex st_tile = ftoti.res.tile + diff; IsCompatibleTrainStationTile(st_tile, ftoti.res.tile); st_tile += diff) {
FindVehicleOnPos(st_tile, &ftoti, FindTrainOnTrackEnum); FindVehicleOnPos(st_tile, &ftoti, FindTrainOnTrackEnum);

View File

@ -12,7 +12,7 @@
TrackBits GetReservedTrackbits(TileIndex t); TrackBits GetReservedTrackbits(TileIndex t);
void SetRailwayStationPlatformReservation(TileIndex start, DiagDirection dir, bool b); void SetRailStationPlatformReservation(TileIndex start, DiagDirection dir, bool b);
bool TryReserveRailTrack(TileIndex tile, Track t); bool TryReserveRailTrack(TileIndex tile, Track t);
void UnreserveRailTrack(TileIndex tile, Track t); void UnreserveRailTrack(TileIndex tile, Track t);

View File

@ -561,7 +561,7 @@ bool AfterLoadGame()
if (HasBit(_m[t].m6, 3)) SetBit(_m[t].m6, 2); if (HasBit(_m[t].m6, 3)) SetBit(_m[t].m6, 2);
StationGfx gfx = GetStationGfx(t); StationGfx gfx = GetStationGfx(t);
StationType st; StationType st;
if ( IsInsideMM(gfx, 0, 8)) { // Railway station if ( IsInsideMM(gfx, 0, 8)) { // Rail station
st = STATION_RAIL; st = STATION_RAIL;
SetStationGfx(t, gfx - 0); SetStationGfx(t, gfx - 0);
} else if (IsInsideMM(gfx, 8, 67)) { // Airport } else if (IsInsideMM(gfx, 8, 67)) { // Airport
@ -573,13 +573,13 @@ bool AfterLoadGame()
} else if (IsInsideMM(gfx, 71, 75)) { // Bus } else if (IsInsideMM(gfx, 71, 75)) { // Bus
st = STATION_BUS; st = STATION_BUS;
SetStationGfx(t, gfx - 71); SetStationGfx(t, gfx - 71);
} else if (gfx == 75) { // Oil rig } else if (gfx == 75) { // Oil rig
st = STATION_OILRIG; st = STATION_OILRIG;
SetStationGfx(t, gfx - 75); SetStationGfx(t, gfx - 75);
} else if (IsInsideMM(gfx, 76, 82)) { // Dock } else if (IsInsideMM(gfx, 76, 82)) { // Dock
st = STATION_DOCK; st = STATION_DOCK;
SetStationGfx(t, gfx - 76); SetStationGfx(t, gfx - 76);
} else if (gfx == 82) { // Buoy } else if (gfx == 82) { // Buoy
st = STATION_BUOY; st = STATION_BUOY;
SetStationGfx(t, gfx - 82); SetStationGfx(t, gfx - 82);
} else if (IsInsideMM(gfx, 83, 168)) { // Extended airport } else if (IsInsideMM(gfx, 83, 168)) { // Extended airport
@ -1654,7 +1654,7 @@ bool AfterLoadGame()
break; break;
case MP_STATION: // Clear PBS reservation on station case MP_STATION: // Clear PBS reservation on station
if (IsRailwayStation(t)) SetRailwayStationReservation(t, false); if (HasStationRail(t)) SetRailStationReservation(t, false);
break; break;
case MP_TUNNELBRIDGE: // Clear PBS reservation on tunnels/birdges case MP_TUNNELBRIDGE: // Clear PBS reservation on tunnels/birdges

View File

@ -64,7 +64,7 @@ void AfterLoadLabelMaps()
break; break;
case MP_STATION: case MP_STATION:
if (IsRailwayStation(t)) { if (HasStationRail(t)) {
SetRailType(t, railtype_conversion_map[GetRailType(t)]); SetRailType(t, railtype_conversion_map[GetRailType(t)]);
} }
break; break;

View File

@ -104,7 +104,7 @@ void MoveWaypointsToBaseStations()
new_wp->facilities |= FACIL_TRAIN; new_wp->facilities |= FACIL_TRAIN;
new_wp->owner = GetTileOwner(t); new_wp->owner = GetTileOwner(t);
SetRailwayStationReservation(t, reserved); SetRailStationReservation(t, reserved);
if (wp->spec != NULL) { if (wp->spec != NULL) {
SetCustomStationSpecIndex(t, AllocateSpecToStation(wp->spec, new_wp, true)); SetCustomStationSpecIndex(t, AllocateSpecToStation(wp->spec, new_wp, true));

View File

@ -182,7 +182,7 @@ void Station::MarkTilesDirty(bool cargo_change) const
} }
/** Obtain the length of a platform /** Obtain the length of a platform
* @pre tile must be a railway station tile * @pre tile must be a rail station tile
* @param tile A tile that contains the platform in question * @param tile A tile that contains the platform in question
* @return The length of the platform * @return The length of the platform
*/ */
@ -210,7 +210,7 @@ uint Station::GetPlatformLength(TileIndex tile) const
/** Determines the REMAINING length of a platform, starting at (and including) /** Determines the REMAINING length of a platform, starting at (and including)
* the given tile. * the given tile.
* @param tile the tile from which to start searching. Must be a railway station tile * @param tile the tile from which to start searching. Must be a rail station tile
* @param dir The direction in which to search. * @param dir The direction in which to search.
* @return The platform length * @return The platform length
*/ */
@ -218,7 +218,7 @@ uint Station::GetPlatformLength(TileIndex tile, DiagDirection dir) const
{ {
TileIndex start_tile = tile; TileIndex start_tile = tile;
uint length = 0; uint length = 0;
assert(IsRailwayStationTile(tile)); assert(IsRailStationTile(tile));
assert(dir < DIAGDIR_END); assert(dir < DIAGDIR_END);
do { do {

View File

@ -133,7 +133,7 @@ public:
/* virtual */ FORCEINLINE bool TileBelongsToRailStation(TileIndex tile) const /* virtual */ FORCEINLINE bool TileBelongsToRailStation(TileIndex tile) const
{ {
return IsRailwayStationTile(tile) && GetStationIndex(tile) == this->index; return IsRailStationTile(tile) && GetStationIndex(tile) == this->index;
} }
/* virtual */ uint32 GetNewGRFVariable(const ResolverObject *object, byte variable, byte parameter, bool *available) const; /* virtual */ uint32 GetNewGRFVariable(const ResolverObject *object, byte variable, byte parameter, bool *available) const;

View File

@ -700,7 +700,7 @@ CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, DoCommandFlag fla
* so station points to INVALID_STATION if we can build on any station. * so station points to INVALID_STATION if we can build on any station.
* Or it points to a station if we're only allowed to build on exactly that station. */ * Or it points to a station if we're only allowed to build on exactly that station. */
if (station != NULL && IsTileType(tile_cur, MP_STATION)) { if (station != NULL && IsTileType(tile_cur, MP_STATION)) {
if (!IsRailwayStation(tile_cur)) { if (!IsRailStation(tile_cur)) {
return ClearTile_Station(tile_cur, DC_AUTO); // get error message return ClearTile_Station(tile_cur, DC_AUTO); // get error message
} else { } else {
StationID st = GetStationIndex(tile_cur); StationID st = GetStationIndex(tile_cur);
@ -1013,15 +1013,15 @@ CommandCost CmdBuildRailroadStation(TileIndex tile_org, DoCommandFlag flags, uin
int w = plat_len; int w = plat_len;
do { do {
byte layout = *layout_ptr++; byte layout = *layout_ptr++;
if (IsRailwayStationTile(tile) && HasStationReservation(tile)) { if (IsRailStationTile(tile) && HasStationReservation(tile)) {
/* Check for trains having a reservation for this tile. */ /* Check for trains having a reservation for this tile. */
Train *v = GetTrainForReservation(tile, AxisToTrack(GetRailStationAxis(tile))); Train *v = GetTrainForReservation(tile, AxisToTrack(GetRailStationAxis(tile)));
if (v != NULL) { if (v != NULL) {
FreeTrainTrackReservation(v); FreeTrainTrackReservation(v);
*affected_vehicles.Append() = v; *affected_vehicles.Append() = v;
if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(v->GetVehicleTrackdir()), false); if (IsRailStationTile(v->tile)) SetRailStationPlatformReservation(v->tile, TrackdirToExitdir(v->GetVehicleTrackdir()), false);
for (; v->Next() != NULL; v = v->Next()) ; for (; v->Next() != NULL; v = v->Next()) ;
if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(ReverseTrackdir(v->GetVehicleTrackdir())), false); if (IsRailStationTile(v->tile)) SetRailStationPlatformReservation(v->tile, TrackdirToExitdir(ReverseTrackdir(v->GetVehicleTrackdir())), false);
} }
} }
@ -1058,10 +1058,10 @@ CommandCost CmdBuildRailroadStation(TileIndex tile_org, DoCommandFlag flags, uin
for (uint i = 0; i < affected_vehicles.Length(); ++i) { for (uint i = 0; i < affected_vehicles.Length(); ++i) {
/* Restore reservations of trains. */ /* Restore reservations of trains. */
Train *v = affected_vehicles[i]; Train *v = affected_vehicles[i];
if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(v->GetVehicleTrackdir()), true); if (IsRailStationTile(v->tile)) SetRailStationPlatformReservation(v->tile, TrackdirToExitdir(v->GetVehicleTrackdir()), true);
TryPathReserve(v, true, true); TryPathReserve(v, true, true);
for (; v->Next() != NULL; v = v->Next()) ; for (; v->Next() != NULL; v = v->Next()) ;
if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(ReverseTrackdir(v->GetVehicleTrackdir())), true); if (IsRailStationTile(v->tile)) SetRailStationPlatformReservation(v->tile, TrackdirToExitdir(ReverseTrackdir(v->GetVehicleTrackdir())), true);
} }
st->MarkTilesDirty(false); st->MarkTilesDirty(false);
@ -1076,7 +1076,7 @@ CommandCost CmdBuildRailroadStation(TileIndex tile_org, DoCommandFlag flags, uin
return cost; return cost;
} }
static void MakeRailwayStationAreaSmaller(Station *st) static void MakeRailStationAreaSmaller(Station *st)
{ {
uint w = st->trainst_w; uint w = st->trainst_w;
uint h = st->trainst_h; uint h = st->trainst_h;
@ -1165,7 +1165,7 @@ CommandCost CmdRemoveFromRailroadStation(TileIndex tile, DoCommandFlag flags, ui
/* Do the action for every tile into the area */ /* Do the action for every tile into the area */
BEGIN_TILE_LOOP(tile2, size_x, size_y, tile) { BEGIN_TILE_LOOP(tile2, size_x, size_y, tile) {
/* Make sure the specified tile is a railroad station */ /* Make sure the specified tile is a railroad station */
if (!IsRailwayStationTile(tile2)) { if (!IsRailStationTile(tile2)) {
continue; continue;
} }
@ -1200,10 +1200,10 @@ CommandCost CmdRemoveFromRailroadStation(TileIndex tile, DoCommandFlag flags, ui
if (v != NULL) { if (v != NULL) {
/* Free train reservation. */ /* Free train reservation. */
FreeTrainTrackReservation(v); FreeTrainTrackReservation(v);
if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(v->GetVehicleTrackdir()), false); if (IsRailStationTile(v->tile)) SetRailStationPlatformReservation(v->tile, TrackdirToExitdir(v->GetVehicleTrackdir()), false);
Vehicle *temp = v; Vehicle *temp = v;
for (; temp->Next() != NULL; temp = temp->Next()) ; for (; temp->Next() != NULL; temp = temp->Next()) ;
if (IsRailwayStationTile(temp->tile)) SetRailwayStationPlatformReservation(temp->tile, TrackdirToExitdir(ReverseTrackdir(temp->GetVehicleTrackdir())), false); if (IsRailStationTile(temp->tile)) SetRailStationPlatformReservation(temp->tile, TrackdirToExitdir(ReverseTrackdir(temp->GetVehicleTrackdir())), false);
} }
} }
@ -1218,10 +1218,10 @@ CommandCost CmdRemoveFromRailroadStation(TileIndex tile, DoCommandFlag flags, ui
if (v != NULL) { if (v != NULL) {
/* Restore station reservation. */ /* Restore station reservation. */
if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(v->GetVehicleTrackdir()), true); if (IsRailStationTile(v->tile)) SetRailStationPlatformReservation(v->tile, TrackdirToExitdir(v->GetVehicleTrackdir()), true);
TryPathReserve(v, true, true); TryPathReserve(v, true, true);
for (; v->Next() != NULL; v = v->Next()) ; for (; v->Next() != NULL; v = v->Next()) ;
if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(ReverseTrackdir(v->GetVehicleTrackdir())), true); if (IsRailStationTile(v->tile)) SetRailStationPlatformReservation(v->tile, TrackdirToExitdir(ReverseTrackdir(v->GetVehicleTrackdir())), true);
} }
} }
} END_TILE_LOOP(tile2, size_x, size_y, tile) } END_TILE_LOOP(tile2, size_x, size_y, tile)
@ -1232,7 +1232,7 @@ CommandCost CmdRemoveFromRailroadStation(TileIndex tile, DoCommandFlag flags, ui
/* now we need to make the "spanned" area of the railway station smaller /* now we need to make the "spanned" area of the railway station smaller
* if we deleted something at the edges. * if we deleted something at the edges.
* we also need to adjust train_tile. */ * we also need to adjust train_tile. */
MakeRailwayStationAreaSmaller(st); MakeRailStationAreaSmaller(st);
st->MarkTilesDirty(false); st->MarkTilesDirty(false);
UpdateStationSignCoord(st); UpdateStationSignCoord(st);
@ -2135,7 +2135,7 @@ static void DrawTile_Station(TileInfo *ti)
int32 total_offset; int32 total_offset;
int32 custom_ground_offset; int32 custom_ground_offset;
if (IsRailwayStation(ti->tile) || IsRailWaypoint(ti->tile)) { if (HasStationRail(ti->tile)) {
const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile)); const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile));
roadtypes = ROADTYPES_NONE; roadtypes = ROADTYPES_NONE;
total_offset = rti->total_offset; total_offset = rti->total_offset;
@ -2212,13 +2212,13 @@ static void DrawTile_Station(TileInfo *ti)
DrawGroundSprite(image, GroundSpritePaletteTransform(image, pal, palette)); DrawGroundSprite(image, GroundSpritePaletteTransform(image, pal, palette));
/* PBS debugging, draw reserved tracks darker */ /* PBS debugging, draw reserved tracks darker */
if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && (IsRailwayStation(ti->tile) || IsRailWaypoint(ti->tile)) && HasStationReservation(ti->tile)) { if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && HasStationRail(ti->tile) && HasStationReservation(ti->tile)) {
const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile)); const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile));
DrawGroundSprite(GetRailStationAxis(ti->tile) == AXIS_X ? rti->base_sprites.single_y : rti->base_sprites.single_x, PALETTE_CRASH); DrawGroundSprite(GetRailStationAxis(ti->tile) == AXIS_X ? rti->base_sprites.single_y : rti->base_sprites.single_x, PALETTE_CRASH);
} }
} }
if ((IsRailwayStation(ti->tile) || IsRailWaypoint(ti->tile)) && HasCatenaryDrawn(GetRailType(ti->tile)) && IsStationTileElectrifiable(ti->tile)) DrawCatenary(ti); if (HasStationRail(ti->tile) && HasCatenaryDrawn(GetRailType(ti->tile)) && IsStationTileElectrifiable(ti->tile)) DrawCatenary(ti);
if (HasBit(roadtypes, ROADTYPE_TRAM)) { if (HasBit(roadtypes, ROADTYPE_TRAM)) {
Axis axis = GetRoadStopDir(ti->tile) == DIAGDIR_NE ? AXIS_X : AXIS_Y; Axis axis = GetRoadStopDir(ti->tile) == DIAGDIR_NE ? AXIS_X : AXIS_Y;
@ -2359,7 +2359,7 @@ static TrackStatus GetTileTrackStatus_Station(TileIndex tile, TransportType mode
switch (mode) { switch (mode) {
case TRANSPORT_RAIL: case TRANSPORT_RAIL:
if ((IsRailwayStation(tile) || IsRailWaypoint(tile)) && !IsStationTileBlocked(tile)) { if (HasStationRail(tile) && !IsStationTileBlocked(tile)) {
trackbits = TrackToTrackBits(GetRailStationTrack(tile)); trackbits = TrackToTrackBits(GetRailStationTrack(tile));
} }
break; break;
@ -2444,7 +2444,7 @@ static void AnimateTile_Station(TileIndex tile)
{ GFX_WINDSACK_INTERCON_FIRST, GFX_WINDSACK_INTERCON_LAST, 1 } { GFX_WINDSACK_INTERCON_FIRST, GFX_WINDSACK_INTERCON_LAST, 1 }
}; };
if (IsRailwayStation(tile)) { if (HasStationRail(tile)) {
AnimateStationTile(tile); AnimateStationTile(tile);
return; return;
} }
@ -2483,7 +2483,7 @@ static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, i
if (v->type == VEH_TRAIN) { if (v->type == VEH_TRAIN) {
if (!v->current_order.ShouldStopAtStation(v, station_id)) return VETSB_CONTINUE; if (!v->current_order.ShouldStopAtStation(v, station_id)) return VETSB_CONTINUE;
if (!IsRailwayStation(tile) || !Train::From(v)->IsFrontEngine()) return VETSB_CONTINUE; if (!IsRailStation(tile) || !Train::From(v)->IsFrontEngine()) return VETSB_CONTINUE;
int station_ahead; int station_ahead;
int station_length; int station_length;

View File

@ -45,6 +45,7 @@ enum {
static inline StationType GetStationType(TileIndex t) static inline StationType GetStationType(TileIndex t)
{ {
assert(IsTileType(t, MP_STATION));
return (StationType)GB(_m[t].m6, 3, 3); return (StationType)GB(_m[t].m6, 3, 3);
} }
@ -78,14 +79,14 @@ static inline void SetStationAnimationFrame(TileIndex t, uint8 frame)
_me[t].m7 = frame; _me[t].m7 = frame;
} }
static inline bool IsRailwayStation(TileIndex t) static inline bool IsRailStation(TileIndex t)
{ {
return GetStationType(t) == STATION_RAIL; return GetStationType(t) == STATION_RAIL;
} }
static inline bool IsRailwayStationTile(TileIndex t) static inline bool IsRailStationTile(TileIndex t)
{ {
return IsTileType(t, MP_STATION) && IsRailwayStation(t); return IsTileType(t, MP_STATION) && IsRailStation(t);
} }
/** /**
@ -118,7 +119,7 @@ static inline bool IsRailWaypointTile(TileIndex t)
*/ */
static inline bool HasStationRail(TileIndex t) static inline bool HasStationRail(TileIndex t)
{ {
return IsRailwayStation(t) || IsRailWaypoint(t); return IsRailStation(t) || IsRailWaypoint(t);
} }
/** /**
@ -230,7 +231,7 @@ static inline bool IsHangarTile(TileIndex t)
static inline Axis GetRailStationAxis(TileIndex t) static inline Axis GetRailStationAxis(TileIndex t)
{ {
assert(IsRailwayStation(t) || IsRailWaypoint(t)); assert(HasStationRail(t));
return HasBit(GetStationGfx(t), 0) ? AXIS_Y : AXIS_X; return HasBit(GetStationGfx(t), 0) ? AXIS_Y : AXIS_X;
} }
@ -247,9 +248,9 @@ static inline TrackBits GetRailStationTrackBits(TileIndex t)
static inline bool IsCompatibleTrainStationTile(TileIndex t1, TileIndex t2) static inline bool IsCompatibleTrainStationTile(TileIndex t1, TileIndex t2)
{ {
assert(IsRailwayStationTile(t2)); assert(IsRailStationTile(t2));
return return
IsRailwayStationTile(t1) && IsRailStationTile(t1) &&
IsCompatibleRail(GetRailType(t1), GetRailType(t2)) && IsCompatibleRail(GetRailType(t1), GetRailType(t2)) &&
GetRailStationAxis(t1) == GetRailStationAxis(t2) && GetRailStationAxis(t1) == GetRailStationAxis(t2) &&
GetStationIndex(t1) == GetStationIndex(t2) && GetStationIndex(t1) == GetStationIndex(t2) &&
@ -258,31 +259,31 @@ static inline bool IsCompatibleTrainStationTile(TileIndex t1, TileIndex t2)
/** /**
* Get the reservation state of the rail station * Get the reservation state of the rail station
* @pre IsRailwayStation(t) || IsRailWaypoint(t) * @pre HasStationRail(t)
* @param t the station tile * @param t the station tile
* @return reservation state * @return reservation state
*/ */
static inline bool HasStationReservation(TileIndex t) static inline bool HasStationReservation(TileIndex t)
{ {
assert(IsRailwayStation(t) || IsRailWaypoint(t)); assert(HasStationRail(t));
return HasBit(_m[t].m6, 2); return HasBit(_m[t].m6, 2);
} }
/** /**
* Set the reservation state of the rail station * Set the reservation state of the rail station
* @pre IsRailwayStation(t) || IsRailWaypoint(t) * @pre HasStationRail(t)
* @param t the station tile * @param t the station tile
* @param b the reservation state * @param b the reservation state
*/ */
static inline void SetRailwayStationReservation(TileIndex t, bool b) static inline void SetRailStationReservation(TileIndex t, bool b)
{ {
assert(IsRailwayStation(t) || IsRailWaypoint(t)); assert(HasStationRail(t));
SB(_m[t].m6, 2, 1, b ? 1 : 0); SB(_m[t].m6, 2, 1, b ? 1 : 0);
} }
/** /**
* Get the reserved track bits for a waypoint * Get the reserved track bits for a waypoint
* @pre IsRailwayStation(t) || IsRailWaypoint(t) * @pre HasStationRail(t)
* @param t the tile * @param t the tile
* @return reserved track bits * @return reserved track bits
*/ */
@ -366,14 +367,14 @@ static inline void MakeRailStation(TileIndex t, Owner o, StationID sid, Axis a,
{ {
MakeStation(t, o, sid, STATION_RAIL, section + a); MakeStation(t, o, sid, STATION_RAIL, section + a);
SetRailType(t, rt); SetRailType(t, rt);
SetRailwayStationReservation(t, false); SetRailStationReservation(t, false);
} }
static inline void MakeRailWaypoint(TileIndex t, Owner o, StationID sid, Axis a, byte section, RailType rt) static inline void MakeRailWaypoint(TileIndex t, Owner o, StationID sid, Axis a, byte section, RailType rt)
{ {
MakeStation(t, o, sid, STATION_WAYPOINT, section + a); MakeStation(t, o, sid, STATION_WAYPOINT, section + a);
SetRailType(t, rt); SetRailType(t, rt);
SetRailwayStationReservation(t, false); SetRailStationReservation(t, false);
} }
static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStopType rst, RoadTypes rt, DiagDirection d) static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStopType rst, RoadTypes rt, DiagDirection d)

View File

@ -482,7 +482,7 @@ static int GetTrainAcceleration(Train *v, bool mode)
assert(max_speed == GetTrainCurveSpeedLimit(v)); // safety check, will be removed later assert(max_speed == GetTrainCurveSpeedLimit(v)); // safety check, will be removed later
int speed = v->cur_speed * 10 / 16; // km-ish/h -> mp/h int speed = v->cur_speed * 10 / 16; // km-ish/h -> mp/h
if (IsRailwayStationTile(v->tile) && v->IsFrontEngine()) { if (IsRailStationTile(v->tile) && v->IsFrontEngine()) {
StationID sid = GetStationIndex(v->tile); StationID sid = GetStationIndex(v->tile);
if (v->current_order.ShouldStopAtStation(v, sid)) { if (v->current_order.ShouldStopAtStation(v, sid)) {
int station_ahead; int station_ahead;
@ -1977,7 +1977,7 @@ static void ReverseTrainDirection(Train *v)
HasSignalOnTrackdir(v->tile, v->GetVehicleTrackdir()) && HasSignalOnTrackdir(v->tile, v->GetVehicleTrackdir()) &&
!IsPbsSignal(GetSignalType(v->tile, FindFirstTrack(v->track)))); !IsPbsSignal(GetSignalType(v->tile, FindFirstTrack(v->track))));
if (IsRailwayStationTile(v->tile)) SetRailwayStationPlatformReservation(v->tile, TrackdirToExitdir(v->GetVehicleTrackdir()), true); if (IsRailStationTile(v->tile)) SetRailStationPlatformReservation(v->tile, TrackdirToExitdir(v->GetVehicleTrackdir()), true);
if (TryPathReserve(v, false, first_tile_okay)) { if (TryPathReserve(v, false, first_tile_okay)) {
/* Do a look-ahead now in case our current tile was already a safe tile. */ /* Do a look-ahead now in case our current tile was already a safe tile. */
CheckNextTrainTile(v); CheckNextTrainTile(v);
@ -2404,7 +2404,7 @@ static void CheckNextTrainTile(Train *v)
/* Exit if we reached our destination depot or are inside a depot. */ /* Exit if we reached our destination depot or are inside a depot. */
if ((v->tile == v->dest_tile && v->current_order.IsType(OT_GOTO_DEPOT)) || v->track == TRACK_BIT_DEPOT) return; if ((v->tile == v->dest_tile && v->current_order.IsType(OT_GOTO_DEPOT)) || v->track == TRACK_BIT_DEPOT) return;
/* Exit if we are on a station tile and are going to stop. */ /* Exit if we are on a station tile and are going to stop. */
if (IsRailwayStationTile(v->tile) && v->current_order.ShouldStopAtStation(v, GetStationIndex(v->tile))) return; if (IsRailStationTile(v->tile) && v->current_order.ShouldStopAtStation(v, GetStationIndex(v->tile))) return;
/* Exit if the current order doesn't have a destination, but the train has orders. */ /* Exit if the current order doesn't have a destination, but the train has orders. */
if ((v->current_order.IsType(OT_NOTHING) || v->current_order.IsType(OT_LEAVESTATION) || v->current_order.IsType(OT_LOADING)) && v->GetNumOrders() > 0) return; if ((v->current_order.IsType(OT_NOTHING) || v->current_order.IsType(OT_LEAVESTATION) || v->current_order.IsType(OT_LOADING)) && v->GetNumOrders() > 0) return;
@ -2529,12 +2529,12 @@ static void ClearPathReservation(const Train *v, TileIndex tile, Trackdir track_
} }
} }
} }
} else if (IsRailwayStationTile(tile)) { } else if (IsRailStationTile(tile)) {
TileIndex new_tile = TileAddByDiagDir(tile, dir); TileIndex new_tile = TileAddByDiagDir(tile, dir);
/* If the new tile is not a further tile of the same station, we /* If the new tile is not a further tile of the same station, we
* clear the reservation for the whole platform. */ * clear the reservation for the whole platform. */
if (!IsCompatibleTrainStationTile(new_tile, tile)) { if (!IsCompatibleTrainStationTile(new_tile, tile)) {
SetRailwayStationPlatformReservation(tile, ReverseDiagDir(dir), false); SetRailStationPlatformReservation(tile, ReverseDiagDir(dir), false);
} }
} else { } else {
/* Any other tile */ /* Any other tile */
@ -2549,8 +2549,8 @@ void FreeTrainTrackReservation(const Train *v, TileIndex origin, Trackdir orig_t
TileIndex tile = origin != INVALID_TILE ? origin : v->tile; TileIndex tile = origin != INVALID_TILE ? origin : v->tile;
Trackdir td = orig_td != INVALID_TRACKDIR ? orig_td : v->GetVehicleTrackdir(); Trackdir td = orig_td != INVALID_TRACKDIR ? orig_td : v->GetVehicleTrackdir();
bool free_tile = tile != v->tile || !(IsRailwayStationTile(v->tile) || IsTileType(v->tile, MP_TUNNELBRIDGE)); bool free_tile = tile != v->tile || !(IsRailStationTile(v->tile) || IsTileType(v->tile, MP_TUNNELBRIDGE));
StationID station_id = IsRailwayStationTile(v->tile) ? GetStationIndex(v->tile) : INVALID_STATION; StationID station_id = IsRailStationTile(v->tile) ? GetStationIndex(v->tile) : INVALID_STATION;
/* Don't free reservation if it's not ours. */ /* Don't free reservation if it's not ours. */
if (TracksOverlap(GetReservedTrackbits(tile) | TrackToTrackBits(TrackdirToTrack(td)))) return; if (TracksOverlap(GetReservedTrackbits(tile) | TrackToTrackBits(TrackdirToTrack(td)))) return;
@ -2607,7 +2607,7 @@ static bool NtpCallbFindStation(TileIndex tile, TrainTrackFollowerData *ttfd, Tr
/* did we reach the final station? */ /* did we reach the final station? */
if ((ttfd->station_index == INVALID_STATION && tile == ttfd->dest_coords) || ( if ((ttfd->station_index == INVALID_STATION && tile == ttfd->dest_coords) || (
IsRailwayStationTile(tile) && IsRailStationTile(tile) &&
GetStationIndex(tile) == ttfd->station_index GetStationIndex(tile) == ttfd->station_index
)) { )) {
/* We do not check for dest_coords if we have a station_index, /* We do not check for dest_coords if we have a station_index,
@ -3010,7 +3010,7 @@ static Track ChooseTrainTrack(Train *v, TileIndex tile, DiagDirection enterdir,
orders.SwitchToNextOrder(false); orders.SwitchToNextOrder(false);
} else if (v->current_order.IsType(OT_LOADING) || (!v->current_order.IsType(OT_GOTO_DEPOT) && ( } else if (v->current_order.IsType(OT_LOADING) || (!v->current_order.IsType(OT_GOTO_DEPOT) && (
v->current_order.IsType(OT_GOTO_STATION) ? v->current_order.IsType(OT_GOTO_STATION) ?
IsRailwayStationTile(v->tile) && v->current_order.GetDestination() == GetStationIndex(v->tile) : IsRailStationTile(v->tile) && v->current_order.GetDestination() == GetStationIndex(v->tile) :
v->tile == v->dest_tile))) { v->tile == v->dest_tile))) {
orders.SwitchToNextOrder(true); orders.SwitchToNextOrder(true);
} }

View File

@ -186,7 +186,7 @@ CommandCost CmdBuildTrainWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1
bool reserved = HasBit(GetRailReservationTrackBits(tile), AxisToTrack(axis)); bool reserved = HasBit(GetRailReservationTrackBits(tile), AxisToTrack(axis));
MakeRailWaypoint(tile, owner, wp->index, axis, 0, GetRailType(tile)); MakeRailWaypoint(tile, owner, wp->index, axis, 0, GetRailType(tile));
SetRailwayStationReservation(tile, reserved); SetRailStationReservation(tile, reserved);
MarkTileDirtyByTile(tile); MarkTileDirtyByTile(tile);
SetCustomStationSpecIndex(tile, AllocateSpecToStation(GetCustomStationSpec(STAT_CLASS_WAYP, p1), wp, true)); SetCustomStationSpecIndex(tile, AllocateSpecToStation(GetCustomStationSpec(STAT_CLASS_WAYP, p1), wp, true));

View File

@ -191,7 +191,7 @@ protected:
m_new_tile = TILE_ADD(m_old_tile, diff); m_new_tile = TILE_ADD(m_old_tile, diff);
/* special handling for stations */ /* special handling for stations */
if (IsRailTT() && IsRailwayStationTile(m_new_tile)) { if (IsRailTT() && IsRailStationTile(m_new_tile)) {
m_is_station = true; m_is_station = true;
} else if (IsRoadTT() && IsRoadStopTile(m_new_tile)) { } else if (IsRoadTT() && IsRoadStopTile(m_new_tile)) {
m_is_station = true; m_is_station = true;

View File

@ -163,7 +163,7 @@ public:
{ {
if (n.m_num_signals_passed >= m_sig_look_ahead_costs.Size() / 2) return 0; if (n.m_num_signals_passed >= m_sig_look_ahead_costs.Size() / 2) return 0;
if (IsRailwayStationTile(tile) && IsAnyStationTileReserved(tile, trackdir, skipped)) { if (IsRailStationTile(tile) && IsAnyStationTileReserved(tile, trackdir, skipped)) {
return Yapf().PfGetSettings().rail_pbs_station_penalty * (skipped + 1); return Yapf().PfGetSettings().rail_pbs_station_penalty * (skipped + 1);
} else if (TrackOverlapsTracks(GetReservedTrackbits(tile), TrackdirToTrack(trackdir))) { } else if (TrackOverlapsTracks(GetReservedTrackbits(tile), TrackdirToTrack(trackdir))) {
int cost = Yapf().PfGetSettings().rail_pbs_cross_penalty; int cost = Yapf().PfGetSettings().rail_pbs_cross_penalty;

View File

@ -160,7 +160,7 @@ public:
{ {
bool bDest; bool bDest;
if (m_dest_station_id != INVALID_STATION) { if (m_dest_station_id != INVALID_STATION) {
bDest = IsRailwayStationTile(tile) bDest = IsRailStationTile(tile)
&& (GetStationIndex(tile) == m_dest_station_id) && (GetStationIndex(tile) == m_dest_station_id)
&& (GetRailStationTrack(tile) == TrackdirToTrack(td)); && (GetRailStationTrack(tile) == TrackdirToTrack(td));
} else { } else {

View File

@ -63,14 +63,14 @@ private:
} }
/** Reserve a railway platform. Tile contains the failed tile on abort. */ /** Reserve a railway platform. Tile contains the failed tile on abort. */
bool ReserveRailwayStationPlatform(TileIndex &tile, DiagDirection dir) bool ReserveRailStationPlatform(TileIndex &tile, DiagDirection dir)
{ {
TileIndex start = tile; TileIndex start = tile;
TileIndexDiff diff = TileOffsByDiagDir(dir); TileIndexDiff diff = TileOffsByDiagDir(dir);
do { do {
if (HasStationReservation(tile)) return false; if (HasStationReservation(tile)) return false;
SetRailwayStationReservation(tile, true); SetRailStationReservation(tile, true);
MarkTileDirtyByTile(tile); MarkTileDirtyByTile(tile);
tile = TILE_ADD(tile, diff); tile = TILE_ADD(tile, diff);
} while (IsCompatibleTrainStationTile(tile, start)); } while (IsCompatibleTrainStationTile(tile, start));
@ -81,8 +81,8 @@ private:
/** Try to reserve a single track/platform. */ /** Try to reserve a single track/platform. */
bool ReserveSingleTrack(TileIndex tile, Trackdir td) bool ReserveSingleTrack(TileIndex tile, Trackdir td)
{ {
if (IsRailwayStationTile(tile)) { if (IsRailStationTile(tile)) {
if (!ReserveRailwayStationPlatform(tile, TrackdirToExitdir(ReverseTrackdir(td)))) { if (!ReserveRailStationPlatform(tile, TrackdirToExitdir(ReverseTrackdir(td)))) {
/* Platform could not be reserved, undo. */ /* Platform could not be reserved, undo. */
m_res_fail_tile = tile; m_res_fail_tile = tile;
m_res_fail_td = td; m_res_fail_td = td;
@ -102,11 +102,11 @@ private:
/** Unreserve a single track/platform. Stops when the previous failer is reached. */ /** Unreserve a single track/platform. Stops when the previous failer is reached. */
bool UnreserveSingleTrack(TileIndex tile, Trackdir td) bool UnreserveSingleTrack(TileIndex tile, Trackdir td)
{ {
if (IsRailwayStationTile(tile)) { if (IsRailStationTile(tile)) {
TileIndex start = tile; TileIndex start = tile;
TileIndexDiff diff = TileOffsByDiagDir(TrackdirToExitdir(ReverseTrackdir(td))); TileIndexDiff diff = TileOffsByDiagDir(TrackdirToExitdir(ReverseTrackdir(td)));
while ((tile != m_res_fail_tile || td != m_res_fail_td) && IsCompatibleTrainStationTile(tile, start)) { while ((tile != m_res_fail_tile || td != m_res_fail_td) && IsCompatibleTrainStationTile(tile, start)) {
SetRailwayStationReservation(tile, false); SetRailStationReservation(tile, false);
tile = TILE_ADD(tile, diff); tile = TILE_ADD(tile, diff);
} }
} else if (tile != m_res_fail_tile || td != m_res_fail_td) { } else if (tile != m_res_fail_tile || td != m_res_fail_td) {