From 012daaa3d973cf5730401edfaf4b1ddd444ec475 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Wed, 19 Feb 2025 18:57:35 +0000 Subject: [PATCH] Codechange: Use member initialisation for TileDesc members. --- src/misc_gui.cpp | 32 +------------------------------- src/tile_cmd.h | 36 ++++++++++++++++++------------------ 2 files changed, 19 insertions(+), 49 deletions(-) diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index aac5cd3dec..3153b8b38c 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -139,38 +139,8 @@ public: { Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority); - /* Because build_date is not set yet in every TileDesc, we make sure it is empty */ - TileDesc td; - - td.build_date = CalendarTime::INVALID_DATE; - - /* Most tiles have only one owner, but - * - drivethrough roadstops can be build on town owned roads (up to 2 owners) and - * - roads can have up to four owners (railroad, road, tram, 3rd-roadtype "highway"). - */ + TileDesc td{}; td.owner_type[0] = STR_LAND_AREA_INFORMATION_OWNER; // At least one owner is displayed, though it might be "N/A". - td.owner_type[1] = STR_NULL; // STR_NULL results in skipping the owner - td.owner_type[2] = STR_NULL; - td.owner_type[3] = STR_NULL; - td.owner[0] = OWNER_NONE; - td.owner[1] = OWNER_NONE; - td.owner[2] = OWNER_NONE; - td.owner[3] = OWNER_NONE; - - td.station_class = STR_NULL; - td.station_name = STR_NULL; - td.airport_class = STR_NULL; - td.airport_name = STR_NULL; - td.airport_tile_name = STR_NULL; - td.railtype = STR_NULL; - td.rail_speed = 0; - td.roadtype = STR_NULL; - td.road_speed = 0; - td.tramtype = STR_NULL; - td.tram_speed = 0; - td.town_can_upgrade = std::nullopt; - - td.grf = nullptr; CargoArray acceptance{}; AddAcceptedCargo(tile, acceptance, nullptr); diff --git a/src/tile_cmd.h b/src/tile_cmd.h index 97fc3f9da4..2a5f9d352a 100644 --- a/src/tile_cmd.h +++ b/src/tile_cmd.h @@ -50,24 +50,24 @@ struct TileInfo { /** Tile description for the 'land area information' tool */ struct TileDesc { - StringID str; ///< Description of the tile - uint64_t dparam; ///< Parameter of the \a str string - Owner owner[4]; ///< Name of the owner(s) - StringID owner_type[4]; ///< Type of each owner - TimerGameCalendar::Date build_date; ///< Date of construction of tile contents - StringID station_class; ///< Class of station - StringID station_name; ///< Type of station within the class - StringID airport_class; ///< Name of the airport class - StringID airport_name; ///< Name of the airport - StringID airport_tile_name; ///< Name of the airport tile - const char *grf; ///< newGRF used for the tile contents - StringID railtype; ///< Type of rail on the tile. - uint16_t rail_speed; ///< Speed limit of rail (bridges and track) - StringID roadtype; ///< Type of road on the tile. - uint16_t road_speed; ///< Speed limit of road (bridges and track) - StringID tramtype; ///< Type of tram on the tile. - uint16_t tram_speed; ///< Speed limit of tram (bridges and track) - std::optional town_can_upgrade; ///< Whether the town can upgrade this house during town growth. + StringID str{}; ///< Description of the tile + uint64_t dparam = 0; ///< Parameter of the \a str string + std::array owner{}; ///< Name of the owner(s) + std::array owner_type{}; ///< Type of each owner + TimerGameCalendar::Date build_date = CalendarTime::INVALID_DATE; ///< Date of construction of tile contents + StringID station_class{}; ///< Class of station + StringID station_name{}; ///< Type of station within the class + StringID airport_class{}; ///< Name of the airport class + StringID airport_name{}; ///< Name of the airport + StringID airport_tile_name{}; ///< Name of the airport tile + const char *grf = nullptr; ///< newGRF used for the tile contents + StringID railtype{}; ///< Type of rail on the tile. + uint16_t rail_speed = 0; ///< Speed limit of rail (bridges and track) + StringID roadtype{}; ///< Type of road on the tile. + uint16_t road_speed = 0; ///< Speed limit of road (bridges and track) + StringID tramtype{}; ///< Type of tram on the tile. + uint16_t tram_speed = 0; ///< Speed limit of tram (bridges and track) + std::optional town_can_upgrade = std::nullopt; ///< Whether the town can upgrade this house during town growth. }; /**