From cb113cfed031bf774b8cea6fd1f4566677c885d4 Mon Sep 17 00:00:00 2001 From: frosch Date: Sat, 19 Apr 2025 22:35:05 +0200 Subject: [PATCH] Codefix: Add missing header includes. --- .github/unused-strings.py | 2 +- src/date_gui.h | 2 +- src/depot_cmd.h | 1 + src/dropdown_common_type.h | 3 +++ src/dropdown_func.h | 1 + src/engine_type.h | 1 + src/game/game_text.hpp | 1 + src/group_gui.h | 2 ++ src/industry_type.h | 2 ++ src/network/core/tcp_content_type.h | 3 +++ src/network/core/tcp_listen.h | 2 ++ src/newgrf/newgrf_act0.cpp | 2 +- src/newgrf/newgrf_act2.cpp | 2 +- src/newgrf/newgrf_act8.cpp | 2 +- src/newgrf/newgrf_stringmapping.cpp | 4 ++-- src/newgrf_act5.h | 2 ++ src/newgrf_class_func.h | 2 ++ src/newgrf_spritegroup.h | 1 + src/rail_cmd.h | 1 + src/road_cmd.h | 2 ++ src/road_gui.h | 1 + src/saveload/newgrf_sl.h | 1 + src/script/api/script_controller.hpp | 1 + src/script/script_gui.h | 2 ++ src/signs_type.h | 2 ++ src/station_cmd.h | 4 ++++ src/subsidy_func.h | 1 + src/subsidy_type.h | 1 + src/table/airporttiles.h | 2 ++ src/table/bridge_land.h | 2 ++ src/table/build_industry.h | 2 ++ src/table/cargo_const.h | 5 +++++ src/table/clear_land.h | 2 ++ src/table/engines.h | 2 ++ src/table/object_land.h | 2 ++ src/table/railtypes.h | 2 ++ src/table/roadtypes.h | 2 ++ src/table/settings.h.preamble | 2 ++ src/timetable_cmd.h | 2 ++ src/train_cmd.h | 1 + 40 files changed, 70 insertions(+), 7 deletions(-) diff --git a/.github/unused-strings.py b/.github/unused-strings.py index 1ebb652982..55e8ec1bfd 100644 --- a/.github/unused-strings.py +++ b/.github/unused-strings.py @@ -158,7 +158,7 @@ def scan_source_files(path, strings_found): # Most files we can just open, but some use magic, that requires the # G++ preprocessor before we can make sense out of it. if new_path == "src/table/cargo_const.h": - p = subprocess.run(["g++", "-E", new_path], stdout=subprocess.PIPE) + p = subprocess.run(["g++", "-E", "-DCHECK_UNUSED_STRINGS", new_path], stdout=subprocess.PIPE) output = p.stdout.decode() else: with open(new_path) as fp: diff --git a/src/date_gui.h b/src/date_gui.h index 631b0301a2..8434f4cfd1 100644 --- a/src/date_gui.h +++ b/src/date_gui.h @@ -10,7 +10,7 @@ #ifndef DATE_GUI_H #define DATE_GUI_H -#include "timer/timer_game_calendar.h" +#include "timer/timer_game_economy.h" #include "window_type.h" /** diff --git a/src/depot_cmd.h b/src/depot_cmd.h index 8e4a7098cd..abd3e1900e 100644 --- a/src/depot_cmd.h +++ b/src/depot_cmd.h @@ -12,6 +12,7 @@ #include "command_type.h" #include "depot_type.h" +#include "vehicle_type.h" CommandCost CmdRenameDepot(DoCommandFlags flags, DepotID depot_id, const std::string &text); diff --git a/src/dropdown_common_type.h b/src/dropdown_common_type.h index 04cb7665f6..dc3c6d44a3 100644 --- a/src/dropdown_common_type.h +++ b/src/dropdown_common_type.h @@ -10,6 +10,7 @@ #ifndef DROPDOWN_COMMON_TYPE_H #define DROPDOWN_COMMON_TYPE_H +#include "dropdown_type.h" #include "gfx_func.h" #include "gfx_type.h" #include "palette_func.h" @@ -17,6 +18,8 @@ #include "strings_func.h" #include "window_gui.h" +#include "table/strings.h" + /** * Drop down divider component. * @tparam TBase Base component. diff --git a/src/dropdown_func.h b/src/dropdown_func.h index 69bf6e035b..7d72c01fbf 100644 --- a/src/dropdown_func.h +++ b/src/dropdown_func.h @@ -10,6 +10,7 @@ #ifndef DROPDOWN_FUNC_H #define DROPDOWN_FUNC_H +#include "dropdown_type.h" #include "window_gui.h" /* Show drop down menu containing a fixed list of strings */ diff --git a/src/engine_type.h b/src/engine_type.h index 41df86276d..94f797430e 100644 --- a/src/engine_type.h +++ b/src/engine_type.h @@ -10,6 +10,7 @@ #ifndef ENGINE_TYPE_H #define ENGINE_TYPE_H +#include "core/pool_type.hpp" #include "economy_type.h" #include "landscape_type.h" #include "newgrf_callbacks.h" diff --git a/src/game/game_text.hpp b/src/game/game_text.hpp index 8c651e3093..66375ebde1 100644 --- a/src/game/game_text.hpp +++ b/src/game/game_text.hpp @@ -10,6 +10,7 @@ #ifndef GAME_TEXT_HPP #define GAME_TEXT_HPP +#include "../string_type.h" #include "../strings_type.h" struct StringParam { diff --git a/src/group_gui.h b/src/group_gui.h index 7b855deafb..a4385ca853 100644 --- a/src/group_gui.h +++ b/src/group_gui.h @@ -11,6 +11,8 @@ #define GROUP_GUI_H #include "company_type.h" +#include "group_type.h" +#include "sortlist_type.h" #include "vehicle_type.h" void ShowCompanyGroup(CompanyID company, VehicleType veh, GroupID group = GroupID::Invalid()); diff --git a/src/industry_type.h b/src/industry_type.h index 7915b45564..76514a19e1 100644 --- a/src/industry_type.h +++ b/src/industry_type.h @@ -10,6 +10,8 @@ #ifndef INDUSTRY_TYPE_H #define INDUSTRY_TYPE_H +#include "core/pool_type.hpp" + using IndustryID = PoolID; typedef uint16_t IndustryGfx; diff --git a/src/network/core/tcp_content_type.h b/src/network/core/tcp_content_type.h index de1792d264..edff5c896a 100644 --- a/src/network/core/tcp_content_type.h +++ b/src/network/core/tcp_content_type.h @@ -14,6 +14,9 @@ #include "../../3rdparty/md5/md5.h" +#include "../../string_type.h" +#include "../../textfile_type.h" + /** The values in the enum are important; they are used as database 'keys' */ enum ContentType : uint8_t { CONTENT_TYPE_BEGIN = 1, ///< Helper to mark the begin of the types diff --git a/src/network/core/tcp_listen.h b/src/network/core/tcp_listen.h index 8af0cbe23e..b68e25b825 100644 --- a/src/network/core/tcp_listen.h +++ b/src/network/core/tcp_listen.h @@ -14,6 +14,8 @@ #include "tcp.h" #include "../network.h" +#include "../network_func.h" +#include "../network_internal.h" #include "../../core/pool_type.hpp" #include "../../debug.h" diff --git a/src/newgrf/newgrf_act0.cpp b/src/newgrf/newgrf_act0.cpp index 6562ff8f8e..496b64b524 100644 --- a/src/newgrf/newgrf_act0.cpp +++ b/src/newgrf/newgrf_act0.cpp @@ -19,7 +19,7 @@ #include "newgrf_bytereader.h" #include "newgrf_internal.h" -#include "../table/strings.h" +#include "table/strings.h" #include "../safeguards.h" diff --git a/src/newgrf/newgrf_act2.cpp b/src/newgrf/newgrf_act2.cpp index 8c9642b649..721b2dc737 100644 --- a/src/newgrf/newgrf_act2.cpp +++ b/src/newgrf/newgrf_act2.cpp @@ -18,7 +18,7 @@ #include "newgrf_bytereader.h" #include "newgrf_internal.h" -#include "../table/strings.h" +#include "table/strings.h" #include "../safeguards.h" diff --git a/src/newgrf/newgrf_act8.cpp b/src/newgrf/newgrf_act8.cpp index 9466efcedb..129377e15a 100644 --- a/src/newgrf/newgrf_act8.cpp +++ b/src/newgrf/newgrf_act8.cpp @@ -13,7 +13,7 @@ #include "newgrf_bytereader.h" #include "newgrf_internal.h" -#include "../table/strings.h" +#include "table/strings.h" #include "../safeguards.h" diff --git a/src/newgrf/newgrf_stringmapping.cpp b/src/newgrf/newgrf_stringmapping.cpp index 8441689488..3de9b7c993 100644 --- a/src/newgrf/newgrf_stringmapping.cpp +++ b/src/newgrf/newgrf_stringmapping.cpp @@ -16,9 +16,9 @@ #include "newgrf_internal.h" #include "newgrf_stringmapping.h" -#include "../safeguards.h" +#include "table/strings.h" -#include "../table/strings.h" +#include "../safeguards.h" /** * Information for mapping static StringIDs. diff --git a/src/newgrf_act5.h b/src/newgrf_act5.h index 1a73fb473d..e560d2beda 100644 --- a/src/newgrf_act5.h +++ b/src/newgrf_act5.h @@ -10,6 +10,8 @@ #ifndef NEWGRF_ACT5_H #define NEWGRF_ACT5_H +#include "gfx_type.h" + /** The type of action 5 type. */ enum Action5BlockType : uint8_t { A5BLOCK_FIXED, ///< Only allow replacing a whole block of sprites. (TTDP compatible) diff --git a/src/newgrf_class_func.h b/src/newgrf_class_func.h index 7332ad7de9..783bb99a3d 100644 --- a/src/newgrf_class_func.h +++ b/src/newgrf_class_func.h @@ -9,6 +9,8 @@ #include "newgrf_class.h" +#include "table/strings.h" + /** Reset the classes, i.e. clear everything. */ template void NewGRFClass::Reset() diff --git a/src/newgrf_spritegroup.h b/src/newgrf_spritegroup.h index 3827c5cd7b..3fb22f1d21 100644 --- a/src/newgrf_spritegroup.h +++ b/src/newgrf_spritegroup.h @@ -10,6 +10,7 @@ #ifndef NEWGRF_SPRITEGROUP_H #define NEWGRF_SPRITEGROUP_H +#include "core/pool_type.hpp" #include "town_type.h" #include "engine_type.h" #include "house_type.h" diff --git a/src/rail_cmd.h b/src/rail_cmd.h index fc27e50b8a..eb78df1d1c 100644 --- a/src/rail_cmd.h +++ b/src/rail_cmd.h @@ -12,6 +12,7 @@ #include "command_type.h" #include "track_type.h" +#include "direction_type.h" #include "rail_type.h" #include "signal_type.h" diff --git a/src/road_cmd.h b/src/road_cmd.h index 84f31c3be0..24b4c2b636 100644 --- a/src/road_cmd.h +++ b/src/road_cmd.h @@ -13,6 +13,8 @@ #include "direction_type.h" #include "road_type.h" #include "command_type.h" +#include "station_type.h" +#include "town_type.h" enum RoadStopClassID : uint16_t; diff --git a/src/road_gui.h b/src/road_gui.h index fefce6b534..7dcf1c99d4 100644 --- a/src/road_gui.h +++ b/src/road_gui.h @@ -10,6 +10,7 @@ #ifndef ROAD_GUI_H #define ROAD_GUI_H +#include "road.h" #include "road_type.h" #include "tile_type.h" #include "direction_type.h" diff --git a/src/saveload/newgrf_sl.h b/src/saveload/newgrf_sl.h index ee6fe98ad3..78a058bc25 100644 --- a/src/saveload/newgrf_sl.h +++ b/src/saveload/newgrf_sl.h @@ -11,6 +11,7 @@ #define SAVELOAD_NEWGRF_SL_H #include "../newgrf_commons.h" +#include "saveload.h" struct NewGRFMappingChunkHandler : ChunkHandler { OverrideManagerBase &mapping; diff --git a/src/script/api/script_controller.hpp b/src/script/api/script_controller.hpp index b1d38d6a6d..59c61f553e 100644 --- a/src/script/api/script_controller.hpp +++ b/src/script/api/script_controller.hpp @@ -11,6 +11,7 @@ #define SCRIPT_CONTROLLER_HPP #include "script_types.hpp" +#include "../../string_func.h" #include "../../company_type.h" /** diff --git a/src/script/script_gui.h b/src/script/script_gui.h index e2adceb40c..3ba6e423fe 100644 --- a/src/script/script_gui.h +++ b/src/script/script_gui.h @@ -13,6 +13,8 @@ #include "../company_type.h" #include "../textfile_type.h" +struct Window; + void ShowScriptListWindow(CompanyID slot, bool show_all); Window *ShowScriptDebugWindow(CompanyID show_company = CompanyID::Invalid(), bool new_window = false); void ShowScriptSettingsWindow(CompanyID slot); diff --git a/src/signs_type.h b/src/signs_type.h index ff298611f6..ff95f5868e 100644 --- a/src/signs_type.h +++ b/src/signs_type.h @@ -10,6 +10,8 @@ #ifndef SIGNS_TYPE_H #define SIGNS_TYPE_H +#include "core/pool_type.hpp" + /** The type of the IDs of signs. */ using SignID = PoolID; diff --git a/src/station_cmd.h b/src/station_cmd.h index e1310da686..cd5c69b7fa 100644 --- a/src/station_cmd.h +++ b/src/station_cmd.h @@ -11,8 +11,12 @@ #define STATION_CMD_H #include "command_type.h" +#include "rail_type.h" +#include "road_type.h" #include "station_type.h" +struct Town; + enum StationClassID : uint16_t; enum RoadStopClassID : uint16_t; diff --git a/src/subsidy_func.h b/src/subsidy_func.h index 89023b96cb..cdd0cb91f8 100644 --- a/src/subsidy_func.h +++ b/src/subsidy_func.h @@ -10,6 +10,7 @@ #ifndef SUBSIDY_FUNC_H #define SUBSIDY_FUNC_H +#include "source_type.h" #include "station_type.h" #include "company_type.h" #include "cargo_type.h" diff --git a/src/subsidy_type.h b/src/subsidy_type.h index de03cc9ba1..5e51bf05a5 100644 --- a/src/subsidy_type.h +++ b/src/subsidy_type.h @@ -11,6 +11,7 @@ #define SUBSIDY_TYPE_H #include "core/enum_type.hpp" +#include "core/pool_type.hpp" /** What part of a subsidy is something? */ enum class PartOfSubsidy : uint8_t { diff --git a/src/table/airporttiles.h b/src/table/airporttiles.h index 0003b91065..b38e6eac4c 100644 --- a/src/table/airporttiles.h +++ b/src/table/airporttiles.h @@ -10,6 +10,8 @@ #ifndef AIRPORTTILES_H #define AIRPORTTILES_H +#include "table/strings.h" + /** Writes all airport tile properties in the AirportTile struct */ #define AT(num_frames, anim_speed) {{num_frames, AnimationStatus::Looping, anim_speed, 0}, STR_NULL, AirportTileCallbackMasks{}, 0, true, GRFFileProps(INVALID_AIRPORTTILE), {}} /** Writes an airport tile without animation in the AirportTile struct */ diff --git a/src/table/bridge_land.h b/src/table/bridge_land.h index 8561149695..e6f4f7f185 100644 --- a/src/table/bridge_land.h +++ b/src/table/bridge_land.h @@ -5,6 +5,8 @@ * 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 . */ +#include "table/strings.h" + /** * @file bridge_land.h This file contains all the sprites for bridges * It consists of a number of arrays. diff --git a/src/table/build_industry.h b/src/table/build_industry.h index 1f2608d10e..27f5fd151a 100644 --- a/src/table/build_industry.h +++ b/src/table/build_industry.h @@ -10,6 +10,8 @@ #ifndef BUILD_INDUSTRY_H #define BUILD_INDUSTRY_H +#include "table/strings.h" + /** * Definition of an industry tiles layout. * @param x offset x of this tile diff --git a/src/table/cargo_const.h b/src/table/cargo_const.h index 07b4a396a3..13880539a6 100644 --- a/src/table/cargo_const.h +++ b/src/table/cargo_const.h @@ -7,6 +7,11 @@ /** @file cargo_const.h Table of all default cargo types */ +#include "../table/sprites.h" +#ifndef CHECK_UNUSED_STRINGS +#include "table/strings.h" +#endif + /** Construction macros for the #CargoSpec StringID entries. */ #define MK_STR_CARGO_PLURAL(label_plural) STR_CARGO_PLURAL_ ## label_plural #define MK_STR_CARGO_SINGULAR(label_singular) STR_CARGO_SINGULAR_ ## label_singular diff --git a/src/table/clear_land.h b/src/table/clear_land.h index 3101e27040..00ea23fd0d 100644 --- a/src/table/clear_land.h +++ b/src/table/clear_land.h @@ -7,6 +7,8 @@ /** @file clear_land.h Tables with sprites for clear land and fences. */ +#include "sprites.h" + static const SpriteID _landscape_clear_sprites_rough[8] = { SPR_FLAT_ROUGH_LAND, SPR_FLAT_ROUGH_LAND_1, diff --git a/src/table/engines.h b/src/table/engines.h index b34b2e7602..b5e745c1b2 100644 --- a/src/table/engines.h +++ b/src/table/engines.h @@ -13,6 +13,8 @@ #ifndef ENGINES_H #define ENGINES_H +#include "table/strings.h" + /** * Writes the properties of a train into the EngineInfo struct. * @see EngineInfo diff --git a/src/table/object_land.h b/src/table/object_land.h index 0ea2ab8eae..3ea1fb91c5 100644 --- a/src/table/object_land.h +++ b/src/table/object_land.h @@ -7,6 +7,8 @@ /** @file object_land.h Sprites to use and how to display them for object tiles. */ +#include "table/strings.h" + #define TILE_SEQ_LINE(sz, img) { 0, 0, 0, 16, 16, sz, {img, PAL_NONE} }, static const DrawTileSeqStruct _object_transmitter_seq[] = { diff --git a/src/table/railtypes.h b/src/table/railtypes.h index 99e9b76ef4..3f687545bb 100644 --- a/src/table/railtypes.h +++ b/src/table/railtypes.h @@ -13,6 +13,8 @@ #ifndef RAILTYPES_H #define RAILTYPES_H +#include "table/strings.h" + /** * Global Railtype definition */ diff --git a/src/table/roadtypes.h b/src/table/roadtypes.h index 87f1f64207..f77c34dc74 100644 --- a/src/table/roadtypes.h +++ b/src/table/roadtypes.h @@ -13,6 +13,8 @@ #ifndef ROADTYPES_H #define ROADTYPES_H +#include "table/strings.h" + /** * Global Roadtype definition */ diff --git a/src/table/settings.h.preamble b/src/table/settings.h.preamble index a9006f3078..f299106867 100644 --- a/src/table/settings.h.preamble +++ b/src/table/settings.h.preamble @@ -7,6 +7,8 @@ /** @file table/settings.h Settings to save in the savegame and config file. */ +#include "table/strings.h" + /* Callback function used in _settings[] as well as _company_settings[] */ static size_t ConvertLandscape(const char *value); diff --git a/src/timetable_cmd.h b/src/timetable_cmd.h index eeda1ff4c1..221b394174 100644 --- a/src/timetable_cmd.h +++ b/src/timetable_cmd.h @@ -11,7 +11,9 @@ #define TIMETABLE_CMD_H #include "command_type.h" +#include "order_type.h" #include "timer/timer_game_tick.h" +#include "vehicle_type.h" CommandCost CmdChangeTimetable(DoCommandFlags flags, VehicleID veh, VehicleOrderID order_number, ModifyTimetableFlags mtf, uint16_t data); CommandCost CmdBulkChangeTimetable(DoCommandFlags flags, VehicleID veh, ModifyTimetableFlags mtf, uint16_t data); diff --git a/src/train_cmd.h b/src/train_cmd.h index cbc84eca85..45a7b5eff1 100644 --- a/src/train_cmd.h +++ b/src/train_cmd.h @@ -12,6 +12,7 @@ #include "command_type.h" #include "engine_type.h" +#include "network/network_type.h" #include "vehicle_type.h" CommandCost CmdBuildRailVehicle(DoCommandFlags flags, TileIndex tile, const Engine *e, Vehicle **ret);