diff --git a/media/baseset/openttd.grf b/media/baseset/openttd.grf index e3ebf2dd67..9e08fb17c3 100644 Binary files a/media/baseset/openttd.grf and b/media/baseset/openttd.grf differ diff --git a/media/baseset/openttd/oneway.nfo b/media/baseset/openttd/oneway.nfo index 46f3b8f947..56d2e2809a 100644 --- a/media/baseset/openttd/oneway.nfo +++ b/media/baseset/openttd/oneway.nfo @@ -4,10 +4,24 @@ // See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . // -1 * 0 0C "One way road graphics" - -1 * 3 05 09 06 - -1 sprites/oneway.png 8bpp 34 8 24 16 -12 -8 normal - -1 sprites/oneway.png 8bpp 66 8 24 16 -12 -8 normal - -1 sprites/oneway.png 8bpp 98 8 24 16 -12 -8 normal - -1 sprites/oneway.png 8bpp 130 8 24 16 -12 -8 normal - -1 sprites/oneway.png 8bpp 162 8 24 16 -12 -8 normal - -1 sprites/oneway.png 8bpp 194 8 24 16 -12 -8 normal + -1 * 3 05 09 12 + -1 sprites/oneway.png 8bpp 34 8 24 16 -10 -9 normal + -1 sprites/oneway.png 8bpp 66 8 24 16 -13 -7 normal + -1 sprites/oneway.png 8bpp 98 8 24 16 -12 -8 normal + -1 sprites/oneway.png 8bpp 130 8 24 16 -15 -10 normal + -1 sprites/oneway.png 8bpp 162 8 24 16 -12 -9 normal + -1 sprites/oneway.png 8bpp 194 8 24 16 -11 -8 normal + + -1 sprites/oneway.png 8bpp 34 40 24 16 -13 -10 normal + -1 sprites/oneway.png 8bpp 66 40 24 16 -12 -8 normal + -1 sprites/oneway.png 8bpp 98 40 24 16 -12 -9 normal + -1 sprites/oneway.png 8bpp 130 40 24 16 -11 -8 normal + -1 sprites/oneway.png 8bpp 162 40 24 16 -9 -10 normal + -1 sprites/oneway.png 8bpp 194 40 24 16 -10 -9 normal + + -1 sprites/oneway.png 8bpp 34 72 24 16 -8 -11 normal + -1 sprites/oneway.png 8bpp 66 72 24 16 -11 -5 normal + -1 sprites/oneway.png 8bpp 98 72 24 16 -12 -8 normal + -1 sprites/oneway.png 8bpp 130 72 24 16 -12 -5 normal + -1 sprites/oneway.png 8bpp 162 72 24 16 -14 -10 normal + -1 sprites/oneway.png 8bpp 194 72 24 16 -12 -8 normal diff --git a/media/baseset/openttd/oneway.png b/media/baseset/openttd/oneway.png index 15542af856..843747677f 100644 Binary files a/media/baseset/openttd/oneway.png and b/media/baseset/openttd/oneway.png differ diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 5f1991ae6e..692ef30850 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -6274,9 +6274,17 @@ static void GraphicsNew(ByteReader *buf) if (offset <= depot_no_track_offset && offset + num > depot_no_track_offset) _loaded_newgrf_features.tram = TRAMWAY_REPLACE_DEPOT_NO_TRACK; } + /* If the baseset or grf only provides sprites for flat tiles (pre #10282), duplicate those for use on slopes. */ + bool dup_oneway_sprites = ((type == 0x09) && (offset + num <= SPR_ONEWAY_SLOPE_N_OFFSET)); + for (; num > 0; num--) { _cur.nfo_line++; - LoadNextSprite(replace == 0 ? _cur.spriteid++ : replace++, *_cur.file, _cur.nfo_line); + int load_index = (replace == 0 ? _cur.spriteid++ : replace++); + LoadNextSprite(load_index, *_cur.file, _cur.nfo_line); + if (dup_oneway_sprites) { + DupSprite(load_index, load_index + SPR_ONEWAY_SLOPE_N_OFFSET); + DupSprite(load_index, load_index + SPR_ONEWAY_SLOPE_S_OFFSET); + } } _cur.skip_sprites = skip_num; diff --git a/src/road.h b/src/road.h index c34579b5bb..c3fcc30ca9 100644 --- a/src/road.h +++ b/src/road.h @@ -66,6 +66,7 @@ enum RoadTypeSpriteGroup { ROTSG_DEPOT, ///< Optional: Depot images ROTSG_reserved3, ///< Placeholder, if we add road fences (for highways). ROTSG_ROADSTOP, ///< Required: Drive-in stop surface + ROTSG_ONEWAY, ///< Optional: One-way indicator images ROTSG_END, }; diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index dda2f2fa2a..94b4423a15 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -1606,7 +1606,17 @@ static void DrawRoadBits(TileInfo *ti) if (road_rti != nullptr) { DisallowedRoadDirections drd = GetDisallowedRoadDirections(ti->tile); if (drd != DRD_NONE) { - DrawGroundSpriteAt(SPR_ONEWAY_BASE + drd - 1 + ((road == ROAD_X) ? 0 : 3), PAL_NONE, 8, 8, GetPartialPixelZ(8, 8, ti->tileh)); + SpriteID oneway = GetCustomRoadSprite(road_rti, ti->tile, ROTSG_ONEWAY); + + if (oneway == 0) oneway = SPR_ONEWAY_BASE; + + if ((ti->tileh == SLOPE_NE) || (ti->tileh == SLOPE_NW)) { + oneway += SPR_ONEWAY_SLOPE_N_OFFSET; + } else if ((ti->tileh == SLOPE_SE) || (ti->tileh == SLOPE_SW)) { + oneway += SPR_ONEWAY_SLOPE_S_OFFSET; + } + + DrawGroundSpriteAt(oneway + drd - 1 + ((road == ROAD_X) ? 0 : 3), PAL_NONE, 8, 8, GetPartialPixelZ(8, 8, ti->tileh)); } } diff --git a/src/table/sprites.h b/src/table/sprites.h index b0e61b5d02..407a7a2d87 100644 --- a/src/table/sprites.h +++ b/src/table/sprites.h @@ -290,8 +290,10 @@ static const SpriteID SPR_TRAMWAY_DEPOT_NO_TRACK = SPR_TRAMWAY_BASE + 113; static const uint16 TRAMWAY_SPRITE_COUNT = 119; /** One way road sprites */ -static const SpriteID SPR_ONEWAY_BASE = SPR_TRAMWAY_BASE + TRAMWAY_SPRITE_COUNT; -static const uint16 ONEWAY_SPRITE_COUNT = 6; +static const SpriteID SPR_ONEWAY_BASE = SPR_TRAMWAY_BASE + TRAMWAY_SPRITE_COUNT; +static const SpriteID SPR_ONEWAY_SLOPE_N_OFFSET = 6; +static const SpriteID SPR_ONEWAY_SLOPE_S_OFFSET = 12; +static const uint16 ONEWAY_SPRITE_COUNT = 18; /** Tunnel sprites with grass only for custom railtype tunnel. */ static const SpriteID SPR_RAILTYPE_TUNNEL_BASE = SPR_ONEWAY_BASE + ONEWAY_SPRITE_COUNT;