Codechange: enum-class-ify Commands

This commit is contained in:
Rubidium
2026-01-15 22:30:11 +01:00
committed by rubidium42
parent 014bf7e750
commit 4adf494ebc
139 changed files with 890 additions and 890 deletions
+11 -11
View File
@@ -350,7 +350,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlags flags, RoadBits pie
if (!IsTileType(tile, TileType::Road)) {
/* If it's the last roadtype, just clear the whole tile */
if (GetRoadType(tile, OtherRoadTramType(rtt)) == INVALID_ROADTYPE) return Command<CMD_LANDSCAPE_CLEAR>::Do(flags, tile);
if (GetRoadType(tile, OtherRoadTramType(rtt)) == INVALID_ROADTYPE) return Command<Commands::LandscapeClear>::Do(flags, tile);
CommandCost cost(EXPENSES_CONSTRUCTION);
if (IsTileType(tile, TileType::TunnelBridge)) {
@@ -805,7 +805,7 @@ do_clear:;
}
if (need_to_clear) {
CommandCost ret = Command<CMD_LANDSCAPE_CLEAR>::Do(flags, tile);
CommandCost ret = Command<Commands::LandscapeClear>::Do(flags, tile);
if (ret.Failed()) return ret;
cost.AddCost(ret.GetCost());
}
@@ -851,7 +851,7 @@ do_clear:;
if (HasPowerOnRoad(rt, existing_rt)) {
rt = existing_rt;
} else if (HasPowerOnRoad(existing_rt, rt)) {
ret = Command<CMD_CONVERT_ROAD>::Do(flags, tile, tile, rt, false);
ret = Command<Commands::ConvertRoad>::Do(flags, tile, tile, rt, false);
if (ret.Failed()) return ret;
cost.AddCost(ret.GetCost());
} else {
@@ -1013,7 +1013,7 @@ CommandCost CmdBuildLongRoad(DoCommandFlags flags, TileIndex end_tile, TileIndex
if (tile == start_tile && start_half) bits &= DiagDirToRoadBits(dir);
}
CommandCost ret = Command<CMD_BUILD_ROAD>::Do(flags, tile, bits, rt, drd, TownID::Invalid());
CommandCost ret = Command<Commands::BuildRoad>::Do(flags, tile, bits, rt, drd, TownID::Invalid());
if (!is_ai && ret.GetErrorMessage() == STR_ERROR_ALREADY_BUILT) had_success = true;
if (ret.Failed()) {
last_error = std::move(ret);
@@ -1097,7 +1097,7 @@ std::tuple<CommandCost, Money> CmdRemoveLongRoad(DoCommandFlags flags, TileIndex
if (flags.Test(DoCommandFlag::Execute)) {
money_spent += ret.GetCost();
if (money_spent > 0 && money_spent > money_available) {
return { cost, std::get<0>(Command<CMD_REMOVE_LONG_ROAD>::Do(DoCommandFlags{flags}.Reset(DoCommandFlag::Execute), end_tile, start_tile, rt, axis, start_half, end_half)).GetCost() };
return { cost, std::get<0>(Command<Commands::RemoveRoadLong>::Do(DoCommandFlags{flags}.Reset(DoCommandFlag::Execute), end_tile, start_tile, rt, axis, start_half, end_half)).GetCost() };
}
RemoveRoad(tile, flags, bits, rtt, false);
}
@@ -1164,7 +1164,7 @@ CommandCost CmdBuildRoadDepot(DoCommandFlags flags, TileIndex tile, RoadType rt,
}
if (!rotate_existing_depot) {
cost.AddCost(Command<CMD_LANDSCAPE_CLEAR>::Do(flags, tile));
cost.AddCost(Command<Commands::LandscapeClear>::Do(flags, tile));
if (cost.Failed()) return cost;
if (IsBridgeAbove(tile)) return CommandCost(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
@@ -1255,7 +1255,7 @@ static CommandCost ClearTile_Road(TileIndex tile, DoCommandFlags flags)
}
if (flags.Test(DoCommandFlag::Execute)) {
Command<CMD_LANDSCAPE_CLEAR>::Do(flags, tile);
Command<Commands::LandscapeClear>::Do(flags, tile);
}
return ret;
}
@@ -2315,7 +2315,7 @@ static void ChangeTileOwner_Road(TileIndex tile, Owner old_owner, Owner new_owne
if (IsRoadDepot(tile)) {
if (GetTileOwner(tile) == old_owner) {
if (new_owner == INVALID_OWNER) {
Command<CMD_LANDSCAPE_CLEAR>::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile);
Command<Commands::LandscapeClear>::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile);
} else {
/* A road depot has two road bits. No need to dirty windows here, we'll redraw the whole screen anyway. */
RoadType rt = GetRoadTypeRoad(tile);
@@ -2352,7 +2352,7 @@ static void ChangeTileOwner_Road(TileIndex tile, Owner old_owner, Owner new_owne
if (IsLevelCrossing(tile)) {
if (GetTileOwner(tile) == old_owner) {
if (new_owner == INVALID_OWNER) {
Command<CMD_REMOVE_SINGLE_RAIL>::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile, GetCrossingRailTrack(tile));
Command<Commands::RemoveRail>::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile, GetCrossingRailTrack(tile));
} else {
/* Update infrastructure counts. No need to dirty windows here, we'll redraw the whole screen anyway. */
Company::Get(old_owner)->infrastructure.rail[GetRailType(tile)] -= LEVELCROSSING_TRACKBIT_FACTOR;
@@ -2400,7 +2400,7 @@ static CommandCost TerraformTile_Road(TileIndex tile, DoCommandFlags flags, int
}
}
return Command<CMD_LANDSCAPE_CLEAR>::Do(flags, tile);
return Command<Commands::LandscapeClear>::Do(flags, tile);
}
/**
@@ -2649,7 +2649,7 @@ CommandCost CmdConvertRoad(DoCommandFlags flags, TileIndex tile, TileIndex area_
static CommandCost CheckBuildAbove_Road(TileIndex tile, DoCommandFlags flags, Axis, int)
{
if (!IsRoadDepot(tile)) return CommandCost();
return Command<CMD_LANDSCAPE_CLEAR>::Do(flags, tile);
return Command<Commands::LandscapeClear>::Do(flags, tile);
}
/** Tile callback functions for road tiles */