mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use EnumBitSet for RoadStopDrawModes.
parent
17f6da413d
commit
c31494a413
|
@ -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<RoadStopDrawMode>(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);
|
||||
}
|
||||
|
|
|
@ -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<RoadStopDrawMode, uint8_t>;
|
||||
|
||||
enum class RoadStopSpecFlag : uint8_t {
|
||||
Cb141RandomBits = 0, ///< Callback 141 needs random bits.
|
||||
|
@ -145,7 +144,7 @@ struct RoadStopSpec : NewGRFSpecBase<RoadStopClassID> {
|
|||
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{};
|
||||
|
||||
|
|
|
@ -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<RoadStopDrawMode>(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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue