diff options
author | Michael Lutz <michi@icosahedron.de> | 2021-10-10 17:20:27 +0200 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2021-12-16 22:28:32 +0100 |
commit | 4fc055d6e97e76faf53ff3f29e36a4a4549bf6e7 (patch) | |
tree | 2b9bb9cd8df023fc41163a39d88cfb9f3c9f0f7e | |
parent | 123c7f99c342aa9eb7ca505f0b49257fc8eee7ff (diff) | |
download | openttd-4fc055d6e97e76faf53ff3f29e36a4a4549bf6e7.tar.xz |
Codechange: Align parameter order of command callbacks to command handlers.
-rw-r--r-- | src/ai/ai_instance.cpp | 5 | ||||
-rw-r--r-- | src/airport_gui.cpp | 2 | ||||
-rw-r--r-- | src/bridge_gui.cpp | 5 | ||||
-rw-r--r-- | src/command.cpp | 2 | ||||
-rw-r--r-- | src/command_type.h | 4 | ||||
-rw-r--r-- | src/depot_gui.cpp | 5 | ||||
-rw-r--r-- | src/dock_gui.cpp | 4 | ||||
-rw-r--r-- | src/game/game_instance.cpp | 5 | ||||
-rw-r--r-- | src/group_gui.cpp | 12 | ||||
-rw-r--r-- | src/industry_gui.cpp | 5 | ||||
-rw-r--r-- | src/main_gui.cpp | 2 | ||||
-rw-r--r-- | src/rail_gui.cpp | 8 | ||||
-rw-r--r-- | src/road_gui.cpp | 14 | ||||
-rw-r--r-- | src/signs_cmd.cpp | 5 | ||||
-rw-r--r-- | src/terraform_gui.cpp | 2 | ||||
-rw-r--r-- | src/town_gui.cpp | 4 | ||||
-rw-r--r-- | src/train_gui.cpp | 5 | ||||
-rw-r--r-- | src/vehicle_gui.cpp | 9 |
18 files changed, 57 insertions, 41 deletions
diff --git a/src/ai/ai_instance.cpp b/src/ai/ai_instance.cpp index da79d7c13..509ed70d2 100644 --- a/src/ai/ai_instance.cpp +++ b/src/ai/ai_instance.cpp @@ -93,12 +93,13 @@ ScriptInfo *AIInstance::FindLibrary(const char *library, int version) /** * DoCommand callback function for all commands executed by AIs. * @param result The result of the command. + * @param cmd cmd as given to DoCommandPInternal. * @param tile The tile on which the command was executed. * @param p1 p1 as given to DoCommandPInternal. * @param p2 p2 as given to DoCommandPInternal. - * @param cmd cmd as given to DoCommandPInternal. + * @param text text as given to DoCommandPInternal. */ -void CcAI(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd) +void CcAI(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) { /* * The company might not exist anymore. Check for this. diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index ca3d8aa71..41fde9b8c 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -41,7 +41,7 @@ static void ShowBuildAirportPicker(Window *parent); SpriteID GetCustomAirportSprite(const AirportSpec *as, byte layout); -void CcBuildAirport(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd) +void CcBuildAirport(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) { if (result.Failed()) return; diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index d5347989e..3524b357c 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -50,15 +50,16 @@ typedef GUIList<BuildBridgeData> GUIBridgeList; ///< List of bridges, used in #B * Callback executed after a build Bridge CMD has been called * * @param result Whether the build succeeded + * @param cmd unused * @param end_tile End tile of the bridge. * @param p1 packed start tile coords (~ dx) * @param p2 various bitstuffed elements * - p2 = (bit 0- 7) - bridge type (hi bh) * - p2 = (bit 8-13) - rail type or road types. * - p2 = (bit 15-16) - transport type. - * @param cmd unused + * @param text unused */ -void CcBuildBridge(const CommandCost &result, TileIndex end_tile, uint32 p1, uint32 p2, Commands cmd) +void CcBuildBridge(const CommandCost &result, Commands cmd, TileIndex end_tile, uint32 p1, uint32 p2, const std::string &text) { if (result.Failed()) return; if (_settings_client.sound.confirm) SndPlayTileFx(SND_27_CONSTRUCTION_BRIDGE, end_tile); diff --git a/src/command.cpp b/src/command.cpp index fccbe6148..001f2ee7d 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -318,7 +318,7 @@ static bool DoCommandP(Commands cmd, StringID err_message, CommandCallback *call } if (!estimate_only && !only_sending && callback != nullptr) { - callback(res, tile, p1, p2, cmd); + callback(res, cmd, tile, p1, p2, text); } return res.Succeeded(); diff --git a/src/command_type.h b/src/command_type.h index 2bd0fee90..fa381ce13 100644 --- a/src/command_type.h +++ b/src/command_type.h @@ -443,12 +443,14 @@ template <Commands Tcmd> struct CommandTraits; * command succeeded or failed. * * @param result The result of the executed command + * @param cmd The command that was executed * @param tile The tile of the command action * @param p1 Additional data of the command * @param p1 Additional data of the command + * @param text Text of the command * @see CommandProc */ -typedef void CommandCallback(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd); +typedef void CommandCallback(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text); /** * Structure for buffering the build command when selecting a station to join. diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 8515258f0..0aba48e40 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -112,12 +112,13 @@ extern void DepotSortList(VehicleList *list); /** * This is the Callback method after the cloning attempt of a vehicle * @param result the result of the cloning command + * @param cmd unused * @param tile unused * @param p1 unused * @param p2 unused - * @param cmd unused + * @param text unused */ -void CcCloneVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd) +void CcCloneVehicle(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) { if (result.Failed()) return; diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index 0ba34e211..52b148381 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -40,7 +40,7 @@ static void ShowBuildDocksDepotPicker(Window *parent); static Axis _ship_depot_direction; -void CcBuildDocks(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd) +void CcBuildDocks(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) { if (result.Failed()) return; @@ -48,7 +48,7 @@ void CcBuildDocks(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); } -void CcPlaySound_CONSTRUCTION_WATER(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd) +void CcPlaySound_CONSTRUCTION_WATER(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) { if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_02_CONSTRUCTION_WATER, tile); } diff --git a/src/game/game_instance.cpp b/src/game/game_instance.cpp index abd054115..47374525f 100644 --- a/src/game/game_instance.cpp +++ b/src/game/game_instance.cpp @@ -82,12 +82,13 @@ void GameInstance::Died() /** * DoCommand callback function for all commands executed by Game Scripts. * @param result The result of the command. + * @param cmd cmd as given to DoCommandPInternal. * @param tile The tile on which the command was executed. * @param p1 p1 as given to DoCommandPInternal. * @param p2 p2 as given to DoCommandPInternal. - * @param cmd cmd as given to DoCommandPInternal. + * @param text text as given to DoCommandPInternal. */ -void CcGame(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd) +void CcGame(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) { if (Game::GetGameInstance()->DoCommandCallback(result, tile, p1, p2, cmd)) { Game::GetGameInstance()->Continue(); diff --git a/src/group_gui.cpp b/src/group_gui.cpp index f72d9d2d6..e9ded9536 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -1141,13 +1141,14 @@ static inline VehicleGroupWindow *FindVehicleGroupWindow(VehicleType vt, Owner o /** * Opens a 'Rename group' window for newly created group. * @param result Did command succeed? + * @param cmd Unused. * @param tile Unused. * @param p1 Vehicle type. * @param p2 Unused. - * @param cmd Unused. + * @param text Unused. * @see CmdCreateGroup */ -void CcCreateGroup(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd) +void CcCreateGroup(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) { if (result.Failed()) return; assert(p1 <= VEH_AIRCRAFT); @@ -1159,17 +1160,18 @@ void CcCreateGroup(const CommandCost &result, TileIndex tile, uint32 p1, uint32 /** * Open rename window after adding a vehicle to a new group via drag and drop. * @param result Did command succeed? + * @param cmd Unused. * @param tile Unused. * @param p1 Unused. * @param p2 Bit 0-19: Vehicle ID. - * @param cmd Unused. + * @param text Unused. */ -void CcAddVehicleNewGroup(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd) +void CcAddVehicleNewGroup(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) { if (result.Failed()) return; assert(Vehicle::IsValidID(GB(p2, 0, 20))); - CcCreateGroup(result, 0, Vehicle::Get(GB(p2, 0, 20))->type, 0, cmd); + CcCreateGroup(result, cmd, 0, Vehicle::Get(GB(p2, 0, 20))->type, 0, text); } /** diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index cfdd2c6ca..5aea6f59a 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -219,12 +219,13 @@ void SortIndustryTypes() /** * Command callback. In case of failure to build an industry, show an error message. * @param result Result of the command. + * @param cmd Unused. * @param tile Tile where the industry is placed. * @param p1 Additional data of the #CMD_BUILD_INDUSTRY command. * @param p2 Additional data of the #CMD_BUILD_INDUSTRY command. - * @param cmd Unused. + * @param text Unused. */ -void CcBuildIndustry(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd) +void CcBuildIndustry(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) { if (result.Succeeded()) return; diff --git a/src/main_gui.cpp b/src/main_gui.cpp index d521f79d1..a4bec45d5 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -76,7 +76,7 @@ bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyl } -void CcPlaySound_EXPLOSION(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd) +void CcPlaySound_EXPLOSION(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) { if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_12_EXPLOSION, tile); } diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 54bef88fd..7cf1b0059 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -85,7 +85,7 @@ static bool IsStationAvailable(const StationSpec *statspec) return Convert8bitBooleanCallback(statspec->grf_prop.grffile, CBID_STATION_AVAILABILITY, cb_res); } -void CcPlaySound_CONSTRUCTION_RAIL(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd) +void CcPlaySound_CONSTRUCTION_RAIL(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) { if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile); } @@ -128,7 +128,7 @@ static const DiagDirection _place_depot_extra_dir[12] = { DIAGDIR_NW, DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_NE, }; -void CcRailDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd) +void CcRailDepot(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) { if (result.Failed()) return; @@ -169,7 +169,7 @@ static void PlaceRail_Waypoint(TileIndex tile) } } -void CcStation(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd) +void CcStation(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) { if (result.Failed()) return; @@ -276,7 +276,7 @@ static void PlaceRail_Bridge(TileIndex tile, Window *w) } /** Command callback for building a tunnel */ -void CcBuildRailTunnel(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd) +void CcBuildRailTunnel(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) { if (result.Succeeded()) { if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile); diff --git a/src/road_gui.cpp b/src/road_gui.cpp index bdd4353ca..eedcc8f59 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -66,7 +66,7 @@ static RoadType _cur_roadtype; static DiagDirection _road_depot_orientation; static DiagDirection _road_station_picker_orientation; -void CcPlaySound_CONSTRUCTION_OTHER(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd) +void CcPlaySound_CONSTRUCTION_OTHER(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) { if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile); } @@ -90,13 +90,14 @@ static void PlaceRoad_Bridge(TileIndex tile, Window *w) * Callback executed after a build road tunnel command has been called. * * @param result Whether the build succeeded. + * @param cmd unused * @param start_tile Starting tile of the tunnel. * @param p1 bit 0-3 railtype or roadtypes * bit 8-9 transport type * @param p2 unused - * @param cmd unused + * @param text unused */ -void CcBuildRoadTunnel(const CommandCost &result, TileIndex start_tile, uint32 p1, uint32 p2, Commands cmd) +void CcBuildRoadTunnel(const CommandCost &result, Commands cmd, TileIndex start_tile, uint32 p1, uint32 p2, const std::string &text) { if (result.Succeeded()) { if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, start_tile); @@ -129,7 +130,7 @@ void ConnectRoadToStructure(TileIndex tile, DiagDirection direction) } } -void CcRoadDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd) +void CcRoadDepot(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) { if (result.Failed()) return; @@ -142,6 +143,7 @@ void CcRoadDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2 /** * Command callback for building road stops. * @param result Result of the build road stop command. + * @param cmd Unused. * @param tile Start tile. * @param p1 bit 0..7: Width of the road stop. * bit 8..15: Length of the road stop. @@ -152,10 +154,10 @@ void CcRoadDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2 * bit 3: #Axis of the road for drive-through stops. * bit 5..9: The roadtype. * bit 16..31: Station ID to join (NEW_STATION if build new one). - * @param cmd Unused. + * @param text Unused. * @see CmdBuildRoadStop */ -void CcRoadStop(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd) +void CcRoadStop(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) { if (result.Failed()) return; diff --git a/src/signs_cmd.cpp b/src/signs_cmd.cpp index c025b1042..cf742df83 100644 --- a/src/signs_cmd.cpp +++ b/src/signs_cmd.cpp @@ -110,12 +110,13 @@ CommandCost CmdRenameSign(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32 /** * Callback function that is called after a sign is placed * @param result of the operation + * @param cmd unused * @param tile unused * @param p1 unused * @param p2 unused - * @param cmd unused + * @param text unused */ -void CcPlaceSign(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd) +void CcPlaceSign(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) { if (result.Failed()) return; diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index a55833279..498d057aa 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -41,7 +41,7 @@ #include "safeguards.h" -void CcTerraform(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd) +void CcTerraform(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) { if (result.Succeeded()) { if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile); diff --git a/src/town_gui.cpp b/src/town_gui.cpp index 9e1ba3968..660b1ac98 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -1008,7 +1008,7 @@ void ShowTownDirectory() new TownDirectoryWindow(&_town_directory_desc); } -void CcFoundTown(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd) +void CcFoundTown(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) { if (result.Failed()) return; @@ -1016,7 +1016,7 @@ void CcFoundTown(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2 if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); } -void CcFoundRandomTown(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd) +void CcFoundRandomTown(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) { if (result.Succeeded()) ScrollMainWindowToTile(Town::Get(_new_town_id)->xy); } diff --git a/src/train_gui.cpp b/src/train_gui.cpp index a630c9fbd..7031a8968 100644 --- a/src/train_gui.cpp +++ b/src/train_gui.cpp @@ -22,12 +22,13 @@ /** * Callback for building wagons. * @param result The result of the command. + * @param cmd Unused. * @param tile The tile the command was executed on. * @param p1 Additional data for the command (for the #CommandProc) * @param p2 Additional data for the command (for the #CommandProc) - * @param cmd Unused. + * @param text Unused. */ -void CcBuildWagon(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd) +void CcBuildWagon(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) { if (result.Failed()) return; diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index abe1b9dd9..cac1985b9 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -2616,11 +2616,13 @@ static const StringID _vehicle_msg_translation_table[][4] = { /** * This is the Callback method after attempting to start/stop a vehicle * @param result the result of the start/stop command + * @param cmd unused * @param tile unused * @param p1 vehicle ID * @param p2 unused + * @param text unused */ -void CcStartStopVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd) +void CcStartStopVehicle(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) { if (result.Failed()) return; @@ -3119,12 +3121,13 @@ void StopGlobalFollowVehicle(const Vehicle *v) /** * This is the Callback method after the construction attempt of a primary vehicle * @param result indicates completion (or not) of the operation + * @param cmd unused * @param tile unused * @param p1 unused * @param p2 unused - * @param cmd unused + * @param text unused */ -void CcBuildPrimaryVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd) +void CcBuildPrimaryVehicle(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) { if (result.Failed()) return; |