From ad046bdf2212a7acdb6d5696cbb779c237f1e272 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Thu, 24 Feb 2022 18:19:57 +0000 Subject: [PATCH] Add a waypoint ground draw flag to NewGRF road stops Adjust overlay draw conditions --- docs/newgrf-roadstops.html | 1 + src/newgrf_roadstop.cpp | 5 ++++- src/newgrf_roadstop.h | 7 ++++--- src/station_cmd.cpp | 8 ++++++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/docs/newgrf-roadstops.html b/docs/newgrf-roadstops.html index 3c95fef7dc..a2ad4fdb91 100644 --- a/docs/newgrf-roadstops.html +++ b/docs/newgrf-roadstops.html @@ -91,6 +91,7 @@ BitValueMeaning 01Bay stops: Draw road type ground sprite 12Drive through stops: Draw road/tram type overlays + 44Road waypoints: Draw sprite layout ground sprite on top of the underlying road (by default the sprite layout ground sprite is not used) The default value is 3 (bits 0 and 1 both set).

diff --git a/src/newgrf_roadstop.cpp b/src/newgrf_roadstop.cpp index c54c570253..920ab595e1 100644 --- a/src/newgrf_roadstop.cpp +++ b/src/newgrf_roadstop.cpp @@ -275,6 +275,9 @@ void DrawRoadStopTile(int x, int y, RoadType roadtype, const RoadStopSpec *spec, if (type == STATION_ROADWAYPOINT) { DrawSprite(SPR_ROAD_PAVED_STRAIGHT_X, PAL_NONE, x, y); + if ((spec->draw_mode & ROADSTOP_DRAW_MODE_WAYP_GROUND) && GB(image, 0, SPRITE_WIDTH) != 0) { + DrawSprite(image, GroundSpritePaletteTransform(image, pal, palette), x, y); + } } else if (GB(image, 0, SPRITE_WIDTH) != 0) { DrawSprite(image, GroundSpritePaletteTransform(image, pal, palette), x, y); } @@ -284,7 +287,7 @@ void DrawRoadStopTile(int x, int y, RoadType roadtype, const RoadStopSpec *spec, uint sprite_offset = 5 - view; /* Road underlay takes precedence over tram */ - if (spec->draw_mode & ROADSTOP_DRAW_MODE_OVERLAY) { + if (type == STATION_ROADWAYPOINT || spec->draw_mode & ROADSTOP_DRAW_MODE_OVERLAY) { if (rti->UsesOverlay()) { SpriteID ground = GetCustomRoadSprite(rti, INVALID_TILE, ROTSG_GROUND); DrawSprite(ground + sprite_offset, PAL_NONE, x, y); diff --git a/src/newgrf_roadstop.h b/src/newgrf_roadstop.h index 3fa467f7fe..b0879c4647 100644 --- a/src/newgrf_roadstop.h +++ b/src/newgrf_roadstop.h @@ -56,9 +56,10 @@ enum RoadStopAvailabilityType : byte { * or road. */ enum RoadStopDrawMode : byte { - ROADSTOP_DRAW_MODE_NONE = 0, - ROADSTOP_DRAW_MODE_ROAD = 1 << 0, ///< 0b01, Draw the road itself - ROADSTOP_DRAW_MODE_OVERLAY = 1 << 1, ///< 0b10, Draw the road overlay for roadstops, e.g. pavement + ROADSTOP_DRAW_MODE_NONE = 0, + ROADSTOP_DRAW_MODE_ROAD = 1 << 0, ///< Bay stops: Draw the road itself + ROADSTOP_DRAW_MODE_OVERLAY = 1 << 1, ///< Drive-through stops: Draw the road overlay, e.g. pavement + ROADSTOP_DRAW_MODE_WAYP_GROUND = 1 << 2, ///< Waypoints: Draw the sprite layout ground tile (on top of the road) }; DECLARE_ENUM_AS_BIT_SET(RoadStopDrawMode) diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 7320194e04..bbcf2226a6 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -3503,16 +3503,20 @@ draw_default_foundation: Axis axis = GetRoadStopDir(ti->tile) == DIAGDIR_NE ? AXIS_X : AXIS_Y; DiagDirection dir = GetRoadStopDir(ti->tile); + StationType type = GetStationType(ti->tile); const RoadStopSpec *stopspec = GetRoadStopSpec(ti->tile); if (stopspec != nullptr) { int view = dir; if (IsDriveThroughStopTile(ti->tile)) view += 4; st = BaseStation::GetByTile(ti->tile); - RoadStopResolverObject object(stopspec, st, ti->tile, INVALID_ROADTYPE, GetStationType(ti->tile), view); + RoadStopResolverObject object(stopspec, st, ti->tile, INVALID_ROADTYPE, type, view); const SpriteGroup *group = object.Resolve(); const DrawTileSprites *dts = ((const TileLayoutSpriteGroup *)group)->ProcessRegisters(nullptr); t = dts; + if (type == STATION_ROADWAYPOINT && (stopspec->draw_mode & ROADSTOP_DRAW_MODE_WAYP_GROUND)) { + draw_ground = true; + } } /* Draw ground sprite */ @@ -3525,7 +3529,7 @@ draw_default_foundation: } if (IsDriveThroughStopTile(ti->tile)) { - if (stopspec == nullptr || (stopspec->draw_mode & ROADSTOP_DRAW_MODE_OVERLAY) != 0) { + if (type != STATION_ROADWAYPOINT && (stopspec == nullptr || (stopspec->draw_mode & ROADSTOP_DRAW_MODE_OVERLAY) != 0)) { uint sprite_offset = axis == AXIS_X ? 1 : 0; DrawRoadOverlays(ti, PAL_NONE, road_rti, tram_rti, sprite_offset, sprite_offset); }