Codechange: Use enum class for Roadside.
This commit is contained in:
@@ -1354,7 +1354,7 @@ static bool DrawRoadAsSnowOrDesert(bool snow_or_desert, Roadside roadside)
|
||||
{
|
||||
return (snow_or_desert &&
|
||||
!(_settings_game.game_creation.landscape == LandscapeType::Tropic && HasGrfMiscBit(GrfMiscBit::DesertPavedRoads) &&
|
||||
roadside != ROADSIDE_BARREN && roadside != ROADSIDE_GRASS && roadside != ROADSIDE_GRASS_ROAD_WORKS));
|
||||
roadside != Roadside::Barren && roadside != Roadside::Grass && roadside != Roadside::GrassRoadWorks));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1558,11 +1558,16 @@ static SpriteID GetRoadGroundSprite(const TileInfo *ti, Roadside roadside, const
|
||||
}
|
||||
|
||||
switch (roadside) {
|
||||
case ROADSIDE_BARREN: *pal = PALETTE_TO_BARE_LAND;
|
||||
return SPR_FLAT_GRASS_TILE + SlopeToSpriteOffset(ti->tileh);
|
||||
case ROADSIDE_GRASS:
|
||||
case ROADSIDE_GRASS_ROAD_WORKS: return SPR_FLAT_GRASS_TILE + SlopeToSpriteOffset(ti->tileh);
|
||||
default: break; // Paved
|
||||
case Roadside::Barren:
|
||||
*pal = PALETTE_TO_BARE_LAND;
|
||||
return SPR_FLAT_GRASS_TILE + SlopeToSpriteOffset(ti->tileh);
|
||||
|
||||
case Roadside::Grass:
|
||||
case Roadside::GrassRoadWorks:
|
||||
return SPR_FLAT_GRASS_TILE + SlopeToSpriteOffset(ti->tileh);
|
||||
|
||||
default:
|
||||
break; // Paved
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1572,10 +1577,17 @@ static SpriteID GetRoadGroundSprite(const TileInfo *ti, Roadside roadside, const
|
||||
image += 19;
|
||||
} else {
|
||||
switch (roadside) {
|
||||
case ROADSIDE_BARREN: *pal = PALETTE_TO_BARE_LAND; break;
|
||||
case ROADSIDE_GRASS: break;
|
||||
case ROADSIDE_GRASS_ROAD_WORKS: break;
|
||||
default: image -= 19; break; // Paved
|
||||
case Roadside::Barren:
|
||||
*pal = PALETTE_TO_BARE_LAND;
|
||||
break;
|
||||
|
||||
case Roadside::Grass:
|
||||
case Roadside::GrassRoadWorks:
|
||||
break;
|
||||
|
||||
default:
|
||||
image -= 19;
|
||||
break; // Paved
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1659,11 +1671,11 @@ static void DrawRoadBits(TileInfo *ti)
|
||||
|
||||
/* Do not draw details (street lights, trees) under low bridge */
|
||||
Roadside roadside = GetRoadside(ti->tile);
|
||||
if (IsBridgeAbove(ti->tile) && (roadside == ROADSIDE_TREES || roadside == ROADSIDE_STREET_LIGHTS)) {
|
||||
if (IsBridgeAbove(ti->tile) && (roadside == Roadside::Trees || roadside == Roadside::StreetLights)) {
|
||||
int height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
|
||||
int minz = GetTileMaxZ(ti->tile) + 2;
|
||||
|
||||
if (roadside == ROADSIDE_TREES) minz++;
|
||||
if (roadside == Roadside::Trees) minz++;
|
||||
|
||||
if (height < minz) return;
|
||||
}
|
||||
@@ -1672,20 +1684,20 @@ static void DrawRoadBits(TileInfo *ti)
|
||||
if (HasAtMostOneBit(road)) return;
|
||||
|
||||
/* Do not draw details when invisible. */
|
||||
if (roadside == ROADSIDE_TREES && IsInvisibilitySet(TO_TREES)) return;
|
||||
if (roadside == ROADSIDE_STREET_LIGHTS && IsInvisibilitySet(TO_HOUSES)) return;
|
||||
if (roadside == Roadside::Trees && IsInvisibilitySet(TO_TREES)) return;
|
||||
if (roadside == Roadside::StreetLights && IsInvisibilitySet(TO_HOUSES)) return;
|
||||
|
||||
/* Check whether details should be transparent. */
|
||||
bool is_transparent = false;
|
||||
if (roadside == ROADSIDE_TREES && IsTransparencySet(TO_TREES)) {
|
||||
if (roadside == Roadside::Trees && IsTransparencySet(TO_TREES)) {
|
||||
is_transparent = true;
|
||||
}
|
||||
if (roadside == ROADSIDE_STREET_LIGHTS && IsTransparencySet(TO_HOUSES)) {
|
||||
if (roadside == Roadside::StreetLights && IsTransparencySet(TO_HOUSES)) {
|
||||
is_transparent = true;
|
||||
}
|
||||
|
||||
/* Draw extra details. */
|
||||
for (const DrawRoadTileStruct *drts = _road_display_table[roadside][road | tram]; drts->image != 0; drts++) {
|
||||
for (const DrawRoadTileStruct *drts = _road_display_table[to_underlying(roadside)][road | tram]; drts->image != 0; drts++) {
|
||||
DrawRoadDetail(drts->image, ti, drts->subcoord_x, drts->subcoord_y, 0x10, is_transparent);
|
||||
}
|
||||
}
|
||||
@@ -1730,9 +1742,16 @@ static void DrawTile_Road(TileInfo *ti)
|
||||
image += 19;
|
||||
} else {
|
||||
switch (roadside) {
|
||||
case ROADSIDE_BARREN: pal = PALETTE_TO_BARE_LAND; break;
|
||||
case ROADSIDE_GRASS: break;
|
||||
default: image -= 19; break; // Paved
|
||||
case Roadside::Barren:
|
||||
pal = PALETTE_TO_BARE_LAND;
|
||||
break;
|
||||
|
||||
case Roadside::Grass:
|
||||
break;
|
||||
|
||||
default:
|
||||
image -= 19;
|
||||
break; // Paved
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1746,9 +1765,16 @@ static void DrawTile_Road(TileInfo *ti)
|
||||
image += 8;
|
||||
} else {
|
||||
switch (roadside) {
|
||||
case ROADSIDE_BARREN: pal = PALETTE_TO_BARE_LAND; break;
|
||||
case ROADSIDE_GRASS: break;
|
||||
default: image += 4; break; // Paved
|
||||
case Roadside::Barren:
|
||||
pal = PALETTE_TO_BARE_LAND;
|
||||
break;
|
||||
|
||||
case Roadside::Grass:
|
||||
break;
|
||||
|
||||
default:
|
||||
image += 4;
|
||||
break; // Paved
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1956,21 +1982,21 @@ static Foundation GetFoundation_Road(TileIndex tile, Slope tileh)
|
||||
}
|
||||
|
||||
static const Roadside _town_road_types[][2] = {
|
||||
{ ROADSIDE_GRASS, ROADSIDE_GRASS },
|
||||
{ ROADSIDE_PAVED, ROADSIDE_PAVED },
|
||||
{ ROADSIDE_PAVED, ROADSIDE_PAVED },
|
||||
{ ROADSIDE_TREES, ROADSIDE_TREES },
|
||||
{ ROADSIDE_STREET_LIGHTS, ROADSIDE_PAVED }
|
||||
{ Roadside::Grass, Roadside::Grass },
|
||||
{ Roadside::Paved, Roadside::Paved },
|
||||
{ Roadside::Paved, Roadside::Paved },
|
||||
{ Roadside::Trees, Roadside::Trees },
|
||||
{ Roadside::StreetLights, Roadside::Paved }
|
||||
};
|
||||
|
||||
static_assert(lengthof(_town_road_types) == NUM_HOUSE_ZONES);
|
||||
|
||||
static const Roadside _town_road_types_2[][2] = {
|
||||
{ ROADSIDE_GRASS, ROADSIDE_GRASS },
|
||||
{ ROADSIDE_PAVED, ROADSIDE_PAVED },
|
||||
{ ROADSIDE_STREET_LIGHTS, ROADSIDE_PAVED },
|
||||
{ ROADSIDE_STREET_LIGHTS, ROADSIDE_PAVED },
|
||||
{ ROADSIDE_STREET_LIGHTS, ROADSIDE_PAVED }
|
||||
{ Roadside::Grass, Roadside::Grass },
|
||||
{ Roadside::Paved, Roadside::Paved },
|
||||
{ Roadside::StreetLights, Roadside::Paved },
|
||||
{ Roadside::StreetLights, Roadside::Paved },
|
||||
{ Roadside::StreetLights, Roadside::Paved }
|
||||
};
|
||||
|
||||
static_assert(lengthof(_town_road_types_2) == NUM_HOUSE_ZONES);
|
||||
@@ -2040,11 +2066,11 @@ static void TileLoop_Road(TileIndex tile)
|
||||
if (cur_rs == new_rs[1]) {
|
||||
cur_rs = new_rs[0];
|
||||
/* We have barren land, install the pre-type */
|
||||
} else if (cur_rs == ROADSIDE_BARREN) {
|
||||
} else if (cur_rs == Roadside::Barren) {
|
||||
cur_rs = new_rs[1];
|
||||
/* We're totally off limits, remove any installation and make barren land */
|
||||
} else {
|
||||
cur_rs = ROADSIDE_BARREN;
|
||||
cur_rs = Roadside::Barren;
|
||||
}
|
||||
SetRoadside(tile, cur_rs);
|
||||
MarkTileDirtyByTile(tile);
|
||||
@@ -2222,7 +2248,7 @@ static void GetTileDesc_Road(TileIndex tile, TileDesc &td)
|
||||
break;
|
||||
|
||||
default: {
|
||||
td.str = (road_rt != INVALID_ROADTYPE ? _road_tile_strings[GetRoadside(tile)] : STR_LAI_ROAD_DESCRIPTION_TRAMWAY);
|
||||
td.str = (road_rt != INVALID_ROADTYPE ? _road_tile_strings[to_underlying(GetRoadside(tile))] : STR_LAI_ROAD_DESCRIPTION_TRAMWAY);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ void UpdateAdjacentLevelCrossingTilesOnLevelCrossingRemoval(TileIndex tile, Axis
|
||||
void UpdateCompanyRoadInfrastructure(RoadType rt, Owner o, int count);
|
||||
|
||||
struct TileInfo;
|
||||
enum Roadside : uint8_t;
|
||||
enum class Roadside : uint8_t;
|
||||
void DrawRoadOverlays(const TileInfo *ti, PaletteID pal, const RoadTypeInfo *road_rti, const RoadTypeInfo *tram_rit, uint road_offset, uint tram_offset, bool draw_underlay = true);
|
||||
void DrawRoadGroundSprites(const TileInfo *ti, RoadBits road, RoadBits tram, const RoadTypeInfo *road_rti, const RoadTypeInfo *tram_rti, Roadside roadside, bool snow_or_desert);
|
||||
|
||||
|
||||
@@ -454,15 +454,15 @@ inline void ToggleSnowOrDesert(Tile t)
|
||||
|
||||
|
||||
/** The possible road side decorations. */
|
||||
enum Roadside : uint8_t {
|
||||
ROADSIDE_BARREN = 0, ///< Road on barren land
|
||||
ROADSIDE_GRASS = 1, ///< Road on grass
|
||||
ROADSIDE_PAVED = 2, ///< Road with paved sidewalks
|
||||
ROADSIDE_STREET_LIGHTS = 3, ///< Road with street lights on paved sidewalks
|
||||
enum class Roadside : uint8_t {
|
||||
Barren = 0, ///< Road on barren land
|
||||
Grass = 1, ///< Road on grass
|
||||
Paved = 2, ///< Road with paved sidewalks
|
||||
StreetLights = 3, ///< Road with street lights on paved sidewalks
|
||||
/* 4 is unused for historical reasons */
|
||||
ROADSIDE_TREES = 5, ///< Road with trees on paved sidewalks
|
||||
ROADSIDE_GRASS_ROAD_WORKS = 6, ///< Road on grass with road works
|
||||
ROADSIDE_PAVED_ROAD_WORKS = 7, ///< Road with sidewalks and road works
|
||||
Trees = 5, ///< Road with trees on paved sidewalks
|
||||
GrassRoadWorks = 6, ///< Road on grass with road works
|
||||
PavedRoadWorks = 7, ///< Road with sidewalks and road works
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -472,7 +472,7 @@ enum Roadside : uint8_t {
|
||||
*/
|
||||
inline Roadside GetRoadside(Tile tile)
|
||||
{
|
||||
return (Roadside)GB(tile.m6(), 3, 3);
|
||||
return static_cast<Roadside>(GB(tile.m6(), 3, 3));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -482,7 +482,7 @@ inline Roadside GetRoadside(Tile tile)
|
||||
*/
|
||||
inline void SetRoadside(Tile tile, Roadside s)
|
||||
{
|
||||
SB(tile.m6(), 3, 3, s);
|
||||
SB(tile.m6(), 3, 3, to_underlying(s));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -492,7 +492,7 @@ inline void SetRoadside(Tile tile, Roadside s)
|
||||
*/
|
||||
inline bool HasRoadWorks(Tile t)
|
||||
{
|
||||
return GetRoadside(t) >= ROADSIDE_GRASS_ROAD_WORKS;
|
||||
return GetRoadside(t) >= Roadside::GrassRoadWorks;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -517,9 +517,14 @@ inline void StartRoadWorks(Tile t)
|
||||
assert(!HasRoadWorks(t));
|
||||
/* Remove any trees or lamps in case or roadwork */
|
||||
switch (GetRoadside(t)) {
|
||||
case ROADSIDE_BARREN:
|
||||
case ROADSIDE_GRASS: SetRoadside(t, ROADSIDE_GRASS_ROAD_WORKS); break;
|
||||
default: SetRoadside(t, ROADSIDE_PAVED_ROAD_WORKS); break;
|
||||
case Roadside::Barren:
|
||||
case Roadside::Grass:
|
||||
SetRoadside(t, Roadside::GrassRoadWorks);
|
||||
break;
|
||||
|
||||
default:
|
||||
SetRoadside(t, Roadside::PavedRoadWorks);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -531,7 +536,7 @@ inline void StartRoadWorks(Tile t)
|
||||
inline void TerminateRoadWorks(Tile t)
|
||||
{
|
||||
assert(HasRoadWorks(t));
|
||||
SetRoadside(t, (Roadside)(GetRoadside(t) - ROADSIDE_GRASS_ROAD_WORKS + ROADSIDE_GRASS));
|
||||
SetRoadside(t, GetRoadside(t) == Roadside::GrassRoadWorks ? Roadside::Grass : Roadside::Paved);
|
||||
/* Stop the counter */
|
||||
SB(t.m7(), 0, 4, 0);
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ static bool FixTTOMapArray()
|
||||
case MP_ROAD: // road (depot) or level crossing
|
||||
switch (GB(tile.m5(), 4, 4)) {
|
||||
case 0: // RoadTileType::Normal
|
||||
if (tile.m2() == 4) tile.m2() = 5; // 'small trees' -> ROADSIDE_TREES
|
||||
if (tile.m2() == 4) tile.m2() = 5; // 'small trees' -> Roadside::Trees
|
||||
break;
|
||||
case 1: // RoadTileType::Crossing (there aren't monorail crossings in TTO)
|
||||
tile.m3() = tile.m1(); // set owner of road = owner of rail
|
||||
|
||||
@@ -3768,11 +3768,11 @@ static void TileLoop_Station(TileIndex tile)
|
||||
}
|
||||
|
||||
/* Adjust road ground type depending on 'new_zone' */
|
||||
Roadside new_rs = new_zone != HouseZone::TownEdge ? ROADSIDE_PAVED : ROADSIDE_GRASS;
|
||||
Roadside new_rs = new_zone != HouseZone::TownEdge ? Roadside::Paved : Roadside::Grass;
|
||||
Roadside cur_rs = GetRoadWaypointRoadside(tile);
|
||||
|
||||
if (new_rs != cur_rs) {
|
||||
SetRoadWaypointRoadside(tile, cur_rs == ROADSIDE_BARREN ? new_rs : ROADSIDE_BARREN);
|
||||
SetRoadWaypointRoadside(tile, cur_rs == Roadside::Barren ? new_rs : Roadside::Barren);
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
|
||||
|
||||
@@ -288,7 +288,7 @@ StationGfx GetTranslatedAirportTileID(StationGfx gfx);
|
||||
static inline Roadside GetRoadWaypointRoadside(Tile tile)
|
||||
{
|
||||
assert(IsRoadWaypointTile(tile));
|
||||
return (Roadside)GB(tile.m3(), 2, 2);
|
||||
return static_cast<Roadside>(GB(tile.m3(), 2, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -299,7 +299,7 @@ static inline Roadside GetRoadWaypointRoadside(Tile tile)
|
||||
static inline void SetRoadWaypointRoadside(Tile tile, Roadside s)
|
||||
{
|
||||
assert(IsRoadWaypointTile(tile));
|
||||
SB(tile.m3(), 2, 2, s);
|
||||
SB(tile.m3(), 2, 2, to_underlying(s));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1002,9 +1002,9 @@ static CommandCost DoClearBridge(TileIndex tile, DoCommandFlags flags)
|
||||
|
||||
for (TileIndex c = tile + delta; c != endtile; c += delta) {
|
||||
/* do not let trees appear from 'nowhere' after removing bridge */
|
||||
if (IsNormalRoadTile(c) && GetRoadside(c) == ROADSIDE_TREES) {
|
||||
if (IsNormalRoadTile(c) && GetRoadside(c) == Roadside::Trees) {
|
||||
int minz = GetTileMaxZ(c) + 3;
|
||||
if (height < minz) SetRoadside(c, ROADSIDE_PAVED);
|
||||
if (height < minz) SetRoadside(c, Roadside::Paved);
|
||||
}
|
||||
ClearBridgeMiddle(c);
|
||||
MarkTileDirtyByTile(c, height - TileHeight(c));
|
||||
|
||||
Reference in New Issue
Block a user