From 123c7f99c342aa9eb7ca505f0b49257fc8eee7ff Mon Sep 17 00:00:00 2001 From: Michael Lutz Date: Sun, 10 Oct 2021 02:35:06 +0200 Subject: [PATCH] Codechange: Move command callback declarations to the cmd header files. --- src/CMakeLists.txt | 2 ++ src/airport_cmd.h | 17 ++++++++++ src/airport_gui.cpp | 1 + src/build_vehicle_gui.cpp | 2 ++ src/command_func.h | 56 --------------------------------- src/depot_cmd.h | 2 ++ src/dock_cmd.h | 18 +++++++++++ src/dock_gui.cpp | 2 ++ src/group_cmd.h | 3 ++ src/group_gui.cpp | 1 + src/industry_cmd.h | 2 ++ src/network/network_command.cpp | 13 ++++++++ src/object_gui.cpp | 1 + src/rail_cmd.h | 5 +++ src/road_cmd.h | 5 +++ src/script/CMakeLists.txt | 1 + src/script/script_cmd.h | 18 +++++++++++ src/terraform_cmd.h | 4 +++ src/terraform_gui.cpp | 2 ++ src/town_cmd.h | 3 ++ src/train_cmd.h | 2 ++ src/tunnelbridge_cmd.h | 2 ++ src/vehicle_cmd.h | 3 ++ src/vehicle_gui.cpp | 1 + 24 files changed, 110 insertions(+), 56 deletions(-) create mode 100644 src/airport_cmd.h create mode 100644 src/dock_cmd.h create mode 100644 src/script/script_cmd.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6950e32757..dd3a6c2f06 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -42,6 +42,7 @@ add_files( aircraft_gui.cpp airport.cpp airport.h + airport_cmd.h airport_gui.cpp animated_tile.cpp animated_tile_func.h @@ -131,6 +132,7 @@ add_files( direction_type.h disaster_vehicle.cpp disaster_vehicle.h + dock_cmd.h dock_gui.cpp driver.cpp driver.h diff --git a/src/airport_cmd.h b/src/airport_cmd.h new file mode 100644 index 0000000000..2e27057d8c --- /dev/null +++ b/src/airport_cmd.h @@ -0,0 +1,17 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . + */ + +/** @file airport_cmd.h Command definitions related to airports. */ + +#ifndef AIRPORT_CMD_H +#define AIRPORT_CMD_H + +#include "command_type.h" + +CommandCallback CcBuildAirport; + +#endif /* AIRPORT_CMD_H */ diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index a031c450c3..ca3d8aa71d 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -26,6 +26,7 @@ #include "hotkeys.h" #include "vehicle_func.h" #include "gui.h" +#include "airport_cmd.h" #include "widgets/airport_widget.h" diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index b1136ec302..34d771090a 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -30,6 +30,8 @@ #include "cargotype.h" #include "core/geometry_func.hpp" #include "autoreplace_func.h" +#include "train_cmd.h" +#include "vehicle_cmd.h" #include "widgets/build_vehicle_widget.h" diff --git a/src/command_func.h b/src/command_func.h index 15c88ea034..03bfc73f1b 100644 --- a/src/command_func.h +++ b/src/command_func.h @@ -67,60 +67,4 @@ static inline DoCommandFlag CommandFlagsToDCFlags(CommandFlags cmd_flags) return flags; } -/*** All command callbacks that exist ***/ - -/* ai/ai_instance.cpp */ -CommandCallback CcAI; - -/* airport_gui.cpp */ -CommandCallback CcBuildAirport; - -/* bridge_gui.cpp */ -CommandCallback CcBuildBridge; - -/* dock_gui.cpp */ -CommandCallback CcBuildDocks; -CommandCallback CcPlaySound_CONSTRUCTION_WATER; - -/* depot_gui.cpp */ -CommandCallback CcCloneVehicle; - -/* game/game_instance.cpp */ -CommandCallback CcGame; - -/* group_gui.cpp */ -CommandCallback CcCreateGroup; -CommandCallback CcAddVehicleNewGroup; - -/* industry_gui.cpp */ -CommandCallback CcBuildIndustry; - -/* main_gui.cpp */ -CommandCallback CcPlaySound_EXPLOSION; -CommandCallback CcPlaceSign; -CommandCallback CcTerraform; - -/* rail_gui.cpp */ -CommandCallback CcPlaySound_CONSTRUCTION_RAIL; -CommandCallback CcRailDepot; -CommandCallback CcStation; -CommandCallback CcBuildRailTunnel; - -/* road_gui.cpp */ -CommandCallback CcPlaySound_CONSTRUCTION_OTHER; -CommandCallback CcBuildRoadTunnel; -CommandCallback CcRoadDepot; -CommandCallback CcRoadStop; - -/* train_gui.cpp */ -CommandCallback CcBuildWagon; - -/* town_gui.cpp */ -CommandCallback CcFoundTown; -CommandCallback CcFoundRandomTown; - -/* vehicle_gui.cpp */ -CommandCallback CcBuildPrimaryVehicle; -CommandCallback CcStartStopVehicle; - #endif /* COMMAND_FUNC_H */ diff --git a/src/depot_cmd.h b/src/depot_cmd.h index 9c39db1e2e..cc9701fb7f 100644 --- a/src/depot_cmd.h +++ b/src/depot_cmd.h @@ -16,4 +16,6 @@ CommandProc CmdRenameDepot; DEF_CMD_TRAIT(CMD_RENAME_DEPOT, CmdRenameDepot, 0, CMDT_OTHER_MANAGEMENT) +CommandCallback CcCloneVehicle; + #endif /* DEPOT_CMD_H */ diff --git a/src/dock_cmd.h b/src/dock_cmd.h new file mode 100644 index 0000000000..d1c1324707 --- /dev/null +++ b/src/dock_cmd.h @@ -0,0 +1,18 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . + */ + +/** @file dock_cmd.h Command definitions related to docks. */ + +#ifndef DOCK_CMD_H +#define DOCK_CMD_H + +#include "command_type.h" + +CommandCallback CcBuildDocks; +CommandCallback CcPlaySound_CONSTRUCTION_WATER; + +#endif /* DOCK_CMD_H */ diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index c1f6156122..0ba34e2114 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -25,6 +25,8 @@ #include "hotkeys.h" #include "gui.h" #include "zoom_func.h" +#include "tunnelbridge_cmd.h" +#include "dock_cmd.h" #include "widgets/dock_widget.h" diff --git a/src/group_cmd.h b/src/group_cmd.h index a58a6f8aa5..7f3496cc9c 100644 --- a/src/group_cmd.h +++ b/src/group_cmd.h @@ -30,4 +30,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; + #endif /* GROUP_CMD_H */ diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 316cdc4f3c..f72d9d2d6a 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -25,6 +25,7 @@ #include "company_base.h" #include "company_gui.h" #include "gui.h" +#include "group_cmd.h" #include "widgets/group_widget.h" diff --git a/src/industry_cmd.h b/src/industry_cmd.h index e1f18932a9..150b59da9b 100644 --- a/src/industry_cmd.h +++ b/src/industry_cmd.h @@ -18,4 +18,6 @@ CommandProc CmdIndustryCtrl; 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; + #endif /* INDUSTRY_CMD_H */ diff --git a/src/network/network_command.cpp b/src/network/network_command.cpp index 6df53d7da1..0fae6bcbf0 100644 --- a/src/network/network_command.cpp +++ b/src/network/network_command.cpp @@ -14,6 +14,19 @@ #include "../command_func.h" #include "../company_func.h" #include "../settings_type.h" +#include "../airport_cmd.h" +#include "../depot_cmd.h" +#include "../dock_cmd.h" +#include "../group_cmd.h" +#include "../industry_cmd.h" +#include "../rail_cmd.h" +#include "../road_cmd.h" +#include "../terraform_cmd.h" +#include "../town_cmd.h" +#include "../train_cmd.h" +#include "../tunnelbridge_cmd.h" +#include "../vehicle_cmd.h" +#include "../script/script_cmd.h" #include "../safeguards.h" diff --git a/src/object_gui.cpp b/src/object_gui.cpp index 234e3eab66..a3ea3f8b17 100644 --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -24,6 +24,7 @@ #include "window_gui.h" #include "window_func.h" #include "zoom_func.h" +#include "terraform_cmd.h" #include "widgets/object_widget.h" diff --git a/src/rail_cmd.h b/src/rail_cmd.h index e625eb03db..1fb0fdee0d 100644 --- a/src/rail_cmd.h +++ b/src/rail_cmd.h @@ -34,4 +34,9 @@ DEF_CMD_TRAIT(CMD_CONVERT_RAIL, CmdConvertRail, 0, DEF_CMD_TRAIT(CMD_BUILD_SIGNAL_TRACK, CmdBuildSignalTrack, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION) DEF_CMD_TRAIT(CMD_REMOVE_SIGNAL_TRACK, CmdRemoveSignalTrack, CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION) +CommandCallback CcPlaySound_CONSTRUCTION_RAIL; +CommandCallback CcRailDepot; +CommandCallback CcStation; +CommandCallback CcBuildRailTunnel; + #endif /* RAIL_CMD_H */ diff --git a/src/road_cmd.h b/src/road_cmd.h index 4908f72e31..05f064b0bc 100644 --- a/src/road_cmd.h +++ b/src/road_cmd.h @@ -29,4 +29,9 @@ DEF_CMD_TRAIT(CMD_BUILD_ROAD, CmdBuildRoad, CMD_AUTO | CMD_NO_WATER | DEF_CMD_TRAIT(CMD_BUILD_ROAD_DEPOT, CmdBuildRoadDepot, CMD_AUTO | CMD_NO_WATER, CMDT_LANDSCAPE_CONSTRUCTION) DEF_CMD_TRAIT(CMD_CONVERT_ROAD, CmdConvertRoad, 0, CMDT_LANDSCAPE_CONSTRUCTION) +CommandCallback CcPlaySound_CONSTRUCTION_OTHER; +CommandCallback CcBuildRoadTunnel; +CommandCallback CcRoadDepot; +CommandCallback CcRoadStop; + #endif /* ROAD_CMD_H */ diff --git a/src/script/CMakeLists.txt b/src/script/CMakeLists.txt index f4b87dc3b8..d1054ca5f8 100644 --- a/src/script/CMakeLists.txt +++ b/src/script/CMakeLists.txt @@ -5,6 +5,7 @@ if(OPTION_TOOLS_ONLY) endif() add_files( + script_cmd.h script_config.cpp script_config.hpp script_fatalerror.hpp diff --git a/src/script/script_cmd.h b/src/script/script_cmd.h new file mode 100644 index 0000000000..bf6aa50c72 --- /dev/null +++ b/src/script/script_cmd.h @@ -0,0 +1,18 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . + */ + +/** @file script_cmd.h Command definitions related to scripts. */ + +#ifndef SCRIPT_CMD_H +#define SCRIPT_CMD_H + +#include "../command_type.h" + +CommandCallback CcAI; +CommandCallback CcGame; + +#endif /* SCRIPT_CMD_H */ diff --git a/src/terraform_cmd.h b/src/terraform_cmd.h index 88aeaec4cb..9b5866efaf 100644 --- a/src/terraform_cmd.h +++ b/src/terraform_cmd.h @@ -18,4 +18,8 @@ CommandProc CmdLevelLand; DEF_CMD_TRAIT(CMD_TERRAFORM_LAND, CmdTerraformLand, CMD_ALL_TILES | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION) DEF_CMD_TRAIT(CMD_LEVEL_LAND, CmdLevelLand, CMD_ALL_TILES | CMD_AUTO | CMD_NO_TEST, CMDT_LANDSCAPE_CONSTRUCTION) // test run might clear tiles multiple times, in execution that only happens once +CommandCallback CcPlaySound_EXPLOSION; +CommandCallback CcPlaceSign; +CommandCallback CcTerraform; + #endif /* TERRAFORM_CMD_H */ diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index 0325a957ff..a558332791 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -31,7 +31,9 @@ #include "hotkeys.h" #include "engine_base.h" #include "terraform_gui.h" +#include "terraform_cmd.h" #include "zoom_func.h" +#include "rail_cmd.h" #include "widgets/terraform_widget.h" diff --git a/src/town_cmd.h b/src/town_cmd.h index bd4f4de11c..7842e7ddaa 100644 --- a/src/town_cmd.h +++ b/src/town_cmd.h @@ -32,4 +32,7 @@ DEF_CMD_TRAIT(CMD_TOWN_SET_TEXT, CmdTownSetText, CMD_DEITY | CMD_STR_CTRL, DEF_CMD_TRAIT(CMD_EXPAND_TOWN, CmdExpandTown, CMD_DEITY, CMDT_LANDSCAPE_CONSTRUCTION) DEF_CMD_TRAIT(CMD_DELETE_TOWN, CmdDeleteTown, CMD_OFFLINE, CMDT_LANDSCAPE_CONSTRUCTION) +CommandCallback CcFoundTown; +CommandCallback CcFoundRandomTown; + #endif /* TOWN_CMD_H */ diff --git a/src/train_cmd.h b/src/train_cmd.h index f9452f1b51..7b286e9983 100644 --- a/src/train_cmd.h +++ b/src/train_cmd.h @@ -25,4 +25,6 @@ DEF_CMD_TRAIT(CMD_MOVE_RAIL_VEHICLE, CmdMoveRailVehicle, 0, CMDT_VEH DEF_CMD_TRAIT(CMD_FORCE_TRAIN_PROCEED, CmdForceTrainProceed, 0, CMDT_VEHICLE_MANAGEMENT) DEF_CMD_TRAIT(CMD_REVERSE_TRAIN_DIRECTION, CmdReverseTrainDirection, 0, CMDT_VEHICLE_MANAGEMENT) +CommandCallback CcBuildWagon; + #endif /* TRAIN_CMD_H */ diff --git a/src/tunnelbridge_cmd.h b/src/tunnelbridge_cmd.h index 58cb9b32ae..6c78db48b1 100644 --- a/src/tunnelbridge_cmd.h +++ b/src/tunnelbridge_cmd.h @@ -18,4 +18,6 @@ CommandProc CmdBuildTunnel; 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; + #endif /* TUNNELBRIDGE_CMD_H */ diff --git a/src/vehicle_cmd.h b/src/vehicle_cmd.h index a2d8d62bf7..e6872e838b 100644 --- a/src/vehicle_cmd.h +++ b/src/vehicle_cmd.h @@ -36,4 +36,7 @@ DEF_CMD_TRAIT(CMD_MASS_START_STOP, CmdMassStartStopVehicle, 0, DEF_CMD_TRAIT(CMD_DEPOT_SELL_ALL_VEHICLES, CmdDepotSellAllVehicles, 0, CMDT_VEHICLE_CONSTRUCTION) DEF_CMD_TRAIT(CMD_DEPOT_MASS_AUTOREPLACE, CmdDepotMassAutoReplace, 0, CMDT_VEHICLE_CONSTRUCTION) +CommandCallback CcBuildPrimaryVehicle; +CommandCallback CcStartStopVehicle; + #endif /* VEHICLE_CMD_H */ diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 69fb158460..abe1b9dd97 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -36,6 +36,7 @@ #include "station_base.h" #include "tilehighlight_func.h" #include "zoom_func.h" +#include "depot_cmd.h" #include "safeguards.h"