mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2026-07-24 03:56:43 +00:00
Codechange: Make TileType enum an enum class.
This commit is contained in:
committed by
rubidium42
parent
7d34e09f94
commit
97f3e5b70f
+25
-23
@@ -430,7 +430,7 @@ CommandCost CmdBuildSingleRail(DoCommandFlags flags, TileIndex tile, RailType ra
|
||||
TrackBits trackbit = TrackToTrackBits(track);
|
||||
|
||||
switch (GetTileType(tile)) {
|
||||
case MP_RAILWAY: {
|
||||
case TileType::Railway: {
|
||||
CommandCost ret = CheckTileOwnership(tile);
|
||||
if (ret.Failed()) return ret;
|
||||
|
||||
@@ -489,7 +489,7 @@ CommandCost CmdBuildSingleRail(DoCommandFlags flags, TileIndex tile, RailType ra
|
||||
break;
|
||||
}
|
||||
|
||||
case MP_ROAD: {
|
||||
case TileType::Road: {
|
||||
/* Level crossings may only be built on these slopes */
|
||||
if (!HasBit(VALID_LEVEL_CROSSING_SLOPES, tileh)) return CommandCost(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
|
||||
|
||||
@@ -564,7 +564,7 @@ CommandCost CmdBuildSingleRail(DoCommandFlags flags, TileIndex tile, RailType ra
|
||||
|
||||
default: {
|
||||
/* Will there be flat water on the lower halftile? */
|
||||
bool water_ground = IsTileType(tile, MP_WATER) && IsSlopeWithOneCornerRaised(tileh);
|
||||
bool water_ground = IsTileType(tile, TileType::Water) && IsSlopeWithOneCornerRaised(tileh);
|
||||
|
||||
CommandCost ret = CheckRailSlope(tileh, trackbit, TRACK_BIT_NONE, tile);
|
||||
if (ret.Failed()) return ret;
|
||||
@@ -626,7 +626,7 @@ CommandCost CmdRemoveSingleRail(DoCommandFlags flags, TileIndex tile, Track trac
|
||||
Train *v = nullptr;
|
||||
|
||||
switch (GetTileType(tile)) {
|
||||
case MP_ROAD: {
|
||||
case TileType::Road: {
|
||||
if (!IsLevelCrossing(tile) || GetCrossingRailBits(tile) != trackbit) return CommandCost(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK);
|
||||
|
||||
if (_current_company != OWNER_WATER) {
|
||||
@@ -658,7 +658,7 @@ CommandCost CmdRemoveSingleRail(DoCommandFlags flags, TileIndex tile, Track trac
|
||||
break;
|
||||
}
|
||||
|
||||
case MP_RAILWAY: {
|
||||
case TileType::Railway: {
|
||||
TrackBits present;
|
||||
/* There are no rails present at depots. */
|
||||
if (!IsPlainRail(tile)) return CommandCost(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK);
|
||||
@@ -1196,7 +1196,7 @@ CommandCost CmdBuildSingleSignal(DoCommandFlags flags, TileIndex tile, Track tra
|
||||
static bool AdvanceSignalAutoFill(TileIndex &tile, Trackdir &trackdir, bool remove)
|
||||
{
|
||||
/* We only process starting tiles of tunnels or bridges so jump to the other end before moving further. */
|
||||
if (IsTileType(tile, MP_TUNNELBRIDGE)) tile = GetOtherTunnelBridgeEnd(tile);
|
||||
if (IsTileType(tile, TileType::TunnelBridge)) tile = GetOtherTunnelBridgeEnd(tile);
|
||||
|
||||
tile = AddTileIndexDiffCWrap(tile, _trackdelta[trackdir]);
|
||||
if (tile == INVALID_TILE) return false;
|
||||
@@ -1217,16 +1217,16 @@ static bool AdvanceSignalAutoFill(TileIndex &tile, Trackdir &trackdir, bool remo
|
||||
if (trackdirbits != TRACKDIR_BIT_NONE) return false;
|
||||
|
||||
switch (GetTileType(tile)) {
|
||||
case MP_RAILWAY:
|
||||
case TileType::Railway:
|
||||
if (IsRailDepot(tile)) return false;
|
||||
if (!remove && HasSignalOnTrack(tile, TrackdirToTrack(trackdir))) return false;
|
||||
break;
|
||||
|
||||
case MP_ROAD:
|
||||
case TileType::Road:
|
||||
if (!IsLevelCrossing(tile)) return false;
|
||||
break;
|
||||
|
||||
case MP_TUNNELBRIDGE: {
|
||||
case TileType::TunnelBridge: {
|
||||
if (GetTunnelBridgeTransportType(tile) != TRANSPORT_RAIL) return false;
|
||||
if (GetTunnelBridgeDirection(tile) != TrackdirToExitdir(trackdir)) return false;
|
||||
break;
|
||||
@@ -1377,15 +1377,15 @@ static CommandCost CmdSignalTrackHelper(DoCommandFlags flags, TileIndex tile, Ti
|
||||
|
||||
if (autofill) {
|
||||
switch (GetTileType(tile)) {
|
||||
case MP_RAILWAY:
|
||||
case TileType::Railway:
|
||||
signal_ctr += (IsDiagonalTrackdir(trackdir) ? TILE_AXIAL_DISTANCE : TILE_CORNER_DISTANCE);
|
||||
break;
|
||||
|
||||
case MP_ROAD:
|
||||
case TileType::Road:
|
||||
signal_ctr += TILE_AXIAL_DISTANCE;
|
||||
break;
|
||||
|
||||
case MP_TUNNELBRIDGE: {
|
||||
case TileType::TunnelBridge: {
|
||||
uint len = (GetTunnelBridgeLength(tile, GetOtherTunnelBridgeEnd(tile)) + 2) * TILE_AXIAL_DISTANCE;
|
||||
if (remove || minimise_gaps) {
|
||||
signal_ctr += len;
|
||||
@@ -1555,19 +1555,19 @@ CommandCost CmdConvertRail(DoCommandFlags flags, TileIndex tile, TileIndex area_
|
||||
|
||||
/* Check if there is any track on tile */
|
||||
switch (tt) {
|
||||
case MP_RAILWAY:
|
||||
case TileType::Railway:
|
||||
break;
|
||||
case MP_STATION:
|
||||
case TileType::Station:
|
||||
if (!HasStationRail(tile)) continue;
|
||||
break;
|
||||
case MP_ROAD:
|
||||
case TileType::Road:
|
||||
if (!IsLevelCrossing(tile)) continue;
|
||||
if (RailNoLevelCrossings(totype)) {
|
||||
error.MakeError(STR_ERROR_CROSSING_DISALLOWED_RAIL);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case MP_TUNNELBRIDGE:
|
||||
case TileType::TunnelBridge:
|
||||
if (GetTunnelBridgeTransportType(tile) != TRANSPORT_RAIL) continue;
|
||||
break;
|
||||
default: continue;
|
||||
@@ -1590,7 +1590,7 @@ CommandCost CmdConvertRail(DoCommandFlags flags, TileIndex tile, TileIndex area_
|
||||
|
||||
/* Vehicle on the tile when not converting Rail <-> ElRail
|
||||
* Tunnels and bridges have special check later */
|
||||
if (tt != MP_TUNNELBRIDGE) {
|
||||
if (tt != TileType::TunnelBridge) {
|
||||
if (!IsCompatibleRail(type, totype)) {
|
||||
ret = IsPlainRailTile(tile) ? EnsureNoTrainOnTrackBits(tile, GetTrackBits(tile)) : EnsureNoVehicleOnGround(tile);
|
||||
if (ret.Failed()) {
|
||||
@@ -1634,7 +1634,8 @@ CommandCost CmdConvertRail(DoCommandFlags flags, TileIndex tile, TileIndex area_
|
||||
}
|
||||
|
||||
switch (tt) {
|
||||
case MP_RAILWAY:
|
||||
default: NOT_REACHED();
|
||||
case TileType::Railway:
|
||||
switch (GetRailTileType(tile)) {
|
||||
case RailTileType::Depot:
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
@@ -1663,7 +1664,7 @@ CommandCost CmdConvertRail(DoCommandFlags flags, TileIndex tile, TileIndex area_
|
||||
}
|
||||
break;
|
||||
|
||||
case MP_TUNNELBRIDGE: {
|
||||
case TileType::TunnelBridge: {
|
||||
TileIndex endtile = GetOtherTunnelBridgeEnd(tile);
|
||||
|
||||
/* If both ends of tunnel/bridge are in the range, do not try to convert twice -
|
||||
@@ -1729,9 +1730,10 @@ CommandCost CmdConvertRail(DoCommandFlags flags, TileIndex tile, TileIndex area_
|
||||
break;
|
||||
}
|
||||
|
||||
default: // MP_STATION, MP_ROAD
|
||||
case TileType::Station:
|
||||
case TileType::Road:
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Track track = ((tt == MP_STATION) ? GetRailStationTrack(tile) : GetCrossingRailTrack(tile));
|
||||
Track track = ((tt == TileType::Station) ? GetRailStationTrack(tile) : GetCrossingRailTrack(tile));
|
||||
YapfNotifyTrackLayoutChange(tile, track);
|
||||
}
|
||||
|
||||
@@ -2688,8 +2690,8 @@ static void TileLoop_Track(TileIndex tile)
|
||||
TileIndex tile2 = tile + TileOffsByDiagDir(d);
|
||||
|
||||
/* Show fences if it's a house, industry, object, road, tunnelbridge or not owned by us. */
|
||||
if (!IsValidTile(tile2) || IsTileType(tile2, MP_HOUSE) || IsTileType(tile2, MP_INDUSTRY) ||
|
||||
IsTileType(tile2, MP_ROAD) || (IsTileType(tile2, MP_OBJECT) && !IsObjectType(tile2, OBJECT_OWNED_LAND)) || IsTileType(tile2, MP_TUNNELBRIDGE) || !IsTileOwner(tile2, owner)) {
|
||||
if (!IsValidTile(tile2) || IsTileType(tile2, TileType::House) || IsTileType(tile2, TileType::Industry) ||
|
||||
IsTileType(tile2, TileType::Road) || (IsTileType(tile2, TileType::Object) && !IsObjectType(tile2, OBJECT_OWNED_LAND)) || IsTileType(tile2, TileType::TunnelBridge) || !IsTileOwner(tile2, owner)) {
|
||||
fences.Set(d);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user