diff options
Diffstat (limited to 'src')
31 files changed, 96 insertions, 75 deletions
diff --git a/src/ai/ai_instance.cpp b/src/ai/ai_instance.cpp index 576a81637..e137745f1 100644 --- a/src/ai/ai_instance.cpp +++ b/src/ai/ai_instance.cpp @@ -113,7 +113,7 @@ void CcAI(Commands cmd, const CommandCost &result, TileIndex tile, const Command } } -CommandCallback *AIInstance::GetDoCommandCallback() +CommandCallbackData *AIInstance::GetDoCommandCallback() { return &CcAI; } diff --git a/src/ai/ai_instance.hpp b/src/ai/ai_instance.hpp index f8d2100b1..2cdabd991 100644 --- a/src/ai/ai_instance.hpp +++ b/src/ai/ai_instance.hpp @@ -29,7 +29,7 @@ public: private: void RegisterAPI() override; void Died() override; - CommandCallback *GetDoCommandCallback() override; + CommandCallbackData *GetDoCommandCallback() override; void LoadDummyScript() override; }; diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index 5efbb98a3..6700cd3bd 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -43,7 +43,7 @@ static void ShowBuildAirportPicker(Window *parent); SpriteID GetCustomAirportSprite(const AirportSpec *as, byte layout); -void CcBuildAirport(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &) +void CcBuildAirport(Commands cmd, const CommandCost &result, TileIndex tile) { if (result.Failed()) return; diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index 77261932b..99628e75c 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -53,15 +53,14 @@ typedef GUIList<BuildBridgeData> GUIBridgeList; ///< List of bridges, used in #B * @param result Whether the build succeeded * @param cmd unused * @param end_tile End tile of the bridge. - * @param data Additional bitstuffed command data. + * @param tile_start start tile + * @param transport_type transport type. */ -void CcBuildBridge(Commands cmd, const CommandCost &result, TileIndex end_tile, const CommandDataBuffer &data) +void CcBuildBridge(Commands cmd, const CommandCost &result, TileIndex end_tile, TileIndex tile_start, TransportType transport_type, BridgeType, byte) { if (result.Failed()) return; if (_settings_client.sound.confirm) SndPlayTileFx(SND_27_CONSTRUCTION_BRIDGE, end_tile); - auto [tile, tile_start, transport_type, bridge_type, road_rail_type] = EndianBufferReader::ToValue<CommandTraits<CMD_BUILD_BRIDGE>::Args>(data); - if (transport_type == TRANSPORT_ROAD) { DiagDirection end_direction = ReverseDiagDir(GetTunnelBridgeDirection(end_tile)); ConnectRoadToStructure(end_tile, end_direction); diff --git a/src/command_func.h b/src/command_func.h index 1793812a2..9219fd2b5 100644 --- a/src/command_func.h +++ b/src/command_func.h @@ -284,7 +284,16 @@ protected: InternalPostResult(res, tile, estimate_only, only_sending, err_message, my_cmd); if (!estimate_only && !only_sending && callback != nullptr) { - callback(Tcmd, res, tile, EndianBufferWriter<CommandDataBuffer>::FromValue(args)); + if constexpr (std::is_same_v<Tcallback, CommandCallback>) { + /* Callback that doesn't need any command arguments. */ + callback(Tcmd, res, tile); + } else if constexpr (std::is_same_v<Tcallback, CommandCallbackData>) { + /* Generic callback that takes packed arguments as a buffer. */ + callback(Tcmd, res, tile, EndianBufferWriter<CommandDataBuffer>::FromValue(args)); + } else { + /* Callback with arguments. We assume that the tile is only interesting if it actually is in the command arguments. */ + std::apply(callback, std::tuple_cat(std::make_tuple(Tcmd, res), args)); + } } return res.Succeeded(); diff --git a/src/command_type.h b/src/command_type.h index 0424782a2..f607969cc 100644 --- a/src/command_type.h +++ b/src/command_type.h @@ -438,9 +438,23 @@ typedef std::vector<byte> CommandDataBuffer; * @param cmd The command that was executed * @param result The result of the executed command * @param tile The tile of the command action + * @see CommandProc + */ +typedef void CommandCallback(Commands cmd, const CommandCost &result, TileIndex tile); + +/** + * Define a callback function for the client, after the command is finished. + * + * Functions of this type are called after the command is finished. The parameters + * are from the #CommandProc callback type. The boolean parameter indicates if the + * command succeeded or failed. + * + * @param cmd The command that was executed + * @param result The result of the executed command + * @param tile The tile of the command action * @param data Additional data of the command * @see CommandProc */ -typedef void CommandCallback(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &data); +typedef void CommandCallbackData(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &data); #endif /* COMMAND_TYPE_H */ diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 7fd2e0347..c63606582 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -114,11 +114,11 @@ 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 result the result of the cloning command * @param tile unused */ -void CcCloneVehicle(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &) +void CcCloneVehicle(Commands cmd, const CommandCost &result, TileIndex tile) { if (result.Failed()) return; diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index d8cd7c5d4..2ec10fe8c 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -43,7 +43,7 @@ static void ShowBuildDocksDepotPicker(Window *parent); static Axis _ship_depot_direction; -void CcBuildDocks(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &) +void CcBuildDocks(Commands cmd, const CommandCost &result, TileIndex tile) { if (result.Failed()) return; @@ -51,7 +51,7 @@ void CcBuildDocks(Commands cmd, const CommandCost &result, TileIndex tile, const if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); } -void CcPlaySound_CONSTRUCTION_WATER(Commands cmd, const CommandCost &result,TileIndex tile, const CommandDataBuffer &) +void CcPlaySound_CONSTRUCTION_WATER(Commands cmd, const CommandCost &result, TileIndex tile) { 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 8433567c7..fa44ee97c 100644 --- a/src/game/game_instance.cpp +++ b/src/game/game_instance.cpp @@ -93,7 +93,7 @@ void CcGame(Commands cmd, const CommandCost &result, TileIndex tile, const Comma } } -CommandCallback *GameInstance::GetDoCommandCallback() +CommandCallbackData *GameInstance::GetDoCommandCallback() { return &CcGame; } diff --git a/src/game/game_instance.hpp b/src/game/game_instance.hpp index 7b3b12b37..84cb20ac5 100644 --- a/src/game/game_instance.hpp +++ b/src/game/game_instance.hpp @@ -29,7 +29,7 @@ public: private: void RegisterAPI() override; void Died() override; - CommandCallback *GetDoCommandCallback() override; + CommandCallbackData *GetDoCommandCallback() override; void LoadDummyScript() override {} }; diff --git a/src/group_cmd.h b/src/group_cmd.h index 70610de75..d3c25fda1 100644 --- a/src/group_cmd.h +++ b/src/group_cmd.h @@ -41,7 +41,7 @@ DEF_CMD_TRAIT(CMD_REMOVE_ALL_VEHICLES_GROUP, CmdRemoveAllVehiclesGroup, 0, CMDT_ DEF_CMD_TRAIT(CMD_SET_GROUP_FLAG, CmdSetGroupFlag, 0, CMDT_ROUTE_MANAGEMENT) DEF_CMD_TRAIT(CMD_SET_GROUP_LIVERY, CmdSetGroupLivery, 0, CMDT_ROUTE_MANAGEMENT) -CommandCallback CcCreateGroup; -CommandCallback CcAddVehicleNewGroup; +void CcCreateGroup(Commands cmd, const CommandCost &result, VehicleType vt, GroupID parent_group); +void CcAddVehicleNewGroup(Commands cmd, const CommandCost &result, GroupID, VehicleID veh_id, bool); #endif /* GROUP_CMD_H */ diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 3175909f0..f614551f7 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -1153,17 +1153,15 @@ static void CcCreateGroup(VehicleType veh_type) * Opens a 'Rename group' window for newly created group. * @param cmd Unused. * @param result Did command succeed? - * @param tile Unused. - * @param data Command data. + * @param vt Vehicle type. + * @param parent_group Parent group of the enw group. * @see CmdCreateGroup */ -void CcCreateGroup(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &data) +void CcCreateGroup(Commands cmd, const CommandCost &result, VehicleType vt, GroupID parent_group) { if (result.Failed()) return; - auto [vt, parent_group] = EndianBufferReader::ToValue<CommandTraits<CMD_CREATE_GROUP>::Args>(data); assert(vt <= VEH_AIRCRAFT); - CcCreateGroup(vt); } @@ -1171,16 +1169,13 @@ void CcCreateGroup(Commands cmd, const CommandCost &result, TileIndex tile, cons * Open rename window after adding a vehicle to a new group via drag and drop. * @param cmd Unused. * @param result Did command succeed? - * @param tile Unused. - * @param data Command data. + * @param veh_id vehicle to add to a group */ -void CcAddVehicleNewGroup(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &data) +void CcAddVehicleNewGroup(Commands cmd, const CommandCost &result, GroupID, VehicleID veh_id, bool) { if (result.Failed()) return; - auto [group_id, veh_id, shared] = EndianBufferReader::ToValue<CommandTraits<CMD_ADD_VEHICLE_GROUP>::Args>(data); assert(Vehicle::IsValidID(veh_id)); - CcCreateGroup(Vehicle::Get(veh_id)->type); } diff --git a/src/industry_cmd.h b/src/industry_cmd.h index b4d965f64..21d9200a3 100644 --- a/src/industry_cmd.h +++ b/src/industry_cmd.h @@ -23,6 +23,6 @@ CommandCost CmdIndustryCtrl(DoCommandFlag flags, IndustryID ind_id, IndustryActi DEF_CMD_TRAIT(CMD_BUILD_INDUSTRY, CmdBuildIndustry, CMD_DEITY, CMDT_LANDSCAPE_CONSTRUCTION) DEF_CMD_TRAIT(CMD_INDUSTRY_CTRL, CmdIndustryCtrl, CMD_DEITY | CMD_STR_CTRL, CMDT_OTHER_MANAGEMENT) -CommandCallback CcBuildIndustry; +void CcBuildIndustry(Commands cmd, const CommandCost &result, TileIndex tile, IndustryType indtype, uint32, bool, uint32); #endif /* INDUSTRY_CMD_H */ diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 8bd4dc574..cb0e89dbd 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -222,13 +222,12 @@ void SortIndustryTypes() * @param cmd Unused. * @param result Result of the command. * @param tile Tile where the industry is placed. - * @param data Additional data of the #CMD_BUILD_INDUSTRY command. + * @param indtype Industry type. */ -void CcBuildIndustry(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &data) +void CcBuildIndustry(Commands cmd, const CommandCost &result, TileIndex tile, IndustryType indtype, uint32, bool, uint32) { if (result.Succeeded()) return; - auto [tile_, indtype, first_layout, fund, seed] = EndianBufferReader::ToValue<CommandTraits<CMD_BUILD_INDUSTRY>::Args>(data); if (indtype < NUM_INDUSTRYTYPES) { const IndustrySpec *indsp = GetIndustrySpec(indtype); if (indsp->enabled) { diff --git a/src/main_gui.cpp b/src/main_gui.cpp index c25186164..b2c4bfee4 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -77,7 +77,7 @@ bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyl } -void CcPlaySound_EXPLOSION(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &) +void CcPlaySound_EXPLOSION(Commands cmd, const CommandCost &result, TileIndex tile) { if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_12_EXPLOSION, tile); } diff --git a/src/network/network_command.cpp b/src/network/network_command.cpp index 28300310b..7b3721457 100644 --- a/src/network/network_command.cpp +++ b/src/network/network_command.cpp @@ -507,6 +507,13 @@ CommandDataBuffer SanitizeCmdStrings(const CommandDataBuffer &data) return EndianBufferWriter<CommandDataBuffer>::FromValue(args); } + +template <typename T> struct CallbackArgsHelper; +template <typename... Targs> +struct CallbackArgsHelper<void(* const)(Commands, const CommandCost &, Targs...)> { + using Args = std::tuple<std::decay_t<Targs>...>; +}; + /** * Unpack a generic command packet into its actual typed components. * @tparam Tcmd Command type to be unpacked. @@ -517,5 +524,12 @@ template <Commands Tcmd, size_t Tcb> void UnpackNetworkCommand(const CommandPacket* cp) { auto args = EndianBufferReader::ToValue<typename CommandTraits<Tcmd>::Args>(cp->data); - Command<Tcmd>::PostFromNet(cp->err_msg, std::get<Tcb>(_callback_tuple), cp->my_cmd, cp->tile, args); + + /* Check if the callback matches with the command arguments. If not, drop the callback. */ + using Tcallback = std::tuple_element_t<Tcb, decltype(_callback_tuple)>; + if constexpr (std::is_same_v<Tcallback, CommandCallback * const> || std::is_same_v<Tcallback, CommandCallbackData * const> || std::is_same_v<typename CommandTraits<Tcmd>::Args, typename CallbackArgsHelper<Tcallback>::Args>) { + Command<Tcmd>::PostFromNet(cp->err_msg, std::get<Tcb>(_callback_tuple), cp->my_cmd, cp->tile, args); + } else { + Command<Tcmd>::PostFromNet(cp->err_msg, (CommandCallback *)nullptr, cp->my_cmd, cp->tile, args); + } } diff --git a/src/rail_cmd.h b/src/rail_cmd.h index 2299435c2..2a1b69690 100644 --- a/src/rail_cmd.h +++ b/src/rail_cmd.h @@ -38,8 +38,8 @@ DEF_CMD_TRAIT(CMD_BUILD_SIGNAL_TRACK, CmdBuildSignalTrack, CMD_AUTO, DEF_CMD_TRAIT(CMD_REMOVE_SIGNAL_TRACK, CmdRemoveSignalTrack, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION) CommandCallback CcPlaySound_CONSTRUCTION_RAIL; -CommandCallback CcRailDepot; CommandCallback CcStation; CommandCallback CcBuildRailTunnel; +void CcRailDepot(Commands cmd, const CommandCost &result, TileIndex tile, RailType rt, DiagDirection dir); #endif /* RAIL_CMD_H */ diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index bac59d747..bab6b4c55 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -89,7 +89,7 @@ static bool IsStationAvailable(const StationSpec *statspec) return Convert8bitBooleanCallback(statspec->grf_prop.grffile, CBID_STATION_AVAILABILITY, cb_res); } -void CcPlaySound_CONSTRUCTION_RAIL(Commands cmd, const CommandCost &result,TileIndex tile, const CommandDataBuffer &) +void CcPlaySound_CONSTRUCTION_RAIL(Commands cmd, const CommandCost &result, TileIndex tile) { if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile); } @@ -135,12 +135,10 @@ static const DiagDirection _place_depot_extra_dir[12] = { DIAGDIR_NW, DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_NE, }; -void CcRailDepot(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &data) +void CcRailDepot(Commands cmd, const CommandCost &result, TileIndex tile, RailType rt, DiagDirection dir) { if (result.Failed()) return; - auto [tile_, rt, dir] = EndianBufferReader::ToValue<CommandTraits<CMD_BUILD_TRAIN_DEPOT>::Args>(data); - if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile); if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); @@ -176,7 +174,7 @@ static void PlaceRail_Waypoint(TileIndex tile) } } -void CcStation(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &) +void CcStation(Commands cmd, const CommandCost &result, TileIndex tile) { if (result.Failed()) return; @@ -275,7 +273,7 @@ static void PlaceRail_Bridge(TileIndex tile, Window *w) } /** Command callback for building a tunnel */ -void CcBuildRailTunnel(Commands cmd, const CommandCost &result,TileIndex tile, const CommandDataBuffer &) +void CcBuildRailTunnel(Commands cmd, const CommandCost &result, TileIndex tile) { if (result.Succeeded()) { if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile); diff --git a/src/road_cmd.h b/src/road_cmd.h index 3c142bdfe..35903dd7a 100644 --- a/src/road_cmd.h +++ b/src/road_cmd.h @@ -31,7 +31,7 @@ DEF_CMD_TRAIT(CMD_CONVERT_ROAD, CmdConvertRoad, 0, CommandCallback CcPlaySound_CONSTRUCTION_OTHER; CommandCallback CcBuildRoadTunnel; -CommandCallback CcRoadDepot; -CommandCallback CcRoadStop; +void CcRoadDepot(Commands cmd, const CommandCost &result, TileIndex tile, RoadType rt, DiagDirection dir); +void CcRoadStop(Commands cmd, const CommandCost &result, TileIndex tile, uint8 width, uint8 length, RoadStopType, bool is_drive_through, DiagDirection dir, RoadType, StationID, bool); #endif /* ROAD_CMD_H */ diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 1aa0b59ac..275f039ba 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -57,7 +57,7 @@ static RoadType _cur_roadtype; static DiagDirection _road_depot_orientation; static DiagDirection _road_station_picker_orientation; -void CcPlaySound_CONSTRUCTION_OTHER(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &) +void CcPlaySound_CONSTRUCTION_OTHER(Commands cmd, const CommandCost &result, TileIndex tile) { if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile); } @@ -84,7 +84,7 @@ static void PlaceRoad_Bridge(TileIndex tile, Window *w) * @param result Whether the build succeeded. * @param start_tile Starting tile of the tunnel. */ -void CcBuildRoadTunnel(Commands cmd, const CommandCost &result, TileIndex start_tile, const CommandDataBuffer &) +void CcBuildRoadTunnel(Commands cmd, const CommandCost &result, TileIndex start_tile) { if (result.Succeeded()) { if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, start_tile); @@ -117,12 +117,10 @@ void ConnectRoadToStructure(TileIndex tile, DiagDirection direction) } } -void CcRoadDepot(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &data) +void CcRoadDepot(Commands cmd, const CommandCost &result, TileIndex tile, RoadType rt, DiagDirection dir) { if (result.Failed()) return; - auto [tile_, rt, dir] = EndianBufferReader::ToValue<CommandTraits<CMD_BUILD_ROAD_DEPOT>::Args>(data); - if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile); if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); ConnectRoadToStructure(tile, dir); @@ -130,18 +128,19 @@ void CcRoadDepot(Commands cmd, const CommandCost &result, TileIndex tile, const /** * Command callback for building road stops. - * @param result Result of the build road stop command. * @param cmd Unused. + * @param result Result of the build road stop command. * @param tile Start tile. - * @param data Command data. + * @param width Width of the road stop. + * @param length Length of the road stop. + * @param is_drive_through False for normal stops, true for drive-through. + * @param dir Entrance direction (#DiagDirection) for normal stops. Converted to the axis for drive-through stops. * @see CmdBuildRoadStop */ -void CcRoadStop(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &data) +void CcRoadStop(Commands cmd, const CommandCost &result, TileIndex tile, uint8 width, uint8 length, RoadStopType, bool is_drive_through, DiagDirection dir, RoadType, StationID, bool) { if (result.Failed()) return; - auto [tile_, width, length, stop_type, is_drive_through, dir, rt, station_to_join, adjacent] = EndianBufferReader::ToValue<CommandTraits<CMD_BUILD_ROAD_STOP>::Args>(data); - if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile); if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); TileArea roadstop_area(tile, width, length); diff --git a/src/script/api/script_object.cpp b/src/script/api/script_object.cpp index de4fab481..ff109dbdf 100644 --- a/src/script/api/script_object.cpp +++ b/src/script/api/script_object.cpp @@ -296,7 +296,7 @@ ScriptObject::ActiveInstance::~ActiveInstance() return GetStorage()->callback_value[index]; } -/* static */ CommandCallback *ScriptObject::GetDoCommandCallback() +/* static */ CommandCallbackData *ScriptObject::GetDoCommandCallback() { return ScriptObject::GetActiveInstance()->GetDoCommandCallback(); } diff --git a/src/script/api/script_object.hpp b/src/script/api/script_object.hpp index 8d9be14c4..11d9542c8 100644 --- a/src/script/api/script_object.hpp +++ b/src/script/api/script_object.hpp @@ -326,7 +326,7 @@ private: /* Helper functions for DoCommand. */ static std::tuple<bool, bool, bool> DoCommandPrep(); static bool DoCommandProcessResult(const CommandCost &res, Script_SuspendCallbackProc *callback, bool estimate_only); - static CommandCallback *GetDoCommandCallback(); + static CommandCallbackData *GetDoCommandCallback(); }; namespace ScriptObjectInternal { diff --git a/src/script/script_cmd.h b/src/script/script_cmd.h index bf6aa50c7..c1b3a9b23 100644 --- a/src/script/script_cmd.h +++ b/src/script/script_cmd.h @@ -12,7 +12,7 @@ #include "../command_type.h" -CommandCallback CcAI; -CommandCallback CcGame; +CommandCallbackData CcAI; +CommandCallbackData CcGame; #endif /* SCRIPT_CMD_H */ diff --git a/src/script/script_instance.hpp b/src/script/script_instance.hpp index c30fd1499..290568fdd 100644 --- a/src/script/script_instance.hpp +++ b/src/script/script_instance.hpp @@ -235,7 +235,7 @@ protected: /** * Get the callback handling DoCommands in case of networking. */ - virtual CommandCallback *GetDoCommandCallback() = 0; + virtual CommandCallbackData *GetDoCommandCallback() = 0; /** * Load the dummy script. diff --git a/src/signs_cmd.cpp b/src/signs_cmd.cpp index 8d20137b4..f50e37583 100644 --- a/src/signs_cmd.cpp +++ b/src/signs_cmd.cpp @@ -105,14 +105,11 @@ CommandCost CmdRenameSign(DoCommandFlag flags, SignID sign_id, const std::string /** * Callback function that is called after a sign is placed - * @param result of the operation * @param cmd unused + * @param result of the operation * @param tile unused - * @param p1 unused - * @param p2 unused - * @param text unused */ -void CcPlaceSign(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &) +void CcPlaceSign(Commands cmd, const CommandCost &result, TileIndex tile) { if (result.Failed()) return; diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index 2e3fec095..ecdc8a6dd 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -44,7 +44,7 @@ #include "safeguards.h" -void CcTerraform(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &) +void CcTerraform(Commands cmd, const CommandCost &result, TileIndex tile) { 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 90aa58855..0c5f86ab7 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -1009,7 +1009,7 @@ void ShowTownDirectory() new TownDirectoryWindow(&_town_directory_desc); } -void CcFoundTown(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &) +void CcFoundTown(Commands cmd, const CommandCost &result, TileIndex tile) { if (result.Failed()) return; @@ -1017,7 +1017,7 @@ void CcFoundTown(Commands cmd, const CommandCost &result, TileIndex tile, const if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); } -void CcFoundRandomTown(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &) +void CcFoundRandomTown(Commands cmd, const CommandCost &result, TileIndex tile) { if (result.Succeeded()) ScrollMainWindowToTile(Town::Get(_new_town_id)->xy); } diff --git a/src/train_gui.cpp b/src/train_gui.cpp index 268b5b40b..d6c7320e6 100644 --- a/src/train_gui.cpp +++ b/src/train_gui.cpp @@ -26,7 +26,7 @@ * @param result The result of the command. * @param tile The tile the command was executed on. */ -void CcBuildWagon(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &) +void CcBuildWagon(Commands cmd, const CommandCost &result, TileIndex tile) { if (result.Failed()) return; diff --git a/src/tunnelbridge_cmd.h b/src/tunnelbridge_cmd.h index ae924cf69..d49131263 100644 --- a/src/tunnelbridge_cmd.h +++ b/src/tunnelbridge_cmd.h @@ -20,6 +20,6 @@ CommandCost CmdBuildTunnel(DoCommandFlag flags, TileIndex start_tile, TransportT DEF_CMD_TRAIT(CMD_BUILD_BRIDGE, CmdBuildBridge, CMD_DEITY | CMD_AUTO | CMD_NO_WATER, CMDT_LANDSCAPE_CONSTRUCTION) DEF_CMD_TRAIT(CMD_BUILD_TUNNEL, CmdBuildTunnel, CMD_DEITY | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION) -CommandCallback CcBuildBridge; +void CcBuildBridge(Commands cmd, const CommandCost &result, TileIndex end_tile, TileIndex tile_start, TransportType transport_type, BridgeType, byte); #endif /* TUNNELBRIDGE_CMD_H */ diff --git a/src/vehicle_cmd.h b/src/vehicle_cmd.h index b2ad08228..38852347c 100644 --- a/src/vehicle_cmd.h +++ b/src/vehicle_cmd.h @@ -40,7 +40,7 @@ DEF_CMD_TRAIT(CMD_DEPOT_SELL_ALL_VEHICLES, CmdDepotSellAllVehicles, 0, DEF_CMD_TRAIT(CMD_DEPOT_MASS_AUTOREPLACE, CmdDepotMassAutoReplace, 0, CMDT_VEHICLE_CONSTRUCTION) CommandCallback CcBuildPrimaryVehicle; -CommandCallback CcStartStopVehicle; +void CcStartStopVehicle(Commands cmd, const CommandCost &result, VehicleID veh_id, bool); template <typename Tcont, typename Titer> inline EndianBufferWriter<Tcont, Titer> &operator <<(EndianBufferWriter<Tcont, Titer> &buffer, const VehicleListIdentifier &vli) diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 289a821e5..4965cac0a 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -2617,16 +2617,14 @@ 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 data Command data + * @param result the result of the start/stop command + * @param veh_id Vehicle ID. */ -void CcStartStopVehicle(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &data) +void CcStartStopVehicle(Commands cmd, const CommandCost &result, VehicleID veh_id, bool) { if (result.Failed()) return; - VehicleID veh_id = std::get<0>(EndianBufferReader::ToValue<CommandTraits<CMD_START_STOP_VEHICLE>::Args>(data)); const Vehicle *v = Vehicle::GetIfValid(veh_id); if (v == nullptr || !v->IsPrimaryVehicle() || v->owner != _local_company) return; @@ -3124,9 +3122,8 @@ void StopGlobalFollowVehicle(const Vehicle *v) * @param result indicates completion (or not) of the operation * @param cmd unused * @param tile unused - * @param data unused */ -void CcBuildPrimaryVehicle(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &data) +void CcBuildPrimaryVehicle(Commands cmd, const CommandCost &result, TileIndex tile) { if (result.Failed()) return; |