summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rail_cmd.cpp8
-rw-r--r--src/road_cmd.cpp7
-rw-r--r--src/road_func.h2
-rw-r--r--src/road_type.h7
-rw-r--r--src/station_cmd.cpp61
-rw-r--r--src/track_type.h7
6 files changed, 38 insertions, 54 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 59c1d27ab..23c68ae86 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -187,14 +187,6 @@ RailType AllocateRailType(RailTypeLabel label)
return INVALID_RAILTYPE;
}
-static const byte _track_sloped_sprites[14] = {
- 14, 15, 22, 13,
- 0, 21, 17, 12,
- 23, 0, 18, 20,
- 19, 16
-};
-
-
/* 4
* ---------
* |\ /|
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 70a014434..fdfde38d1 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -1318,13 +1318,6 @@ static Foundation GetRoadFoundation(Slope tileh, RoadBits bits)
return (bits == ROAD_X ? FOUNDATION_INCLINED_X : FOUNDATION_INCLINED_Y);
}
-const byte _road_sloped_sprites[14] = {
- 0, 0, 2, 0,
- 0, 1, 0, 0,
- 3, 0, 0, 0,
- 0, 0
-};
-
/**
* Get the sprite offset within a spritegroup.
* @param slope Slope
diff --git a/src/road_func.h b/src/road_func.h
index aa8bb2a26..937646057 100644
--- a/src/road_func.h
+++ b/src/road_func.h
@@ -159,6 +159,4 @@ void UpdateCompanyRoadInfrastructure(RoadType rt, Owner o, int count);
struct TileInfo;
void DrawRoadOverlays(const TileInfo *ti, PaletteID pal, const RoadTypeInfo *road_rti, const RoadTypeInfo *tram_rit, uint road_offset, uint tram_offset);
-Foundation GetRoadFoundation(Slope tileh, RoadBits bits);
-
#endif /* ROAD_FUNC_H */
diff --git a/src/road_type.h b/src/road_type.h
index 969b141ba..1af4275eb 100644
--- a/src/road_type.h
+++ b/src/road_type.h
@@ -68,4 +68,11 @@ enum RoadBits {
DECLARE_ENUM_AS_BIT_SET(RoadBits)
template <> struct EnumPropsT<RoadBits> : MakeEnumPropsT<RoadBits, byte, ROAD_NONE, ROAD_END, ROAD_NONE, 4> {};
+const byte _road_sloped_sprites[14] = {
+ 0, 0, 2, 0,
+ 0, 1, 0, 0,
+ 3, 0, 0, 0,
+ 0, 0
+};
+
#endif /* ROAD_TYPE_H */
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 560563292..1707bdf15 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -814,9 +814,9 @@ CommandCost CheckBuildableTile(TileIndex tile, uint invalid_dirs, int &allowed_z
cost.AddCost(_price[PR_BUILD_FOUNDATION]);
}
- /* get corresponding flat level and make sure that all parts of the station have the same level. */
- if (allowed_z == -1) {
- /* first tile */
+ /* The level of this tile must be equal to allowed_z. */
+ if (allowed_z < 0) {
+ /* First tile. */
allowed_z = flat_z;
} else if (allowed_z != flat_z) {
return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED);
@@ -855,7 +855,6 @@ static CommandCost CheckFlatLandAirport(AirportTileTableIterator tile_iter, DoCo
* @param flags Operation to perform.
* @param axis Rail station axis.
* @param station StationID to be queried and returned if available.
- * @param bool check_facing_slope to check which stations are allowed to build on slopes facing the slope
* @param rt The rail type to check for (overbuilding rail stations over rail).
* @param affected_vehicles List of trains with PBS reservations on the tiles
* @param spec_class Station class.
@@ -864,7 +863,7 @@ static CommandCost CheckFlatLandAirport(AirportTileTableIterator tile_iter, DoCo
* @param numtracks Number of platforms.
* @return The cost in case of success, or an error code if it failed.
*/
-static CommandCost CheckFlatLandRailStation(TileArea tile_area, DoCommandFlag flags, Axis axis, StationID *station, bool check_facing_slope, RailType rt, std::vector<Train *> &affected_vehicles, StationClassID spec_class, byte spec_index, byte plat_len, byte numtracks)
+static CommandCost CheckFlatLandRailStation(TileArea tile_area, DoCommandFlag flags, Axis axis, StationID *station, RailType rt, std::vector<Train *> &affected_vehicles, StationClassID spec_class, byte spec_index, byte plat_len, byte numtracks)
{
CommandCost cost(EXPENSES_CONSTRUCTION);
int allowed_z = -1;
@@ -2814,9 +2813,6 @@ bool SplitGroundSpriteForOverlay(const TileInfo *ti, SpriteID *ground, RailTrack
return true;
}
-extern const byte _road_sloped_sprites[14];
-extern const byte _track_sloped_sprites[14];
-
static void DrawTile_Station(TileInfo *ti)
{
const NewGRFSpriteLayout *layout = nullptr;
@@ -2829,9 +2825,8 @@ static void DrawTile_Station(TileInfo *ti)
BaseStation *st = nullptr;
const StationSpec *statspec = nullptr;
uint tile_layout = 0;
- RailtypeInfo *rti;
- if (IsRailwayStation(ti->tile) || IsRailWaypoint(ti->tile)) {
+ if (HasStationRail(ti->tile)) {
rti = GetRailTypeInfo(GetRailType(ti->tile));
total_offset = rti->GetRailtypeSpriteOffset();
@@ -2908,7 +2903,7 @@ static void DrawTile_Station(TileInfo *ti)
if (ti->tileh != SLOPE_FLAT && (IsAirport(ti->tile) || IsStandardRoadStopTile(ti->tile)))
DrawFoundation(ti, FOUNDATION_LEVELED);
- if (IsCustomStationSpecIndex(ti->tile)) {
+ if (HasStationTileRail(ti->tile) && IsCustomStationSpecIndex(ti->tile)) {
/* look for customization */
st = BaseStation::GetByTile(ti->tile);
statspec = st->speclist[GetCustomStationSpecIndex(ti->tile)].spec;
@@ -3057,31 +3052,24 @@ draw_default_foundation:
image += HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE) ? ground_relocation : total_offset;
if (HasBit(pal, SPRITE_MODIFIER_CUSTOM_SPRITE)) {
pal += ground_relocation;
- } else if (ti->tileh != SLOPE_FLAT && (IsRailwayStation(ti->tile) || IsRoadStop(ti->tile))) {
- /* It's a sloped rail/road station? */
+ } else if (ti->tileh != SLOPE_FLAT && IsRailStation(ti->tile)) {
+ /* It's a sloped rail station? */
Foundation rf = FOUNDATION_NONE;
- if (IsRoadStop(ti->tile)) {
- /* Roadstops without foundation on a slope
- * and on Slopes with one corner raised */
- rf = GetRoadFoundation(ti->tileh, AxisToRoadBits(DiagDirToAxis(GetRoadStopDir(ti->tile))));
- DrawFoundation(ti, rf);
- /* Draws the sloped road */
- if (ti->tileh != SLOPE_FLAT) image = _road_sloped_sprites[ti->tileh - 1] + 0x53F;
+ /* sloped rail station */
+ TrackBits track = AxisToTrackBits(GetRailStationAxis(ti->tile));
+ rf = GetRailFoundation(ti->tileh, track);
+ DrawFoundation(ti, rf);
+ if (rf != FOUNDATION_LEVELED) {
+ image = _track_sloped_sprites[ti->tileh - 1] + rti->base_sprites.track_y;
} else {
- /* sloped rail station */
- TrackBits track = AxisToTrackBits(GetRailStationAxis(ti->tile));
- rf = GetRailFoundation(ti->tileh, track);
- DrawFoundation(ti, rf);
- if (rf != FOUNDATION_LEVELED) {
- image = _track_sloped_sprites[ti->tileh - 1] + rti->base_sprites.track_y;
- } else {
- (image = rti->base_sprites.track_y, track == TRACK_BIT_Y ) || (image++, track == TRACK_BIT_X);
- }
+ (image = rti->base_sprites.track_y, track == TRACK_BIT_Y ) || (image++, track == TRACK_BIT_X);
}
+ }
DrawGroundSprite(image, GroundSpritePaletteTransform(image, pal, palette));
/* PBS debugging, draw reserved tracks darker */
if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && HasStationRail(ti->tile) && HasStationReservation(ti->tile)) {
+ const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile));
TrackBits pbs = AxisToTrackBits(GetRailStationAxis(ti->tile));
// TODO: possibly inverted in 7b136d1fddbb2d0840076dfe2ddbe666b29fee8d
if (pbs & TRACK_BIT_X) {
@@ -3195,15 +3183,14 @@ void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, Ro
static int GetSlopePixelZ_Station(TileIndex tile, uint x, uint y)
{
- Axis axis;
- uint z;
- Slope tileh = GetTileSlope(tile, &z);
-
/* this code makes vehicles and trains follow the slope on sloped stations */
- if (IsRailwayStation(tile) || IsRoadStopTile(tile) && !IsStandardRoadStopTile(tile)) {
- axis = IsRailwayStation(tile)?GetRailStationAxis(tile):DiagDirToAxis(GetRoadStopDir(tile));
- z += ApplyFoundationToSlope(GetRailFoundation(tileh,AxisToTrackBits(axis)), &tileh);
- return z + GetPartialZ(x & 0xF, y & 0xF, tileh);
+ if (IsRailStation(tile)) {
+ int z;
+ Slope tileh = GetTilePixelSlope(tile, &z);
+ Axis axis = GetRailStationAxis(tile);
+
+ z += 8*ApplyFoundationToSlope(GetRailFoundation(tileh,AxisToTrackBits(axis)), &tileh);
+ return z + GetPartialPixelZ(x & 0xF, y & 0xF, tileh);
}
return GetTileMaxPixelZ(tile);
diff --git a/src/track_type.h b/src/track_type.h
index 70278c58d..0c64b9978 100644
--- a/src/track_type.h
+++ b/src/track_type.h
@@ -120,4 +120,11 @@ DECLARE_ENUM_AS_BIT_SET(TrackdirBits)
typedef uint32 TrackStatus;
+static const byte _track_sloped_sprites[14] = {
+ 14, 15, 22, 13,
+ 0, 21, 17, 12,
+ 23, 0, 18, 20,
+ 19, 16
+};
+
#endif /* TRACK_TYPE_H */