Add a waypoint ground draw flag to NewGRF road stops

Adjust overlay draw conditions
This commit is contained in:
Jonathan G Rennison
2022-02-24 18:19:57 +00:00
parent 5109083564
commit ad046bdf22
4 changed files with 15 additions and 6 deletions

View File

@@ -91,6 +91,7 @@
<tr><th>Bit</th><th>Value</th><th>Meaning</th></tr> <tr><th>Bit</th><th>Value</th><th>Meaning</th></tr>
<tr><td>0</td><td>1</td><td>Bay stops: Draw road type ground sprite</td></tr> <tr><td>0</td><td>1</td><td>Bay stops: Draw road type ground sprite</td></tr>
<tr><td>1</td><td>2</td><td>Drive through stops: Draw road/tram type overlays</td></tr> <tr><td>1</td><td>2</td><td>Drive through stops: Draw road/tram type overlays</td></tr>
<tr><td>4</td><td>4</td><td>Road waypoints: Draw sprite layout ground sprite on top of the underlying road (by default the sprite layout ground sprite is not used)</td></tr>
</table> </table>
The default value is 3 (bits 0 and 1 both set). The default value is 3 (bits 0 and 1 both set).
</p> </p>

View File

@@ -275,6 +275,9 @@ void DrawRoadStopTile(int x, int y, RoadType roadtype, const RoadStopSpec *spec,
if (type == STATION_ROADWAYPOINT) { if (type == STATION_ROADWAYPOINT) {
DrawSprite(SPR_ROAD_PAVED_STRAIGHT_X, PAL_NONE, x, y); 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) { } else if (GB(image, 0, SPRITE_WIDTH) != 0) {
DrawSprite(image, GroundSpritePaletteTransform(image, pal, palette), x, y); 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; uint sprite_offset = 5 - view;
/* Road underlay takes precedence over tram */ /* 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()) { if (rti->UsesOverlay()) {
SpriteID ground = GetCustomRoadSprite(rti, INVALID_TILE, ROTSG_GROUND); SpriteID ground = GetCustomRoadSprite(rti, INVALID_TILE, ROTSG_GROUND);
DrawSprite(ground + sprite_offset, PAL_NONE, x, y); DrawSprite(ground + sprite_offset, PAL_NONE, x, y);

View File

@@ -56,9 +56,10 @@ enum RoadStopAvailabilityType : byte {
* or road. * or road.
*/ */
enum RoadStopDrawMode : byte { enum RoadStopDrawMode : byte {
ROADSTOP_DRAW_MODE_NONE = 0, ROADSTOP_DRAW_MODE_NONE = 0,
ROADSTOP_DRAW_MODE_ROAD = 1 << 0, ///< 0b01, Draw the road itself ROADSTOP_DRAW_MODE_ROAD = 1 << 0, ///< Bay stops: Draw the road itself
ROADSTOP_DRAW_MODE_OVERLAY = 1 << 1, ///< 0b10, Draw the road overlay for roadstops, e.g. pavement 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) DECLARE_ENUM_AS_BIT_SET(RoadStopDrawMode)

View File

@@ -3503,16 +3503,20 @@ draw_default_foundation:
Axis axis = GetRoadStopDir(ti->tile) == DIAGDIR_NE ? AXIS_X : AXIS_Y; Axis axis = GetRoadStopDir(ti->tile) == DIAGDIR_NE ? AXIS_X : AXIS_Y;
DiagDirection dir = GetRoadStopDir(ti->tile); DiagDirection dir = GetRoadStopDir(ti->tile);
StationType type = GetStationType(ti->tile);
const RoadStopSpec *stopspec = GetRoadStopSpec(ti->tile); const RoadStopSpec *stopspec = GetRoadStopSpec(ti->tile);
if (stopspec != nullptr) { if (stopspec != nullptr) {
int view = dir; int view = dir;
if (IsDriveThroughStopTile(ti->tile)) view += 4; if (IsDriveThroughStopTile(ti->tile)) view += 4;
st = BaseStation::GetByTile(ti->tile); 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 SpriteGroup *group = object.Resolve();
const DrawTileSprites *dts = ((const TileLayoutSpriteGroup *)group)->ProcessRegisters(nullptr); const DrawTileSprites *dts = ((const TileLayoutSpriteGroup *)group)->ProcessRegisters(nullptr);
t = dts; t = dts;
if (type == STATION_ROADWAYPOINT && (stopspec->draw_mode & ROADSTOP_DRAW_MODE_WAYP_GROUND)) {
draw_ground = true;
}
} }
/* Draw ground sprite */ /* Draw ground sprite */
@@ -3525,7 +3529,7 @@ draw_default_foundation:
} }
if (IsDriveThroughStopTile(ti->tile)) { 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; uint sprite_offset = axis == AXIS_X ? 1 : 0;
DrawRoadOverlays(ti, PAL_NONE, road_rti, tram_rti, sprite_offset, sprite_offset); DrawRoadOverlays(ti, PAL_NONE, road_rti, tram_rti, sprite_offset, sprite_offset);
} }