diff --git a/src/newgrf_roadstop.cpp b/src/newgrf_roadstop.cpp index c67144a15f..a091368fbb 100644 --- a/src/newgrf_roadstop.cpp +++ b/src/newgrf_roadstop.cpp @@ -294,7 +294,7 @@ void DrawRoadStopTile(int x, int y, RoadType roadtype, const RoadStopSpec *spec, SpriteID image = dts->ground.sprite; PaletteID pal = dts->ground.pal; - RoadStopDrawMode draw_mode; + RoadStopDrawModes draw_mode; if (spec->flags.Test(RoadStopSpecFlag::DrawModeRegister)) { draw_mode = static_cast(GetRegister(0x100)); } else { @@ -303,7 +303,7 @@ void DrawRoadStopTile(int x, int y, RoadType roadtype, const RoadStopSpec *spec, if (type == StationType::RoadWaypoint) { DrawSprite(SPR_ROAD_PAVED_STRAIGHT_X, PAL_NONE, x, y); - if ((draw_mode & ROADSTOP_DRAW_MODE_WAYP_GROUND) && GB(image, 0, SPRITE_WIDTH) != 0) { + if (draw_mode.Test(RoadStopDrawMode::WaypGround) && GB(image, 0, SPRITE_WIDTH) != 0) { DrawSprite(image, GroundSpritePaletteTransform(image, pal, palette), x, y); } } else if (GB(image, 0, SPRITE_WIDTH) != 0) { @@ -315,7 +315,7 @@ void DrawRoadStopTile(int x, int y, RoadType roadtype, const RoadStopSpec *spec, uint sprite_offset = 5 - view; /* Road underlay takes precedence over tram */ - if (type == StationType::RoadWaypoint || draw_mode & ROADSTOP_DRAW_MODE_OVERLAY) { + if (type == StationType::RoadWaypoint || draw_mode.Test(RoadStopDrawMode::Overlay)) { if (rti->UsesOverlay()) { SpriteID ground = GetCustomRoadSprite(rti, INVALID_TILE, ROTSG_GROUND); DrawSprite(ground + sprite_offset, PAL_NONE, x, y); @@ -328,7 +328,7 @@ void DrawRoadStopTile(int x, int y, RoadType roadtype, const RoadStopSpec *spec, } } else { /* Bay stop */ - if ((draw_mode & ROADSTOP_DRAW_MODE_ROAD) && rti->UsesOverlay()) { + if (draw_mode.Test(RoadStopDrawMode::Road) && rti->UsesOverlay()) { SpriteID ground = GetCustomRoadSprite(rti, INVALID_TILE, ROTSG_ROADSTOP); DrawSprite(ground + view, PAL_NONE, x, y); } diff --git a/src/newgrf_roadstop.h b/src/newgrf_roadstop.h index e5314cb2c2..f4cc3c4eee 100644 --- a/src/newgrf_roadstop.h +++ b/src/newgrf_roadstop.h @@ -59,13 +59,12 @@ enum RoadStopAvailabilityType : uint8_t { * Different draw modes to disallow rendering of some parts of the stop * or road. */ -enum RoadStopDrawMode : uint8_t { - 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) +enum class RoadStopDrawMode : uint8_t { + Road = 0, ///< Bay stops: Draw the road itself + Overlay = 1, ///< Drive-through stops: Draw the road overlay, e.g. pavement + WaypGround = 2, ///< Waypoints: Draw the sprite layout ground tile (on top of the road) }; -DECLARE_ENUM_AS_BIT_SET(RoadStopDrawMode) +using RoadStopDrawModes = EnumBitSet; enum class RoadStopSpecFlag : uint8_t { Cb141RandomBits = 0, ///< Callback 141 needs random bits. @@ -145,7 +144,7 @@ struct RoadStopSpec : NewGRFSpecBase { StringID name; ///< Name of this stop RoadStopAvailabilityType stop_type = ROADSTOPTYPE_ALL; - RoadStopDrawMode draw_mode = ROADSTOP_DRAW_MODE_ROAD | ROADSTOP_DRAW_MODE_OVERLAY; + RoadStopDrawModes draw_mode = {RoadStopDrawMode::Road, RoadStopDrawMode::Overlay}; RoadStopCallbackMasks callback_mask{}; RoadStopSpecFlags flags{}; diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 350264c849..0172a2490b 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -3335,7 +3335,7 @@ draw_default_foundation: StationType type = GetStationType(ti->tile); const RoadStopSpec *stopspec = GetRoadStopSpec(ti->tile); - RoadStopDrawMode stop_draw_mode{}; + RoadStopDrawModes stop_draw_mode{}; if (stopspec != nullptr) { stop_draw_mode = stopspec->draw_mode; st = BaseStation::GetByTile(ti->tile); @@ -3345,7 +3345,7 @@ draw_default_foundation: if (stopspec->flags.Test(RoadStopSpecFlag::DrawModeRegister)) { stop_draw_mode = static_cast(GetRegister(0x100)); } - if (type == StationType::RoadWaypoint && (stop_draw_mode & ROADSTOP_DRAW_MODE_WAYP_GROUND)) { + if (type == StationType::RoadWaypoint && stop_draw_mode.Test(RoadStopDrawMode::WaypGround)) { draw_ground = true; } t = ((const TileLayoutSpriteGroup *)group)->ProcessRegisters(nullptr); @@ -3364,7 +3364,7 @@ draw_default_foundation: } if (IsDriveThroughStopTile(ti->tile)) { - if (type != StationType::RoadWaypoint && (stopspec == nullptr || (stop_draw_mode & ROADSTOP_DRAW_MODE_OVERLAY) != 0)) { + if (type != StationType::RoadWaypoint && (stopspec == nullptr || stop_draw_mode.Test(RoadStopDrawMode::Overlay))) { uint sprite_offset = GetDriveThroughStopAxis(ti->tile) == AXIS_X ? 1 : 0; DrawRoadOverlays(ti, PAL_NONE, road_rti, tram_rti, sprite_offset, sprite_offset); } @@ -3372,7 +3372,7 @@ draw_default_foundation: /* Non-drivethrough road stops are only valid for roads. */ assert(road_rt != INVALID_ROADTYPE && tram_rt == INVALID_ROADTYPE); - if ((stopspec == nullptr || (stop_draw_mode & ROADSTOP_DRAW_MODE_ROAD) != 0) && road_rti->UsesOverlay()) { + if ((stopspec == nullptr || stop_draw_mode.Test(RoadStopDrawMode::Road)) && road_rti->UsesOverlay()) { SpriteID ground = GetCustomRoadSprite(road_rti, ti->tile, ROTSG_ROADSTOP); DrawGroundSprite(ground + view, PAL_NONE); }