1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-23 04:04:09 +01:00

Codechange: Use enum class for water-related enums. (#14804)

This commit is contained in:
Peter Nelson
2025-11-19 20:35:11 +00:00
committed by GitHub
parent 4e24c205d6
commit 98275ee5d3
21 changed files with 190 additions and 190 deletions

View File

@@ -55,11 +55,11 @@ WaterClass GetEffectiveWaterClass(TileIndex tile)
if (HasTileWaterClass(tile)) return GetWaterClass(tile);
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
assert(GetTunnelBridgeTransportType(tile) == TRANSPORT_WATER);
return WATER_CLASS_CANAL;
return WaterClass::Canal;
}
if (IsTileType(tile, MP_RAILWAY)) {
assert(GetRailGroundType(tile) == RailGroundType::HalfTileWater);
return WATER_CLASS_SEA;
return WaterClass::Sea;
}
NOT_REACHED();
}
@@ -233,7 +233,7 @@ void Ship::UpdateCache()
const ShipVehicleInfo *svi = ShipVehInfo(this->engine_type);
/* Get speed fraction for the current water type. Aqueducts are always canals. */
bool is_ocean = GetEffectiveWaterClass(this->tile) == WATER_CLASS_SEA;
bool is_ocean = GetEffectiveWaterClass(this->tile) == WaterClass::Sea;
uint raw_speed = GetVehicleProperty(this, PROP_SHIP_SPEED, svi->max_speed);
this->vcache.cached_max_speed = svi->ApplyWaterClassSpeedFrac(raw_speed, is_ocean);
@@ -566,7 +566,7 @@ static const ShipSubcoordData _ship_subcoord[DIAGDIR_END][TRACK_END] = {
static int ShipTestUpDownOnLock(const Ship *v)
{
/* Suitable tile? */
if (!IsTileType(v->tile, MP_WATER) || !IsLock(v->tile) || GetLockPart(v->tile) != LOCK_PART_MIDDLE) return 0;
if (!IsTileType(v->tile, MP_WATER) || !IsLock(v->tile) || GetLockPart(v->tile) != LockPart::Middle) return 0;
/* Must be at the centre of the lock */
if ((v->x_pos & 0xF) != 8 || (v->y_pos & 0xF) != 8) return 0;