diff options
author | Michael Lutz <michi@icosahedron.de> | 2021-10-30 01:31:46 +0200 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2021-12-16 22:28:32 +0100 |
commit | e740c24eb7a90bc771f5976d64d80639ee7576e5 (patch) | |
tree | b3c8f0c87419cb11c106ba1cb58d6ae0648beef4 /src/station_cmd.cpp | |
parent | c88b104ec662ea80bec89f58aa7ad9d0baac7704 (diff) | |
download | openttd-e740c24eb7a90bc771f5976d64d80639ee7576e5.tar.xz |
Codechange: Template DoCommand to automagically reflect the parameters of the command proc.
When finished, this will allow each command handler to take individually
different parameters, obliviating the need for bit-packing.
Diffstat (limited to 'src/station_cmd.cpp')
-rw-r--r-- | src/station_cmd.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index f53523bc3..33f86146c 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -58,6 +58,8 @@ #include "tunnelbridge_map.h" #include "station_cmd.h" #include "waypoint_cmd.h" +#include "landscape_cmd.h" +#include "rail_cmd.h" #include "table/strings.h" @@ -843,7 +845,7 @@ static CommandCost CheckFlatLandAirport(AirportTileTableIterator tile_iter, DoCo if (ret.Failed()) return ret; cost.AddCost(ret); - ret = DoCommand(flags, CMD_LANDSCAPE_CLEAR, tile_iter, 0, 0); + ret = Command<CMD_LANDSCAPE_CLEAR>::Do(flags, tile_iter, 0, 0, {}); if (ret.Failed()) return ret; cost.AddCost(ret); } @@ -923,14 +925,14 @@ static CommandCost CheckFlatLandRailStation(TileArea tile_area, DoCommandFlag fl affected_vehicles.push_back(v); } } - CommandCost ret = DoCommand(flags, CMD_REMOVE_SINGLE_RAIL, tile_cur, 0, track); + CommandCost ret = Command<CMD_REMOVE_SINGLE_RAIL>::Do(flags, tile_cur, 0, track, {}); if (ret.Failed()) return ret; cost.AddCost(ret); /* With flags & ~DC_EXEC CmdLandscapeClear would fail since the rail still exists */ continue; } } - ret = DoCommand(flags, CMD_LANDSCAPE_CLEAR, tile_cur, 0, 0); + ret = Command<CMD_LANDSCAPE_CLEAR>::Do(flags, tile_cur, 0, 0, {}); if (ret.Failed()) return ret; cost.AddCost(ret); } @@ -1048,7 +1050,7 @@ static CommandCost CheckFlatLandRoadStop(TileArea tile_area, DoCommandFlag flags cost.AddCost(RoadBuildCost(rt) * 2); } } else { - ret = DoCommand(flags, CMD_LANDSCAPE_CLEAR, cur_tile, 0, 0); + ret = Command<CMD_LANDSCAPE_CLEAR>::Do(flags, cur_tile, 0, 0, {}); if (ret.Failed()) return ret; cost.AddCost(ret); cost.AddCost(RoadBuildCost(rt) * 2); @@ -1754,7 +1756,7 @@ static CommandCost RemoveRailStation(TileIndex tile, DoCommandFlag flags) { /* if there is flooding, remove platforms tile by tile */ if (_current_company == OWNER_WATER) { - return DoCommand(DC_EXEC, CMD_REMOVE_FROM_RAIL_STATION, tile, 0, 0); + return Command<CMD_REMOVE_FROM_RAIL_STATION>::Do(DC_EXEC, tile, 0, 0, {}); } Station *st = Station::GetByTile(tile); @@ -1775,7 +1777,7 @@ static CommandCost RemoveRailWaypoint(TileIndex tile, DoCommandFlag flags) { /* if there is flooding, remove waypoints tile by tile */ if (_current_company == OWNER_WATER) { - return DoCommand(DC_EXEC, CMD_REMOVE_FROM_RAIL_WAYPOINT, tile, 0, 0); + return Command<CMD_REMOVE_FROM_RAIL_WAYPOINT>::Do(DC_EXEC, tile, 0, 0, {}); } return RemoveRailStation(Waypoint::GetByTile(tile), flags, _price[PR_CLEAR_WAYPOINT_RAIL]); @@ -2537,7 +2539,7 @@ CommandCost CmdBuildDock(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32 if (IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST); CommandCost cost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_STATION_DOCK]); - ret = DoCommand(flags, CMD_LANDSCAPE_CLEAR, tile, 0, 0); + ret = Command<CMD_LANDSCAPE_CLEAR>::Do(flags, tile, 0, 0, {}); if (ret.Failed()) return ret; cost.AddCost(ret); @@ -2552,7 +2554,7 @@ CommandCost CmdBuildDock(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32 /* Get the water class of the water tile before it is cleared.*/ WaterClass wc = GetWaterClass(tile_cur); - ret = DoCommand(flags, CMD_LANDSCAPE_CLEAR, tile_cur, 0, 0); + ret = Command<CMD_LANDSCAPE_CLEAR>::Do(flags, tile_cur, 0, 0, {}); if (ret.Failed()) return ret; tile_cur += TileOffsByDiagDir(direction); @@ -4242,12 +4244,12 @@ static void ChangeTileOwner_Station(TileIndex tile, Owner old_owner, Owner new_o } else { if (IsDriveThroughStopTile(tile)) { /* Remove the drive-through road stop */ - DoCommand(DC_EXEC | DC_BANKRUPT, CMD_REMOVE_ROAD_STOP, tile, 1 | 1 << 8, (GetStationType(tile) == STATION_TRUCK) ? ROADSTOP_TRUCK : ROADSTOP_BUS); + Command<CMD_REMOVE_ROAD_STOP>::Do(DC_EXEC | DC_BANKRUPT, tile, 1 | 1 << 8, (GetStationType(tile) == STATION_TRUCK) ? ROADSTOP_TRUCK : ROADSTOP_BUS, {}); assert(IsTileType(tile, MP_ROAD)); /* Change owner of tile and all roadtypes */ ChangeTileOwner(tile, old_owner, new_owner); } else { - DoCommand(DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR, tile, 0, 0); + Command<CMD_LANDSCAPE_CLEAR>::Do(DC_EXEC | DC_BANKRUPT, tile, 0, 0, {}); /* Set tile owner of water under (now removed) buoy and dock to OWNER_NONE. * Update owner of buoy if it was not removed (was in orders). * Do not update when owned by OWNER_WATER (sea and rivers). */ @@ -4364,7 +4366,7 @@ static CommandCost TerraformTile_Station(TileIndex tile, DoCommandFlag flags, in } } } - return DoCommand(flags, CMD_LANDSCAPE_CLEAR, tile, 0, 0); + return Command<CMD_LANDSCAPE_CLEAR>::Do(flags, tile, 0, 0, {}); } /** |