mirror of
https://github.com/OpenTTD/OpenTTD
synced 2025-12-13 16:32:13 +01:00
Codechange: Use enum class for RailGroundType.
This commit is contained in:
committed by
Peter Nelson
parent
0f5a4290df
commit
2851c70a59
@@ -350,7 +350,7 @@ uint32_t GetTerrainType(TileIndex tile, TileContext context)
|
|||||||
/* During map generation the snowstate may not be valid yet, as the tileloop may not have run yet. */
|
/* During map generation the snowstate may not be valid yet, as the tileloop may not have run yet. */
|
||||||
if (_generating_world) goto genworld; // we do not care about foundations here
|
if (_generating_world) goto genworld; // we do not care about foundations here
|
||||||
RailGroundType ground = GetRailGroundType(tile);
|
RailGroundType ground = GetRailGroundType(tile);
|
||||||
has_snow = (ground == RAIL_GROUND_ICE_DESERT || (context == TCX_UPPER_HALFTILE && ground == RAIL_GROUND_HALF_SNOW));
|
has_snow = (ground == RailGroundType::SnowOrDesert || (context == TCX_UPPER_HALFTILE && ground == RailGroundType::HalfTileSnow));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
118
src/rail_cmd.cpp
118
src/rail_cmd.cpp
@@ -473,7 +473,7 @@ CommandCost CmdBuildSingleRail(DoCommandFlags flags, TileIndex tile, RailType ra
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flags.Test(DoCommandFlag::Execute)) {
|
if (flags.Test(DoCommandFlag::Execute)) {
|
||||||
SetRailGroundType(tile, RAIL_GROUND_BARREN);
|
SetRailGroundType(tile, RailGroundType::Barren);
|
||||||
TrackBits bits = GetTrackBits(tile);
|
TrackBits bits = GetTrackBits(tile);
|
||||||
SetTrackBits(tile, bits | trackbit);
|
SetTrackBits(tile, bits | trackbit);
|
||||||
/* Subtract old infrastructure count. */
|
/* Subtract old infrastructure count. */
|
||||||
@@ -582,7 +582,7 @@ CommandCost CmdBuildSingleRail(DoCommandFlags flags, TileIndex tile, RailType ra
|
|||||||
if (flags.Test(DoCommandFlag::Execute)) {
|
if (flags.Test(DoCommandFlag::Execute)) {
|
||||||
MakeRailNormal(tile, _current_company, trackbit, railtype);
|
MakeRailNormal(tile, _current_company, trackbit, railtype);
|
||||||
if (water_ground) {
|
if (water_ground) {
|
||||||
SetRailGroundType(tile, RAIL_GROUND_WATER);
|
SetRailGroundType(tile, RailGroundType::HalfTileWater);
|
||||||
if (IsPossibleDockingTile(tile)) CheckForDockingTile(tile);
|
if (IsPossibleDockingTile(tile)) CheckForDockingTile(tile);
|
||||||
}
|
}
|
||||||
Company::Get(_current_company)->infrastructure.rail[railtype]++;
|
Company::Get(_current_company)->infrastructure.rail[railtype]++;
|
||||||
@@ -704,7 +704,7 @@ CommandCost CmdRemoveSingleRail(DoCommandFlags flags, TileIndex tile, Track trac
|
|||||||
if (present == 0) {
|
if (present == 0) {
|
||||||
Slope tileh = GetTileSlope(tile);
|
Slope tileh = GetTileSlope(tile);
|
||||||
/* If there is flat water on the lower halftile, convert the tile to shore so the water remains */
|
/* If there is flat water on the lower halftile, convert the tile to shore so the water remains */
|
||||||
if (GetRailGroundType(tile) == RAIL_GROUND_WATER && IsSlopeWithOneCornerRaised(tileh)) {
|
if (GetRailGroundType(tile) == RailGroundType::HalfTileWater && IsSlopeWithOneCornerRaised(tileh)) {
|
||||||
bool docking = IsDockingTile(tile);
|
bool docking = IsDockingTile(tile);
|
||||||
MakeShore(tile);
|
MakeShore(tile);
|
||||||
SetDockingTile(tile, docking);
|
SetDockingTile(tile, docking);
|
||||||
@@ -761,7 +761,7 @@ bool FloodHalftile(TileIndex t)
|
|||||||
assert(IsPlainRailTile(t));
|
assert(IsPlainRailTile(t));
|
||||||
|
|
||||||
bool flooded = false;
|
bool flooded = false;
|
||||||
if (GetRailGroundType(t) == RAIL_GROUND_WATER) return flooded;
|
if (GetRailGroundType(t) == RailGroundType::HalfTileWater) return flooded;
|
||||||
|
|
||||||
Slope tileh = GetTileSlope(t);
|
Slope tileh = GetTileSlope(t);
|
||||||
TrackBits rail_bits = GetTrackBits(t);
|
TrackBits rail_bits = GetTrackBits(t);
|
||||||
@@ -785,7 +785,7 @@ bool FloodHalftile(TileIndex t)
|
|||||||
|
|
||||||
if (IsNonContinuousFoundation(GetRailFoundation(tileh, rail_bits))) {
|
if (IsNonContinuousFoundation(GetRailFoundation(tileh, rail_bits))) {
|
||||||
flooded = true;
|
flooded = true;
|
||||||
SetRailGroundType(t, RAIL_GROUND_WATER);
|
SetRailGroundType(t, RailGroundType::HalfTileWater);
|
||||||
MarkTileDirtyByTile(t);
|
MarkTileDirtyByTile(t);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -793,7 +793,7 @@ bool FloodHalftile(TileIndex t)
|
|||||||
if (ApplyFoundationToSlope(GetRailFoundation(tileh, rail_bits), tileh) == 0) {
|
if (ApplyFoundationToSlope(GetRailFoundation(tileh, rail_bits), tileh) == 0) {
|
||||||
if (IsSteepSlope(tileh) || IsSlopeWithThreeCornersRaised(tileh)) {
|
if (IsSteepSlope(tileh) || IsSlopeWithThreeCornersRaised(tileh)) {
|
||||||
flooded = true;
|
flooded = true;
|
||||||
SetRailGroundType(t, RAIL_GROUND_WATER);
|
SetRailGroundType(t, RailGroundType::HalfTileWater);
|
||||||
MarkTileDirtyByTile(t);
|
MarkTileDirtyByTile(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1810,7 +1810,7 @@ static CommandCost ClearTile_Track(TileIndex tile, DoCommandFlags flags)
|
|||||||
case RailTileType::Normal: {
|
case RailTileType::Normal: {
|
||||||
Slope tileh = GetTileSlope(tile);
|
Slope tileh = GetTileSlope(tile);
|
||||||
/* Is there flat water on the lower halftile that gets cleared expensively? */
|
/* Is there flat water on the lower halftile that gets cleared expensively? */
|
||||||
bool water_ground = (GetRailGroundType(tile) == RAIL_GROUND_WATER && IsSlopeWithOneCornerRaised(tileh));
|
bool water_ground = (GetRailGroundType(tile) == RailGroundType::HalfTileWater && IsSlopeWithOneCornerRaised(tileh));
|
||||||
|
|
||||||
TrackBits tracks = GetTrackBits(tile);
|
TrackBits tracks = GetTrackBits(tile);
|
||||||
while (tracks != TRACK_BIT_NONE) {
|
while (tracks != TRACK_BIT_NONE) {
|
||||||
@@ -2006,19 +2006,19 @@ static void DrawTrackDetails(const TileInfo *ti, const RailTypeInfo *rti, Palett
|
|||||||
assert(num_sprites > 0);
|
assert(num_sprites > 0);
|
||||||
|
|
||||||
switch (GetRailGroundType(ti->tile)) {
|
switch (GetRailGroundType(ti->tile)) {
|
||||||
case RAIL_GROUND_FENCE_NW: DrawTrackFence_NW(ti, psid, num_sprites); break;
|
case RailGroundType::FenceNW: DrawTrackFence_NW(ti, psid, num_sprites); break;
|
||||||
case RAIL_GROUND_FENCE_SE: DrawTrackFence_SE(ti, psid, num_sprites); break;
|
case RailGroundType::FenceSE: DrawTrackFence_SE(ti, psid, num_sprites); break;
|
||||||
case RAIL_GROUND_FENCE_SENW: DrawTrackFence_NW(ti, psid, num_sprites);
|
case RailGroundType::FenceSENW: DrawTrackFence_NW(ti, psid, num_sprites);
|
||||||
DrawTrackFence_SE(ti, psid, num_sprites); break;
|
DrawTrackFence_SE(ti, psid, num_sprites); break;
|
||||||
case RAIL_GROUND_FENCE_NE: DrawTrackFence_NE(ti, psid, num_sprites); break;
|
case RailGroundType::FenceNE: DrawTrackFence_NE(ti, psid, num_sprites); break;
|
||||||
case RAIL_GROUND_FENCE_SW: DrawTrackFence_SW(ti, psid, num_sprites); break;
|
case RailGroundType::FenceSW: DrawTrackFence_SW(ti, psid, num_sprites); break;
|
||||||
case RAIL_GROUND_FENCE_NESW: DrawTrackFence_NE(ti, psid, num_sprites);
|
case RailGroundType::FenceNESW: DrawTrackFence_NE(ti, psid, num_sprites);
|
||||||
DrawTrackFence_SW(ti, psid, num_sprites); break;
|
DrawTrackFence_SW(ti, psid, num_sprites); break;
|
||||||
case RAIL_GROUND_FENCE_VERT1: DrawTrackFence(ti, psid, num_sprites, RFO_FLAT_LEFT); break;
|
case RailGroundType::FenceVert1: DrawTrackFence(ti, psid, num_sprites, RFO_FLAT_LEFT); break;
|
||||||
case RAIL_GROUND_FENCE_VERT2: DrawTrackFence(ti, psid, num_sprites, RFO_FLAT_RIGHT); break;
|
case RailGroundType::FenceVert2: DrawTrackFence(ti, psid, num_sprites, RFO_FLAT_RIGHT); break;
|
||||||
case RAIL_GROUND_FENCE_HORIZ1: DrawTrackFence(ti, psid, num_sprites, RFO_FLAT_UPPER); break;
|
case RailGroundType::FenceHoriz1: DrawTrackFence(ti, psid, num_sprites, RFO_FLAT_UPPER); break;
|
||||||
case RAIL_GROUND_FENCE_HORIZ2: DrawTrackFence(ti, psid, num_sprites, RFO_FLAT_LOWER); break;
|
case RailGroundType::FenceHoriz2: DrawTrackFence(ti, psid, num_sprites, RFO_FLAT_LOWER); break;
|
||||||
case RAIL_GROUND_WATER: {
|
case RailGroundType::HalfTileWater: {
|
||||||
Corner track_corner;
|
Corner track_corner;
|
||||||
if (IsHalftileSlope(ti->tileh)) {
|
if (IsHalftileSlope(ti->tileh)) {
|
||||||
/* Steep slope or one-corner-raised slope with halftile foundation */
|
/* Steep slope or one-corner-raised slope with halftile foundation */
|
||||||
@@ -2072,7 +2072,7 @@ static void DrawTrackBitsOverlay(TileInfo *ti, TrackBits track, const RailTypeIn
|
|||||||
/* DrawFoundation modifies ti */
|
/* DrawFoundation modifies ti */
|
||||||
|
|
||||||
/* Draw ground */
|
/* Draw ground */
|
||||||
if (rgt == RAIL_GROUND_WATER) {
|
if (rgt == RailGroundType::HalfTileWater) {
|
||||||
if (track != TRACK_BIT_NONE || IsSteepSlope(ti->tileh)) {
|
if (track != TRACK_BIT_NONE || IsSteepSlope(ti->tileh)) {
|
||||||
/* three-corner-raised slope or steep slope with track on upper part */
|
/* three-corner-raised slope or steep slope with track on upper part */
|
||||||
DrawShoreTile(ti->tileh);
|
DrawShoreTile(ti->tileh);
|
||||||
@@ -2084,9 +2084,9 @@ static void DrawTrackBitsOverlay(TileInfo *ti, TrackBits track, const RailTypeIn
|
|||||||
SpriteID image;
|
SpriteID image;
|
||||||
|
|
||||||
switch (rgt) {
|
switch (rgt) {
|
||||||
case RAIL_GROUND_BARREN: image = SPR_FLAT_BARE_LAND; break;
|
case RailGroundType::Barren: image = SPR_FLAT_BARE_LAND; break;
|
||||||
case RAIL_GROUND_ICE_DESERT: image = SPR_FLAT_SNOW_DESERT_TILE; break;
|
case RailGroundType::SnowOrDesert: image = SPR_FLAT_SNOW_DESERT_TILE; break;
|
||||||
default: image = SPR_FLAT_GRASS_TILE; break;
|
default: image = SPR_FLAT_GRASS_TILE; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
image += SlopeToSpriteOffset(ti->tileh);
|
image += SlopeToSpriteOffset(ti->tileh);
|
||||||
@@ -2186,10 +2186,10 @@ static void DrawTrackBitsOverlay(TileInfo *ti, TrackBits track, const RailTypeIn
|
|||||||
|
|
||||||
SpriteID image;
|
SpriteID image;
|
||||||
switch (rgt) {
|
switch (rgt) {
|
||||||
case RAIL_GROUND_BARREN: image = SPR_FLAT_BARE_LAND; break;
|
case RailGroundType::Barren: image = SPR_FLAT_BARE_LAND; break;
|
||||||
case RAIL_GROUND_ICE_DESERT:
|
case RailGroundType::SnowOrDesert:
|
||||||
case RAIL_GROUND_HALF_SNOW: image = SPR_FLAT_SNOW_DESERT_TILE; break;
|
case RailGroundType::HalfTileSnow: image = SPR_FLAT_SNOW_DESERT_TILE; break;
|
||||||
default: image = SPR_FLAT_GRASS_TILE; break;
|
default: image = SPR_FLAT_GRASS_TILE; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
image += SlopeToSpriteOffset(fake_slope);
|
image += SlopeToSpriteOffset(fake_slope);
|
||||||
@@ -2251,7 +2251,7 @@ static void DrawTrackBits(TileInfo *ti, TrackBits track)
|
|||||||
/* Select the sprite to use. */
|
/* Select the sprite to use. */
|
||||||
if (track == 0) {
|
if (track == 0) {
|
||||||
/* Clear ground (only track on halftile foundation) */
|
/* Clear ground (only track on halftile foundation) */
|
||||||
if (rgt == RAIL_GROUND_WATER) {
|
if (rgt == RailGroundType::HalfTileWater) {
|
||||||
if (IsSteepSlope(ti->tileh)) {
|
if (IsSteepSlope(ti->tileh)) {
|
||||||
DrawShoreTile(ti->tileh);
|
DrawShoreTile(ti->tileh);
|
||||||
image = 0;
|
image = 0;
|
||||||
@@ -2260,9 +2260,9 @@ static void DrawTrackBits(TileInfo *ti, TrackBits track)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (rgt) {
|
switch (rgt) {
|
||||||
case RAIL_GROUND_BARREN: image = SPR_FLAT_BARE_LAND; break;
|
case RailGroundType::Barren: image = SPR_FLAT_BARE_LAND; break;
|
||||||
case RAIL_GROUND_ICE_DESERT: image = SPR_FLAT_SNOW_DESERT_TILE; break;
|
case RailGroundType::SnowOrDesert: image = SPR_FLAT_SNOW_DESERT_TILE; break;
|
||||||
default: image = SPR_FLAT_GRASS_TILE; break;
|
default: image = SPR_FLAT_GRASS_TILE; break;
|
||||||
}
|
}
|
||||||
image += SlopeToSpriteOffset(ti->tileh);
|
image += SlopeToSpriteOffset(ti->tileh);
|
||||||
}
|
}
|
||||||
@@ -2299,9 +2299,9 @@ static void DrawTrackBits(TileInfo *ti, TrackBits track)
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (rgt) {
|
switch (rgt) {
|
||||||
case RAIL_GROUND_BARREN: pal = PALETTE_TO_BARE_LAND; break;
|
case RailGroundType::Barren: pal = PALETTE_TO_BARE_LAND; break;
|
||||||
case RAIL_GROUND_ICE_DESERT: image += rti->snow_offset; break;
|
case RailGroundType::SnowOrDesert: image += rti->snow_offset; break;
|
||||||
case RAIL_GROUND_WATER: {
|
case RailGroundType::HalfTileWater: {
|
||||||
/* three-corner-raised slope */
|
/* three-corner-raised slope */
|
||||||
DrawShoreTile(ti->tileh);
|
DrawShoreTile(ti->tileh);
|
||||||
Corner track_corner = OppositeCorner(GetHighestSlopeCorner(ComplementSlope(ti->tileh)));
|
Corner track_corner = OppositeCorner(GetHighestSlopeCorner(ComplementSlope(ti->tileh)));
|
||||||
@@ -2356,9 +2356,9 @@ static void DrawTrackBits(TileInfo *ti, TrackBits track)
|
|||||||
image = _track_sloped_sprites[fake_slope - 1] + rti->base_sprites.track_y;
|
image = _track_sloped_sprites[fake_slope - 1] + rti->base_sprites.track_y;
|
||||||
pal = PAL_NONE;
|
pal = PAL_NONE;
|
||||||
switch (rgt) {
|
switch (rgt) {
|
||||||
case RAIL_GROUND_BARREN: pal = PALETTE_TO_BARE_LAND; break;
|
case RailGroundType::Barren: pal = PALETTE_TO_BARE_LAND; break;
|
||||||
case RAIL_GROUND_ICE_DESERT:
|
case RailGroundType::SnowOrDesert:
|
||||||
case RAIL_GROUND_HALF_SNOW: image += rti->snow_offset; break; // higher part has snow in this case too
|
case RailGroundType::HalfTileSnow: image += rti->snow_offset; break; // higher part has snow in this case too
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
DrawGroundSprite(image, pal, &(_halftile_sub_sprite[halftile_corner]));
|
DrawGroundSprite(image, pal, &(_halftile_sub_sprite[halftile_corner]));
|
||||||
@@ -2582,7 +2582,7 @@ static void TileLoop_Track(TileIndex tile)
|
|||||||
RailGroundType old_ground = GetRailGroundType(tile);
|
RailGroundType old_ground = GetRailGroundType(tile);
|
||||||
RailGroundType new_ground;
|
RailGroundType new_ground;
|
||||||
|
|
||||||
if (old_ground == RAIL_GROUND_WATER) {
|
if (old_ground == RailGroundType::HalfTileWater) {
|
||||||
TileLoop_Water(tile);
|
TileLoop_Water(tile);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2635,9 +2635,9 @@ static void TileLoop_Track(TileIndex tile)
|
|||||||
if (z > GetSnowLine()) {
|
if (z > GetSnowLine()) {
|
||||||
if (half && z - GetSnowLine() == 1) {
|
if (half && z - GetSnowLine() == 1) {
|
||||||
/* track on non-continuous foundation, lower part is not under snow */
|
/* track on non-continuous foundation, lower part is not under snow */
|
||||||
new_ground = RAIL_GROUND_HALF_SNOW;
|
new_ground = RailGroundType::HalfTileSnow;
|
||||||
} else {
|
} else {
|
||||||
new_ground = RAIL_GROUND_ICE_DESERT;
|
new_ground = RailGroundType::SnowOrDesert;
|
||||||
}
|
}
|
||||||
goto set_ground;
|
goto set_ground;
|
||||||
}
|
}
|
||||||
@@ -2646,7 +2646,7 @@ static void TileLoop_Track(TileIndex tile)
|
|||||||
|
|
||||||
case LandscapeType::Tropic:
|
case LandscapeType::Tropic:
|
||||||
if (GetTropicZone(tile) == TROPICZONE_DESERT) {
|
if (GetTropicZone(tile) == TROPICZONE_DESERT) {
|
||||||
new_ground = RAIL_GROUND_ICE_DESERT;
|
new_ground = RailGroundType::SnowOrDesert;
|
||||||
goto set_ground;
|
goto set_ground;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -2655,9 +2655,9 @@ static void TileLoop_Track(TileIndex tile)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
new_ground = RAIL_GROUND_GRASS;
|
new_ground = RailGroundType::Grass;
|
||||||
|
|
||||||
if (IsPlainRail(tile) && old_ground != RAIL_GROUND_BARREN) { // wait until bottom is green
|
if (IsPlainRail(tile) && old_ground != RailGroundType::Barren) { // wait until bottom is green
|
||||||
/* determine direction of fence */
|
/* determine direction of fence */
|
||||||
TrackBits rail = GetTrackBits(tile);
|
TrackBits rail = GetTrackBits(tile);
|
||||||
|
|
||||||
@@ -2681,16 +2681,16 @@ static void TileLoop_Track(TileIndex tile)
|
|||||||
|
|
||||||
switch (fences.base()) {
|
switch (fences.base()) {
|
||||||
case DiagDirections{}.base(): break;
|
case DiagDirections{}.base(): break;
|
||||||
case DiagDirections{DIAGDIR_NE}.base(): new_ground = RAIL_GROUND_FENCE_NE; break;
|
case DiagDirections{DIAGDIR_NE}.base(): new_ground = RailGroundType::FenceNE; break;
|
||||||
case DiagDirections{DIAGDIR_SE}.base(): new_ground = RAIL_GROUND_FENCE_SE; break;
|
case DiagDirections{DIAGDIR_SE}.base(): new_ground = RailGroundType::FenceSE; break;
|
||||||
case DiagDirections{DIAGDIR_SW}.base(): new_ground = RAIL_GROUND_FENCE_SW; break;
|
case DiagDirections{DIAGDIR_SW}.base(): new_ground = RailGroundType::FenceSW; break;
|
||||||
case DiagDirections{DIAGDIR_NW}.base(): new_ground = RAIL_GROUND_FENCE_NW; break;
|
case DiagDirections{DIAGDIR_NW}.base(): new_ground = RailGroundType::FenceNW; break;
|
||||||
case DiagDirections{DIAGDIR_NE, DIAGDIR_SW}.base(): new_ground = RAIL_GROUND_FENCE_NESW; break;
|
case DiagDirections{DIAGDIR_NE, DIAGDIR_SW}.base(): new_ground = RailGroundType::FenceNESW; break;
|
||||||
case DiagDirections{DIAGDIR_SE, DIAGDIR_NW}.base(): new_ground = RAIL_GROUND_FENCE_SENW; break;
|
case DiagDirections{DIAGDIR_SE, DIAGDIR_NW}.base(): new_ground = RailGroundType::FenceSENW; break;
|
||||||
case DiagDirections{DIAGDIR_NE, DIAGDIR_SE}.base(): new_ground = RAIL_GROUND_FENCE_VERT1; break;
|
case DiagDirections{DIAGDIR_NE, DIAGDIR_SE}.base(): new_ground = RailGroundType::FenceVert1; break;
|
||||||
case DiagDirections{DIAGDIR_NE, DIAGDIR_NW}.base(): new_ground = RAIL_GROUND_FENCE_HORIZ2; break;
|
case DiagDirections{DIAGDIR_NE, DIAGDIR_NW}.base(): new_ground = RailGroundType::FenceHoriz2; break;
|
||||||
case DiagDirections{DIAGDIR_SE, DIAGDIR_SW}.base(): new_ground = RAIL_GROUND_FENCE_HORIZ1; break;
|
case DiagDirections{DIAGDIR_SE, DIAGDIR_SW}.base(): new_ground = RailGroundType::FenceHoriz1; break;
|
||||||
case DiagDirections{DIAGDIR_SW, DIAGDIR_NW}.base(): new_ground = RAIL_GROUND_FENCE_VERT2; break;
|
case DiagDirections{DIAGDIR_SW, DIAGDIR_NW}.base(): new_ground = RailGroundType::FenceVert2; break;
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2706,7 +2706,7 @@ set_ground:
|
|||||||
static TrackStatus GetTileTrackStatus_Track(TileIndex tile, TransportType mode, uint, DiagDirection side)
|
static TrackStatus GetTileTrackStatus_Track(TileIndex tile, TransportType mode, uint, DiagDirection side)
|
||||||
{
|
{
|
||||||
/* Case of half tile slope with water. */
|
/* Case of half tile slope with water. */
|
||||||
if (mode == TRANSPORT_WATER && IsPlainRail(tile) && GetRailGroundType(tile) == RAIL_GROUND_WATER && IsSlopeWithOneCornerRaised(GetTileSlope(tile))) {
|
if (mode == TRANSPORT_WATER && IsPlainRail(tile) && GetRailGroundType(tile) == RailGroundType::HalfTileWater && IsSlopeWithOneCornerRaised(GetTileSlope(tile))) {
|
||||||
TrackBits tb = GetTrackBits(tile);
|
TrackBits tb = GetTrackBits(tile);
|
||||||
switch (tb) {
|
switch (tb) {
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
@@ -3019,8 +3019,8 @@ static CommandCost TestAutoslopeOnRailTile(TileIndex tile, DoCommandFlags flags,
|
|||||||
/* Make the ground dirty, if surface slope has changed */
|
/* Make the ground dirty, if surface slope has changed */
|
||||||
if (tileh_old != tileh_new) {
|
if (tileh_old != tileh_new) {
|
||||||
/* If there is flat water on the lower halftile add the cost for clearing it */
|
/* If there is flat water on the lower halftile add the cost for clearing it */
|
||||||
if (GetRailGroundType(tile) == RAIL_GROUND_WATER && IsSlopeWithOneCornerRaised(tileh_old)) cost.AddCost(_price[PR_CLEAR_WATER]);
|
if (GetRailGroundType(tile) == RailGroundType::HalfTileWater && IsSlopeWithOneCornerRaised(tileh_old)) cost.AddCost(_price[PR_CLEAR_WATER]);
|
||||||
if (flags.Test(DoCommandFlag::Execute)) SetRailGroundType(tile, RAIL_GROUND_BARREN);
|
if (flags.Test(DoCommandFlag::Execute)) SetRailGroundType(tile, RailGroundType::Barren);
|
||||||
}
|
}
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
@@ -3031,7 +3031,7 @@ static CommandCost TerraformTile_Track(TileIndex tile, DoCommandFlags flags, int
|
|||||||
if (IsPlainRail(tile)) {
|
if (IsPlainRail(tile)) {
|
||||||
TrackBits rail_bits = GetTrackBits(tile);
|
TrackBits rail_bits = GetTrackBits(tile);
|
||||||
/* Is there flat water on the lower halftile that must be cleared expensively? */
|
/* Is there flat water on the lower halftile that must be cleared expensively? */
|
||||||
bool was_water = (GetRailGroundType(tile) == RAIL_GROUND_WATER && IsSlopeWithOneCornerRaised(tileh_old));
|
bool was_water = (GetRailGroundType(tile) == RailGroundType::HalfTileWater && IsSlopeWithOneCornerRaised(tileh_old));
|
||||||
|
|
||||||
/* Allow clearing the water only if there is no ship */
|
/* Allow clearing the water only if there is no ship */
|
||||||
if (was_water && HasVehicleOnTile(tile, [](const Vehicle *v) {
|
if (was_water && HasVehicleOnTile(tile, [](const Vehicle *v) {
|
||||||
@@ -3063,7 +3063,7 @@ static CommandCost TerraformTile_Track(TileIndex tile, DoCommandFlags flags, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Make the ground dirty */
|
/* Make the ground dirty */
|
||||||
if (flags.Test(DoCommandFlag::Execute)) SetRailGroundType(tile, RAIL_GROUND_BARREN);
|
if (flags.Test(DoCommandFlag::Execute)) SetRailGroundType(tile, RailGroundType::Barren);
|
||||||
|
|
||||||
/* allow terraforming */
|
/* allow terraforming */
|
||||||
return CommandCost(EXPENSES_CONSTRUCTION, was_water ? _price[PR_CLEAR_WATER] : (Money)0);
|
return CommandCost(EXPENSES_CONSTRUCTION, was_water ? _price[PR_CLEAR_WATER] : (Money)0);
|
||||||
|
|||||||
@@ -481,37 +481,37 @@ inline bool HasOnewaySignalBlockingTrackdir(Tile tile, Trackdir td)
|
|||||||
RailType GetTileRailType(Tile tile);
|
RailType GetTileRailType(Tile tile);
|
||||||
|
|
||||||
/** The ground 'under' the rail */
|
/** The ground 'under' the rail */
|
||||||
enum RailGroundType : uint8_t {
|
enum class RailGroundType : uint8_t {
|
||||||
RAIL_GROUND_BARREN = 0, ///< Nothing (dirt)
|
Barren = 0, ///< Nothing (dirt)
|
||||||
RAIL_GROUND_GRASS = 1, ///< Grassy
|
Grass = 1, ///< Grassy
|
||||||
RAIL_GROUND_FENCE_NW = 2, ///< Grass with a fence at the NW edge
|
FenceNW = 2, ///< Grass with a fence at the NW edge
|
||||||
RAIL_GROUND_FENCE_SE = 3, ///< Grass with a fence at the SE edge
|
FenceSE = 3, ///< Grass with a fence at the SE edge
|
||||||
RAIL_GROUND_FENCE_SENW = 4, ///< Grass with a fence at the NW and SE edges
|
FenceSENW = 4, ///< Grass with a fence at the NW and SE edges
|
||||||
RAIL_GROUND_FENCE_NE = 5, ///< Grass with a fence at the NE edge
|
FenceNE = 5, ///< Grass with a fence at the NE edge
|
||||||
RAIL_GROUND_FENCE_SW = 6, ///< Grass with a fence at the SW edge
|
FenceSW = 6, ///< Grass with a fence at the SW edge
|
||||||
RAIL_GROUND_FENCE_NESW = 7, ///< Grass with a fence at the NE and SW edges
|
FenceNESW = 7, ///< Grass with a fence at the NE and SW edges
|
||||||
RAIL_GROUND_FENCE_VERT1 = 8, ///< Grass with a fence at the eastern side
|
FenceVert1 = 8, ///< Grass with a fence at the eastern side
|
||||||
RAIL_GROUND_FENCE_VERT2 = 9, ///< Grass with a fence at the western side
|
FenceVert2 = 9, ///< Grass with a fence at the western side
|
||||||
RAIL_GROUND_FENCE_HORIZ1 = 10, ///< Grass with a fence at the southern side
|
FenceHoriz1 = 10, ///< Grass with a fence at the southern side
|
||||||
RAIL_GROUND_FENCE_HORIZ2 = 11, ///< Grass with a fence at the northern side
|
FenceHoriz2 = 11, ///< Grass with a fence at the northern side
|
||||||
RAIL_GROUND_ICE_DESERT = 12, ///< Icy or sandy
|
SnowOrDesert = 12, ///< Icy or sandy
|
||||||
RAIL_GROUND_WATER = 13, ///< Grass with a fence and shore or water on the free halftile
|
HalfTileWater = 13, ///< Grass with a fence and shore or water on the free halftile
|
||||||
RAIL_GROUND_HALF_SNOW = 14, ///< Snow only on higher part of slope (steep or one corner raised)
|
HalfTileSnow = 14, ///< Snow only on higher part of slope (steep or one corner raised)
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void SetRailGroundType(Tile t, RailGroundType rgt)
|
inline void SetRailGroundType(Tile t, RailGroundType rgt)
|
||||||
{
|
{
|
||||||
SB(t.m4(), 0, 4, rgt);
|
SB(t.m4(), 0, 4, to_underlying(rgt));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline RailGroundType GetRailGroundType(Tile t)
|
inline RailGroundType GetRailGroundType(Tile t)
|
||||||
{
|
{
|
||||||
return (RailGroundType)GB(t.m4(), 0, 4);
|
return static_cast<RailGroundType>(GB(t.m4(), 0, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool IsSnowRailGround(Tile t)
|
inline bool IsSnowRailGround(Tile t)
|
||||||
{
|
{
|
||||||
return GetRailGroundType(t) == RAIL_GROUND_ICE_DESERT;
|
return GetRailGroundType(t) == RailGroundType::SnowOrDesert;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ void SetWaterClassDependingOnSurroundings(Tile t, bool include_invalid_water_cla
|
|||||||
|
|
||||||
case MP_RAILWAY:
|
case MP_RAILWAY:
|
||||||
/* Shore or flooded halftile */
|
/* Shore or flooded halftile */
|
||||||
has_water |= (GetRailGroundType(neighbour) == RAIL_GROUND_WATER);
|
has_water |= (GetRailGroundType(neighbour) == RailGroundType::HalfTileWater);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MP_TREES:
|
case MP_TREES:
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ static bool FixTTOMapArray()
|
|||||||
* Instead of using bits in m3 it uses a different tile type. */
|
* Instead of using bits in m3 it uses a different tile type. */
|
||||||
tile.m3() = 1; // rail type = monorail (in TTD)
|
tile.m3() = 1; // rail type = monorail (in TTD)
|
||||||
SetTileType(tile, MP_RAILWAY);
|
SetTileType(tile, MP_RAILWAY);
|
||||||
tile.m2() = 1; // set monorail ground to RAIL_GROUND_GRASS
|
tile.m2() = 1; // set monorail ground to RailGroundType::Grass
|
||||||
tt = MP_RAILWAY;
|
tt = MP_RAILWAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ WaterClass GetEffectiveWaterClass(TileIndex tile)
|
|||||||
return WATER_CLASS_CANAL;
|
return WATER_CLASS_CANAL;
|
||||||
}
|
}
|
||||||
if (IsTileType(tile, MP_RAILWAY)) {
|
if (IsTileType(tile, MP_RAILWAY)) {
|
||||||
assert(GetRailGroundType(tile) == RAIL_GROUND_WATER);
|
assert(GetRailGroundType(tile) == RailGroundType::HalfTileWater);
|
||||||
return WATER_CLASS_SEA;
|
return WATER_CLASS_SEA;
|
||||||
}
|
}
|
||||||
NOT_REACHED();
|
NOT_REACHED();
|
||||||
|
|||||||
@@ -675,7 +675,7 @@ bool IsWateredTile(TileIndex tile, Direction from)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case MP_RAILWAY:
|
case MP_RAILWAY:
|
||||||
if (GetRailGroundType(tile) == RAIL_GROUND_WATER) {
|
if (GetRailGroundType(tile) == RailGroundType::HalfTileWater) {
|
||||||
assert(IsPlainRail(tile));
|
assert(IsPlainRail(tile));
|
||||||
switch (GetTileSlope(tile)) {
|
switch (GetTileSlope(tile)) {
|
||||||
case SLOPE_W: return (from == DIR_SE) || (from == DIR_E) || (from == DIR_NE);
|
case SLOPE_W: return (from == DIR_SE) || (from == DIR_E) || (from == DIR_NE);
|
||||||
@@ -1132,7 +1132,7 @@ FloodingBehaviour GetFloodingBehaviour(TileIndex tile)
|
|||||||
return (GetWaterClass(tile) == WATER_CLASS_SEA) ? FLOOD_ACTIVE : FLOOD_NONE;
|
return (GetWaterClass(tile) == WATER_CLASS_SEA) ? FLOOD_ACTIVE : FLOOD_NONE;
|
||||||
|
|
||||||
case MP_RAILWAY:
|
case MP_RAILWAY:
|
||||||
if (GetRailGroundType(tile) == RAIL_GROUND_WATER) {
|
if (GetRailGroundType(tile) == RailGroundType::HalfTileWater) {
|
||||||
return (IsSlopeWithOneCornerRaised(GetTileSlope(tile)) ? FLOOD_ACTIVE : FLOOD_DRYUP);
|
return (IsSlopeWithOneCornerRaised(GetTileSlope(tile)) ? FLOOD_ACTIVE : FLOOD_DRYUP);
|
||||||
}
|
}
|
||||||
return FLOOD_NONE;
|
return FLOOD_NONE;
|
||||||
@@ -1226,14 +1226,14 @@ static void DoDryUp(TileIndex tile)
|
|||||||
switch (GetTileType(tile)) {
|
switch (GetTileType(tile)) {
|
||||||
case MP_RAILWAY:
|
case MP_RAILWAY:
|
||||||
assert(IsPlainRail(tile));
|
assert(IsPlainRail(tile));
|
||||||
assert(GetRailGroundType(tile) == RAIL_GROUND_WATER);
|
assert(GetRailGroundType(tile) == RailGroundType::HalfTileWater);
|
||||||
|
|
||||||
RailGroundType new_ground;
|
RailGroundType new_ground;
|
||||||
switch (GetTrackBits(tile)) {
|
switch (GetTrackBits(tile)) {
|
||||||
case TRACK_BIT_UPPER: new_ground = RAIL_GROUND_FENCE_HORIZ1; break;
|
case TRACK_BIT_UPPER: new_ground = RailGroundType::FenceHoriz1; break;
|
||||||
case TRACK_BIT_LOWER: new_ground = RAIL_GROUND_FENCE_HORIZ2; break;
|
case TRACK_BIT_LOWER: new_ground = RailGroundType::FenceHoriz2; break;
|
||||||
case TRACK_BIT_LEFT: new_ground = RAIL_GROUND_FENCE_VERT1; break;
|
case TRACK_BIT_LEFT: new_ground = RailGroundType::FenceVert1; break;
|
||||||
case TRACK_BIT_RIGHT: new_ground = RAIL_GROUND_FENCE_VERT2; break;
|
case TRACK_BIT_RIGHT: new_ground = RailGroundType::FenceVert2; break;
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
}
|
}
|
||||||
SetRailGroundType(tile, new_ground);
|
SetRailGroundType(tile, new_ground);
|
||||||
|
|||||||
Reference in New Issue
Block a user