Codechange: Use enum class for water-related enums. (#14804)
This commit is contained in:
@@ -226,7 +226,7 @@ static inline bool NeighbourIsNormal(TileIndex tile)
|
|||||||
TileIndex t = tile + TileOffsByDiagDir(dir);
|
TileIndex t = tile + TileOffsByDiagDir(dir);
|
||||||
if (!IsValidTile(t)) continue;
|
if (!IsValidTile(t)) continue;
|
||||||
if (GetTropicZone(t) != TROPICZONE_DESERT) return true;
|
if (GetTropicZone(t) != TROPICZONE_DESERT) return true;
|
||||||
if (HasTileWaterClass(t) && GetWaterClass(t) == WATER_CLASS_SEA) return true;
|
if (HasTileWaterClass(t) && GetWaterClass(t) == WaterClass::Sea) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -264,13 +264,13 @@ struct BuildDocksToolbarWindow : Window {
|
|||||||
break;
|
break;
|
||||||
case DDSP_CREATE_WATER:
|
case DDSP_CREATE_WATER:
|
||||||
if (_game_mode == GM_EDITOR) {
|
if (_game_mode == GM_EDITOR) {
|
||||||
Command<CMD_BUILD_CANAL>::Post(STR_ERROR_CAN_T_BUILD_CANALS, CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, _ctrl_pressed ? WATER_CLASS_SEA : WATER_CLASS_CANAL, false);
|
Command<CMD_BUILD_CANAL>::Post(STR_ERROR_CAN_T_BUILD_CANALS, CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, _ctrl_pressed ? WaterClass::Sea : WaterClass::Canal, false);
|
||||||
} else {
|
} else {
|
||||||
Command<CMD_BUILD_CANAL>::Post(STR_ERROR_CAN_T_BUILD_CANALS, CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, WATER_CLASS_CANAL, _ctrl_pressed);
|
Command<CMD_BUILD_CANAL>::Post(STR_ERROR_CAN_T_BUILD_CANALS, CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, WaterClass::Canal, _ctrl_pressed);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DDSP_CREATE_RIVER:
|
case DDSP_CREATE_RIVER:
|
||||||
Command<CMD_BUILD_CANAL>::Post(STR_ERROR_CAN_T_PLACE_RIVERS, CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, WATER_CLASS_RIVER, _ctrl_pressed);
|
Command<CMD_BUILD_CANAL>::Post(STR_ERROR_CAN_T_PLACE_RIVERS, CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, WaterClass::River, _ctrl_pressed);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: break;
|
default: break;
|
||||||
@@ -560,8 +560,8 @@ public:
|
|||||||
int y = (ir.Height() - ScaleSpriteTrad(64)) / 2;
|
int y = (ir.Height() - ScaleSpriteTrad(64)) / 2;
|
||||||
int x1 = ScaleSpriteTrad(63);
|
int x1 = ScaleSpriteTrad(63);
|
||||||
int x2 = ScaleSpriteTrad(31);
|
int x2 = ScaleSpriteTrad(31);
|
||||||
DrawShipDepotSprite(x + (axis == AXIS_X ? x1 : x2), y + ScaleSpriteTrad(17), axis, DEPOT_PART_NORTH);
|
DrawShipDepotSprite(x + (axis == AXIS_X ? x1 : x2), y + ScaleSpriteTrad(17), axis, DepotPart::North);
|
||||||
DrawShipDepotSprite(x + (axis == AXIS_X ? x2 : x1), y + ScaleSpriteTrad(33), axis, DEPOT_PART_SOUTH);
|
DrawShipDepotSprite(x + (axis == AXIS_X ? x2 : x1), y + ScaleSpriteTrad(33), axis, DepotPart::South);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1938,7 +1938,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
|
|||||||
if (it.gfx != GFX_WATERTILE_SPECIALCHECK) {
|
if (it.gfx != GFX_WATERTILE_SPECIALCHECK) {
|
||||||
i->location.Add(cur_tile);
|
i->location.Add(cur_tile);
|
||||||
|
|
||||||
WaterClass wc = (IsWaterTile(cur_tile) ? GetWaterClass(cur_tile) : WATER_CLASS_INVALID);
|
WaterClass wc = (IsWaterTile(cur_tile) ? GetWaterClass(cur_tile) : WaterClass::Invalid);
|
||||||
|
|
||||||
Command<CMD_LANDSCAPE_CLEAR>::Do({DoCommandFlag::Execute, DoCommandFlag::NoTestTownRating, DoCommandFlag::NoModifyTownRating}, cur_tile);
|
Command<CMD_LANDSCAPE_CLEAR>::Do({DoCommandFlag::Execute, DoCommandFlag::NoTestTownRating, DoCommandFlag::NoModifyTownRating}, cur_tile);
|
||||||
|
|
||||||
|
|||||||
@@ -681,9 +681,9 @@ CommandCost CmdLandscapeClear(DoCommandFlags flags, TileIndex tile)
|
|||||||
bool do_clear = false;
|
bool do_clear = false;
|
||||||
/* Test for stuff which results in water when cleared. Then add the cost to also clear the water. */
|
/* Test for stuff which results in water when cleared. Then add the cost to also clear the water. */
|
||||||
if (flags.Test(DoCommandFlag::ForceClearTile) && HasTileWaterClass(tile) && IsTileOnWater(tile) && !IsWaterTile(tile) && !IsCoastTile(tile)) {
|
if (flags.Test(DoCommandFlag::ForceClearTile) && HasTileWaterClass(tile) && IsTileOnWater(tile) && !IsWaterTile(tile) && !IsCoastTile(tile)) {
|
||||||
if (flags.Test(DoCommandFlag::Auto) && GetWaterClass(tile) == WATER_CLASS_CANAL) return CommandCost(STR_ERROR_MUST_DEMOLISH_CANAL_FIRST);
|
if (flags.Test(DoCommandFlag::Auto) && GetWaterClass(tile) == WaterClass::Canal) return CommandCost(STR_ERROR_MUST_DEMOLISH_CANAL_FIRST);
|
||||||
do_clear = true;
|
do_clear = true;
|
||||||
cost.AddCost(GetWaterClass(tile) == WATER_CLASS_CANAL ? _price[PR_CLEAR_CANAL] : _price[PR_CLEAR_WATER]);
|
cost.AddCost(GetWaterClass(tile) == WaterClass::Canal ? _price[PR_CLEAR_CANAL] : _price[PR_CLEAR_WATER]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Company *c = flags.Any({DoCommandFlag::Auto, DoCommandFlag::Bankrupt}) ? nullptr : Company::GetIfValid(_current_company);
|
Company *c = flags.Any({DoCommandFlag::Auto, DoCommandFlag::Bankrupt}) ? nullptr : Company::GetIfValid(_current_company);
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ struct CanalResolverObject : public ResolverObject {
|
|||||||
case 0x80: {
|
case 0x80: {
|
||||||
int z = GetTileZ(this->tile);
|
int z = GetTileZ(this->tile);
|
||||||
/* Return consistent height within locks */
|
/* Return consistent height within locks */
|
||||||
if (IsTileType(this->tile, MP_WATER) && IsLock(this->tile) && GetLockPart(this->tile) == LOCK_PART_UPPER) z--;
|
if (IsTileType(this->tile, MP_WATER) && IsLock(this->tile) && GetLockPart(this->tile) == LockPart::Upper) z--;
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -443,7 +443,7 @@ uint32_t GetNearbyTileInformation(TileIndex tile, bool grf_version8)
|
|||||||
|
|
||||||
auto [tileh, z] = GetTilePixelSlope(tile);
|
auto [tileh, z] = GetTilePixelSlope(tile);
|
||||||
/* Return 0 if the tile is a land tile */
|
/* Return 0 if the tile is a land tile */
|
||||||
uint8_t terrain_type = (HasTileWaterClass(tile) ? (GetWaterClass(tile) + 1) & 3 : 0) << 5 | GetTerrainType(tile) << 2 | (tile_type == MP_WATER ? 1 : 0) << 1;
|
uint8_t terrain_type = (HasTileWaterClass(tile) ? (to_underlying(GetWaterClass(tile)) + 1) & 3 : 0) << 5 | GetTerrainType(tile) << 2 | (tile_type == MP_WATER ? 1 : 0) << 1;
|
||||||
if (grf_version8) z /= TILE_HEIGHT;
|
if (grf_version8) z /= TILE_HEIGHT;
|
||||||
return tile_type << 24 | ClampTo<uint8_t>(z) << 16 | terrain_type << 8 | tileh;
|
return tile_type << 24 | ClampTo<uint8_t>(z) << 16 | terrain_type << 8 | tileh;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ void AmbientSoundEffectCallback(TileIndex tile)
|
|||||||
object.generic_scope.feature = GSF_SOUNDFX;
|
object.generic_scope.feature = GSF_SOUNDFX;
|
||||||
|
|
||||||
uint32_t param1_v7 = GetTileType(tile) << 28 | Clamp(TileHeight(tile), 0, 15) << 24 | GB(r, 16, 8) << 16 | GetTerrainType(tile);
|
uint32_t param1_v7 = GetTileType(tile) << 28 | Clamp(TileHeight(tile), 0, 15) << 24 | GB(r, 16, 8) << 16 | GetTerrainType(tile);
|
||||||
uint32_t param1_v8 = GetTileType(tile) << 24 | GetTileZ(tile) << 16 | GB(r, 16, 8) << 8 | (HasTileWaterClass(tile) ? GetWaterClass(tile) : 0) << 3 | GetTerrainType(tile);
|
uint32_t param1_v8 = GetTileType(tile) << 24 | GetTileZ(tile) << 16 | GB(r, 16, 8) << 8 | (HasTileWaterClass(tile) ? to_underlying(GetWaterClass(tile)) : 0) << 3 | GetTerrainType(tile);
|
||||||
|
|
||||||
/* Run callback. */
|
/* Run callback. */
|
||||||
auto callback = GetGenericCallbackResult(GSF_SOUNDFX, object, param1_v7, param1_v8);
|
auto callback = GetGenericCallbackResult(GSF_SOUNDFX, object, param1_v7, param1_v8);
|
||||||
|
|||||||
@@ -116,9 +116,9 @@ void BuildObject(ObjectType type, TileIndex tile, CompanyID owner, Town *town, u
|
|||||||
for (TileIndex t : ta) {
|
for (TileIndex t : ta) {
|
||||||
if (IsWaterTile(t)) ClearNeighbourNonFloodingStates(t);
|
if (IsWaterTile(t)) ClearNeighbourNonFloodingStates(t);
|
||||||
if (HasTileWaterGround(t)) InvalidateWaterRegion(t);
|
if (HasTileWaterGround(t)) InvalidateWaterRegion(t);
|
||||||
WaterClass wc = (IsWaterTile(t) ? GetWaterClass(t) : WATER_CLASS_INVALID);
|
WaterClass wc = (IsWaterTile(t) ? GetWaterClass(t) : WaterClass::Invalid);
|
||||||
/* Update company infrastructure counts for objects build on canals owned by nobody. */
|
/* Update company infrastructure counts for objects build on canals owned by nobody. */
|
||||||
if (wc == WATER_CLASS_CANAL && owner != OWNER_NONE && (IsTileOwner(t, OWNER_NONE) || IsTileOwner(t, OWNER_WATER))) {
|
if (wc == WaterClass::Canal && owner != OWNER_NONE && (IsTileOwner(t, OWNER_NONE) || IsTileOwner(t, OWNER_WATER))) {
|
||||||
Company::Get(owner)->infrastructure.water++;
|
Company::Get(owner)->infrastructure.water++;
|
||||||
DirtyCompanyInfrastructureWindows(owner);
|
DirtyCompanyInfrastructureWindows(owner);
|
||||||
}
|
}
|
||||||
@@ -769,7 +769,7 @@ static bool TryBuildLightHouse()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Only build lighthouses at tiles where the border is sea. */
|
/* Only build lighthouses at tiles where the border is sea. */
|
||||||
if (!IsTileType(tile, MP_WATER) || GetWaterClass(tile) != WATER_CLASS_SEA) return false;
|
if (!IsTileType(tile, MP_WATER) || GetWaterClass(tile) != WaterClass::Sea) return false;
|
||||||
|
|
||||||
for (int j = 0; j < 19; j++) {
|
for (int j = 0; j < 19; j++) {
|
||||||
int h;
|
int h;
|
||||||
@@ -873,7 +873,7 @@ static void ChangeTileOwner_Object(TileIndex tile, Owner old_owner, Owner new_ow
|
|||||||
ObjectType type = GetObjectType(tile);
|
ObjectType type = GetObjectType(tile);
|
||||||
if ((type == OBJECT_OWNED_LAND || type >= NEW_OBJECT_OFFSET) && new_owner != INVALID_OWNER) {
|
if ((type == OBJECT_OWNED_LAND || type >= NEW_OBJECT_OFFSET) && new_owner != INVALID_OWNER) {
|
||||||
SetTileOwner(tile, new_owner);
|
SetTileOwner(tile, new_owner);
|
||||||
if (GetWaterClass(tile) == WATER_CLASS_CANAL) {
|
if (GetWaterClass(tile) == WaterClass::Canal) {
|
||||||
Company::Get(old_owner)->infrastructure.water--;
|
Company::Get(old_owner)->infrastructure.water--;
|
||||||
Company::Get(new_owner)->infrastructure.water++;
|
Company::Get(new_owner)->infrastructure.water++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -385,11 +385,11 @@ public:
|
|||||||
|
|
||||||
/* Ocean/canal speed penalty. */
|
/* Ocean/canal speed penalty. */
|
||||||
const ShipVehicleInfo *svi = ShipVehInfo(Yapf().GetVehicle()->engine_type);
|
const ShipVehicleInfo *svi = ShipVehInfo(Yapf().GetVehicle()->engine_type);
|
||||||
uint8_t speed_frac = (GetEffectiveWaterClass(n.GetTile()) == WATER_CLASS_SEA) ? svi->ocean_speed_frac : svi->canal_speed_frac;
|
uint8_t speed_frac = (GetEffectiveWaterClass(n.GetTile()) == WaterClass::Sea) ? svi->ocean_speed_frac : svi->canal_speed_frac;
|
||||||
if (speed_frac > 0) c += YAPF_TILE_LENGTH * (1 + follower->tiles_skipped) * speed_frac / (256 - speed_frac);
|
if (speed_frac > 0) c += YAPF_TILE_LENGTH * (1 + follower->tiles_skipped) * speed_frac / (256 - speed_frac);
|
||||||
|
|
||||||
/* Lock penalty. */
|
/* Lock penalty. */
|
||||||
if (IsTileType(n.GetTile(), MP_WATER) && IsLock(n.GetTile()) && GetLockPart(n.GetTile()) == LOCK_PART_MIDDLE) {
|
if (IsTileType(n.GetTile(), MP_WATER) && IsLock(n.GetTile()) && GetLockPart(n.GetTile()) == LockPart::Middle) {
|
||||||
const uint canal_speed = svi->ApplyWaterClassSpeedFrac(svi->max_speed, false);
|
const uint canal_speed = svi->ApplyWaterClassSpeedFrac(svi->max_speed, false);
|
||||||
/* Cost is proportional to the vehicle's speed as the vehicle stops in the lock. */
|
/* Cost is proportional to the vehicle's speed as the vehicle stops in the lock. */
|
||||||
c += (TILE_HEIGHT * YAPF_TILE_LENGTH * canal_speed) / 128;
|
c += (TILE_HEIGHT * YAPF_TILE_LENGTH * canal_speed) / 128;
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ extern void ClearOldOrders();
|
|||||||
* This as for example docks and shipdepots do not store
|
* This as for example docks and shipdepots do not store
|
||||||
* whether the tile used to be canal or 'normal' water.
|
* whether the tile used to be canal or 'normal' water.
|
||||||
* @param t the tile to change.
|
* @param t the tile to change.
|
||||||
* @param include_invalid_water_class Also consider WATER_CLASS_INVALID, i.e. industry tiles on land
|
* @param include_invalid_water_class Also consider WaterClass::Invalid, i.e. industry tiles on land
|
||||||
*/
|
*/
|
||||||
void SetWaterClassDependingOnSurroundings(Tile t, bool include_invalid_water_class)
|
void SetWaterClassDependingOnSurroundings(Tile t, bool include_invalid_water_class)
|
||||||
{
|
{
|
||||||
@@ -94,7 +94,7 @@ void SetWaterClassDependingOnSurroundings(Tile t, bool include_invalid_water_cla
|
|||||||
* Note: Wrt. autosloping under industry tiles this is the most fool-proof behaviour. */
|
* Note: Wrt. autosloping under industry tiles this is the most fool-proof behaviour. */
|
||||||
if (!IsTileFlat(t)) {
|
if (!IsTileFlat(t)) {
|
||||||
if (include_invalid_water_class) {
|
if (include_invalid_water_class) {
|
||||||
SetWaterClass(t, WATER_CLASS_INVALID);
|
SetWaterClass(t, WaterClass::Invalid);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
SlErrorCorrupt("Invalid water class for dry tile");
|
SlErrorCorrupt("Invalid water class for dry tile");
|
||||||
@@ -105,8 +105,8 @@ void SetWaterClassDependingOnSurroundings(Tile t, bool include_invalid_water_cla
|
|||||||
MarkTileDirtyByTile(t);
|
MarkTileDirtyByTile(t);
|
||||||
|
|
||||||
if (TileX(t) == 0 || TileY(t) == 0 || TileX(t) == Map::MaxX() - 1 || TileY(t) == Map::MaxY() - 1) {
|
if (TileX(t) == 0 || TileY(t) == 0 || TileX(t) == Map::MaxX() - 1 || TileY(t) == Map::MaxY() - 1) {
|
||||||
/* tiles at map borders are always WATER_CLASS_SEA */
|
/* tiles at map borders are always WaterClass::Sea */
|
||||||
SetWaterClass(t, WATER_CLASS_SEA);
|
SetWaterClass(t, WaterClass::Sea);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,9 +123,9 @@ void SetWaterClassDependingOnSurroundings(Tile t, bool include_invalid_water_cla
|
|||||||
has_water = true;
|
has_water = true;
|
||||||
} else if (!IsLock(neighbour)) {
|
} else if (!IsLock(neighbour)) {
|
||||||
switch (GetWaterClass(neighbour)) {
|
switch (GetWaterClass(neighbour)) {
|
||||||
case WATER_CLASS_SEA: has_water = true; break;
|
case WaterClass::Sea: has_water = true; break;
|
||||||
case WATER_CLASS_CANAL: has_canal = true; break;
|
case WaterClass::Canal: has_canal = true; break;
|
||||||
case WATER_CLASS_RIVER: has_river = true; break;
|
case WaterClass::River: has_river = true; break;
|
||||||
default: SlErrorCorrupt("Invalid water class for tile");
|
default: SlErrorCorrupt("Invalid water class for tile");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,16 +146,16 @@ void SetWaterClassDependingOnSurroundings(Tile t, bool include_invalid_water_cla
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!has_water && !has_canal && !has_river && include_invalid_water_class) {
|
if (!has_water && !has_canal && !has_river && include_invalid_water_class) {
|
||||||
SetWaterClass(t, WATER_CLASS_INVALID);
|
SetWaterClass(t, WaterClass::Invalid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_river && !has_canal) {
|
if (has_river && !has_canal) {
|
||||||
SetWaterClass(t, WATER_CLASS_RIVER);
|
SetWaterClass(t, WaterClass::River);
|
||||||
} else if (has_canal || !has_water) {
|
} else if (has_canal || !has_water) {
|
||||||
SetWaterClass(t, WATER_CLASS_CANAL);
|
SetWaterClass(t, WaterClass::Canal);
|
||||||
} else {
|
} else {
|
||||||
SetWaterClass(t, WATER_CLASS_SEA);
|
SetWaterClass(t, WaterClass::Sea);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -853,12 +853,12 @@ bool AfterLoadGame()
|
|||||||
|
|
||||||
switch (GB(t.m5(), 4, 4)) {
|
switch (GB(t.m5(), 4, 4)) {
|
||||||
case 0x0: /* Previously WBL_TYPE_NORMAL, Clear water or coast. */
|
case 0x0: /* Previously WBL_TYPE_NORMAL, Clear water or coast. */
|
||||||
SetWaterTileType(t, HasBit(t.m5(), WBL_COAST_FLAG) ? WATER_TILE_COAST : WATER_TILE_CLEAR);
|
SetWaterTileType(t, HasBit(t.m5(), WBL_COAST_FLAG) ? WaterTileType::Coast : WaterTileType::Clear);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x1: SetWaterTileType(t, WATER_TILE_LOCK); break; /* Previously WBL_TYPE_LOCK */
|
case 0x1: SetWaterTileType(t, WaterTileType::Lock); break; /* Previously WBL_TYPE_LOCK */
|
||||||
case 0x8: SetWaterTileType(t, WATER_TILE_DEPOT); break; /* Previously WBL_TYPE_DEPOT */
|
case 0x8: SetWaterTileType(t, WaterTileType::Depot); break; /* Previously WBL_TYPE_DEPOT */
|
||||||
default: SetWaterTileType(t, WATER_TILE_CLEAR); break; /* Shouldn't happen... */
|
default: SetWaterTileType(t, WaterTileType::Clear); break; /* Shouldn't happen... */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -870,7 +870,7 @@ bool AfterLoadGame()
|
|||||||
default: break;
|
default: break;
|
||||||
|
|
||||||
case MP_WATER:
|
case MP_WATER:
|
||||||
if (GetWaterTileType(t) == WATER_TILE_LOCK && GetTileOwner(t) == OWNER_WATER) SetTileOwner(t, OWNER_NONE);
|
if (GetWaterTileType(t) == WaterTileType::Lock && GetTileOwner(t) == OWNER_WATER) SetTileOwner(t, OWNER_NONE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MP_STATION: {
|
case MP_STATION: {
|
||||||
@@ -1740,7 +1740,7 @@ bool AfterLoadGame()
|
|||||||
if (IsSavegameVersionBefore(SLV_82)) {
|
if (IsSavegameVersionBefore(SLV_82)) {
|
||||||
for (const auto t : Map::Iterate()) {
|
for (const auto t : Map::Iterate()) {
|
||||||
if (IsTileType(t, MP_WATER) &&
|
if (IsTileType(t, MP_WATER) &&
|
||||||
GetWaterTileType(t) == WATER_TILE_CLEAR &&
|
GetWaterTileType(t) == WaterTileType::Clear &&
|
||||||
GetTileOwner(t) == OWNER_WATER &&
|
GetTileOwner(t) == OWNER_WATER &&
|
||||||
TileHeight(t) != 0) {
|
TileHeight(t) != 0) {
|
||||||
SetTileOwner(t, OWNER_NONE);
|
SetTileOwner(t, OWNER_NONE);
|
||||||
@@ -1872,7 +1872,7 @@ bool AfterLoadGame()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
SetWaterClass(t, WATER_CLASS_INVALID);
|
SetWaterClass(t, WaterClass::Invalid);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1883,7 +1883,7 @@ bool AfterLoadGame()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MP_OBJECT:
|
case MP_OBJECT:
|
||||||
SetWaterClass(t, WATER_CLASS_INVALID);
|
SetWaterClass(t, WaterClass::Invalid);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -1897,7 +1897,7 @@ bool AfterLoadGame()
|
|||||||
for (auto t : Map::Iterate()) {
|
for (auto t : Map::Iterate()) {
|
||||||
/* Move river flag and update canals to use water class */
|
/* Move river flag and update canals to use water class */
|
||||||
if (IsTileType(t, MP_WATER)) {
|
if (IsTileType(t, MP_WATER)) {
|
||||||
if (GetWaterClass(t) != WATER_CLASS_RIVER) {
|
if (GetWaterClass(t) != WaterClass::River) {
|
||||||
if (IsWater(t)) {
|
if (IsWater(t)) {
|
||||||
Owner o = GetTileOwner(t);
|
Owner o = GetTileOwner(t);
|
||||||
if (o == OWNER_WATER) {
|
if (o == OWNER_WATER) {
|
||||||
@@ -1907,7 +1907,7 @@ bool AfterLoadGame()
|
|||||||
}
|
}
|
||||||
} else if (IsShipDepot(t)) {
|
} else if (IsShipDepot(t)) {
|
||||||
Owner o = (Owner)t.m4(); // Original water owner
|
Owner o = (Owner)t.m4(); // Original water owner
|
||||||
SetWaterClass(t, o == OWNER_WATER ? WATER_CLASS_SEA : WATER_CLASS_CANAL);
|
SetWaterClass(t, o == OWNER_WATER ? WaterClass::Sea : WaterClass::Canal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1931,7 +1931,7 @@ bool AfterLoadGame()
|
|||||||
(TileX(t) == 0 || TileY(t) == 0 || TileX(t) == Map::MaxX() - 1 || TileY(t) == Map::MaxY() - 1)) {
|
(TileX(t) == 0 || TileY(t) == 0 || TileX(t) == Map::MaxX() - 1 || TileY(t) == Map::MaxY() - 1)) {
|
||||||
/* Some version 86 savegames have wrong water class at map borders (under buoy, or after removing buoy).
|
/* Some version 86 savegames have wrong water class at map borders (under buoy, or after removing buoy).
|
||||||
* This conversion has to be done before buoys with invalid owner are removed. */
|
* This conversion has to be done before buoys with invalid owner are removed. */
|
||||||
SetWaterClass(t, WATER_CLASS_SEA);
|
SetWaterClass(t, WaterClass::Sea);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsBuoyTile(t) || IsDriveThroughStopTile(t) || IsTileType(t, MP_WATER)) {
|
if (IsBuoyTile(t) || IsDriveThroughStopTile(t) || IsTileType(t, MP_WATER)) {
|
||||||
@@ -2003,7 +2003,7 @@ bool AfterLoadGame()
|
|||||||
if (GetIndustrySpec(GetIndustryType(t))->behaviour.Test(IndustryBehaviour::BuiltOnWater)) {
|
if (GetIndustrySpec(GetIndustryType(t))->behaviour.Test(IndustryBehaviour::BuiltOnWater)) {
|
||||||
SetWaterClassDependingOnSurroundings(t, true);
|
SetWaterClassDependingOnSurroundings(t, true);
|
||||||
} else {
|
} else {
|
||||||
SetWaterClass(t, WATER_CLASS_INVALID);
|
SetWaterClass(t, WaterClass::Invalid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2594,7 +2594,7 @@ bool AfterLoadGame()
|
|||||||
for (const auto t : Map::Iterate()) {
|
for (const auto t : Map::Iterate()) {
|
||||||
if (!IsTileType(t, MP_STATION)) continue;
|
if (!IsTileType(t, MP_STATION)) continue;
|
||||||
if (!IsBuoy(t) && !IsOilRig(t) && !(IsDock(t) && IsTileFlat(t))) {
|
if (!IsBuoy(t) && !IsOilRig(t) && !(IsDock(t) && IsTileFlat(t))) {
|
||||||
SetWaterClass(t, WATER_CLASS_INVALID);
|
SetWaterClass(t, WaterClass::Invalid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3149,7 +3149,7 @@ bool AfterLoadGame()
|
|||||||
/* Move ships from lock slope to upper or lower position. */
|
/* Move ships from lock slope to upper or lower position. */
|
||||||
for (Ship *s : Ship::Iterate()) {
|
for (Ship *s : Ship::Iterate()) {
|
||||||
/* Suitable tile? */
|
/* Suitable tile? */
|
||||||
if (!IsTileType(s->tile, MP_WATER) || !IsLock(s->tile) || GetLockPart(s->tile) != LOCK_PART_MIDDLE) continue;
|
if (!IsTileType(s->tile, MP_WATER) || !IsLock(s->tile) || GetLockPart(s->tile) != LockPart::Middle) continue;
|
||||||
|
|
||||||
/* We don't need to adjust position when at the tile centre */
|
/* We don't need to adjust position when at the tile centre */
|
||||||
int x = s->x_pos & 0xF;
|
int x = s->x_pos & 0xF;
|
||||||
@@ -3205,7 +3205,7 @@ bool AfterLoadGame()
|
|||||||
if (IsSavegameVersionBefore(SLV_TREES_WATER_CLASS)) {
|
if (IsSavegameVersionBefore(SLV_TREES_WATER_CLASS)) {
|
||||||
/* Update water class for trees. */
|
/* Update water class for trees. */
|
||||||
for (const auto t : Map::Iterate()) {
|
for (const auto t : Map::Iterate()) {
|
||||||
if (IsTileType(t, MP_TREES)) SetWaterClass(t, GetTreeGround(t) == TREE_GROUND_SHORE ? WATER_CLASS_SEA : WATER_CLASS_INVALID);
|
if (IsTileType(t, MP_TREES)) SetWaterClass(t, GetTreeGround(t) == TREE_GROUND_SHORE ? WaterClass::Sea : WaterClass::Invalid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ void AfterLoadCompanyStats()
|
|||||||
|
|
||||||
case StationType::Dock:
|
case StationType::Dock:
|
||||||
case StationType::Buoy:
|
case StationType::Buoy:
|
||||||
if (GetWaterClass(tile) == WATER_CLASS_CANAL) {
|
if (GetWaterClass(tile) == WaterClass::Canal) {
|
||||||
if (c != nullptr) c->infrastructure.water++;
|
if (c != nullptr) c->infrastructure.water++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -212,7 +212,7 @@ void AfterLoadCompanyStats()
|
|||||||
c = Company::GetIfValid(GetTileOwner(tile));
|
c = Company::GetIfValid(GetTileOwner(tile));
|
||||||
if (c != nullptr) {
|
if (c != nullptr) {
|
||||||
if (IsShipDepot(tile)) c->infrastructure.water += LOCK_DEPOT_TILE_FACTOR;
|
if (IsShipDepot(tile)) c->infrastructure.water += LOCK_DEPOT_TILE_FACTOR;
|
||||||
if (IsLock(tile) && GetLockPart(tile) == LOCK_PART_MIDDLE) {
|
if (IsLock(tile) && GetLockPart(tile) == LockPart::Middle) {
|
||||||
/* The middle tile specifies the owner of the lock. */
|
/* The middle tile specifies the owner of the lock. */
|
||||||
c->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // the middle tile specifies the owner of the
|
c->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // the middle tile specifies the owner of the
|
||||||
break; // do not count the middle tile as canal
|
break; // do not count the middle tile as canal
|
||||||
@@ -222,7 +222,7 @@ void AfterLoadCompanyStats()
|
|||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
|
|
||||||
case MP_OBJECT:
|
case MP_OBJECT:
|
||||||
if (GetWaterClass(tile) == WATER_CLASS_CANAL) {
|
if (GetWaterClass(tile) == WaterClass::Canal) {
|
||||||
c = Company::GetIfValid(GetTileOwner(tile));
|
c = Company::GetIfValid(GetTileOwner(tile));
|
||||||
if (c != nullptr) c->infrastructure.water++;
|
if (c != nullptr) c->infrastructure.water++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ static void FixTTDMapArray()
|
|||||||
SetTileType(tile, MP_WATER);
|
SetTileType(tile, MP_WATER);
|
||||||
SetTileOwner(tile, OWNER_WATER);
|
SetTileOwner(tile, OWNER_WATER);
|
||||||
tile.m2() = 0;
|
tile.m2() = 0;
|
||||||
tile.m3() = 2; // WATER_CLASS_RIVER
|
tile.m3() = 2; // WaterClass::River
|
||||||
tile.m4() = Random();
|
tile.m4() = Random();
|
||||||
tile.m5() = 0;
|
tile.m5() = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
{
|
{
|
||||||
if (!::IsValidTile(tile)) return false;
|
if (!::IsValidTile(tile)) return false;
|
||||||
|
|
||||||
return ::IsTileType(tile, MP_WATER) && ::GetWaterTileType(tile) == WATER_TILE_DEPOT;
|
return ::IsTileType(tile, MP_WATER) && ::GetWaterTileType(tile) == WaterTileType::Depot;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ bool ScriptMarine::IsDockTile(TileIndex tile)
|
/* static */ bool ScriptMarine::IsDockTile(TileIndex tile)
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
{
|
{
|
||||||
if (!::IsValidTile(tile)) return false;
|
if (!::IsValidTile(tile)) return false;
|
||||||
|
|
||||||
return ::IsTileType(tile, MP_WATER) && ::GetWaterTileType(tile) == WATER_TILE_LOCK;
|
return ::IsTileType(tile, MP_WATER) && ::GetWaterTileType(tile) == WaterTileType::Lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ bool ScriptMarine::IsCanalTile(TileIndex tile)
|
/* static */ bool ScriptMarine::IsCanalTile(TileIndex tile)
|
||||||
@@ -116,7 +116,7 @@
|
|||||||
EnforceCompanyModeValid(false);
|
EnforceCompanyModeValid(false);
|
||||||
EnforcePrecondition(false, ::IsValidTile(tile));
|
EnforcePrecondition(false, ::IsValidTile(tile));
|
||||||
|
|
||||||
return ScriptObject::Command<CMD_BUILD_CANAL>::Do(tile, tile, WATER_CLASS_CANAL, false);
|
return ScriptObject::Command<CMD_BUILD_CANAL>::Do(tile, tile, WaterClass::Canal, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ bool ScriptMarine::RemoveWaterDepot(TileIndex tile)
|
/* static */ bool ScriptMarine::RemoveWaterDepot(TileIndex tile)
|
||||||
|
|||||||
@@ -55,11 +55,11 @@ WaterClass GetEffectiveWaterClass(TileIndex tile)
|
|||||||
if (HasTileWaterClass(tile)) return GetWaterClass(tile);
|
if (HasTileWaterClass(tile)) return GetWaterClass(tile);
|
||||||
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
|
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
|
||||||
assert(GetTunnelBridgeTransportType(tile) == TRANSPORT_WATER);
|
assert(GetTunnelBridgeTransportType(tile) == TRANSPORT_WATER);
|
||||||
return WATER_CLASS_CANAL;
|
return WaterClass::Canal;
|
||||||
}
|
}
|
||||||
if (IsTileType(tile, MP_RAILWAY)) {
|
if (IsTileType(tile, MP_RAILWAY)) {
|
||||||
assert(GetRailGroundType(tile) == RailGroundType::HalfTileWater);
|
assert(GetRailGroundType(tile) == RailGroundType::HalfTileWater);
|
||||||
return WATER_CLASS_SEA;
|
return WaterClass::Sea;
|
||||||
}
|
}
|
||||||
NOT_REACHED();
|
NOT_REACHED();
|
||||||
}
|
}
|
||||||
@@ -233,7 +233,7 @@ void Ship::UpdateCache()
|
|||||||
const ShipVehicleInfo *svi = ShipVehInfo(this->engine_type);
|
const ShipVehicleInfo *svi = ShipVehInfo(this->engine_type);
|
||||||
|
|
||||||
/* Get speed fraction for the current water type. Aqueducts are always canals. */
|
/* 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);
|
uint raw_speed = GetVehicleProperty(this, PROP_SHIP_SPEED, svi->max_speed);
|
||||||
this->vcache.cached_max_speed = svi->ApplyWaterClassSpeedFrac(raw_speed, is_ocean);
|
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)
|
static int ShipTestUpDownOnLock(const Ship *v)
|
||||||
{
|
{
|
||||||
/* Suitable tile? */
|
/* 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 */
|
/* Must be at the centre of the lock */
|
||||||
if ((v->x_pos & 0xF) != 8 || (v->y_pos & 0xF) != 8) return 0;
|
if ((v->x_pos & 0xF) != 8 || (v->y_pos & 0xF) != 8) return 0;
|
||||||
|
|||||||
@@ -2702,7 +2702,7 @@ CommandCost CmdBuildAirport(DoCommandFlags flags, TileIndex tile, uint8_t airpor
|
|||||||
|
|
||||||
for (AirportTileTableIterator iter(as->layouts[layout].tiles, tile); iter != INVALID_TILE; ++iter) {
|
for (AirportTileTableIterator iter(as->layouts[layout].tiles, tile); iter != INVALID_TILE; ++iter) {
|
||||||
Tile t(iter);
|
Tile t(iter);
|
||||||
MakeAirport(t, st->owner, st->index, iter.GetStationGfx(), WATER_CLASS_INVALID);
|
MakeAirport(t, st->owner, st->index, iter.GetStationGfx(), WaterClass::Invalid);
|
||||||
SetStationTileRandomBits(t, GB(Random(), 0, 4));
|
SetStationTileRandomBits(t, GB(Random(), 0, 4));
|
||||||
st->airport.Add(iter);
|
st->airport.Add(iter);
|
||||||
|
|
||||||
@@ -2946,7 +2946,7 @@ CommandCost CmdBuildDock(DoCommandFlags flags, TileIndex tile, StationID station
|
|||||||
* This is needed as we've cleared that tile before.
|
* This is needed as we've cleared that tile before.
|
||||||
* Clearing object tiles may result in water tiles which are already accounted for in the water infrastructure total.
|
* Clearing object tiles may result in water tiles which are already accounted for in the water infrastructure total.
|
||||||
* See: MakeWaterKeepingClass() */
|
* See: MakeWaterKeepingClass() */
|
||||||
if (wc == WATER_CLASS_CANAL && !(HasTileWaterClass(flat_tile) && GetWaterClass(flat_tile) == WATER_CLASS_CANAL && IsTileOwner(flat_tile, _current_company))) {
|
if (wc == WaterClass::Canal && !(HasTileWaterClass(flat_tile) && GetWaterClass(flat_tile) == WaterClass::Canal && IsTileOwner(flat_tile, _current_company))) {
|
||||||
Company::Get(st->owner)->infrastructure.water++;
|
Company::Get(st->owner)->infrastructure.water++;
|
||||||
}
|
}
|
||||||
Company::Get(st->owner)->infrastructure.station += 2;
|
Company::Get(st->owner)->infrastructure.station += 2;
|
||||||
@@ -3357,8 +3357,8 @@ static void DrawTile_Station(TileInfo *ti)
|
|||||||
} else {
|
} else {
|
||||||
assert(IsDock(ti->tile));
|
assert(IsDock(ti->tile));
|
||||||
TileIndex water_tile = ti->tile + TileOffsByDiagDir(GetDockDirection(ti->tile));
|
TileIndex water_tile = ti->tile + TileOffsByDiagDir(GetDockDirection(ti->tile));
|
||||||
WaterClass wc = HasTileWaterClass(water_tile) ? GetWaterClass(water_tile) : WATER_CLASS_INVALID;
|
WaterClass wc = HasTileWaterClass(water_tile) ? GetWaterClass(water_tile) : WaterClass::Invalid;
|
||||||
if (wc == WATER_CLASS_SEA) {
|
if (wc == WaterClass::Sea) {
|
||||||
DrawShoreTile(ti->tileh);
|
DrawShoreTile(ti->tileh);
|
||||||
} else {
|
} else {
|
||||||
DrawClearLandTile(ti, 3);
|
DrawClearLandTile(ti, 3);
|
||||||
@@ -4748,7 +4748,7 @@ static void ChangeTileOwner_Station(TileIndex tile, Owner old_owner, Owner new_o
|
|||||||
|
|
||||||
case StationType::Buoy:
|
case StationType::Buoy:
|
||||||
case StationType::Dock:
|
case StationType::Dock:
|
||||||
if (GetWaterClass(tile) == WATER_CLASS_CANAL) {
|
if (GetWaterClass(tile) == WaterClass::Canal) {
|
||||||
old_company->infrastructure.water--;
|
old_company->infrastructure.water--;
|
||||||
new_company->infrastructure.water++;
|
new_company->infrastructure.water++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -714,7 +714,7 @@ inline uint8_t GetStationTileRandomBits(Tile t)
|
|||||||
* @param section the StationGfx to be used for this tile
|
* @param section the StationGfx to be used for this tile
|
||||||
* @param wc The water class of the station
|
* @param wc The water class of the station
|
||||||
*/
|
*/
|
||||||
inline void MakeStation(Tile t, Owner o, StationID sid, StationType st, uint8_t section, WaterClass wc = WATER_CLASS_INVALID)
|
inline void MakeStation(Tile t, Owner o, StationID sid, StationType st, uint8_t section, WaterClass wc = WaterClass::Invalid)
|
||||||
{
|
{
|
||||||
SetTileType(t, MP_STATION);
|
SetTileType(t, MP_STATION);
|
||||||
SetTileOwner(t, o);
|
SetTileOwner(t, o);
|
||||||
|
|||||||
@@ -44,14 +44,14 @@ static const DrawTileSeqStruct _shipdepot_display_se_seq[] = {
|
|||||||
TILE_SEQ_LINE( 15, 0, 0, 1, 16, 0x14, 0xFE7 | (1 << PALETTE_MODIFIER_COLOUR))
|
TILE_SEQ_LINE( 15, 0, 0, 1, 16, 0x14, 0xFE7 | (1 << PALETTE_MODIFIER_COLOUR))
|
||||||
};
|
};
|
||||||
|
|
||||||
static const DrawTileSpriteSpan _shipdepot_display_data[][DEPOT_PART_END] = {
|
static const DrawTileSpriteSpan _shipdepot_display_data[][to_underlying(DepotPart::End)] = {
|
||||||
{ // AXIS_X
|
{ // AXIS_X
|
||||||
TILE_SPRITE_LINE(0xFDD, _shipdepot_display_ne_seq) // DEPOT_PART_NORTH
|
TILE_SPRITE_LINE(0xFDD, _shipdepot_display_ne_seq) // DepotPart::North
|
||||||
TILE_SPRITE_LINE(0xFDD, _shipdepot_display_sw_seq) // DEPOT_PART_SOUTH
|
TILE_SPRITE_LINE(0xFDD, _shipdepot_display_sw_seq) // DepotPart::South
|
||||||
},
|
},
|
||||||
{ // AXIS_Y
|
{ // AXIS_Y
|
||||||
TILE_SPRITE_LINE(0xFDD, _shipdepot_display_nw_seq) // DEPOT_PART_NORTH
|
TILE_SPRITE_LINE(0xFDD, _shipdepot_display_nw_seq) // DepotPart::North
|
||||||
TILE_SPRITE_LINE(0xFDD, _shipdepot_display_se_seq) // DEPOT_PART_SOUTH
|
TILE_SPRITE_LINE(0xFDD, _shipdepot_display_se_seq) // DepotPart::South
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -123,21 +123,21 @@ static const DrawTileSeqStruct _lock_display_upper_nw_seq[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const DrawTileSpriteSpan _lock_display_data[][DIAGDIR_END] = {
|
static const DrawTileSpriteSpan _lock_display_data[][DIAGDIR_END] = {
|
||||||
{ // LOCK_PART_MIDDLE
|
{ // LockPart::Middle
|
||||||
TILE_SPRITE_LINE(1, _lock_display_middle_ne_seq) // NE
|
TILE_SPRITE_LINE(1, _lock_display_middle_ne_seq) // NE
|
||||||
TILE_SPRITE_LINE(0, _lock_display_middle_se_seq) // SE
|
TILE_SPRITE_LINE(0, _lock_display_middle_se_seq) // SE
|
||||||
TILE_SPRITE_LINE(2, _lock_display_middle_sw_seq) // SW
|
TILE_SPRITE_LINE(2, _lock_display_middle_sw_seq) // SW
|
||||||
TILE_SPRITE_LINE(3, _lock_display_middle_nw_seq) // NW
|
TILE_SPRITE_LINE(3, _lock_display_middle_nw_seq) // NW
|
||||||
},
|
},
|
||||||
|
|
||||||
{ // LOCK_PART_LOWER
|
{ // LockPart::Lower
|
||||||
TILE_SPRITE_LINE(0xFDD, _lock_display_lower_ne_seq) // NE
|
TILE_SPRITE_LINE(0xFDD, _lock_display_lower_ne_seq) // NE
|
||||||
TILE_SPRITE_LINE(0xFDD, _lock_display_lower_se_seq) // SE
|
TILE_SPRITE_LINE(0xFDD, _lock_display_lower_se_seq) // SE
|
||||||
TILE_SPRITE_LINE(0xFDD, _lock_display_lower_sw_seq) // SW
|
TILE_SPRITE_LINE(0xFDD, _lock_display_lower_sw_seq) // SW
|
||||||
TILE_SPRITE_LINE(0xFDD, _lock_display_lower_nw_seq) // NW
|
TILE_SPRITE_LINE(0xFDD, _lock_display_lower_nw_seq) // NW
|
||||||
},
|
},
|
||||||
|
|
||||||
{ // LOCK_PART_UPPER
|
{ // LockPart::Upper
|
||||||
TILE_SPRITE_LINE(0xFDD, _lock_display_upper_ne_seq) // NE
|
TILE_SPRITE_LINE(0xFDD, _lock_display_upper_ne_seq) // NE
|
||||||
TILE_SPRITE_LINE(0xFDD, _lock_display_upper_se_seq) // SE
|
TILE_SPRITE_LINE(0xFDD, _lock_display_upper_se_seq) // SE
|
||||||
TILE_SPRITE_LINE(0xFDD, _lock_display_upper_sw_seq) // SW
|
TILE_SPRITE_LINE(0xFDD, _lock_display_upper_sw_seq) // SW
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ inline void SetTreeGroundDensity(Tile t, TreeGround g, uint d)
|
|||||||
assert(IsTileType(t, MP_TREES)); // XXX incomplete
|
assert(IsTileType(t, MP_TREES)); // XXX incomplete
|
||||||
SB(t.m2(), 4, 2, d);
|
SB(t.m2(), 4, 2, d);
|
||||||
SB(t.m2(), 6, 3, g);
|
SB(t.m2(), 6, 3, g);
|
||||||
SetWaterClass(t, g == TREE_GROUND_SHORE ? WATER_CLASS_SEA : WATER_CLASS_INVALID);
|
SetWaterClass(t, g == TREE_GROUND_SHORE ? WaterClass::Sea : WaterClass::Invalid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -245,7 +245,7 @@ inline void MakeTree(Tile t, TreeType type, uint count, TreeGrowthStage growth,
|
|||||||
{
|
{
|
||||||
SetTileType(t, MP_TREES);
|
SetTileType(t, MP_TREES);
|
||||||
SetTileOwner(t, OWNER_NONE);
|
SetTileOwner(t, OWNER_NONE);
|
||||||
SetWaterClass(t, ground == TREE_GROUND_SHORE ? WATER_CLASS_SEA : WATER_CLASS_INVALID);
|
SetWaterClass(t, ground == TREE_GROUND_SHORE ? WaterClass::Sea : WaterClass::Invalid);
|
||||||
t.m2() = ground << 6 | density << 4 | 0;
|
t.m2() = ground << 6 | density << 4 | 0;
|
||||||
t.m3() = type;
|
t.m3() = type;
|
||||||
t.m4() = 0 << 5 | 0 << 2;
|
t.m4() = 0 << 5 | 0 << 2;
|
||||||
|
|||||||
@@ -1462,7 +1462,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
|
|||||||
|
|
||||||
if (!HasTunnelBridgeSnowOrDesert(ti->tile)) {
|
if (!HasTunnelBridgeSnowOrDesert(ti->tile)) {
|
||||||
TileIndex next = ti->tile + TileOffsByDiagDir(tunnelbridge_direction);
|
TileIndex next = ti->tile + TileOffsByDiagDir(tunnelbridge_direction);
|
||||||
if (ti->tileh != SLOPE_FLAT && ti->z == 0 && HasTileWaterClass(next) && GetWaterClass(next) == WATER_CLASS_SEA) {
|
if (ti->tileh != SLOPE_FLAT && ti->z == 0 && HasTileWaterClass(next) && GetWaterClass(next) == WaterClass::Sea) {
|
||||||
DrawShoreTile(ti->tileh);
|
DrawShoreTile(ti->tileh);
|
||||||
} else {
|
} else {
|
||||||
DrawClearLandTile(ti, 3);
|
DrawClearLandTile(ti, 3);
|
||||||
|
|||||||
@@ -151,14 +151,14 @@ CommandCost CmdBuildShipDepot(DoCommandFlags flags, TileIndex tile, Axis axis)
|
|||||||
/* Update infrastructure counts after the tile clears earlier.
|
/* Update infrastructure counts after the tile clears earlier.
|
||||||
* Clearing object tiles may result in water tiles which are already accounted for in the water infrastructure total.
|
* Clearing object tiles may result in water tiles which are already accounted for in the water infrastructure total.
|
||||||
* See: MakeWaterKeepingClass() */
|
* See: MakeWaterKeepingClass() */
|
||||||
if (wc1 == WATER_CLASS_CANAL && !(HasTileWaterClass(tile) && GetWaterClass(tile) == WATER_CLASS_CANAL && IsTileOwner(tile, _current_company))) new_water_infra++;
|
if (wc1 == WaterClass::Canal && !(HasTileWaterClass(tile) && GetWaterClass(tile) == WaterClass::Canal && IsTileOwner(tile, _current_company))) new_water_infra++;
|
||||||
if (wc2 == WATER_CLASS_CANAL && !(HasTileWaterClass(tile2) && GetWaterClass(tile2) == WATER_CLASS_CANAL && IsTileOwner(tile2, _current_company))) new_water_infra++;
|
if (wc2 == WaterClass::Canal && !(HasTileWaterClass(tile2) && GetWaterClass(tile2) == WaterClass::Canal && IsTileOwner(tile2, _current_company))) new_water_infra++;
|
||||||
|
|
||||||
Company::Get(_current_company)->infrastructure.water += new_water_infra;
|
Company::Get(_current_company)->infrastructure.water += new_water_infra;
|
||||||
DirtyCompanyInfrastructureWindows(_current_company);
|
DirtyCompanyInfrastructureWindows(_current_company);
|
||||||
|
|
||||||
MakeShipDepot(tile, _current_company, depot->index, DEPOT_PART_NORTH, axis, wc1);
|
MakeShipDepot(tile, _current_company, depot->index, DepotPart::North, axis, wc1);
|
||||||
MakeShipDepot(tile2, _current_company, depot->index, DEPOT_PART_SOUTH, axis, wc2);
|
MakeShipDepot(tile2, _current_company, depot->index, DepotPart::South, axis, wc2);
|
||||||
CheckForDockingTile(tile);
|
CheckForDockingTile(tile);
|
||||||
CheckForDockingTile(tile2);
|
CheckForDockingTile(tile2);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
@@ -174,7 +174,7 @@ bool IsPossibleDockingTile(Tile t)
|
|||||||
assert(IsValidTile(t));
|
assert(IsValidTile(t));
|
||||||
switch (GetTileType(t)) {
|
switch (GetTileType(t)) {
|
||||||
case MP_WATER:
|
case MP_WATER:
|
||||||
if (IsLock(t) && GetLockPart(t) == LOCK_PART_MIDDLE) return false;
|
if (IsLock(t) && GetLockPart(t) == LockPart::Middle) return false;
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case MP_RAILWAY:
|
case MP_RAILWAY:
|
||||||
case MP_STATION:
|
case MP_STATION:
|
||||||
@@ -223,7 +223,7 @@ void MakeWaterKeepingClass(TileIndex tile, Owner o)
|
|||||||
auto [slope, z] = GetTileSlopeZ(tile);
|
auto [slope, z] = GetTileSlopeZ(tile);
|
||||||
|
|
||||||
if (slope != SLOPE_FLAT) {
|
if (slope != SLOPE_FLAT) {
|
||||||
if (wc == WATER_CLASS_CANAL) {
|
if (wc == WaterClass::Canal) {
|
||||||
/* If we clear the canal, we have to remove it from the infrastructure count as well. */
|
/* If we clear the canal, we have to remove it from the infrastructure count as well. */
|
||||||
Company *c = Company::GetIfValid(o);
|
Company *c = Company::GetIfValid(o);
|
||||||
if (c != nullptr) {
|
if (c != nullptr) {
|
||||||
@@ -231,16 +231,16 @@ void MakeWaterKeepingClass(TileIndex tile, Owner o)
|
|||||||
DirtyCompanyInfrastructureWindows(c->index);
|
DirtyCompanyInfrastructureWindows(c->index);
|
||||||
}
|
}
|
||||||
/* Sloped canals are locks and no natural water remains whatever the slope direction */
|
/* Sloped canals are locks and no natural water remains whatever the slope direction */
|
||||||
wc = WATER_CLASS_INVALID;
|
wc = WaterClass::Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only river water should be restored on appropriate slopes. Other water would be invalid on slopes */
|
/* Only river water should be restored on appropriate slopes. Other water would be invalid on slopes */
|
||||||
if (wc != WATER_CLASS_RIVER || GetInclinedSlopeDirection(slope) == INVALID_DIAGDIR) {
|
if (wc != WaterClass::River || GetInclinedSlopeDirection(slope) == INVALID_DIAGDIR) {
|
||||||
wc = WATER_CLASS_INVALID;
|
wc = WaterClass::Invalid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wc == WATER_CLASS_SEA && z > 0) {
|
if (wc == WaterClass::Sea && z > 0) {
|
||||||
/* Update company infrastructure count. */
|
/* Update company infrastructure count. */
|
||||||
Company *c = Company::GetIfValid(o);
|
Company *c = Company::GetIfValid(o);
|
||||||
if (c != nullptr) {
|
if (c != nullptr) {
|
||||||
@@ -248,7 +248,7 @@ void MakeWaterKeepingClass(TileIndex tile, Owner o)
|
|||||||
DirtyCompanyInfrastructureWindows(c->index);
|
DirtyCompanyInfrastructureWindows(c->index);
|
||||||
}
|
}
|
||||||
|
|
||||||
wc = WATER_CLASS_CANAL;
|
wc = WaterClass::Canal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Zero map array and terminate animation */
|
/* Zero map array and terminate animation */
|
||||||
@@ -256,13 +256,13 @@ void MakeWaterKeepingClass(TileIndex tile, Owner o)
|
|||||||
|
|
||||||
/* Maybe change to water */
|
/* Maybe change to water */
|
||||||
switch (wc) {
|
switch (wc) {
|
||||||
case WATER_CLASS_SEA: MakeSea(tile); break;
|
case WaterClass::Sea: MakeSea(tile); break;
|
||||||
case WATER_CLASS_CANAL: MakeCanal(tile, o, Random()); break;
|
case WaterClass::Canal: MakeCanal(tile, o, Random()); break;
|
||||||
case WATER_CLASS_RIVER: MakeRiver(tile, Random()); break;
|
case WaterClass::River: MakeRiver(tile, Random()); break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wc != WATER_CLASS_INVALID) CheckForDockingTile(tile);
|
if (wc != WaterClass::Invalid) CheckForDockingTile(tile);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,7 +290,7 @@ static CommandCost RemoveShipDepot(TileIndex tile, DoCommandFlags flags)
|
|||||||
Company *c = Company::GetIfValid(GetTileOwner(tile));
|
Company *c = Company::GetIfValid(GetTileOwner(tile));
|
||||||
if (c != nullptr) {
|
if (c != nullptr) {
|
||||||
c->infrastructure.water -= 2 * LOCK_DEPOT_TILE_FACTOR;
|
c->infrastructure.water -= 2 * LOCK_DEPOT_TILE_FACTOR;
|
||||||
if (do_clear && GetWaterClass(tile) == WATER_CLASS_CANAL) c->infrastructure.water--;
|
if (do_clear && GetWaterClass(tile) == WaterClass::Canal) c->infrastructure.water--;
|
||||||
DirtyCompanyInfrastructureWindows(c->index);
|
DirtyCompanyInfrastructureWindows(c->index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,10 +308,10 @@ static CommandCost RemoveShipDepot(TileIndex tile, DoCommandFlags flags)
|
|||||||
*/
|
*/
|
||||||
static uint8_t GetLockPartMinimalBridgeHeight(LockPart lock_part)
|
static uint8_t GetLockPartMinimalBridgeHeight(LockPart lock_part)
|
||||||
{
|
{
|
||||||
static constexpr uint8_t MINIMAL_BRIDGE_HEIGHT[LOCK_PART_END] = {
|
static constexpr uint8_t MINIMAL_BRIDGE_HEIGHT[to_underlying(LockPart::End)] = {
|
||||||
2, // LOCK_PART_MIDDLE
|
2, // LockPart::Middle
|
||||||
3, // LOCK_PART_LOWER
|
3, // LockPart::Lower
|
||||||
2, // LOCK_PART_UPPER
|
2, // LockPart::Upper
|
||||||
};
|
};
|
||||||
return MINIMAL_BRIDGE_HEIGHT[to_underlying(lock_part)];
|
return MINIMAL_BRIDGE_HEIGHT[to_underlying(lock_part)];
|
||||||
}
|
}
|
||||||
@@ -334,7 +334,7 @@ static CommandCost DoBuildLock(TileIndex tile, DiagDirection dir, DoCommandFlags
|
|||||||
if (ret.Failed()) return ret;
|
if (ret.Failed()) return ret;
|
||||||
|
|
||||||
/* middle tile */
|
/* middle tile */
|
||||||
WaterClass wc_middle = HasTileWaterGround(tile) ? GetWaterClass(tile) : WATER_CLASS_CANAL;
|
WaterClass wc_middle = HasTileWaterGround(tile) ? GetWaterClass(tile) : WaterClass::Canal;
|
||||||
ret = Command<CMD_LANDSCAPE_CLEAR>::Do(flags, tile);
|
ret = Command<CMD_LANDSCAPE_CLEAR>::Do(flags, tile);
|
||||||
if (ret.Failed()) return ret;
|
if (ret.Failed()) return ret;
|
||||||
cost.AddCost(ret.GetCost());
|
cost.AddCost(ret.GetCost());
|
||||||
@@ -349,7 +349,7 @@ static CommandCost DoBuildLock(TileIndex tile, DiagDirection dir, DoCommandFlags
|
|||||||
if (!IsTileFlat(tile - delta)) {
|
if (!IsTileFlat(tile - delta)) {
|
||||||
return CommandCost(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
|
return CommandCost(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
|
||||||
}
|
}
|
||||||
WaterClass wc_lower = IsWaterTile(tile - delta) ? GetWaterClass(tile - delta) : WATER_CLASS_CANAL;
|
WaterClass wc_lower = IsWaterTile(tile - delta) ? GetWaterClass(tile - delta) : WaterClass::Canal;
|
||||||
|
|
||||||
/* upper tile */
|
/* upper tile */
|
||||||
if (!IsWaterTile(tile + delta)) {
|
if (!IsWaterTile(tile + delta)) {
|
||||||
@@ -361,9 +361,9 @@ static CommandCost DoBuildLock(TileIndex tile, DiagDirection dir, DoCommandFlags
|
|||||||
if (!IsTileFlat(tile + delta)) {
|
if (!IsTileFlat(tile + delta)) {
|
||||||
return CommandCost(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
|
return CommandCost(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
|
||||||
}
|
}
|
||||||
WaterClass wc_upper = IsWaterTile(tile + delta) ? GetWaterClass(tile + delta) : WATER_CLASS_CANAL;
|
WaterClass wc_upper = IsWaterTile(tile + delta) ? GetWaterClass(tile + delta) : WaterClass::Canal;
|
||||||
|
|
||||||
for (LockPart lock_part = LOCK_PART_MIDDLE; TileIndex t : {tile, tile - delta, tile + delta}) {
|
for (LockPart lock_part = LockPart::Middle; TileIndex t : {tile, tile - delta, tile + delta}) {
|
||||||
if (IsBridgeAbove(t) && GetBridgeHeight(GetSouthernBridgeEnd(t)) < GetTileMaxZ(t) + GetLockPartMinimalBridgeHeight(lock_part)) {
|
if (IsBridgeAbove(t) && GetBridgeHeight(GetSouthernBridgeEnd(t)) < GetTileMaxZ(t) + GetLockPartMinimalBridgeHeight(lock_part)) {
|
||||||
int height_diff = (GetTileMaxZ(tile) + GetLockPartMinimalBridgeHeight(lock_part) - GetBridgeHeight(GetSouthernBridgeEnd(t))) * TILE_HEIGHT_STEP;
|
int height_diff = (GetTileMaxZ(tile) + GetLockPartMinimalBridgeHeight(lock_part) - GetBridgeHeight(GetSouthernBridgeEnd(t))) * TILE_HEIGHT_STEP;
|
||||||
return CommandCostWithParam(STR_ERROR_BRIDGE_TOO_LOW_FOR_LOCK, height_diff);
|
return CommandCostWithParam(STR_ERROR_BRIDGE_TOO_LOW_FOR_LOCK, height_diff);
|
||||||
@@ -428,7 +428,7 @@ static CommandCost RemoveLock(TileIndex tile, DoCommandFlags flags)
|
|||||||
DirtyCompanyInfrastructureWindows(c->index);
|
DirtyCompanyInfrastructureWindows(c->index);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetWaterClass(tile) == WATER_CLASS_RIVER) {
|
if (GetWaterClass(tile) == WaterClass::River) {
|
||||||
MakeRiver(tile, Random());
|
MakeRiver(tile, Random());
|
||||||
} else {
|
} else {
|
||||||
DoClearSquare(tile);
|
DoClearSquare(tile);
|
||||||
@@ -494,7 +494,7 @@ CommandCost CmdBuildCanal(DoCommandFlags flags, TileIndex tile, TileIndex start_
|
|||||||
if (start_tile >= Map::Size() || !IsValidWaterClass(wc)) return CMD_ERROR;
|
if (start_tile >= Map::Size() || !IsValidWaterClass(wc)) return CMD_ERROR;
|
||||||
|
|
||||||
/* Outside of the editor you can only build canals, not oceans */
|
/* Outside of the editor you can only build canals, not oceans */
|
||||||
if (wc != WATER_CLASS_CANAL && _game_mode != GM_EDITOR) return CMD_ERROR;
|
if (wc != WaterClass::Canal && _game_mode != GM_EDITOR) return CMD_ERROR;
|
||||||
|
|
||||||
CommandCost cost(EXPENSES_CONSTRUCTION);
|
CommandCost cost(EXPENSES_CONSTRUCTION);
|
||||||
|
|
||||||
@@ -504,7 +504,7 @@ CommandCost CmdBuildCanal(DoCommandFlags flags, TileIndex tile, TileIndex start_
|
|||||||
CommandCost ret;
|
CommandCost ret;
|
||||||
|
|
||||||
Slope slope = GetTileSlope(current_tile);
|
Slope slope = GetTileSlope(current_tile);
|
||||||
if (slope != SLOPE_FLAT && (wc != WATER_CLASS_RIVER || !IsInclinedSlope(slope))) {
|
if (slope != SLOPE_FLAT && (wc != WaterClass::River || !IsInclinedSlope(slope))) {
|
||||||
return CommandCost(STR_ERROR_FLAT_LAND_REQUIRED);
|
return CommandCost(STR_ERROR_FLAT_LAND_REQUIRED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -528,7 +528,7 @@ CommandCost CmdBuildCanal(DoCommandFlags flags, TileIndex tile, TileIndex start_
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (wc) {
|
switch (wc) {
|
||||||
case WATER_CLASS_RIVER:
|
case WaterClass::River:
|
||||||
MakeRiver(current_tile, Random());
|
MakeRiver(current_tile, Random());
|
||||||
if (_game_mode == GM_EDITOR) {
|
if (_game_mode == GM_EDITOR) {
|
||||||
/* Remove desert directly around the river tile. */
|
/* Remove desert directly around the river tile. */
|
||||||
@@ -538,7 +538,7 @@ CommandCost CmdBuildCanal(DoCommandFlags flags, TileIndex tile, TileIndex start_
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WATER_CLASS_SEA:
|
case WaterClass::Sea:
|
||||||
if (TileHeight(current_tile) == 0) {
|
if (TileHeight(current_tile) == 0) {
|
||||||
MakeSea(current_tile);
|
MakeSea(current_tile);
|
||||||
break;
|
break;
|
||||||
@@ -572,7 +572,7 @@ CommandCost CmdBuildCanal(DoCommandFlags flags, TileIndex tile, TileIndex start_
|
|||||||
static CommandCost ClearTile_Water(TileIndex tile, DoCommandFlags flags)
|
static CommandCost ClearTile_Water(TileIndex tile, DoCommandFlags flags)
|
||||||
{
|
{
|
||||||
switch (GetWaterTileType(tile)) {
|
switch (GetWaterTileType(tile)) {
|
||||||
case WATER_TILE_CLEAR: {
|
case WaterTileType::Clear: {
|
||||||
if (flags.Test(DoCommandFlag::NoWater)) return CommandCost(STR_ERROR_CAN_T_BUILD_ON_WATER);
|
if (flags.Test(DoCommandFlag::NoWater)) return CommandCost(STR_ERROR_CAN_T_BUILD_ON_WATER);
|
||||||
|
|
||||||
Money base_cost = IsCanal(tile) ? _price[PR_CLEAR_CANAL] : _price[PR_CLEAR_WATER];
|
Money base_cost = IsCanal(tile) ? _price[PR_CLEAR_CANAL] : _price[PR_CLEAR_WATER];
|
||||||
@@ -605,7 +605,7 @@ static CommandCost ClearTile_Water(TileIndex tile, DoCommandFlags flags)
|
|||||||
return CommandCost(EXPENSES_CONSTRUCTION, base_cost);
|
return CommandCost(EXPENSES_CONSTRUCTION, base_cost);
|
||||||
}
|
}
|
||||||
|
|
||||||
case WATER_TILE_COAST: {
|
case WaterTileType::Coast: {
|
||||||
Slope slope = GetTileSlope(tile);
|
Slope slope = GetTileSlope(tile);
|
||||||
|
|
||||||
/* Make sure no vehicle is on the tile */
|
/* Make sure no vehicle is on the tile */
|
||||||
@@ -624,21 +624,21 @@ static CommandCost ClearTile_Water(TileIndex tile, DoCommandFlags flags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case WATER_TILE_LOCK: {
|
case WaterTileType::Lock: {
|
||||||
static const TileIndexDiffC _lock_tomiddle_offs[][DIAGDIR_END] = {
|
static const TileIndexDiffC _lock_tomiddle_offs[to_underlying(LockPart::End)][DIAGDIR_END] = {
|
||||||
/* NE SE SW NW */
|
/* NE SE SW NW */
|
||||||
{ { 0, 0}, {0, 0}, { 0, 0}, {0, 0} }, // LOCK_PART_MIDDLE
|
{ { 0, 0}, {0, 0}, { 0, 0}, {0, 0} }, // LockPart::Middle
|
||||||
{ {-1, 0}, {0, 1}, { 1, 0}, {0, -1} }, // LOCK_PART_LOWER
|
{ {-1, 0}, {0, 1}, { 1, 0}, {0, -1} }, // LockPart::Lower
|
||||||
{ { 1, 0}, {0, -1}, {-1, 0}, {0, 1} }, // LOCK_PART_UPPER
|
{ { 1, 0}, {0, -1}, {-1, 0}, {0, 1} }, // LockPart::Upper
|
||||||
};
|
};
|
||||||
|
|
||||||
if (flags.Test(DoCommandFlag::Auto)) return CommandCost(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
|
if (flags.Test(DoCommandFlag::Auto)) return CommandCost(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
|
||||||
if (_current_company == OWNER_WATER) return CMD_ERROR;
|
if (_current_company == OWNER_WATER) return CMD_ERROR;
|
||||||
/* move to the middle tile.. */
|
/* move to the middle tile.. */
|
||||||
return RemoveLock(tile + ToTileIndexDiff(_lock_tomiddle_offs[GetLockPart(tile)][GetLockDirection(tile)]), flags);
|
return RemoveLock(tile + ToTileIndexDiff(_lock_tomiddle_offs[to_underlying(GetLockPart(tile))][GetLockDirection(tile)]), flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
case WATER_TILE_DEPOT:
|
case WaterTileType::Depot:
|
||||||
if (flags.Test(DoCommandFlag::Auto)) return CommandCost(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
|
if (flags.Test(DoCommandFlag::Auto)) return CommandCost(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
|
||||||
return RemoveShipDepot(tile, flags);
|
return RemoveShipDepot(tile, flags);
|
||||||
|
|
||||||
@@ -661,10 +661,10 @@ bool IsWateredTile(TileIndex tile, Direction from)
|
|||||||
case MP_WATER:
|
case MP_WATER:
|
||||||
switch (GetWaterTileType(tile)) {
|
switch (GetWaterTileType(tile)) {
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
case WATER_TILE_DEPOT: case WATER_TILE_CLEAR: return true;
|
case WaterTileType::Depot: case WaterTileType::Clear: return true;
|
||||||
case WATER_TILE_LOCK: return DiagDirToAxis(GetLockDirection(tile)) == DiagDirToAxis(DirToDiagDir(from));
|
case WaterTileType::Lock: return DiagDirToAxis(GetLockDirection(tile)) == DiagDirToAxis(DirToDiagDir(from));
|
||||||
|
|
||||||
case WATER_TILE_COAST:
|
case WaterTileType::Coast:
|
||||||
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);
|
||||||
case SLOPE_S: return (from == DIR_NE) || (from == DIR_N) || (from == DIR_NW);
|
case SLOPE_S: return (from == DIR_NE) || (from == DIR_N) || (from == DIR_NW);
|
||||||
@@ -839,8 +839,8 @@ static void DrawWaterTileStruct(const TileInfo *ti, std::span<const DrawTileSeqS
|
|||||||
/** Draw a lock tile. */
|
/** Draw a lock tile. */
|
||||||
static void DrawWaterLock(const TileInfo *ti)
|
static void DrawWaterLock(const TileInfo *ti)
|
||||||
{
|
{
|
||||||
int part = GetLockPart(ti->tile);
|
LockPart part = GetLockPart(ti->tile);
|
||||||
const DrawTileSprites &dts = _lock_display_data[part][GetLockDirection(ti->tile)];
|
const DrawTileSprites &dts = _lock_display_data[to_underlying(part)][GetLockDirection(ti->tile)];
|
||||||
|
|
||||||
/* Draw ground sprite. */
|
/* Draw ground sprite. */
|
||||||
SpriteID image = dts.ground.sprite;
|
SpriteID image = dts.ground.sprite;
|
||||||
@@ -868,7 +868,7 @@ static void DrawWaterLock(const TileInfo *ti)
|
|||||||
if (base == 0) {
|
if (base == 0) {
|
||||||
/* If no custom graphics, use defaults. */
|
/* If no custom graphics, use defaults. */
|
||||||
base = SPR_LOCK_BASE;
|
base = SPR_LOCK_BASE;
|
||||||
uint8_t z_threshold = part == LOCK_PART_UPPER ? 8 : 0;
|
uint8_t z_threshold = part == LockPart::Upper ? 8 : 0;
|
||||||
zoffs = ti->z > z_threshold ? 24 : 0;
|
zoffs = ti->z > z_threshold ? 24 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -879,7 +879,7 @@ static void DrawWaterLock(const TileInfo *ti)
|
|||||||
static void DrawWaterDepot(const TileInfo *ti)
|
static void DrawWaterDepot(const TileInfo *ti)
|
||||||
{
|
{
|
||||||
DrawWaterClassGround(ti);
|
DrawWaterClassGround(ti);
|
||||||
DrawWaterTileStruct(ti, _shipdepot_display_data[GetShipDepotAxis(ti->tile)][GetShipDepotPart(ti->tile)].seq, 0, 0, GetCompanyPalette(GetTileOwner(ti->tile)), CF_END);
|
DrawWaterTileStruct(ti, _shipdepot_display_data[GetShipDepotAxis(ti->tile)][to_underlying(GetShipDepotPart(ti->tile))].seq, 0, 0, GetCompanyPalette(GetTileOwner(ti->tile)), CF_END);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DrawRiverWater(const TileInfo *ti)
|
static void DrawRiverWater(const TileInfo *ti)
|
||||||
@@ -940,9 +940,9 @@ void DrawShoreTile(Slope tileh)
|
|||||||
void DrawWaterClassGround(const TileInfo *ti)
|
void DrawWaterClassGround(const TileInfo *ti)
|
||||||
{
|
{
|
||||||
switch (GetWaterClass(ti->tile)) {
|
switch (GetWaterClass(ti->tile)) {
|
||||||
case WATER_CLASS_SEA: DrawSeaWater(ti->tile); break;
|
case WaterClass::Sea: DrawSeaWater(ti->tile); break;
|
||||||
case WATER_CLASS_CANAL: DrawCanalWater(ti->tile); break;
|
case WaterClass::Canal: DrawCanalWater(ti->tile); break;
|
||||||
case WATER_CLASS_RIVER: DrawRiverWater(ti); break;
|
case WaterClass::River: DrawRiverWater(ti); break;
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -950,27 +950,27 @@ void DrawWaterClassGround(const TileInfo *ti)
|
|||||||
static void DrawTile_Water(TileInfo *ti)
|
static void DrawTile_Water(TileInfo *ti)
|
||||||
{
|
{
|
||||||
switch (GetWaterTileType(ti->tile)) {
|
switch (GetWaterTileType(ti->tile)) {
|
||||||
case WATER_TILE_CLEAR:
|
case WaterTileType::Clear:
|
||||||
DrawWaterClassGround(ti);
|
DrawWaterClassGround(ti);
|
||||||
/* A plain water tile can be traversed in any direction, so setting blocked pillars here would mean all bridges
|
/* A plain water tile can be traversed in any direction, so setting blocked pillars here would mean all bridges
|
||||||
* with edges would have no pillars above water. Instead prefer current behaviour of ships passing through. */
|
* with edges would have no pillars above water. Instead prefer current behaviour of ships passing through. */
|
||||||
DrawBridgeMiddle(ti, {});
|
DrawBridgeMiddle(ti, {});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WATER_TILE_COAST: {
|
case WaterTileType::Coast: {
|
||||||
DrawShoreTile(ti->tileh);
|
DrawShoreTile(ti->tileh);
|
||||||
DrawBridgeMiddle(ti, {});
|
DrawBridgeMiddle(ti, {});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WATER_TILE_LOCK:
|
case WaterTileType::Lock:
|
||||||
DrawWaterLock(ti);
|
DrawWaterLock(ti);
|
||||||
DrawBridgeMiddle(ti, DiagDirToAxis(GetLockDirection(ti->tile)) == AXIS_X
|
DrawBridgeMiddle(ti, DiagDirToAxis(GetLockDirection(ti->tile)) == AXIS_X
|
||||||
? BridgePillarFlags{BridgePillarFlag::EdgeNE, BridgePillarFlag::EdgeSW}
|
? BridgePillarFlags{BridgePillarFlag::EdgeNE, BridgePillarFlag::EdgeSW}
|
||||||
: BridgePillarFlags{BridgePillarFlag::EdgeNW, BridgePillarFlag::EdgeSE});
|
: BridgePillarFlags{BridgePillarFlag::EdgeNW, BridgePillarFlag::EdgeSE});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WATER_TILE_DEPOT:
|
case WaterTileType::Depot:
|
||||||
DrawWaterDepot(ti);
|
DrawWaterDepot(ti);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -978,7 +978,7 @@ static void DrawTile_Water(TileInfo *ti)
|
|||||||
|
|
||||||
void DrawShipDepotSprite(int x, int y, Axis axis, DepotPart part)
|
void DrawShipDepotSprite(int x, int y, Axis axis, DepotPart part)
|
||||||
{
|
{
|
||||||
const DrawTileSprites &dts = _shipdepot_display_data[axis][part];
|
const DrawTileSprites &dts = _shipdepot_display_data[axis][to_underlying(part)];
|
||||||
|
|
||||||
DrawSprite(dts.ground.sprite, dts.ground.pal, x, y);
|
DrawSprite(dts.ground.sprite, dts.ground.pal, x, y);
|
||||||
DrawOrigTileSeqInGUI(x, y, &dts, GetCompanyPalette(_local_company));
|
DrawOrigTileSeqInGUI(x, y, &dts, GetCompanyPalette(_local_company));
|
||||||
@@ -1000,17 +1000,17 @@ static Foundation GetFoundation_Water(TileIndex, Slope)
|
|||||||
static void GetTileDesc_Water(TileIndex tile, TileDesc &td)
|
static void GetTileDesc_Water(TileIndex tile, TileDesc &td)
|
||||||
{
|
{
|
||||||
switch (GetWaterTileType(tile)) {
|
switch (GetWaterTileType(tile)) {
|
||||||
case WATER_TILE_CLEAR:
|
case WaterTileType::Clear:
|
||||||
switch (GetWaterClass(tile)) {
|
switch (GetWaterClass(tile)) {
|
||||||
case WATER_CLASS_SEA: td.str = STR_LAI_WATER_DESCRIPTION_WATER; break;
|
case WaterClass::Sea: td.str = STR_LAI_WATER_DESCRIPTION_WATER; break;
|
||||||
case WATER_CLASS_CANAL: td.str = STR_LAI_WATER_DESCRIPTION_CANAL; break;
|
case WaterClass::Canal: td.str = STR_LAI_WATER_DESCRIPTION_CANAL; break;
|
||||||
case WATER_CLASS_RIVER: td.str = STR_LAI_WATER_DESCRIPTION_RIVER; break;
|
case WaterClass::River: td.str = STR_LAI_WATER_DESCRIPTION_RIVER; break;
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WATER_TILE_COAST: td.str = STR_LAI_WATER_DESCRIPTION_COAST_OR_RIVERBANK; break;
|
case WaterTileType::Coast: td.str = STR_LAI_WATER_DESCRIPTION_COAST_OR_RIVERBANK; break;
|
||||||
case WATER_TILE_LOCK : td.str = STR_LAI_WATER_DESCRIPTION_LOCK; break;
|
case WaterTileType::Lock : td.str = STR_LAI_WATER_DESCRIPTION_LOCK; break;
|
||||||
case WATER_TILE_DEPOT:
|
case WaterTileType::Depot:
|
||||||
td.str = STR_LAI_WATER_DESCRIPTION_SHIP_DEPOT;
|
td.str = STR_LAI_WATER_DESCRIPTION_SHIP_DEPOT;
|
||||||
td.build_date = Depot::GetByTile(tile)->build_date;
|
td.build_date = Depot::GetByTile(tile)->build_date;
|
||||||
break;
|
break;
|
||||||
@@ -1129,7 +1129,7 @@ FloodingBehaviour GetFloodingBehaviour(TileIndex tile)
|
|||||||
case MP_STATION:
|
case MP_STATION:
|
||||||
case MP_INDUSTRY:
|
case MP_INDUSTRY:
|
||||||
case MP_OBJECT:
|
case MP_OBJECT:
|
||||||
return (GetWaterClass(tile) == WATER_CLASS_SEA) ? FLOOD_ACTIVE : FLOOD_NONE;
|
return (GetWaterClass(tile) == WaterClass::Sea) ? FLOOD_ACTIVE : FLOOD_NONE;
|
||||||
|
|
||||||
case MP_RAILWAY:
|
case MP_RAILWAY:
|
||||||
if (GetRailGroundType(tile) == RailGroundType::HalfTileWater) {
|
if (GetRailGroundType(tile) == RailGroundType::HalfTileWater) {
|
||||||
@@ -1366,10 +1366,10 @@ static TrackStatus GetTileTrackStatus_Water(TileIndex tile, TransportType mode,
|
|||||||
if (mode != TRANSPORT_WATER) return 0;
|
if (mode != TRANSPORT_WATER) return 0;
|
||||||
|
|
||||||
switch (GetWaterTileType(tile)) {
|
switch (GetWaterTileType(tile)) {
|
||||||
case WATER_TILE_CLEAR: ts = IsTileFlat(tile) ? TRACK_BIT_ALL : TRACK_BIT_NONE; break;
|
case WaterTileType::Clear: ts = IsTileFlat(tile) ? TRACK_BIT_ALL : TRACK_BIT_NONE; break;
|
||||||
case WATER_TILE_COAST: ts = coast_tracks[GetTileSlope(tile) & 0xF]; break;
|
case WaterTileType::Coast: ts = coast_tracks[GetTileSlope(tile) & 0xF]; break;
|
||||||
case WATER_TILE_LOCK: ts = DiagDirToDiagTrackBits(GetLockDirection(tile)); break;
|
case WaterTileType::Lock: ts = DiagDirToDiagTrackBits(GetLockDirection(tile)); break;
|
||||||
case WATER_TILE_DEPOT: ts = AxisToTrackBits(GetShipDepotAxis(tile)); break;
|
case WaterTileType::Depot: ts = AxisToTrackBits(GetShipDepotAxis(tile)); break;
|
||||||
default: return 0;
|
default: return 0;
|
||||||
}
|
}
|
||||||
if (TileX(tile) == 0) {
|
if (TileX(tile) == 0) {
|
||||||
@@ -1385,7 +1385,7 @@ static TrackStatus GetTileTrackStatus_Water(TileIndex tile, TransportType mode,
|
|||||||
|
|
||||||
static bool ClickTile_Water(TileIndex tile)
|
static bool ClickTile_Water(TileIndex tile)
|
||||||
{
|
{
|
||||||
if (GetWaterTileType(tile) == WATER_TILE_DEPOT) {
|
if (GetWaterTileType(tile) == WaterTileType::Depot) {
|
||||||
ShowDepotWindow(GetShipDepotNorthTile(tile), VEH_SHIP);
|
ShowDepotWindow(GetShipDepotNorthTile(tile), VEH_SHIP);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1396,7 +1396,7 @@ static void ChangeTileOwner_Water(TileIndex tile, Owner old_owner, Owner new_own
|
|||||||
{
|
{
|
||||||
if (!IsTileOwner(tile, old_owner)) return;
|
if (!IsTileOwner(tile, old_owner)) return;
|
||||||
|
|
||||||
bool is_lock_middle = IsLock(tile) && GetLockPart(tile) == LOCK_PART_MIDDLE;
|
bool is_lock_middle = IsLock(tile) && GetLockPart(tile) == LockPart::Middle;
|
||||||
|
|
||||||
/* No need to dirty company windows here, we'll redraw the whole screen anyway. */
|
/* No need to dirty company windows here, we'll redraw the whole screen anyway. */
|
||||||
if (is_lock_middle) Company::Get(old_owner)->infrastructure.water -= 3 * LOCK_DEPOT_TILE_FACTOR; // Lock has three parts.
|
if (is_lock_middle) Company::Get(old_owner)->infrastructure.water -= 3 * LOCK_DEPOT_TILE_FACTOR; // Lock has three parts.
|
||||||
@@ -1404,7 +1404,7 @@ static void ChangeTileOwner_Water(TileIndex tile, Owner old_owner, Owner new_own
|
|||||||
if (is_lock_middle) Company::Get(new_owner)->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // Lock has three parts.
|
if (is_lock_middle) Company::Get(new_owner)->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // Lock has three parts.
|
||||||
/* Only subtract from the old owner here if the new owner is valid,
|
/* Only subtract from the old owner here if the new owner is valid,
|
||||||
* otherwise we clear ship depots and canal water below. */
|
* otherwise we clear ship depots and canal water below. */
|
||||||
if (GetWaterClass(tile) == WATER_CLASS_CANAL && !is_lock_middle) {
|
if (GetWaterClass(tile) == WaterClass::Canal && !is_lock_middle) {
|
||||||
Company::Get(old_owner)->infrastructure.water--;
|
Company::Get(old_owner)->infrastructure.water--;
|
||||||
Company::Get(new_owner)->infrastructure.water++;
|
Company::Get(new_owner)->infrastructure.water++;
|
||||||
}
|
}
|
||||||
@@ -1423,7 +1423,7 @@ static void ChangeTileOwner_Water(TileIndex tile, Owner old_owner, Owner new_own
|
|||||||
/* Set owner of canals and locks ... and also canal under dock there was before.
|
/* Set owner of canals and locks ... and also canal under dock there was before.
|
||||||
* Check if the new owner after removing depot isn't OWNER_WATER. */
|
* Check if the new owner after removing depot isn't OWNER_WATER. */
|
||||||
if (IsTileOwner(tile, old_owner)) {
|
if (IsTileOwner(tile, old_owner)) {
|
||||||
if (GetWaterClass(tile) == WATER_CLASS_CANAL && !is_lock_middle) Company::Get(old_owner)->infrastructure.water--;
|
if (GetWaterClass(tile) == WaterClass::Canal && !is_lock_middle) Company::Get(old_owner)->infrastructure.water--;
|
||||||
SetTileOwner(tile, OWNER_NONE);
|
SetTileOwner(tile, OWNER_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,19 +28,19 @@ static constexpr uint8_t WBL_DEPOT_PART = 0; ///< Depot part flag.
|
|||||||
static constexpr uint8_t WBL_DEPOT_AXIS = 1; ///< Depot axis flag.
|
static constexpr uint8_t WBL_DEPOT_AXIS = 1; ///< Depot axis flag.
|
||||||
|
|
||||||
/** Available water tile types. */
|
/** Available water tile types. */
|
||||||
enum WaterTileType : uint8_t {
|
enum class WaterTileType : uint8_t {
|
||||||
WATER_TILE_CLEAR, ///< Plain water.
|
Clear = 0, ///< Plain water.
|
||||||
WATER_TILE_COAST, ///< Coast.
|
Coast = 1, ///< Coast.
|
||||||
WATER_TILE_LOCK, ///< Water lock.
|
Lock = 2, ///< Water lock.
|
||||||
WATER_TILE_DEPOT, ///< Water Depot.
|
Depot = 3, ///< Water Depot.
|
||||||
};
|
};
|
||||||
|
|
||||||
/** classes of water (for #WATER_TILE_CLEAR water tile type). */
|
/** classes of water (for #WaterTileType::Clear water tile type). */
|
||||||
enum WaterClass : uint8_t {
|
enum class WaterClass : uint8_t {
|
||||||
WATER_CLASS_SEA, ///< Sea.
|
Sea = 0, ///< Sea.
|
||||||
WATER_CLASS_CANAL, ///< Canal.
|
Canal = 1, ///< Canal.
|
||||||
WATER_CLASS_RIVER, ///< River.
|
River = 2, ///< River.
|
||||||
WATER_CLASS_INVALID, ///< Used for industry tiles on land (also for oilrig if newgrf says so).
|
Invalid = 3, ///< Used for industry tiles on land (also for oilrig if newgrf says so).
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,22 +51,22 @@ enum WaterClass : uint8_t {
|
|||||||
*/
|
*/
|
||||||
inline bool IsValidWaterClass(WaterClass wc)
|
inline bool IsValidWaterClass(WaterClass wc)
|
||||||
{
|
{
|
||||||
return wc < WATER_CLASS_INVALID;
|
return wc < WaterClass::Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sections of the water depot. */
|
/** Sections of the water depot. */
|
||||||
enum DepotPart : uint8_t {
|
enum class DepotPart : uint8_t {
|
||||||
DEPOT_PART_NORTH = 0, ///< Northern part of a depot.
|
North = 0, ///< Northern part of a depot.
|
||||||
DEPOT_PART_SOUTH = 1, ///< Southern part of a depot.
|
South = 1, ///< Southern part of a depot.
|
||||||
DEPOT_PART_END
|
End,
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Sections of the water lock. */
|
/** Sections of the water lock. */
|
||||||
enum LockPart : uint8_t {
|
enum class LockPart : uint8_t {
|
||||||
LOCK_PART_MIDDLE = 0, ///< Middle part of a lock.
|
Middle = 0, ///< Middle part of a lock.
|
||||||
LOCK_PART_LOWER = 1, ///< Lower part of a lock.
|
Lower = 1, ///< Lower part of a lock.
|
||||||
LOCK_PART_UPPER = 2, ///< Upper part of a lock.
|
Upper = 2, ///< Upper part of a lock.
|
||||||
LOCK_PART_END,
|
End,
|
||||||
};
|
};
|
||||||
DECLARE_INCREMENT_DECREMENT_OPERATORS(LockPart);
|
DECLARE_INCREMENT_DECREMENT_OPERATORS(LockPart);
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ inline bool HasTileWaterClass(Tile t)
|
|||||||
inline WaterClass GetWaterClass(Tile t)
|
inline WaterClass GetWaterClass(Tile t)
|
||||||
{
|
{
|
||||||
assert(HasTileWaterClass(t));
|
assert(HasTileWaterClass(t));
|
||||||
return (WaterClass)GB(t.m1(), 5, 2);
|
return static_cast<WaterClass>(GB(t.m1(), 5, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -126,7 +126,7 @@ inline WaterClass GetWaterClass(Tile t)
|
|||||||
inline void SetWaterClass(Tile t, WaterClass wc)
|
inline void SetWaterClass(Tile t, WaterClass wc)
|
||||||
{
|
{
|
||||||
assert(HasTileWaterClass(t));
|
assert(HasTileWaterClass(t));
|
||||||
SB(t.m1(), 5, 2, wc);
|
SB(t.m1(), 5, 2, to_underlying(wc));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,7 +137,7 @@ inline void SetWaterClass(Tile t, WaterClass wc)
|
|||||||
*/
|
*/
|
||||||
inline bool IsTileOnWater(Tile t)
|
inline bool IsTileOnWater(Tile t)
|
||||||
{
|
{
|
||||||
return (GetWaterClass(t) != WATER_CLASS_INVALID);
|
return (GetWaterClass(t) != WaterClass::Invalid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -148,7 +148,7 @@ inline bool IsTileOnWater(Tile t)
|
|||||||
*/
|
*/
|
||||||
inline bool IsWater(Tile t)
|
inline bool IsWater(Tile t)
|
||||||
{
|
{
|
||||||
return GetWaterTileType(t) == WATER_TILE_CLEAR;
|
return GetWaterTileType(t) == WaterTileType::Clear;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -159,7 +159,7 @@ inline bool IsWater(Tile t)
|
|||||||
*/
|
*/
|
||||||
inline bool IsSea(Tile t)
|
inline bool IsSea(Tile t)
|
||||||
{
|
{
|
||||||
return IsWater(t) && GetWaterClass(t) == WATER_CLASS_SEA;
|
return IsWater(t) && GetWaterClass(t) == WaterClass::Sea;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -170,7 +170,7 @@ inline bool IsSea(Tile t)
|
|||||||
*/
|
*/
|
||||||
inline bool IsCanal(Tile t)
|
inline bool IsCanal(Tile t)
|
||||||
{
|
{
|
||||||
return IsWater(t) && GetWaterClass(t) == WATER_CLASS_CANAL;
|
return IsWater(t) && GetWaterClass(t) == WaterClass::Canal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -181,7 +181,7 @@ inline bool IsCanal(Tile t)
|
|||||||
*/
|
*/
|
||||||
inline bool IsRiver(Tile t)
|
inline bool IsRiver(Tile t)
|
||||||
{
|
{
|
||||||
return IsWater(t) && GetWaterClass(t) == WATER_CLASS_RIVER;
|
return IsWater(t) && GetWaterClass(t) == WaterClass::River;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -202,7 +202,7 @@ inline bool IsWaterTile(Tile t)
|
|||||||
*/
|
*/
|
||||||
inline bool IsCoast(Tile t)
|
inline bool IsCoast(Tile t)
|
||||||
{
|
{
|
||||||
return GetWaterTileType(t) == WATER_TILE_COAST;
|
return GetWaterTileType(t) == WaterTileType::Coast;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -212,7 +212,7 @@ inline bool IsCoast(Tile t)
|
|||||||
*/
|
*/
|
||||||
inline bool IsCoastTile(Tile t)
|
inline bool IsCoastTile(Tile t)
|
||||||
{
|
{
|
||||||
return (IsTileType(t, MP_WATER) && IsCoast(t)) || (IsTileType(t, MP_TREES) && GetWaterClass(t) != WATER_CLASS_INVALID);
|
return (IsTileType(t, MP_WATER) && IsCoast(t)) || (IsTileType(t, MP_TREES) && GetWaterClass(t) != WaterClass::Invalid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -223,7 +223,7 @@ inline bool IsCoastTile(Tile t)
|
|||||||
*/
|
*/
|
||||||
inline bool IsShipDepot(Tile t)
|
inline bool IsShipDepot(Tile t)
|
||||||
{
|
{
|
||||||
return GetWaterTileType(t) == WATER_TILE_DEPOT;
|
return GetWaterTileType(t) == WaterTileType::Depot;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -257,7 +257,7 @@ inline Axis GetShipDepotAxis(Tile t)
|
|||||||
inline DepotPart GetShipDepotPart(Tile t)
|
inline DepotPart GetShipDepotPart(Tile t)
|
||||||
{
|
{
|
||||||
assert(IsShipDepotTile(t));
|
assert(IsShipDepotTile(t));
|
||||||
return (DepotPart)GB(t.m5(), WBL_DEPOT_PART, 1);
|
return static_cast<DepotPart>(GB(t.m5(), WBL_DEPOT_PART, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -268,7 +268,7 @@ inline DepotPart GetShipDepotPart(Tile t)
|
|||||||
*/
|
*/
|
||||||
inline DiagDirection GetShipDepotDirection(Tile t)
|
inline DiagDirection GetShipDepotDirection(Tile t)
|
||||||
{
|
{
|
||||||
return XYNSToDiagDir(GetShipDepotAxis(t), GetShipDepotPart(t));
|
return XYNSToDiagDir(GetShipDepotAxis(t), to_underlying(GetShipDepotPart(t)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -279,7 +279,7 @@ inline DiagDirection GetShipDepotDirection(Tile t)
|
|||||||
*/
|
*/
|
||||||
inline TileIndex GetOtherShipDepotTile(Tile t)
|
inline TileIndex GetOtherShipDepotTile(Tile t)
|
||||||
{
|
{
|
||||||
return TileIndex(t) + (GetShipDepotPart(t) != DEPOT_PART_NORTH ? -1 : 1) * TileOffsByAxis(GetShipDepotAxis(t));
|
return TileIndex(t) + (GetShipDepotPart(t) != DepotPart::North ? -1 : 1) * TileOffsByAxis(GetShipDepotAxis(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -304,7 +304,7 @@ inline TileIndex GetShipDepotNorthTile(Tile t)
|
|||||||
*/
|
*/
|
||||||
inline bool IsLock(Tile t)
|
inline bool IsLock(Tile t)
|
||||||
{
|
{
|
||||||
return GetWaterTileType(t) == WATER_TILE_LOCK;
|
return GetWaterTileType(t) == WaterTileType::Lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -384,13 +384,13 @@ inline void MakeShore(Tile t)
|
|||||||
{
|
{
|
||||||
SetTileType(t, MP_WATER);
|
SetTileType(t, MP_WATER);
|
||||||
SetTileOwner(t, OWNER_WATER);
|
SetTileOwner(t, OWNER_WATER);
|
||||||
SetWaterClass(t, WATER_CLASS_SEA);
|
SetWaterClass(t, WaterClass::Sea);
|
||||||
SetDockingTile(t, false);
|
SetDockingTile(t, false);
|
||||||
t.m2() = 0;
|
t.m2() = 0;
|
||||||
t.m3() = 0;
|
t.m3() = 0;
|
||||||
t.m4() = 0;
|
t.m4() = 0;
|
||||||
t.m5() = 0;
|
t.m5() = 0;
|
||||||
SetWaterTileType(t, WATER_TILE_COAST);
|
SetWaterTileType(t, WaterTileType::Coast);
|
||||||
SB(t.m6(), 2, 6, 0);
|
SB(t.m6(), 2, 6, 0);
|
||||||
t.m7() = 0;
|
t.m7() = 0;
|
||||||
t.m8() = 0;
|
t.m8() = 0;
|
||||||
@@ -413,7 +413,7 @@ inline void MakeWater(Tile t, Owner o, WaterClass wc, uint8_t random_bits)
|
|||||||
t.m3() = 0;
|
t.m3() = 0;
|
||||||
t.m4() = random_bits;
|
t.m4() = random_bits;
|
||||||
t.m5() = 0;
|
t.m5() = 0;
|
||||||
SetWaterTileType(t, WATER_TILE_CLEAR);
|
SetWaterTileType(t, WaterTileType::Clear);
|
||||||
SB(t.m6(), 2, 6, 0);
|
SB(t.m6(), 2, 6, 0);
|
||||||
t.m7() = 0;
|
t.m7() = 0;
|
||||||
t.m8() = 0;
|
t.m8() = 0;
|
||||||
@@ -425,7 +425,7 @@ inline void MakeWater(Tile t, Owner o, WaterClass wc, uint8_t random_bits)
|
|||||||
*/
|
*/
|
||||||
inline void MakeSea(Tile t)
|
inline void MakeSea(Tile t)
|
||||||
{
|
{
|
||||||
MakeWater(t, OWNER_WATER, WATER_CLASS_SEA, 0);
|
MakeWater(t, OWNER_WATER, WaterClass::Sea, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -435,7 +435,7 @@ inline void MakeSea(Tile t)
|
|||||||
*/
|
*/
|
||||||
inline void MakeRiver(Tile t, uint8_t random_bits)
|
inline void MakeRiver(Tile t, uint8_t random_bits)
|
||||||
{
|
{
|
||||||
MakeWater(t, OWNER_WATER, WATER_CLASS_RIVER, random_bits);
|
MakeWater(t, OWNER_WATER, WaterClass::River, random_bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -447,7 +447,7 @@ inline void MakeRiver(Tile t, uint8_t random_bits)
|
|||||||
inline void MakeCanal(Tile t, Owner o, uint8_t random_bits)
|
inline void MakeCanal(Tile t, Owner o, uint8_t random_bits)
|
||||||
{
|
{
|
||||||
assert(o != OWNER_WATER);
|
assert(o != OWNER_WATER);
|
||||||
MakeWater(t, o, WATER_CLASS_CANAL, random_bits);
|
MakeWater(t, o, WaterClass::Canal, random_bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -455,7 +455,7 @@ inline void MakeCanal(Tile t, Owner o, uint8_t random_bits)
|
|||||||
* @param t Tile to place the ship depot section.
|
* @param t Tile to place the ship depot section.
|
||||||
* @param o Owner of the depot.
|
* @param o Owner of the depot.
|
||||||
* @param did Depot ID.
|
* @param did Depot ID.
|
||||||
* @param part Depot part (either #DEPOT_PART_NORTH or #DEPOT_PART_SOUTH).
|
* @param part Depot part (either #DepotPart::North or #DepotPart::South).
|
||||||
* @param a Axis of the depot.
|
* @param a Axis of the depot.
|
||||||
* @param original_water_class Original water class.
|
* @param original_water_class Original water class.
|
||||||
*/
|
*/
|
||||||
@@ -468,8 +468,8 @@ inline void MakeShipDepot(Tile t, Owner o, DepotID did, DepotPart part, Axis a,
|
|||||||
t.m2() = did.base();
|
t.m2() = did.base();
|
||||||
t.m3() = 0;
|
t.m3() = 0;
|
||||||
t.m4() = 0;
|
t.m4() = 0;
|
||||||
t.m5() = part << WBL_DEPOT_PART | a << WBL_DEPOT_AXIS;
|
t.m5() = to_underlying(part) << WBL_DEPOT_PART | a << WBL_DEPOT_AXIS;
|
||||||
SetWaterTileType(t, WATER_TILE_DEPOT);
|
SetWaterTileType(t, WaterTileType::Depot);
|
||||||
SB(t.m6(), 2, 6, 0);
|
SB(t.m6(), 2, 6, 0);
|
||||||
t.m7() = 0;
|
t.m7() = 0;
|
||||||
t.m8() = 0;
|
t.m8() = 0;
|
||||||
@@ -493,8 +493,8 @@ inline void MakeLockTile(Tile t, Owner o, LockPart part, DiagDirection dir, Wate
|
|||||||
t.m2() = 0;
|
t.m2() = 0;
|
||||||
t.m3() = 0;
|
t.m3() = 0;
|
||||||
t.m4() = 0;
|
t.m4() = 0;
|
||||||
t.m5() = part << WBL_LOCK_PART_BEGIN | dir << WBL_LOCK_ORIENT_BEGIN;
|
t.m5() = to_underlying(part) << WBL_LOCK_PART_BEGIN | dir << WBL_LOCK_ORIENT_BEGIN;
|
||||||
SetWaterTileType(t, WATER_TILE_LOCK);
|
SetWaterTileType(t, WaterTileType::Lock);
|
||||||
SB(t.m6(), 2, 6, 0);
|
SB(t.m6(), 2, 6, 0);
|
||||||
t.m7() = 0;
|
t.m7() = 0;
|
||||||
t.m8() = 0;
|
t.m8() = 0;
|
||||||
@@ -517,9 +517,9 @@ inline void MakeLock(Tile t, Owner o, DiagDirection d, WaterClass wc_lower, Wate
|
|||||||
|
|
||||||
/* Keep the current waterclass and owner for the tiles.
|
/* Keep the current waterclass and owner for the tiles.
|
||||||
* It allows to restore them after the lock is deleted */
|
* It allows to restore them after the lock is deleted */
|
||||||
MakeLockTile(t, o, LOCK_PART_MIDDLE, d, wc_middle);
|
MakeLockTile(t, o, LockPart::Middle, d, wc_middle);
|
||||||
MakeLockTile(lower_tile, IsWaterTile(lower_tile) ? GetTileOwner(lower_tile) : o, LOCK_PART_LOWER, d, wc_lower);
|
MakeLockTile(lower_tile, IsWaterTile(lower_tile) ? GetTileOwner(lower_tile) : o, LockPart::Lower, d, wc_lower);
|
||||||
MakeLockTile(upper_tile, IsWaterTile(upper_tile) ? GetTileOwner(upper_tile) : o, LOCK_PART_UPPER, d, wc_upper);
|
MakeLockTile(upper_tile, IsWaterTile(upper_tile) ? GetTileOwner(upper_tile) : o, LockPart::Upper, d, wc_upper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user