diff options
author | Erich Eckner <git@eckner.net> | 2018-11-19 22:51:11 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2021-07-21 19:01:20 +0200 |
commit | c2e0bc7fac90c44efe952206d6c59906bc8f749b (patch) | |
tree | 073c8b6f5912903dc38789c04533ecbde82a29dd /src | |
parent | 95f4c22ef5897c597592b03bcd0617f8d2d2aa8d (diff) | |
download | openttd-c2e0bc7fac90c44efe952206d6c59906bc8f749b.tar.xz |
fix something about the slopes
Diffstat (limited to 'src')
-rw-r--r-- | src/road_cmd.cpp | 5 | ||||
-rw-r--r-- | src/road_cmd.h | 3 | ||||
-rw-r--r-- | src/station_cmd.cpp | 44 |
3 files changed, 32 insertions, 20 deletions
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index fdfde38d1..a72ff4eb7 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -37,6 +37,7 @@ #include "genworld.h" #include "company_gui.h" #include "road_func.h" +#include "road_cmd.h" #include "table/strings.h" #include "table/roadtypes.h" @@ -251,8 +252,6 @@ static const RoadBits _invalid_tileh_slopes_road[2][15] = { } }; -static Foundation GetRoadFoundation(Slope tileh, RoadBits bits); - /** * Is it allowed to remove the given road bits from the given tile? * @param tile the tile to remove the road from @@ -1296,7 +1295,7 @@ struct DrawRoadTileStruct { * @param bits The RoadBits part * @return The resulting Foundation */ -static Foundation GetRoadFoundation(Slope tileh, RoadBits bits) +Foundation GetRoadFoundation(Slope tileh, RoadBits bits) { /* Flat land and land without a road doesn't require a foundation */ if (tileh == SLOPE_FLAT || bits == ROAD_NONE) return FOUNDATION_NONE; diff --git a/src/road_cmd.h b/src/road_cmd.h index 753ebd21d..87dee9722 100644 --- a/src/road_cmd.h +++ b/src/road_cmd.h @@ -12,8 +12,11 @@ #include "direction_type.h" #include "road_type.h" +#include "slope_type.h" void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt); void UpdateNearestTownForRoadTiles(bool invalidate); +Foundation GetRoadFoundation(Slope tileh, RoadBits bits); + #endif /* ROAD_CMD_H */ diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 60396da7a..ea29e2479 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -56,6 +56,7 @@ #include "linkgraph/refresh.h" #include "widgets/station_widget.h" #include "tunnelbridge_map.h" +#include "road_cmd.h" #include "table/strings.h" @@ -949,13 +950,13 @@ static CommandCost CheckFlatLandRailStation(TileArea tile_area, DoCommandFlag fl * @param rt Road type to build. * @return The cost in case of success, or an error code if it failed. */ -static CommandCost CheckFlatLandRoadStop(TileArea tile_area, DoCommandFlag flags, bool is_drive_through, bool is_truck_stop, Axis axis, StationID *station, RoadType rt) +static CommandCost CheckFlatLandRoadStop(TileArea tile_area, DoCommandFlag flags, uint invalid_dirs, bool is_drive_through, bool is_truck_stop, Axis axis, StationID *station, RoadType rt) { CommandCost cost(EXPENSES_CONSTRUCTION); int allowed_z = -2; for (TileIndex cur_tile : tile_area) { - CommandCost ret = CheckBuildableTile(cur_tile, 0, allowed_z, true); + CommandCost ret = CheckBuildableTile(cur_tile, invalid_dirs, allowed_z, true); if (ret.Failed()) return ret; cost.AddCost(ret); @@ -1878,7 +1879,7 @@ CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uin /* Total road stop cost. */ CommandCost cost(EXPENSES_CONSTRUCTION, roadstop_area.w * roadstop_area.h * _price[type ? PR_BUILD_STATION_TRUCK : PR_BUILD_STATION_BUS]); StationID est = INVALID_STATION; - ret = CheckFlatLandRoadStop(roadstop_area, flags, is_drive_through, type, axis, &est, rt); + ret = CheckFlatLandRoadStop(roadstop_area, flags, is_drive_through ? 0 : 1 << ddir, is_drive_through, type, axis, &est, rt); if (ret.Failed()) return ret; cost.AddCost(ret); @@ -2990,10 +2991,10 @@ static void DrawTile_Station(TileInfo *ti) } OffsetGroundSprite(31, 1); - ti->z += ApplyPixelFoundationToSlope(FOUNDATION_LEVELED, &ti->tileh); + ti->z += ApplyPixelFoundationToSlope(FOUNDATION_NONE, &ti->tileh); //FOUNDATION_LEVELED, &ti->tileh); } else { draw_default_foundation: - DrawFoundation(ti, FOUNDATION_LEVELED); + DrawFoundation(ti, FOUNDATION_NONE); //FOUNDATION_LEVELED); } } @@ -3048,22 +3049,31 @@ draw_default_foundation: DrawGroundSprite(overlay + overlay_offset, PALETTE_CRASH); } } else { - 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 && IsRailStation(ti->tile)) { + } else if (ti->tileh != SLOPE_FLAT && (IsRailStation(ti->tile) || IsRoadStop(ti->tile))) { /* It's a sloped rail station? */ Foundation rf = FOUNDATION_NONE; - /* 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); - } - } + 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; + } 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); + } + } + } else + image += HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE) ? ground_relocation : total_offset; DrawGroundSprite(image, GroundSpritePaletteTransform(image, pal, palette)); /* PBS debugging, draw reserved tracks darker */ |