diff --git a/src/aircraft.h b/src/aircraft.h index a6b747d5cf..310e8b4f5e 100644 --- a/src/aircraft.h +++ b/src/aircraft.h @@ -25,7 +25,7 @@ static constexpr int HELICOPTER_HOLD_MAX_FLYING_ALTITUDE = 184; ///< holding fly struct Aircraft; /** An aircraft can be one of those types. */ -enum AircraftSubType { +enum AircraftSubType : uint8_t { AIR_HELICOPTER = 0, ///< an helicopter AIR_AIRCRAFT = 2, ///< an airplane AIR_SHADOW = 4, ///< shadow of the aircraft @@ -33,7 +33,7 @@ enum AircraftSubType { }; /** Flags for air vehicles; shared with disaster vehicles. */ -enum AirVehicleFlags { +enum AirVehicleFlags : uint8_t { VAF_DEST_TOO_FAR = 0, ///< Next destination is too far away. /* The next two flags are to prevent stair climbing of the aircraft. The idea is that the aircraft diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index d2574b8510..c1f6a336b7 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -107,7 +107,7 @@ bool IsValidImageIndex(uint8_t image_index) } /** Helicopter rotor animation states */ -enum HelicopterRotorStates { +enum HelicopterRotorStates : uint8_t { HRS_ROTOR_STOPPED, HRS_ROTOR_MOVING_1, HRS_ROTOR_MOVING_2, diff --git a/src/airport.h b/src/airport.h index d5df10e275..2662639341 100644 --- a/src/airport.h +++ b/src/airport.h @@ -25,7 +25,7 @@ static const uint NEW_AIRPORTTILE_OFFSET = 74; ///< offset of firs static const uint INVALID_AIRPORTTILE = NUM_AIRPORTTILES; ///< id for an invalid airport tile /** Airport types */ -enum AirportTypes { +enum AirportTypes : uint8_t { AT_SMALL = 0, ///< Small airport. AT_LARGE = 1, ///< Large airport. AT_HELIPORT = 2, ///< Heli port. @@ -44,7 +44,7 @@ enum AirportTypes { }; /** Flags for airport movement data. */ -enum AirportMovingDataFlags { +enum AirportMovingDataFlags : uint16_t { AMED_NOSPDCLAMP = 1 << 0, ///< No speed restrictions. AMED_TAKEOFF = 1 << 1, ///< Takeoff movement. AMED_SLOWTURN = 1 << 2, ///< Turn slowly (mostly used in the air). @@ -57,7 +57,7 @@ enum AirportMovingDataFlags { }; /** Movement States on Airports (headings target) */ -enum AirportMovementStates { +enum AirportMovementStates : uint8_t { TO_ALL = 0, ///< Go in this direction for every target. HANGAR = 1, ///< Heading for hangar. TERM1 = 2, ///< Heading for terminal 1. @@ -143,7 +143,7 @@ struct AirportFTAbuildup; struct AirportFTAClass { public: /** Bitmask of airport flags. */ - enum Flags { + enum Flags : uint8_t { AIRPLANES = 0x1, ///< Can planes land on this airport type? HELICOPTERS = 0x2, ///< Can helicopters land on this airport type? ALL = AIRPLANES | HELICOPTERS, ///< Mask to check for both planes and helicopters. diff --git a/src/base_media_base.h b/src/base_media_base.h index 0164a1176a..93bdfabb42 100644 --- a/src/base_media_base.h +++ b/src/base_media_base.h @@ -24,7 +24,7 @@ struct ContentInfo; /** Structure holding filename and MD5 information about a single file */ struct MD5File { /** The result of a checksum check */ - enum ChecksumResult { + enum ChecksumResult : uint8_t { CR_UNKNOWN, ///< The file has not been checked yet CR_MATCH, ///< The file did exist and the md5 checksum did match CR_MISMATCH, ///< The file did exist, just the md5 checksum did not match @@ -238,7 +238,7 @@ template const char *TryGetBaseSetFile(const ContentInfo *ci, bool md5sum, const Tbase_set *s); /** Types of graphics in the base graphics set */ -enum GraphicsFileType { +enum GraphicsFileType : uint8_t { GFT_BASE, ///< Base sprites for all climates GFT_LOGOS, ///< Logos, landscape icons and original terrain generator sprites GFT_ARCTIC, ///< Landscape replacement sprites for arctic @@ -249,7 +249,7 @@ enum GraphicsFileType { }; /** Blitter type for base graphics sets. */ -enum BlitterType { +enum BlitterType : uint8_t { BLT_8BPP, ///< Base set has 8 bpp sprites only. BLT_32BPP, ///< Base set has both 8 bpp and 32 bpp sprites. }; @@ -316,7 +316,7 @@ static const uint NUM_SONGS_PLAYLIST = 32; std::optional GetMusicCatEntryName(const std::string &filename, size_t entrynum); std::optional> GetMusicCatEntryData(const std::string &filename, size_t entrynum); -enum MusicTrackType { +enum MusicTrackType : uint8_t { MTT_STANDARDMIDI, ///< Standard MIDI file MTT_MPSMIDI, ///< MPS GM driver MIDI format (contained in a CAT file) }; diff --git a/src/base_station_base.h b/src/base_station_base.h index 72a5bb85ce..e4e6965f6a 100644 --- a/src/base_station_base.h +++ b/src/base_station_base.h @@ -34,8 +34,7 @@ struct RoadStopTileData { /** StationRect - used to track station spread out rectangle - cheaper than scanning whole map */ struct StationRect : public Rect { - enum StationRectMode - { + enum StationRectMode : uint8_t { ADD_TEST = 0, ADD_TRY, ADD_FORCE diff --git a/src/blitter/32bpp_sse2.hpp b/src/blitter/32bpp_sse2.hpp index ebbb31e059..257395f9ba 100644 --- a/src/blitter/32bpp_sse2.hpp +++ b/src/blitter/32bpp_sse2.hpp @@ -38,14 +38,14 @@ public: static_assert(sizeof(MapValue) == 2); /** Helper for creating specialised functions for specific optimisations. */ - enum ReadMode { + enum ReadMode : uint8_t { RM_WITH_SKIP, ///< Use normal code for skipping empty pixels. RM_WITH_MARGIN, ///< Use cached number of empty pixels at begin and end of line to reduce work. RM_NONE, ///< No specialisation. }; /** Helper for creating specialised functions for the case where the sprite width is odd or even. */ - enum BlockType { + enum BlockType : uint8_t { BT_EVEN, ///< An even number of pixels in the width; no need for a special case for the last pixel. BT_ODD, ///< An odd number of pixels in the width; special case for the last pixel. BT_NONE, ///< No specialisation for either case. @@ -56,7 +56,7 @@ public: * - calculations (alpha blending), * - heavy branching (remap lookups and animation buffer handling). */ - enum SpriteFlags { + enum SpriteFlags : uint8_t { SF_NONE = 0, SF_TRANSLUCENT = 1 << 1, ///< The sprite has at least 1 translucent pixel. SF_NO_REMAP = 1 << 2, ///< The sprite has no remappable colour pixel. diff --git a/src/bridge.h b/src/bridge.h index e54e94cf72..0fa4822336 100644 --- a/src/bridge.h +++ b/src/bridge.h @@ -19,7 +19,7 @@ * which is used to determine the proper sprite table to use * while drawing a given bridge part. */ -enum BridgePieces { +enum BridgePieces : uint8_t { BRIDGE_PIECE_NORTH = 0, BRIDGE_PIECE_SOUTH, BRIDGE_PIECE_INNER_NORTH, diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index be43b94707..09ecb4e68b 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -1159,7 +1159,7 @@ void GUIEngineListAddChildren(GUIEngineList &dst, const GUIEngineList &src, Engi } /** Enum referring to the Hotkeys in the build vehicle window */ -enum BuildVehicleHotkeys { +enum BuildVehicleHotkeys : int32_t { BVHK_FOCUS_FILTER_BOX, ///< Focus the edit box for editing the filter string }; diff --git a/src/cargo_type.h b/src/cargo_type.h index 0b3cf9da4e..009a8d060f 100644 --- a/src/cargo_type.h +++ b/src/cargo_type.h @@ -80,7 +80,7 @@ static const CargoType CARGO_NO_REFIT = 0xFE; ///< Do not refit cargo of a vehic static const CargoType INVALID_CARGO = UINT8_MAX; /** Mixed cargo types for definitions with cargo that can vary depending on climate. */ -enum MixedCargoType { +enum MixedCargoType : uint8_t { MCT_LIVESTOCK_FRUIT, ///< Cargo can be livestock or fruit. MCT_GRAIN_WHEAT_MAIZE, ///< Cargo can be grain, wheat or maize. MCT_VALUABLES_GOLD_DIAMONDS, ///< Cargo can be valuables, gold or diamonds. diff --git a/src/cargopacket.h b/src/cargopacket.h index 6e6ffee9c1..42c12fbb5b 100644 --- a/src/cargopacket.h +++ b/src/cargopacket.h @@ -292,7 +292,7 @@ public: typedef typename Tcont::const_reverse_iterator ConstReverseIterator; /** Kind of actions that could be done with packets on move. */ - enum MoveToAction { + enum MoveToAction : uint8_t { MTA_BEGIN = 0, MTA_TRANSFER = 0, ///< Transfer the cargo to the station. MTA_DELIVER, ///< Deliver the cargo to some town or industry. diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp index 4d1b1b7526..89f9b4d98a 100644 --- a/src/cheat_gui.cpp +++ b/src/cheat_gui.cpp @@ -168,7 +168,7 @@ static int32_t ClickChangeMaxHlCheat(int32_t new_value, int32_t) } /** Available cheats. */ -enum CheatNumbers { +enum CheatNumbers : uint8_t { CHT_MONEY, ///< Change amount of money. CHT_CHANGE_COMPANY, ///< Switch company. CHT_EXTRA_DYNAMITE, ///< Dynamite anything. diff --git a/src/clear_map.h b/src/clear_map.h index 64eb640d12..4399d2c169 100644 --- a/src/clear_map.h +++ b/src/clear_map.h @@ -16,7 +16,7 @@ /** * Ground types. Valid densities in comments after the enum. */ -enum ClearGround { +enum ClearGround : uint8_t { CLEAR_GRASS = 0, ///< 0-3 CLEAR_ROUGH = 1, ///< 3 CLEAR_ROCKS = 2, ///< 3 diff --git a/src/command_type.h b/src/command_type.h index 5b6aca1123..1fac124552 100644 --- a/src/command_type.h +++ b/src/command_type.h @@ -184,7 +184,7 @@ public: * * @see _command_proc_table */ -enum Commands : uint16_t { +enum Commands : uint8_t { CMD_BUILD_RAILROAD_TRACK, ///< build a rail track CMD_REMOVE_RAILROAD_TRACK, ///< remove a rail track CMD_BUILD_SINGLE_RAIL, ///< build a single rail track @@ -371,7 +371,7 @@ enum Commands : uint16_t { * * This enums defines some flags which can be used for the commands. */ -enum DoCommandFlag { +enum DoCommandFlag : uint16_t { DC_NONE = 0x000, ///< no flag is set DC_EXEC = 0x001, ///< execute the given command DC_AUTO = 0x002, ///< don't allow building on structures @@ -393,7 +393,7 @@ DECLARE_ENUM_AS_BIT_SET(DoCommandFlag) * * This enumeration defines flags for the _command_proc_table. */ -enum CommandFlags { +enum CommandFlags : uint16_t { CMD_SERVER = 0x001, ///< the command can only be initiated by the server CMD_SPECTATOR = 0x002, ///< the command may be initiated by a spectator CMD_OFFLINE = 0x004, ///< the command cannot be executed in a multiplayer game; single-player only @@ -410,7 +410,7 @@ enum CommandFlags { DECLARE_ENUM_AS_BIT_SET(CommandFlags) /** Types of commands we have. */ -enum CommandType { +enum CommandType : uint8_t { CMDT_LANDSCAPE_CONSTRUCTION, ///< Construction and destruction of objects on the map. CMDT_VEHICLE_CONSTRUCTION, ///< Construction, modification (incl. refit) and destruction of vehicles. CMDT_MONEY_MANAGEMENT, ///< Management of money, i.e. loans. @@ -425,7 +425,7 @@ enum CommandType { }; /** Different command pause levels. */ -enum CommandPauseLevel { +enum CommandPauseLevel : uint8_t { CMDPL_NO_ACTIONS, ///< No user actions may be executed. CMDPL_NO_CONSTRUCTION, ///< No construction actions may be executed. CMDPL_NO_LANDSCAPING, ///< No landscaping actions may be executed. diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 28cca27403..90971fe180 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -2208,7 +2208,7 @@ struct CompanyWindow : Window CompanyWidgets query_widget; /** Display planes in the company window. */ - enum CompanyWindowPlanes { + enum CompanyWindowPlanes : uint8_t { /* Display planes of the #WID_C_SELECT_VIEW_BUILD_HQ selection widget. */ CWP_VB_VIEW = 0, ///< Display the view button CWP_VB_BUILD, ///< Display the build button diff --git a/src/company_manager_face.h b/src/company_manager_face.h index db64b720f8..c36a629c4e 100644 --- a/src/company_manager_face.h +++ b/src/company_manager_face.h @@ -16,7 +16,7 @@ #include "company_type.h" /** The gender/race combinations that we have faces for */ -enum GenderEthnicity { +enum GenderEthnicity : uint8_t { GENDER_FEMALE = 0, ///< This bit set means a female, otherwise male ETHNICITY_BLACK = 1, ///< This bit set means black, otherwise white @@ -29,7 +29,7 @@ enum GenderEthnicity { DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) ///< See GenderRace as a bitset /** Bitgroups of the CompanyManagerFace variable */ -enum CompanyManagerFaceVariable { +enum CompanyManagerFaceVariable : uint8_t { CMFV_GENDER, CMFV_ETHNICITY, CMFV_GEN_ETHN, diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index cae08abe2e..9e234b6698 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -1959,7 +1959,7 @@ static std::vector> _consol { "server", &_settings_client.network.server_authorized_keys }, }; -enum ConNetworkAuthorizedKeyAction { +enum ConNetworkAuthorizedKeyAction : uint8_t { CNAKA_LIST, CNAKA_ADD, CNAKA_REMOVE, diff --git a/src/console_internal.h b/src/console_internal.h index 4f6dcb4714..cbf4c61bc5 100644 --- a/src/console_internal.h +++ b/src/console_internal.h @@ -16,7 +16,7 @@ static const uint ICON_CMDLN_SIZE = 1024; ///< maximum length of a typed in static const uint ICON_MAX_STREAMSIZE = 2048; ///< maximum length of a totally expanded command /** Return values of console hooks (#IConsoleHook). */ -enum ConsoleHookResult { +enum ConsoleHookResult : uint8_t { CHR_ALLOW, ///< Allow command execution. CHR_DISALLOW, ///< Disallow command execution. CHR_HIDE, ///< Hide the existence of the command. diff --git a/src/console_type.h b/src/console_type.h index 8c40b4f5b5..705f58e5fe 100644 --- a/src/console_type.h +++ b/src/console_type.h @@ -13,7 +13,7 @@ #include "gfx_type.h" /** Modes of the in-game console. */ -enum IConsoleModes { +enum IConsoleModes : uint8_t { ICONSOLE_FULL, ///< In-game console is opened, whole screen. ICONSOLE_OPENED, ///< In-game console is opened, upper 1/3 of the screen. ICONSOLE_CLOSED, ///< In-game console is closed. diff --git a/src/core/pool_type.hpp b/src/core/pool_type.hpp index 97f92299a4..2cdb3254c4 100644 --- a/src/core/pool_type.hpp +++ b/src/core/pool_type.hpp @@ -13,7 +13,7 @@ #include "enum_type.hpp" /** Various types of a pool. */ -enum PoolType { +enum PoolType : uint8_t { PT_NONE = 0x00, ///< No pool is selected. PT_NORMAL = 0x01, ///< Normal pool containing game objects. PT_NCLIENT = 0x02, ///< Network client pools. diff --git a/src/currency.h b/src/currency.h index d7f8a75e07..bc9cb75550 100644 --- a/src/currency.h +++ b/src/currency.h @@ -23,7 +23,7 @@ static constexpr TimerGameCalendar::Year MIN_EURO_YEAR{2000}; ///< The earliest * savegame compatibility and in order to refer to them quickly, especially * for referencing the custom one. */ -enum Currencies { +enum Currencies : uint8_t { CURRENCY_GBP, ///< British Pound CURRENCY_USD, ///< US Dollar CURRENCY_EUR, ///< Euro diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 856381fb2a..797884929a 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -436,7 +436,7 @@ struct DepotWindow : Window { const Vehicle *wagon; }; - enum DepotGUIAction { + enum DepotGUIAction : uint8_t { MODE_ERROR, MODE_DRAG_VEHICLE, MODE_SHOW_VEHICLE, diff --git a/src/direction_type.h b/src/direction_type.h index b372300f38..0a2fd78b5c 100644 --- a/src/direction_type.h +++ b/src/direction_type.h @@ -55,7 +55,7 @@ DECLARE_INCREMENT_DECREMENT_OPERATORS(Direction) * modulo DIR_END or use the #ChangeDirDiff(DirDiff, DirDiff) function. * @see ChangeDirDiff(DirDiff, DirDiff) */ -enum DirDiff { +enum DirDiff : uint8_t { DIRDIFF_SAME = 0, ///< Both directions faces to the same direction DIRDIFF_45RIGHT = 1, ///< Angle of 45 degrees right DIRDIFF_90RIGHT = 2, ///< Angle of 90 degrees right @@ -92,7 +92,7 @@ DECLARE_ENUM_AS_ADDABLE(DiagDirection) * * @see DirDiff */ -enum DiagDirDiff { +enum DiagDirDiff : uint8_t { DIAGDIRDIFF_BEGIN = 0, ///< Used for iterations DIAGDIRDIFF_SAME = 0, ///< Same directions DIAGDIRDIFF_90RIGHT = 1, ///< 90 degrees right diff --git a/src/disaster_vehicle.h b/src/disaster_vehicle.h index 3911140527..7b24c58895 100644 --- a/src/disaster_vehicle.h +++ b/src/disaster_vehicle.h @@ -13,7 +13,7 @@ #include "vehicle_base.h" /** Different sub types of disaster vehicles. */ -enum DisasterSubType { +enum DisasterSubType : uint8_t { ST_ZEPPELINER, ///< Zeppelin, crashes at airports. ST_ZEPPELINER_SHADOW, ///< Shadow of the zeppelin. ST_SMALL_UFO, ///< Small UFO, tries to find a road vehicle to destroy. diff --git a/src/driver.h b/src/driver.h index 37d14e8064..73fb677464 100644 --- a/src/driver.h +++ b/src/driver.h @@ -35,7 +35,7 @@ public: virtual ~Driver() = default; /** The type of driver */ - enum Type { + enum Type : uint8_t { DT_BEGIN = 0, ///< Helper for iteration DT_MUSIC = 0, ///< A music driver, needs to be before sound to properly shut down extmidi forked music players DT_SOUND, ///< A sound driver diff --git a/src/economy_type.h b/src/economy_type.h index 0ee5e9e79b..24e2ef7d1c 100644 --- a/src/economy_type.h +++ b/src/economy_type.h @@ -57,7 +57,7 @@ struct Economy { }; /** Score categories in the detailed performance rating. */ -enum ScoreID { +enum ScoreID : uint8_t { SCORE_BEGIN = 0, SCORE_VEHICLES = 0, SCORE_STATIONS = 1, @@ -71,11 +71,16 @@ enum ScoreID { SCORE_TOTAL = 9, ///< This must always be the last entry SCORE_END = 10, ///< How many scores are there.. - SCORE_MAX = 1000, ///< The max score that can be in the performance history - /* the scores together of score_info is allowed to be more! */ + }; DECLARE_INCREMENT_DECREMENT_OPERATORS(ScoreID) +/** + * The max score that can be in the performance history. + * The scores together of score_info is allowed to be more! + */ +static constexpr int SCORE_MAX = 1000; + /** Data structure for storing how the score is computed for a single score id. */ struct ScoreInfo { int needed; ///< How much you need to get the perfect score @@ -195,7 +200,7 @@ using Expenses = std::array; /** * Categories of a price bases. */ -enum PriceCategory { +enum PriceCategory : uint8_t { PCAT_NONE, ///< Not affected by difficulty settings PCAT_RUNNING, ///< Price is affected by "vehicle running cost" difficulty setting PCAT_CONSTRUCTION, ///< Price is affected by "construction cost" difficulty setting diff --git a/src/effectvehicle_func.h b/src/effectvehicle_func.h index 198f47ac7e..a611bda3cd 100644 --- a/src/effectvehicle_func.h +++ b/src/effectvehicle_func.h @@ -13,7 +13,7 @@ #include "vehicle_type.h" /** Effect vehicle types */ -enum EffectVehicleType { +enum EffectVehicleType : uint8_t { EV_CHIMNEY_SMOKE = 0, ///< Smoke of power plant (industry). EV_STEAM_SMOKE = 1, ///< Smoke of steam engines. EV_DIESEL_SMOKE = 2, ///< Smoke of diesel engines. diff --git a/src/engine_type.h b/src/engine_type.h index 74d4005f77..ee41c09866 100644 --- a/src/engine_type.h +++ b/src/engine_type.h @@ -90,7 +90,7 @@ struct ShipVehicleInfo { * If bit 0 is 0 then it is a helicopter, otherwise it is a plane * in which case bit 1 tells us whether it's a big(fast) plane or not. */ -enum AircraftSubTypeBits { +enum AircraftSubTypeBits : uint8_t { AIR_HELI = 0, AIR_CTOL = 1, ///< Conventional Take Off and Landing, i.e. planes AIR_FAST = 2 @@ -168,7 +168,7 @@ struct EngineInfo { /** * EngineInfo.misc_flags is a bitmask, with the following values */ -enum EngineMiscFlags { +enum EngineMiscFlags : uint8_t { EF_RAIL_TILTS = 0, ///< Rail vehicle tilts in curves EF_ROAD_TRAM = 0, ///< Road vehicle is a tram/light rail vehicle EF_USES_2CC = 1, ///< Vehicle uses two company colours @@ -183,7 +183,7 @@ enum EngineMiscFlags { /** * Engine.flags is a bitmask, with the following values. */ -enum EngineFlags { +enum EngineFlags : uint8_t { ENGINE_AVAILABLE = 1, ///< This vehicle is available to everyone. ENGINE_EXCLUSIVE_PREVIEW = 2, ///< This vehicle is in the exclusive preview stage, either being used or being offered to a company. }; diff --git a/src/error.h b/src/error.h index f9480745f4..7cfe9addcb 100644 --- a/src/error.h +++ b/src/error.h @@ -20,7 +20,7 @@ struct GRFFile; /** Message severity/type */ -enum WarningLevel { +enum WarningLevel : uint8_t { WL_INFO, ///< Used for DoCommand-like (and some non-fatal AI GUI) errors/information WL_WARNING, ///< Other information WL_ERROR, ///< Errors (eg. saving/loading failed) diff --git a/src/fileio_func.h b/src/fileio_func.h index 0c2cff30f9..a6b11538b3 100644 --- a/src/fileio_func.h +++ b/src/fileio_func.h @@ -60,7 +60,7 @@ class TarScanner : FileScanner { uint DoScan(Subdirectory sd); public: /** The mode of tar scanning. */ - enum Mode { + enum Mode : uint8_t { NONE = 0, ///< Scan nothing. BASESET = 1 << 0, ///< Scan for base sets. NEWGRF = 1 << 1, ///< Scan for non-base sets. diff --git a/src/fileio_type.h b/src/fileio_type.h index 1b55b257a3..78e97f438d 100644 --- a/src/fileio_type.h +++ b/src/fileio_type.h @@ -13,7 +13,7 @@ #include "core/enum_type.hpp" /** The different abstract types of files that the system knows about. */ -enum AbstractFileType { +enum AbstractFileType : uint8_t { FT_NONE, ///< nothing to do FT_SAVEGAME, ///< old or new savegame FT_SCENARIO, ///< old or new scenario @@ -26,7 +26,7 @@ enum AbstractFileType { }; /** Kinds of files in each #AbstractFileType. */ -enum DetailedFileType { +enum DetailedFileType : uint8_t { /* Save game and scenario files. */ DFT_OLD_GAME_FILE, ///< Old save game or scenario file. DFT_GAME_FILE, ///< Save game or scenario file. @@ -50,7 +50,7 @@ enum DetailedFileType { }; /** Operation performed on the file. */ -enum SaveLoadOperation { +enum SaveLoadOperation : uint8_t { SLO_CHECK, ///< Load file for checking and/or preview. SLO_LOAD, ///< File is being loaded. SLO_SAVE, ///< File is being saved. @@ -70,7 +70,7 @@ enum SaveLoadOperation { * Values are a combination of #AbstractFileType and #DetailedFileType. * @see GetAbstractFileType GetDetailedFileType */ -enum FiosType { +enum FiosType : uint16_t { FIOS_TYPE_DRIVE = MAKE_FIOS_TYPE(FT_NONE, DFT_FIOS_DRIVE), FIOS_TYPE_PARENT = MAKE_FIOS_TYPE(FT_NONE, DFT_FIOS_PARENT), FIOS_TYPE_DIR = MAKE_FIOS_TYPE(FT_NONE, DFT_FIOS_DIR), @@ -112,7 +112,7 @@ inline DetailedFileType GetDetailedFileType(FiosType fios_type) /** * The different kinds of subdirectories OpenTTD uses */ -enum Subdirectory { +enum Subdirectory : uint8_t { BASE_DIR, ///< Base directory for all subdirectories SAVE_DIR, ///< Base directory for all savegames AUTOSAVE_DIR, ///< Subdirectory of save for autosaves @@ -136,7 +136,7 @@ enum Subdirectory { /** * Types of searchpaths OpenTTD might use */ -enum Searchpath : unsigned { +enum Searchpath : uint8_t { SP_FIRST_DIR, SP_WORKING_DIR = SP_FIRST_DIR, ///< Search in the working directory #ifdef USE_XDG diff --git a/src/fios.h b/src/fios.h index 03ccf64edb..f93f01e3c2 100644 --- a/src/fios.h +++ b/src/fios.h @@ -19,7 +19,7 @@ /** Special values for save-load window for the data parameter of #InvalidateWindowData. */ -enum SaveLoadInvalidateWindowData { +enum SaveLoadInvalidateWindowData : uint8_t { SLIWD_RESCAN_FILES, ///< Rescan all files (when changed directory, ...) SLIWD_SELECTION_CHANGES, ///< File selection has changed (user click, ...) SLIWD_FILTER_CHANGES, ///< The filename filter has changed (via the editbox) @@ -91,7 +91,7 @@ public: const FiosItem *FindItem(const std::string_view file); }; -enum SortingBits { +enum SortingBits : uint8_t { SORT_ASCENDING = 0, SORT_DESCENDING = 1, SORT_BY_DATE = 0, diff --git a/src/framerate_type.h b/src/framerate_type.h index 722595519b..3697a545d9 100644 --- a/src/framerate_type.h +++ b/src/framerate_type.h @@ -44,7 +44,7 @@ * @note When adding new elements here, make sure to also update all other locations depending on the length and order of this enum. * See Adding new measurements above. */ -enum PerformanceElement { +enum PerformanceElement : uint8_t { PFE_FIRST = 0, PFE_GAMELOOP = 0, ///< Speed of gameloop processing. PFE_GL_ECONOMY, ///< Time spent processing cargo movement diff --git a/src/game/game_text.hpp b/src/game/game_text.hpp index 47941d6e36..1f9c0c5c34 100644 --- a/src/game/game_text.hpp +++ b/src/game/game_text.hpp @@ -13,7 +13,7 @@ #include "../strings_type.h" struct StringParam { - enum ParamType { + enum ParamType : uint8_t { UNUSED, RAW_STRING, STRING, diff --git a/src/genworld.h b/src/genworld.h index 14bc5dda9e..4c90930f81 100644 --- a/src/genworld.h +++ b/src/genworld.h @@ -14,7 +14,7 @@ #include /** Constants related to world generation */ -enum LandscapeGenerator { +enum LandscapeGenerator : uint8_t { /* Order of these enums has to be the same as in lang/english.txt * Otherwise you will get inconsistent behaviour. */ LG_ORIGINAL = 0, ///< The original landscape generator @@ -24,7 +24,7 @@ enum LandscapeGenerator { static const uint32_t GENERATE_NEW_SEED = UINT32_MAX; ///< Create a new random seed /** Modes for GenerateWorld */ -enum GenWorldMode { +enum GenWorldMode : uint8_t { GWM_NEWGAME = 0, ///< Generate a map for a new game GWM_EMPTY = 1, ///< Generate an empty map (sea-level) GWM_RANDOM = 2, ///< Generate a random map for SE @@ -32,7 +32,7 @@ enum GenWorldMode { }; /** Smoothness presets. */ -enum TgenSmoothness { +enum TgenSmoothness : uint8_t { TGEN_SMOOTHNESS_BEGIN, ///< First smoothness value. TGEN_SMOOTHNESS_VERY_SMOOTH = TGEN_SMOOTHNESS_BEGIN, ///< Smoothness preset 'very smooth'. TGEN_SMOOTHNESS_SMOOTH, ///< Smoothness preset 'smooth'. @@ -66,7 +66,7 @@ struct GenWorldInfo { }; /** Current stage of world generation process */ -enum GenWorldProgress { +enum GenWorldProgress : uint8_t { GWP_MAP_INIT, ///< Initialize/allocate the map, start economy GWP_LANDSCAPE, ///< Create the landscape GWP_RIVER, ///< Create the rivers diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index d19807ba2c..e558744825 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -43,7 +43,7 @@ extern void MakeNewgameSettingsLive(); /** Enum for the modes we can generate in. */ -enum GenerateLandscapeWindowMode { +enum GenerateLandscapeWindowMode : uint8_t { GLWM_GENERATE, ///< Generate new game. GLWM_HEIGHTMAP, ///< Load from heightmap. GLWM_SCENARIO, ///< Generate flat land. diff --git a/src/gfx_type.h b/src/gfx_type.h index 984c2d9132..59a0933267 100644 --- a/src/gfx_type.h +++ b/src/gfx_type.h @@ -24,7 +24,7 @@ struct PalSpriteID { PaletteID pal; ///< The palette (use \c PAL_NONE) if not needed) }; -enum WindowKeyCodes { +enum WindowKeyCodes : uint16_t { WKC_SHIFT = 0x8000, WKC_CTRL = 0x4000, WKC_ALT = 0x2000, @@ -239,7 +239,7 @@ static_assert(sizeof(Colour) == sizeof(uint32_t)); /** Available font sizes */ -enum FontSize { +enum FontSize : uint8_t { FS_NORMAL, ///< Index of the normal font in the font tables. FS_SMALL, ///< Index of the small font in the font tables. FS_LARGE, ///< Index of the large font in the font tables. @@ -291,7 +291,7 @@ DECLARE_INCREMENT_DECREMENT_OPERATORS(Colours) DECLARE_ENUM_AS_ADDABLE(Colours) /** Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palette.png */ -enum TextColour { +enum TextColour : uint16_t { TC_BEGIN = 0x00, TC_FROMSTRING = 0x00, TC_BLUE = 0x00, @@ -328,14 +328,14 @@ static constexpr uint8_t PALETTE_ANIM_SIZE = 28; ///< number of animated colours static constexpr uint8_t PALETTE_ANIM_START = 227; ///< Index in the _palettes array from which all animations are taking places (table/palettes.h) /** Define the operation GfxFillRect performs */ -enum FillRectMode { +enum FillRectMode : uint8_t { FILLRECT_OPAQUE, ///< Fill rectangle with a single colour FILLRECT_CHECKER, ///< Draw only every second pixel, used for greying-out FILLRECT_RECOLOUR, ///< Apply a recolour sprite to the screen content }; /** Palettes OpenTTD supports. */ -enum PaletteType { +enum PaletteType : uint8_t { PAL_DOS, ///< Use the DOS palette. PAL_WINDOWS, ///< Use the Windows palette. }; @@ -364,14 +364,14 @@ struct Palette { }; /** Modes for 8bpp support */ -enum Support8bpp { +enum Support8bpp : uint8_t { S8BPP_NONE = 0, ///< No support for 8bpp by OS or hardware, force 32bpp blitters. S8BPP_SYSTEM, ///< No 8bpp support by hardware, do not try to use 8bpp video modes or hardware palettes. S8BPP_HARDWARE, ///< Full 8bpp support by OS and hardware. }; /** How to align the to-be drawn text. */ -enum StringAlignment { +enum StringAlignment : uint8_t { SA_LEFT = 0 << 0, ///< Left align the text. SA_HOR_CENTER = 1 << 0, ///< Horizontally center the text. SA_RIGHT = 2 << 0, ///< Right align the text (must be a single bit). diff --git a/src/goal_gui.cpp b/src/goal_gui.cpp index 504687dc13..3780c9f290 100644 --- a/src/goal_gui.cpp +++ b/src/goal_gui.cpp @@ -31,7 +31,7 @@ #include "safeguards.h" /** Goal list columns. */ -enum GoalColumn { +enum GoalColumn : uint8_t { GC_GOAL = 0, ///< Goal text column. GC_PROGRESS, ///< Goal progress column. }; diff --git a/src/ground_vehicle.hpp b/src/ground_vehicle.hpp index c14d04ca79..b82cb33e3c 100644 --- a/src/ground_vehicle.hpp +++ b/src/ground_vehicle.hpp @@ -18,7 +18,7 @@ #include "widgets/vehicle_widget.h" /** What is the status of our acceleration? */ -enum AccelStatus { +enum AccelStatus : uint8_t { AS_ACCEL, ///< We want to go faster, if possible of course. AS_BRAKE, ///< We want to stop. }; @@ -51,7 +51,7 @@ struct GroundVehicleCache { }; /** Ground vehicle flags. */ -enum GroundVehicleFlags { +enum GroundVehicleFlags : uint8_t { GVF_GOINGUP_BIT = 0, ///< Vehicle is currently going uphill. (Cached track information for acceleration) GVF_GOINGDOWN_BIT = 1, ///< Vehicle is currently going downhill. (Cached track information for acceleration) GVF_SUPPRESS_IMPLICIT_ORDERS = 2, ///< Disable insertion and removal of automatic orders until the vehicle completes the real order. diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 9f813db8ad..4dd3892ea6 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -190,7 +190,7 @@ void BuildGuiGroupList(GUIGroupList &dst, bool fold, Owner owner, VehicleType ve class VehicleGroupWindow : public BaseVehicleListWindow { private: /* Columns in the group list */ - enum ListColumns { + enum ListColumns : uint8_t { VGC_FOLD, ///< Fold / Unfold button. VGC_NAME, ///< Group name. VGC_PROTECT, ///< Autoreplace protect icon. diff --git a/src/heightmap.h b/src/heightmap.h index 20e7ff5938..5809e1b126 100644 --- a/src/heightmap.h +++ b/src/heightmap.h @@ -16,7 +16,7 @@ * Order of these enums has to be the same as in lang/english.txt * Otherwise you will get inconsistent behaviour. */ -enum HeightmapRotation { +enum HeightmapRotation : uint8_t { HM_COUNTER_CLOCKWISE, ///< Rotate the map counter clockwise 45 degrees HM_CLOCKWISE, ///< Rotate the map clockwise 45 degrees }; diff --git a/src/industry.h b/src/industry.h index a3e66f1ae1..6e19921cdf 100644 --- a/src/industry.h +++ b/src/industry.h @@ -306,7 +306,7 @@ extern IndustryBuildData _industry_builder; /** Special values for the industry list window for the data parameter of #InvalidateWindowData. */ -enum IndustryDirectoryInvalidateWindowData { +enum IndustryDirectoryInvalidateWindowData : uint8_t { IDIWD_FORCE_REBUILD, IDIWD_PRODUCTION_CHANGE, IDIWD_FORCE_RESORT, diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index ca451840c3..13fad2e46d 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -58,14 +58,14 @@ bool _ignore_restrictions; std::bitset _displayed_industries; ///< Communication from the industry chain window to the smallmap window about what industries to display. /** Cargo suffix type (for which window is it requested) */ -enum CargoSuffixType { +enum CargoSuffixType : uint8_t { CST_FUND, ///< Fund-industry window CST_VIEW, ///< View-industry window CST_DIR, ///< Industry-directory window }; /** Ways of displaying the cargo. */ -enum CargoSuffixDisplay { +enum CargoSuffixDisplay : uint8_t { CSD_CARGO, ///< Display the cargo without sub-type (cb37 result 401). CSD_CARGO_AMOUNT, ///< Display the cargo and amount (if useful), but no sub-type (cb37 result 400 or fail). CSD_CARGO_TEXT, ///< Display then cargo and supplied string (cb37 result 800-BFF). @@ -138,7 +138,7 @@ static void GetCargoSuffix(uint cargo, CargoSuffixType cst, const Industry *ind, } } -enum CargoSuffixInOut { +enum CargoSuffixInOut : uint8_t { CARGOSUFFIX_OUT = 0, CARGOSUFFIX_IN = 1, }; @@ -789,14 +789,14 @@ static inline bool IsProductionAlterable(const Industry *i) class IndustryViewWindow : public Window { /** Modes for changing production */ - enum Editability { + enum Editability : uint8_t { EA_NONE, ///< Not alterable EA_MULTIPLIER, ///< Allow changing the production multiplier EA_RATE, ///< Allow changing the production rates }; /** Specific lines in the info panel */ - enum InfoLine { + enum InfoLine : uint8_t { IL_NONE, ///< No line IL_MULTIPLIER, ///< Production multiplier IL_RATE1, ///< Production rate of cargo 1 @@ -1334,7 +1334,7 @@ static bool CargoFilter(const Industry * const *industry, const std::pair Playlist; - enum PlaylistChoices { + enum PlaylistChoices : uint8_t { PLCH_ALLMUSIC, PLCH_OLDSTYLE, PLCH_NEWSTYLE, diff --git a/src/network/core/address.h b/src/network/core/address.h index 3dbffc6c23..1eaad8479d 100644 --- a/src/network/core/address.h +++ b/src/network/core/address.h @@ -183,7 +183,7 @@ public: * * Sorting will prefer entries at the top of this list above ones at the bottom. */ -enum ServerAddressType { +enum ServerAddressType : uint8_t { SERVER_ADDRESS_DIRECT, ///< Server-address is based on an hostname:port. SERVER_ADDRESS_INVITE_CODE, ///< Server-address is based on an invite code. }; diff --git a/src/network/core/core.h b/src/network/core/core.h index 3b63aadc5f..aa354d326c 100644 --- a/src/network/core/core.h +++ b/src/network/core/core.h @@ -20,7 +20,7 @@ bool NetworkCoreInitialize(); void NetworkCoreShutdown(); /** Status of a network client; reasons why a client has quit */ -enum NetworkRecvStatus { +enum NetworkRecvStatus : uint8_t { NETWORK_RECV_STATUS_OKAY, ///< Everything is okay. NETWORK_RECV_STATUS_DESYNC, ///< A desync did occur. NETWORK_RECV_STATUS_NEWGRF_MISMATCH, ///< We did not have the required NewGRFs. diff --git a/src/network/core/tcp.h b/src/network/core/tcp.h index b63bfdea6d..f7c0830b1a 100644 --- a/src/network/core/tcp.h +++ b/src/network/core/tcp.h @@ -20,7 +20,7 @@ #include /** The states of sending the packets. */ -enum SendPacketsState { +enum SendPacketsState : uint8_t { SPS_CLOSED, ///< The connection got closed. SPS_NONE_SENT, ///< The buffer is still full, so no (parts of) packets could be sent. SPS_PARTLY_SENT, ///< The packets are partly sent; there are more packets to be sent in the queue. @@ -80,7 +80,7 @@ private: * game-thread, and not at another random time where we might not have the * lock on the game-state. */ - enum class Status { + enum class Status : uint8_t { Init, ///< TCPConnecter is created but resolving hasn't started. Resolving, ///< The hostname is being resolved (threaded). Failure, ///< Resolving failed. diff --git a/src/network/core/tcp_admin.h b/src/network/core/tcp_admin.h index 41a653165e..e5d71cc0fa 100644 --- a/src/network/core/tcp_admin.h +++ b/src/network/core/tcp_admin.h @@ -70,7 +70,7 @@ enum PacketAdminType : uint8_t { }; /** Status of an admin. */ -enum AdminStatus { +enum AdminStatus : uint8_t { ADMIN_STATUS_INACTIVE, ///< The admin is not connected nor active. ADMIN_STATUS_AUTHENTICATE, ///< The admin is connected and working on authentication. ADMIN_STATUS_ACTIVE, ///< The admin is active. @@ -78,7 +78,7 @@ enum AdminStatus { }; /** Update types an admin can register a frequency for */ -enum AdminUpdateType { +enum AdminUpdateType : uint8_t { ADMIN_UPDATE_DATE, ///< Updates about the date of the game. ADMIN_UPDATE_CLIENT_INFO, ///< Updates about the information of clients. ADMIN_UPDATE_COMPANY_INFO, ///< Updates about the generic information of companies. @@ -93,7 +93,7 @@ enum AdminUpdateType { }; /** Update frequencies an admin can register. */ -enum AdminUpdateFrequency { +enum AdminUpdateFrequency : uint8_t { ADMIN_FREQUENCY_POLL = 0x01, ///< The admin can poll this. ADMIN_FREQUENCY_DAILY = 0x02, ///< The admin gets information about this on a daily basis. ADMIN_FREQUENCY_WEEKLY = 0x04, ///< The admin gets information about this on a weekly basis. @@ -105,7 +105,7 @@ enum AdminUpdateFrequency { DECLARE_ENUM_AS_BIT_SET(AdminUpdateFrequency) /** Reasons for removing a company - communicated to admins. */ -enum AdminCompanyRemoveReason { +enum AdminCompanyRemoveReason : uint8_t { ADMIN_CRR_MANUAL, ///< The company is manually removed. ADMIN_CRR_AUTOCLEAN, ///< The company is removed due to autoclean. ADMIN_CRR_BANKRUPT, ///< The company went belly-up. diff --git a/src/network/core/tcp_content_type.h b/src/network/core/tcp_content_type.h index 23a0d65c4c..de1792d264 100644 --- a/src/network/core/tcp_content_type.h +++ b/src/network/core/tcp_content_type.h @@ -15,7 +15,7 @@ #include "../../3rdparty/md5/md5.h" /** The values in the enum are important; they are used as database 'keys' */ -enum ContentType { +enum ContentType : uint8_t { CONTENT_TYPE_BEGIN = 1, ///< Helper to mark the begin of the types CONTENT_TYPE_BASE_GRAPHICS = 1, ///< The content consists of base graphics CONTENT_TYPE_NEWGRF = 2, ///< The content consists of a NewGRF @@ -44,14 +44,14 @@ enum PacketContentType : uint8_t { }; /** Unique identifier for the content. */ -enum ContentID { - INVALID_CONTENT_ID = UINT32_MAX, ///< Sentinel for invalid content. -}; +using ContentID = uint32_t; + +static constexpr ContentID INVALID_CONTENT_ID = UINT32_MAX; ///< Sentinel for invalid content. /** Container for all important information about a piece of content. */ struct ContentInfo { /** The state the content can be in. */ - enum State { + enum State : uint8_t { UNSELECTED, ///< The content has not been selected SELECTED, ///< The content has been manually selected AUTOSELECTED, ///< The content has been selected as dependency diff --git a/src/network/core/tcp_coordinator.h b/src/network/core/tcp_coordinator.h index 27ed65ec87..a39d13748c 100644 --- a/src/network/core/tcp_coordinator.h +++ b/src/network/core/tcp_coordinator.h @@ -49,7 +49,7 @@ enum PacketCoordinatorType : uint8_t { /** * The type of connection the Game Coordinator can detect we have. */ -enum ConnectionType { +enum ConnectionType : uint8_t { CONNECTION_TYPE_UNKNOWN, ///< The Game Coordinator hasn't informed us yet what type of connection we have. CONNECTION_TYPE_ISOLATED, ///< The Game Coordinator failed to find a way to connect to your server. Nobody will be able to join. CONNECTION_TYPE_DIRECT, ///< The Game Coordinator can directly connect to your server. @@ -60,7 +60,7 @@ enum ConnectionType { /** * The type of error from the Game Coordinator. */ -enum NetworkCoordinatorErrorType { +enum NetworkCoordinatorErrorType : uint8_t { NETWORK_COORDINATOR_ERROR_UNKNOWN, ///< There was an unknown error. NETWORK_COORDINATOR_ERROR_REGISTRATION_FAILED, ///< Your request for registration failed. NETWORK_COORDINATOR_ERROR_INVALID_INVITE_CODE, ///< The invite code given is invalid. diff --git a/src/network/network_client.h b/src/network/network_client.h index b697e8add2..2b1423c82e 100644 --- a/src/network/network_client.h +++ b/src/network/network_client.h @@ -21,7 +21,7 @@ private: uint8_t token = 0; ///< The token we need to send back to the server to prove we're the right client. /** Status of the connection with the server. */ - enum ServerStatus { + enum ServerStatus : uint8_t { STATUS_INACTIVE, ///< The client is not connected nor active. STATUS_JOIN, ///< We are trying to join a server. STATUS_AUTH_GAME, ///< Last action was requesting game (server) password. diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index 9dc26eebeb..9fcf6f5017 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -320,7 +320,7 @@ struct ContentListFilterData { }; /** Filter criteria for NetworkContentListWindow. */ -enum ContentListFilterCriteria { +enum ContentListFilterCriteria : uint8_t { CONTENT_FILTER_TEXT = 0, ///< Filter by query sting CONTENT_FILTER_TYPE_OR_SELECTED,///< Filter by being of displayed type or selected for download }; diff --git a/src/network/network_crypto.h b/src/network/network_crypto.h index aa03ea79ce..8db3f96f07 100644 --- a/src/network/network_crypto.h +++ b/src/network/network_crypto.h @@ -222,7 +222,7 @@ public: class NetworkAuthenticationClientHandler : public NetworkAuthenticationHandler { public: /** The processing result of receiving a request. */ - enum RequestResult { + enum RequestResult : uint8_t { AWAIT_USER_INPUT, ///< We have requested some user input, but must wait on that. READY_FOR_RESPONSE, ///< We do not have to wait for user input, and can immediately respond to the server. INVALID, ///< We have received an invalid request. @@ -258,7 +258,7 @@ public: class NetworkAuthenticationServerHandler : public NetworkAuthenticationHandler { public: /** The processing result of receiving a response. */ - enum ResponseResult { + enum ResponseResult : uint8_t { AUTHENTICATED, ///< The client was authenticated successfully. NOT_AUTHENTICATED, ///< All authentications for this handler have been exhausted. RETRY_NEXT_METHOD, ///< The client failed to authenticate, but there is another method to try. diff --git a/src/network/network_crypto_internal.h b/src/network/network_crypto_internal.h index e2b11997c6..8ddee7e656 100644 --- a/src/network/network_crypto_internal.h +++ b/src/network/network_crypto_internal.h @@ -49,7 +49,7 @@ using X25519Mac = std::array; using X25519KeyExchangeMessage = std::array; /** The side of the key exchange. */ -enum class X25519KeyExchangeSide { +enum class X25519KeyExchangeSide : uint8_t { CLIENT, ///< We are the client. SERVER, ///< We are the server. }; diff --git a/src/network/network_gamelist.h b/src/network/network_gamelist.h index cabedd8ff7..e66a386fe3 100644 --- a/src/network/network_gamelist.h +++ b/src/network/network_gamelist.h @@ -15,7 +15,7 @@ #include "network_type.h" /** The status a server can be in. */ -enum NetworkGameListStatus { +enum NetworkGameListStatus : uint8_t { NGLS_OFFLINE, ///< Server is offline (or cannot be queried). NGLS_ONLINE, ///< Server is online. NGLS_FULL, ///< Server is full and cannot be queried. diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 6c3163ccab..c8577f1d8d 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -1313,7 +1313,7 @@ static WindowDesc _client_list_desc( * The possibly entries in a DropDown for an admin. * Client and companies are mixed; they just have to be unique. */ -enum DropDownAdmin { +enum DropDownAdmin : uint8_t { DD_CLIENT_ADMIN_KICK, DD_CLIENT_ADMIN_BAN, DD_COMPANY_ADMIN_RESET, diff --git a/src/network/network_gui.h b/src/network/network_gui.h index 6c2555a5bf..30a476c696 100644 --- a/src/network/network_gui.h +++ b/src/network/network_gui.h @@ -38,7 +38,7 @@ struct NetworkCompanyInfo : NetworkCompanyStats { std::string clients; ///< The clients that control this company (Name1, name2, ..) }; -enum NetworkRelayWindowCloseData { +enum NetworkRelayWindowCloseData : uint8_t { NRWCD_UNHANDLED = 0, ///< Relay request is unhandled. NRWCD_HANDLED = 1, ///< Relay request is handled, either by user or by timeout. }; diff --git a/src/network/network_internal.h b/src/network/network_internal.h index aa394f6e44..4c9e7ecae4 100644 --- a/src/network/network_internal.h +++ b/src/network/network_internal.h @@ -40,7 +40,7 @@ typedef class ServerNetworkGameSocketHandler NetworkClientSocket; /** Status of the clients during joining. */ -enum NetworkJoinStatus { +enum NetworkJoinStatus : uint8_t { NETWORK_JOIN_STATUS_CONNECTING, NETWORK_JOIN_STATUS_AUTHORIZING, NETWORK_JOIN_STATUS_WAITING, diff --git a/src/network/network_server.h b/src/network/network_server.h index 26dcf3d795..05d3f7bb10 100644 --- a/src/network/network_server.h +++ b/src/network/network_server.h @@ -50,7 +50,7 @@ protected: public: /** Status of a client */ - enum ClientStatus { + enum ClientStatus : uint8_t { STATUS_INACTIVE, ///< The client is not connected nor active. STATUS_AUTH_GAME, ///< The client is authorizing with game (server) password. STATUS_IDENTIFY, ///< The client is identifying itself. diff --git a/src/network/network_survey.h b/src/network/network_survey.h index 8acddb9ede..aa1b664b2b 100644 --- a/src/network/network_survey.h +++ b/src/network/network_survey.h @@ -24,7 +24,7 @@ protected: bool IsCancelled() const override { return false; } public: - enum class Reason { + enum class Reason : uint8_t { PREVIEW, ///< User is previewing the survey result. LEAVE, ///< User is leaving the game (but not exiting the application). EXIT, ///< User is exiting the application. diff --git a/src/network/network_type.h b/src/network/network_type.h index 3e6fb79c20..34375445d7 100644 --- a/src/network/network_type.h +++ b/src/network/network_type.h @@ -25,7 +25,7 @@ static const uint MAX_CLIENT_SLOTS = 256; /** * Vehicletypes in the order they are send in info packets. */ -enum NetworkVehicleType { +enum NetworkVehicleType : uint8_t { NETWORK_VEH_TRAIN = 0, NETWORK_VEH_LORRY, NETWORK_VEH_BUS, @@ -87,7 +87,7 @@ DECLARE_ENUM_AS_ADDABLE(DestType) * Actions that can be used for NetworkTextMessage. * @warning The values of the enum items are part of the admin network API. Only append at the end. */ -enum NetworkAction { +enum NetworkAction : uint8_t { NETWORK_ACTION_JOIN, NETWORK_ACTION_LEAVE, NETWORK_ACTION_SERVER_MESSAGE, @@ -107,7 +107,7 @@ enum NetworkAction { * The error codes we send around in the protocols. * @warning The values of the enum items are part of the admin network API. Only append at the end. */ -enum NetworkErrorCode { +enum NetworkErrorCode : uint8_t { NETWORK_ERROR_GENERAL, // Try to use this one like never /* Signals from clients */ diff --git a/src/newgrf.cpp b/src/newgrf.cpp index c62b304cd2..acf04ff06c 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -314,7 +314,7 @@ static const uint NUM_STATIONS_PER_GRF = UINT16_MAX - 1; /** Temporary engine data used when loading only */ struct GRFTempEngineData { /** Summary state of refittability properties */ - enum Refittability { + enum Refittability : uint8_t { UNSET = 0, ///< No properties assigned. Default refit masks shall be activated. EMPTY, ///< GRF defined vehicle as not-refittable. The vehicle shall only carry the default cargo. NONEMPTY, ///< GRF defined the vehicle as refittable. If the refitmask is empty after translation (cargotypes not available), disable the vehicle. @@ -997,7 +997,7 @@ static void ConvertTTDBasePrice(uint32_t base_pointer, const char *error_locatio } /** Possible return values for the FeatureChangeInfo functions */ -enum ChangeInfoResult { +enum ChangeInfoResult : uint8_t { CIR_SUCCESS, ///< Variable was parsed and read CIR_DISABLED, ///< GRF was disabled due to error CIR_UNHANDLED, ///< Variable was parsed but unread diff --git a/src/newgrf.h b/src/newgrf.h index 518f9cb2c4..f99af841e0 100644 --- a/src/newgrf.h +++ b/src/newgrf.h @@ -23,7 +23,7 @@ * List of different canal 'features'. * Each feature gets an entry in the canal spritegroup table */ -enum CanalFeature { +enum CanalFeature : uint8_t { CF_WATERSLOPE, CF_LOCKS, CF_DIKES, @@ -42,7 +42,7 @@ struct CanalProperties { uint8_t flags; ///< Flags controlling display. }; -enum GrfLoadingStage { +enum GrfLoadingStage : uint8_t { GLS_FILESCAN, GLS_SAFETYSCAN, GLS_LABELSCAN, @@ -54,7 +54,7 @@ enum GrfLoadingStage { DECLARE_INCREMENT_DECREMENT_OPERATORS(GrfLoadingStage) -enum GrfMiscBit { +enum GrfMiscBit : uint8_t { GMB_DESERT_TREES_FIELDS = 0, // Unsupported. GMB_DESERT_PAVED_ROADS = 1, GMB_FIELD_BOUNDING_BOX = 2, // Unsupported. @@ -64,7 +64,7 @@ enum GrfMiscBit { GMB_SECOND_ROCKY_TILE_SET = 6, }; -enum GrfSpecFeature { +enum GrfSpecFeature : uint8_t { GSF_TRAINS, GSF_ROADVEHICLES, GSF_SHIPS, @@ -159,14 +159,14 @@ struct GRFFile : ZeroedMemoryAllocator { } }; -enum ShoreReplacement { +enum ShoreReplacement : uint8_t { SHORE_REPLACE_NONE, ///< No shore sprites were replaced. SHORE_REPLACE_ACTION_5, ///< Shore sprites were replaced by Action5. SHORE_REPLACE_ACTION_A, ///< Shore sprites were replaced by ActionA (using grass tiles for the corner-shores). SHORE_REPLACE_ONLY_NEW, ///< Only corner-shores were loaded by Action5 (openttd(w/d).grf only). }; -enum TramReplacement { +enum TramReplacement : uint8_t { TRAMWAY_REPLACE_DEPOT_NONE, ///< No tram depot graphics were loaded. TRAMWAY_REPLACE_DEPOT_WITH_TRACK, ///< Electrified depot graphics with tram track were loaded. TRAMWAY_REPLACE_DEPOT_NO_TRACK, ///< Electrified depot graphics without tram track were loaded. diff --git a/src/newgrf_act5.h b/src/newgrf_act5.h index f16872424f..1a73fb473d 100644 --- a/src/newgrf_act5.h +++ b/src/newgrf_act5.h @@ -11,7 +11,7 @@ #define NEWGRF_ACT5_H /** The type of action 5 type. */ -enum Action5BlockType { +enum Action5BlockType : uint8_t { A5BLOCK_FIXED, ///< Only allow replacing a whole block of sprites. (TTDP compatible) A5BLOCK_ALLOW_OFFSET, ///< Allow replacing any subset by specifiing an offset. A5BLOCK_INVALID, ///< unknown/not-implemented type diff --git a/src/newgrf_airport.h b/src/newgrf_airport.h index 9c1607a6e0..6e65899ae5 100644 --- a/src/newgrf_airport.h +++ b/src/newgrf_airport.h @@ -67,7 +67,7 @@ public: }; /** List of default airport classes. */ -enum AirportClassID { +enum AirportClassID : uint8_t { APC_BEGIN = 0, ///< Lowest valid airport class id APC_SMALL = 0, ///< id for small airports class APC_LARGE, ///< id for large airports class @@ -80,7 +80,7 @@ enum AirportClassID { DECLARE_INCREMENT_DECREMENT_OPERATORS(AirportClassID) /** TTDP airport types. Used to map our types to TTDPatch's */ -enum TTDPAirportType { +enum TTDPAirportType : uint8_t { ATP_TTDP_SMALL, ///< Same as AT_SMALL ATP_TTDP_LARGE, ///< Same as AT_LARGE ATP_TTDP_HELIPORT, ///< Same as AT_HELIPORT diff --git a/src/newgrf_animation_type.h b/src/newgrf_animation_type.h index 04ad501148..6835111bfb 100644 --- a/src/newgrf_animation_type.h +++ b/src/newgrf_animation_type.h @@ -23,7 +23,7 @@ struct AnimationInfo { }; /** Animation triggers for station. */ -enum StationAnimationTrigger { +enum StationAnimationTrigger : uint8_t { SAT_BUILT, ///< Trigger tile when built. SAT_NEW_CARGO, ///< Trigger station on new cargo arrival. SAT_CARGO_TAKEN, ///< Trigger station when cargo is completely taken. @@ -34,7 +34,7 @@ enum StationAnimationTrigger { }; /** Animation triggers of the industries. */ -enum IndustryAnimationTrigger { +enum IndustryAnimationTrigger : uint8_t { IAT_CONSTRUCTION_STATE_CHANGE, ///< Trigger whenever the construction state changes. IAT_TILELOOP, ///< Trigger in the periodic tile loop. IAT_INDUSTRY_TICK, ///< Trigger every tick. @@ -43,7 +43,7 @@ enum IndustryAnimationTrigger { }; /** Animation triggers for airport tiles */ -enum AirpAnimationTrigger { +enum AirpAnimationTrigger : uint8_t { AAT_BUILT, ///< Triggered when the airport is built (for all tiles at the same time). AAT_TILELOOP, ///< Triggered in the periodic tile loop. AAT_STATION_NEW_CARGO, ///< Triggered when new cargo arrives at the station (for all tiles at the same time). @@ -53,7 +53,7 @@ enum AirpAnimationTrigger { }; /** Animation triggers for objects. */ -enum ObjectAnimationTrigger { +enum ObjectAnimationTrigger : uint8_t { OAT_BUILT, ///< Triggered when the object is built (for all tiles at the same time). OAT_TILELOOP, ///< Triggered in the periodic tile loop. OAT_256_TICKS, ///< Triggered every 256 ticks (for all tiles at the same time). diff --git a/src/newgrf_callbacks.h b/src/newgrf_callbacks.h index 3362641776..792692b34a 100644 --- a/src/newgrf_callbacks.h +++ b/src/newgrf_callbacks.h @@ -17,7 +17,7 @@ * industry, etc. * Names are formatted as CBID__ */ -enum CallbackID { +enum CallbackID : uint16_t { /** Set when using the callback resolve system, but not to resolve a callback. */ CBID_NO_CALLBACK = 0x00, @@ -297,7 +297,7 @@ enum CallbackID { * Callback masks for vehicles, indicates which callbacks are used by a vehicle. * Some callbacks are always used and don't have a mask. */ -enum VehicleCallbackMask { +enum VehicleCallbackMask : uint8_t { CBM_VEHICLE_VISUAL_EFFECT = 0, ///< Visual effects and wagon power (trains, road vehicles and ships) CBM_VEHICLE_LENGTH = 1, ///< Vehicle length (trains and road vehicles) CBM_VEHICLE_LOAD_AMOUNT = 2, ///< Load amount @@ -313,7 +313,7 @@ enum VehicleCallbackMask { /** * Callback masks for stations. */ -enum StationCallbackMask { +enum StationCallbackMask : uint8_t { CBM_STATION_AVAIL = 0, ///< Availability of station in construction window CBM_STATION_DRAW_TILE_LAYOUT = 1, ///< Use callback to select a tile layout to use when drawing. CBM_STATION_ANIMATION_NEXT_FRAME = 2, ///< Use a custom next frame callback @@ -324,7 +324,7 @@ enum StationCallbackMask { /** * Callback masks for road stops. */ -enum RoadStopCallbackMask { +enum RoadStopCallbackMask : uint8_t { CBM_ROAD_STOP_AVAIL = 0, ///< Availability of road stop in construction window CBM_ROAD_STOP_ANIMATION_NEXT_FRAME = 1, ///< Use a custom next frame callback CBM_ROAD_STOP_ANIMATION_SPEED = 2, ///< Customize the animation speed of the road stop @@ -333,7 +333,7 @@ enum RoadStopCallbackMask { /** * Callback masks for houses. */ -enum HouseCallbackMask { +enum HouseCallbackMask : uint8_t { CBM_HOUSE_ALLOW_CONSTRUCTION = 0, ///< decide whether the house can be built on a given tile CBM_HOUSE_ANIMATION_NEXT_FRAME = 1, ///< decides next animation frame CBM_HOUSE_ANIMATION_START_STOP = 2, ///< periodically start/stop the animation @@ -352,14 +352,14 @@ enum HouseCallbackMask { /** * Callback masks for canals. */ -enum CanalCallbackMask { +enum CanalCallbackMask : uint8_t { CBM_CANAL_SPRITE_OFFSET = 0, ///< Enable add sprite offset callback }; /** * Callback masks for cargoes. */ -enum CargoCallbackMask { +enum CargoCallbackMask : uint8_t { CBM_CARGO_PROFIT_CALC = 0, ///< custom profit calculation CBM_CARGO_STATION_RATING_CALC = 1, ///< custom station rating for this cargo type }; @@ -367,7 +367,7 @@ enum CargoCallbackMask { /** * Callback masks for Industries */ -enum IndustryCallbackMask { +enum IndustryCallbackMask : uint8_t { CBM_IND_PROBABILITY = 0, ///< industry availability/probability callback CBM_IND_PRODUCTION_CARGO_ARRIVAL = 1, ///< call production callback when cargo arrives at the industry CBM_IND_PRODUCTION_256_TICKS = 2, ///< call production callback every 256 ticks @@ -388,7 +388,7 @@ enum IndustryCallbackMask { /** * Callback masks for industry tiles */ -enum IndustryTileCallbackMask { +enum IndustryTileCallbackMask : uint8_t { CBM_INDT_ANIM_NEXT_FRAME = 0, ///< decides next animation frame CBM_INDT_ANIM_SPEED = 1, ///< decides animation speed CBM_INDT_CARGO_ACCEPTANCE = 2, ///< decides amount of cargo acceptance @@ -401,7 +401,7 @@ enum IndustryTileCallbackMask { /** * Callback masks for objects */ -enum ObjectCallbackMask { +enum ObjectCallbackMask : uint8_t { CBM_OBJ_SLOPE_CHECK = 0, ///< decides slope suitability CBM_OBJ_ANIMATION_NEXT_FRAME = 1, ///< decides next animation frame CBM_OBJ_ANIMATION_SPEED = 2, ///< decides animation speed @@ -413,7 +413,7 @@ enum ObjectCallbackMask { /** * Callback masks for airport tiles */ -enum AirportTileCallbackMask { +enum AirportTileCallbackMask : uint8_t { CBM_AIRT_ANIM_NEXT_FRAME = 0, ///< decides next animation frame CBM_AIRT_ANIM_SPEED = 1, ///< decides animation speed CBM_AIRT_SHAPE_CHECK = 4, ///< decides slope suitability diff --git a/src/newgrf_canal.h b/src/newgrf_canal.h index 7214499b5f..416403888a 100644 --- a/src/newgrf_canal.h +++ b/src/newgrf_canal.h @@ -14,7 +14,7 @@ #include "tile_type.h" /** Flags controlling the display of canals. */ -enum CanalFeatureFlag { +enum CanalFeatureFlag : uint8_t { CFF_HAS_FLAT_SPRITE = 0, ///< Additional flat ground sprite in the beginning. }; diff --git a/src/newgrf_commons.h b/src/newgrf_commons.h index 0c82254e80..2c1d0cc216 100644 --- a/src/newgrf_commons.h +++ b/src/newgrf_commons.h @@ -20,7 +20,7 @@ #include "company_type.h" /** Context for tile accesses */ -enum TileContext { +enum TileContext : uint8_t { TCX_NORMAL, ///< Nothing special. TCX_UPPER_HALFTILE, ///< Querying information about the upper part of a tile with halftile foundation. TCX_ON_BRIDGE, ///< Querying information about stuff on the bridge (via some bridgehead). @@ -29,7 +29,7 @@ enum TileContext { /** * Flags to enable register usage in sprite layouts. */ -enum TileLayoutFlags { +enum TileLayoutFlags : uint8_t { TLF_NOTHING = 0x00, TLF_DODRAW = 0x01, ///< Only draw sprite if value of register TileLayoutRegisters::dodraw is non-zero. @@ -49,7 +49,7 @@ enum TileLayoutFlags { TLF_KNOWN_FLAGS = 0xFF, ///< Known flags. Any unknown set flag will disable the GRF. /** Flags which are still required after loading the GRF. */ - TLF_DRAWING_FLAGS = ~TLF_CUSTOM_PALETTE, + TLF_DRAWING_FLAGS = TLF_KNOWN_FLAGS & ~TLF_CUSTOM_PALETTE, /** Flags which do not work for the (first) ground sprite. */ TLF_NON_GROUND_FLAGS = TLF_BB_XY_OFFSET | TLF_BB_Z_OFFSET | TLF_CHILD_X_OFFSET | TLF_CHILD_Y_OFFSET, diff --git a/src/newgrf_config.h b/src/newgrf_config.h index 5f8e10a9bd..27bc906207 100644 --- a/src/newgrf_config.h +++ b/src/newgrf_config.h @@ -17,7 +17,7 @@ #include "3rdparty/md5/md5.h" /** GRF config bit flags */ -enum GCF_Flags { +enum GCF_Flags : uint8_t { GCF_SYSTEM, ///< GRF file is an openttd-internal system grf GCF_UNSAFE, ///< GRF file is unsafe for static usage GCF_STATIC, ///< GRF file is used statically (can be used in any MP game) @@ -29,7 +29,7 @@ enum GCF_Flags { }; /** Status of GRF */ -enum GRFStatus { +enum GRFStatus : uint8_t { GCS_UNKNOWN, ///< The status of this grf file is unknown GCS_DISABLED, ///< GRF file is disabled GCS_NOT_FOUND, ///< GRF file was not found in the local cache @@ -38,7 +38,7 @@ enum GRFStatus { }; /** Encountered GRF bugs */ -enum GRFBugs { +enum GRFBugs : uint8_t { GBUG_VEH_LENGTH, ///< Length of rail vehicle changes when not inside a depot GBUG_VEH_REFIT, ///< Articulated vehicles carry different cargoes resp. are differently refittable than specified in purchase list GBUG_VEH_POWERED_WAGON, ///< Powered wagon changed poweredness state when not inside a depot @@ -47,14 +47,14 @@ enum GRFBugs { }; /** Status of post-gameload GRF compatibility check */ -enum GRFListCompatibility { +enum GRFListCompatibility : uint8_t { GLC_ALL_GOOD, ///< All GRF needed by game are present GLC_COMPATIBLE, ///< Compatible (eg. the same ID, but different checksum) GRF found in at least one case GLC_NOT_FOUND, ///< At least one GRF couldn't be found (higher priority than GLC_COMPATIBLE) }; /** Information that can/has to be stored about a GRF's palette. */ -enum GRFPalette { +enum GRFPalette : uint8_t { GRFP_USE_BIT = 0, ///< The bit used for storing the palette to use. GRFP_GRF_OFFSET = 2, ///< The offset of the GRFP_GRF data. GRFP_GRF_SIZE = 2, ///< The size of the GRFP_GRF data. @@ -202,7 +202,7 @@ struct GRFConfig { using GRFConfigList = GRFConfig *; /** Method to find GRFs using FindGRFConfig */ -enum FindGRFConfigMode { +enum FindGRFConfigMode : uint8_t { FGCM_EXACT, ///< Only find Grfs matching md5sum FGCM_COMPATIBLE, ///< Find best compatible Grf wrt. desired_version FGCM_NEWEST, ///< Find newest Grf diff --git a/src/newgrf_debug.h b/src/newgrf_debug.h index dfec7ce7f5..989514db0e 100644 --- a/src/newgrf_debug.h +++ b/src/newgrf_debug.h @@ -15,7 +15,7 @@ #include "vehicle_type.h" /** Current state of spritepicker */ -enum NewGrfDebugSpritePickerMode { +enum NewGrfDebugSpritePickerMode : uint8_t { SPM_NONE, SPM_WAIT_CLICK, SPM_REDRAW, diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp index c608c8ad9c..43826b230b 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -77,7 +77,7 @@ static inline uint GetInspectWindowNumber(GrfSpecFeature feature, uint index) * The type of a property to show. This is used to * provide an appropriate representation in the GUI. */ -enum NIType { +enum NIType : uint8_t { NIT_INT, ///< The property is a simple integer NIT_CARGO, ///< The property is a cargo }; diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index 36c39a8e41..fe07dc16e4 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -94,7 +94,7 @@ static int MapOldSubType(const Vehicle *v) /* TTDP style aircraft movement states for GRF Action 2 Var 0xE2 */ -enum TTDPAircraftMovementStates { +enum TTDPAircraftMovementStates : uint8_t { AMS_TTDP_HANGAR, AMS_TTDP_TO_HANGAR, AMS_TTDP_TO_PAD1, @@ -230,7 +230,7 @@ static uint8_t MapAircraftMovementState(const Aircraft *v) /* TTDP style aircraft movement action for GRF Action 2 Var 0xE6 */ -enum TTDPAircraftMovementActions { +enum TTDPAircraftMovementActions : uint8_t { AMA_TTDP_IN_HANGAR, AMA_TTDP_ON_PAD1, AMA_TTDP_ON_PAD2, diff --git a/src/newgrf_engine.h b/src/newgrf_engine.h index cbd286bbe8..c08e4b19f7 100644 --- a/src/newgrf_engine.h +++ b/src/newgrf_engine.h @@ -46,7 +46,7 @@ struct VehicleScopeResolver : public ScopeResolver { /** Resolver for a vehicle (chain) */ struct VehicleResolverObject : public ResolverObject { /** Application of 'wagon overrides'. */ - enum WagonOverride { + enum WagonOverride : uint8_t { WO_NONE, //!< Resolve no wagon overrides. WO_UNCACHED, //!< Resolve wagon overrides. WO_CACHED, //!< Resolve wagon overrides using TrainCache::cached_override. @@ -103,13 +103,13 @@ bool UsesWagonOverride(const Vehicle *v); int GetVehicleProperty(const Vehicle *v, PropertyID property, int orig_value, bool is_signed = false); int GetEngineProperty(EngineID engine, PropertyID property, int orig_value, const Vehicle *v = nullptr, bool is_signed = false); -enum class BuildProbabilityType { +enum class BuildProbabilityType : uint8_t { Reversed = 0, }; bool TestVehicleBuildProbability(Vehicle *v, EngineID engine, BuildProbabilityType type); -enum VehicleTrigger { +enum VehicleTrigger : uint8_t { VEHICLE_TRIGGER_NEW_CARGO = 0x01, /* Externally triggered only for the first vehicle in chain */ VEHICLE_TRIGGER_DEPOT = 0x02, diff --git a/src/newgrf_generic.h b/src/newgrf_generic.h index 65b19bca3d..28c0a709b0 100644 --- a/src/newgrf_generic.h +++ b/src/newgrf_generic.h @@ -17,7 +17,7 @@ struct SpriteGroup; /** AI events for asking the NewGRF for information. */ -enum AIConstructionEvent { +enum AIConstructionEvent : uint8_t { AICE_TRAIN_CHECK_RAIL_ENGINE = 0x00, ///< Check if we should build an engine AICE_TRAIN_CHECK_ELRAIL_ENGINE = 0x01, ///< Check if we should build an engine AICE_TRAIN_CHECK_MONORAIL_ENGINE = 0x02, ///< Check if we should build an engine diff --git a/src/newgrf_house.h b/src/newgrf_house.h index 954417b7a7..5ad224d004 100644 --- a/src/newgrf_house.h +++ b/src/newgrf_house.h @@ -109,7 +109,7 @@ bool CanDeleteHouse(TileIndex tile); bool NewHouseTileLoop(TileIndex tile); -enum HouseTrigger { +enum HouseTrigger : uint8_t { /* The tile of the house has been triggered during the tileloop. */ HOUSE_TRIGGER_TILE_LOOP = 0x01, /* diff --git a/src/newgrf_industries.h b/src/newgrf_industries.h index abf297dc19..c074f6e528 100644 --- a/src/newgrf_industries.h +++ b/src/newgrf_industries.h @@ -68,7 +68,7 @@ struct IndustriesResolverObject : public ResolverObject { }; /** When should the industry(tile) be triggered for random bits? */ -enum IndustryTrigger { +enum IndustryTrigger : uint8_t { /** Triggered each tile loop */ INDUSTRY_TRIGGER_TILELOOP_PROCESS = 1, /** Triggered (whole industry) each 256 ticks */ @@ -78,7 +78,7 @@ enum IndustryTrigger { }; /** From where has callback #CBID_INDUSTRY_PROBABILITY been called */ -enum IndustryAvailabilityCallType { +enum IndustryAvailabilityCallType : uint8_t { IACT_MAPGENERATION, ///< during random map generation IACT_RANDOMCREATION, ///< during creation of random ingame industry IACT_USERCREATION, ///< from the Fund/build window diff --git a/src/newgrf_industrytiles.h b/src/newgrf_industrytiles.h index e9431edf00..3a10d72c96 100644 --- a/src/newgrf_industrytiles.h +++ b/src/newgrf_industrytiles.h @@ -67,7 +67,7 @@ bool StartStopIndustryTileAnimation(const Industry *ind, IndustryAnimationTrigge /** Available industry tile triggers. */ -enum IndustryTileTrigger { +enum IndustryTileTrigger : uint8_t { INDTILE_TRIGGER_TILE_LOOP = 0x01, ///< The tile of the industry has been triggered during the tileloop. INDUSTRY_TRIGGER_INDUSTRY_TICK = 0x02, ///< The industry has been triggered via its tick. INDUSTRY_TRIGGER_RECEIVED_CARGO = 0x04, ///< Cargo has been delivered. diff --git a/src/newgrf_properties.h b/src/newgrf_properties.h index a33e02f165..4d4a31a983 100644 --- a/src/newgrf_properties.h +++ b/src/newgrf_properties.h @@ -15,7 +15,7 @@ * Names are formatted as PROP__ * @todo Currently the list only contains properties which are used more than once in the code. I.e. they are available for callback 0x36. */ -enum PropertyID { +enum PropertyID : uint8_t { PROP_VEHICLE_LOAD_AMOUNT = 0x07, ///< Loading speed PROP_TRAIN_SPEED = 0x09, ///< Max. speed: 1 unit = 1/1.6 mph = 1 km-ish/h diff --git a/src/newgrf_roadstop.h b/src/newgrf_roadstop.h index eb661f5d72..ce454477fd 100644 --- a/src/newgrf_roadstop.h +++ b/src/newgrf_roadstop.h @@ -34,7 +34,7 @@ enum RoadStopClassID : uint16_t { DECLARE_INCREMENT_DECREMENT_OPERATORS(RoadStopClassID) /* Some Triggers etc. */ -enum RoadStopRandomTrigger { +enum RoadStopRandomTrigger : uint8_t { RSRT_NEW_CARGO, ///< Trigger roadstop on arrival of new cargo. RSRT_CARGO_TAKEN, ///< Trigger roadstop when cargo is completely taken. RSRT_VEH_ARRIVES, ///< Trigger roadstop when road vehicle arrives. @@ -66,7 +66,7 @@ enum RoadStopDrawMode : uint8_t { }; DECLARE_ENUM_AS_BIT_SET(RoadStopDrawMode) -enum RoadStopSpecFlags { +enum RoadStopSpecFlags : uint8_t { RSF_CB141_RANDOM_BITS = 0, ///< Callback 141 needs random bits. RSF_NO_CATENARY = 2, ///< Do not show catenary. RSF_DRIVE_THROUGH_ONLY = 3, ///< Stop is drive-through only. @@ -76,7 +76,7 @@ enum RoadStopSpecFlags { RSF_DRAW_MODE_REGISTER = 8, ///< Read draw mode from register 0x100. }; -enum RoadStopView { +enum RoadStopView : uint8_t { RSV_BAY_NE = 0, ///< Bay road stop, facing Northeast RSV_BAY_SE = 1, ///< Bay road stop, facing Southeast RSV_BAY_SW = 2, ///< Bay road stop, facing Southwest diff --git a/src/newgrf_sound.h b/src/newgrf_sound.h index e67a3c49d8..9e33377258 100644 --- a/src/newgrf_sound.h +++ b/src/newgrf_sound.h @@ -15,7 +15,7 @@ #include "vehicle_type.h" /** Events at which a sound might be played. */ -enum VehicleSoundEvent { +enum VehicleSoundEvent : uint8_t { VSE_START = 1, ///< Vehicle starting, i.e. leaving, the station. VSE_TUNNEL = 2, ///< Train entering a tunnel. VSE_BREAKDOWN = 3, ///< Vehicle breaking down. diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp index 429b180ea3..6f21b47ee7 100644 --- a/src/newgrf_station.cpp +++ b/src/newgrf_station.cpp @@ -49,7 +49,7 @@ template class NewGRFClass; static const uint NUM_STATIONSSPECS_PER_STATION = 255; ///< Maximum number of parts per station. -enum TriggerArea { +enum TriggerArea : uint8_t { TA_TILE, TA_PLATFORM, TA_WHOLE, diff --git a/src/newgrf_station.h b/src/newgrf_station.h index 763243698c..6a58001f14 100644 --- a/src/newgrf_station.h +++ b/src/newgrf_station.h @@ -93,7 +93,7 @@ enum StationClassID : uint16_t { /** Allow incrementing of StationClassID variables */ DECLARE_INCREMENT_DECREMENT_OPERATORS(StationClassID) -enum StationSpecFlags { +enum StationSpecFlags : uint8_t { SSF_SEPARATE_GROUND, ///< Use different sprite set for ground sprites. SSF_DIV_BY_STATION_SIZE, ///< Divide cargo amount by station size. SSF_CB141_RANDOM_BITS, ///< Callback 141 needs random bits. @@ -102,7 +102,7 @@ enum StationSpecFlags { }; /** Randomisation triggers for stations */ -enum StationRandomTrigger { +enum StationRandomTrigger : uint8_t { SRT_NEW_CARGO, ///< Trigger station on new cargo arrival. SRT_CARGO_TAKEN, ///< Trigger station when cargo is completely taken. SRT_TRAIN_ARRIVES, ///< Trigger platform when train arrives. diff --git a/src/newgrf_storage.h b/src/newgrf_storage.h index 3d5ab0ac04..3db901b984 100644 --- a/src/newgrf_storage.h +++ b/src/newgrf_storage.h @@ -17,7 +17,7 @@ /** * Mode switches to the behaviour of persistent storage array. */ -enum PersistentStorageMode { +enum PersistentStorageMode : uint8_t { PSM_ENTER_GAMELOOP, ///< Enter the gameloop, changes will be permanent. PSM_LEAVE_GAMELOOP, ///< Leave the gameloop, changes will be temporary. PSM_ENTER_COMMAND, ///< Enter command scope, changes will be permanent. diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp index 8954de15c9..ceed99b30a 100644 --- a/src/newgrf_text.cpp +++ b/src/newgrf_text.cpp @@ -39,7 +39,7 @@ * the grf base will not be used in order to find the string, but rather for * jumping from standard langID scheme to the new one. */ -enum GRFBaseLanguages { +enum GRFBaseLanguages : uint8_t { GRFLB_AMERICAN = 0x01, GRFLB_ENGLISH = 0x02, GRFLB_GERMAN = 0x04, @@ -48,7 +48,7 @@ enum GRFBaseLanguages { GRFLB_GENERIC = 0x80, }; -enum GRFExtendedLanguages { +enum GRFExtendedLanguages : uint8_t { GRFLX_AMERICAN = 0x00, GRFLX_ENGLISH = 0x01, GRFLX_GERMAN = 0x02, diff --git a/src/news_type.h b/src/news_type.h index 7f642a5425..d094e016b4 100644 --- a/src/news_type.h +++ b/src/news_type.h @@ -103,7 +103,7 @@ DECLARE_ENUM_AS_BIT_SET(NewsFlag) /** * News display options */ -enum NewsDisplay { +enum NewsDisplay : uint8_t { ND_OFF, ///< Only show a reminder in the status bar ND_SUMMARY, ///< Show ticker ND_FULL, ///< Show newspaper diff --git a/src/openttd.h b/src/openttd.h index f6728ee70d..c38225201c 100644 --- a/src/openttd.h +++ b/src/openttd.h @@ -15,7 +15,7 @@ #include "core/enum_type.hpp" /** Mode which defines the state of the game. */ -enum GameMode { +enum GameMode : uint8_t { GM_MENU, GM_NORMAL, GM_EDITOR, @@ -23,7 +23,7 @@ enum GameMode { }; /** Mode which defines what mode we're switching to. */ -enum SwitchMode { +enum SwitchMode : uint8_t { SM_NONE, SM_NEWGAME, ///< New Game --> 'Random game'. SM_RESTARTGAME, ///< Restart --> 'Random game' with current settings. @@ -42,7 +42,7 @@ enum SwitchMode { }; /** Display Options */ -enum DisplayOptions { +enum DisplayOptions : uint8_t { DO_SHOW_TOWN_NAMES = 0, ///< Display town names. DO_SHOW_STATION_NAMES = 1, ///< Display station names. DO_SHOW_SIGNS = 2, ///< Display signs. diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 56b44e01fd..3f9e39388f 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -477,7 +477,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile) } /** Hotkeys for order window. */ -enum { +enum OrderHotKeys : int32_t { OHK_SKIP, OHK_DELETE, OHK_GOTO, @@ -534,7 +534,7 @@ enum { struct OrdersWindow : public Window { private: /** Under what reason are we using the PlaceObject functionality? */ - enum OrderPlaceObjectState { + enum OrderPlaceObjectState : uint8_t { OPOS_NONE, OPOS_GOTO, OPOS_CONDITIONAL, @@ -543,7 +543,7 @@ private: }; /** Displayed planes of the #NWID_SELECTION widgets. */ - enum DisplayPane { + enum DisplayPane : uint8_t { /* WID_O_SEL_TOP_ROW_GROUNDVEHICLE */ DP_GROUNDVEHICLE_ROW_NORMAL = 0, ///< Display the row for normal/depot orders in the top row of the train/rv order window. DP_GROUNDVEHICLE_ROW_CONDITIONAL = 1, ///< Display the row for conditional orders in the top row of the train/rv order window. diff --git a/src/order_type.h b/src/order_type.h index 0fb9b2290d..6b7e4a4ce5 100644 --- a/src/order_type.h +++ b/src/order_type.h @@ -49,7 +49,7 @@ enum OrderType : uint8_t { /** * Flags related to the unloading order. */ -enum OrderUnloadFlags { +enum OrderUnloadFlags : uint8_t { OUF_UNLOAD_IF_POSSIBLE = 0, ///< Unload all cargo that the station accepts. OUFB_UNLOAD = 1 << 0, ///< Force unloading all cargo onto the platform, possibly not getting paid. OUFB_TRANSFER = 1 << 1, ///< Transfer all cargo onto the platform. @@ -59,7 +59,7 @@ enum OrderUnloadFlags { /** * Flags related to the loading order. */ -enum OrderLoadFlags { +enum OrderLoadFlags : uint8_t { OLF_LOAD_IF_POSSIBLE = 0, ///< Load as long as there is cargo that fits in the train. OLFB_FULL_LOAD = 1 << 1, ///< Full load all cargoes of the consist. OLF_FULL_LOAD_ANY = 3, ///< Full load a single cargo of the consist. @@ -69,7 +69,7 @@ enum OrderLoadFlags { /** * Non-stop order flags. */ -enum OrderNonStopFlags { +enum OrderNonStopFlags : uint8_t { ONSF_STOP_EVERYWHERE = 0, ///< The vehicle will stop at any station it passes and the destination. ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS = 1, ///< The vehicle will not stop at any stations it passes except the destination. ONSF_NO_STOP_AT_DESTINATION_STATION = 2, ///< The vehicle will stop at any station it passes except the destination. @@ -80,7 +80,7 @@ enum OrderNonStopFlags { /** * Where to stop the trains. */ -enum OrderStopLocation { +enum OrderStopLocation : uint8_t { OSL_PLATFORM_NEAR_END = 0, ///< Stop at the near end of the platform OSL_PLATFORM_MIDDLE = 1, ///< Stop at the middle of the platform OSL_PLATFORM_FAR_END = 2, ///< Stop at the far end of the platform @@ -90,7 +90,7 @@ enum OrderStopLocation { /** * Reasons that could cause us to go to the depot. */ -enum OrderDepotTypeFlags { +enum OrderDepotTypeFlags : uint8_t { ODTF_MANUAL = 0, ///< Manually initiated order. ODTFB_SERVICE = 1 << 0, ///< This depot order is because of the servicing limit. ODTFB_PART_OF_ORDERS = 1 << 1, ///< This depot order is because of a regular order. @@ -99,7 +99,7 @@ enum OrderDepotTypeFlags { /** * Actions that can be performed when the vehicle enters the depot. */ -enum OrderDepotActionFlags { +enum OrderDepotActionFlags : uint8_t { ODATF_SERVICE_ONLY = 0, ///< Only service the vehicle. ODATFB_HALT = 1 << 0, ///< Service the vehicle and then halt it. ODATFB_NEAREST_DEPOT = 1 << 1, ///< Send the vehicle to the nearest depot. @@ -110,7 +110,7 @@ DECLARE_ENUM_AS_BIT_SET(OrderDepotActionFlags) /** * Variables (of a vehicle) to 'cause' skipping on. */ -enum OrderConditionVariable { +enum OrderConditionVariable : uint8_t { OCV_LOAD_PERCENTAGE, ///< Skip based on the amount of load OCV_RELIABILITY, ///< Skip based on the reliability OCV_MAX_SPEED, ///< Skip based on the maximum speed @@ -125,7 +125,7 @@ enum OrderConditionVariable { /** * Comparator for the skip reasoning. */ -enum OrderConditionComparator { +enum OrderConditionComparator : uint8_t { OCC_EQUALS, ///< Skip if both values are equal OCC_NOT_EQUALS, ///< Skip if both values are not equal OCC_LESS_THAN, ///< Skip if the value is less than the limit @@ -157,7 +157,7 @@ enum ModifyOrderFlags : uint8_t { /** * Depot action to switch to when doing a #MOF_DEPOT_ACTION. */ -enum OrderDepotAction { +enum OrderDepotAction : uint8_t { DA_ALWAYS_GO, ///< Always go to the depot DA_SERVICE, ///< Service only if needed DA_STOP, ///< Go to the depot and stop there diff --git a/src/os/macosx/string_osx.cpp b/src/os/macosx/string_osx.cpp index 4af0421f9f..bca3e8e567 100644 --- a/src/os/macosx/string_osx.cpp +++ b/src/os/macosx/string_osx.cpp @@ -36,7 +36,7 @@ extern "C" { CTRunDelegateGetWidthCallback getWidth; } CTRunDelegateCallbacks; - enum { + enum : int32_t { kCTRunDelegateVersion1 = 1, kCTRunDelegateCurrentVersion = kCTRunDelegateVersion1 }; diff --git a/src/osk_gui.cpp b/src/osk_gui.cpp index 6303523606..feda688263 100644 --- a/src/osk_gui.cpp +++ b/src/osk_gui.cpp @@ -27,7 +27,7 @@ std::string _keyboard_opt[2]; static char32_t _keyboard[2][OSK_KEYBOARD_ENTRIES]; -enum KeyStateBits { +enum KeyStateBits : uint8_t { KEYS_NONE, KEYS_SHIFT, KEYS_CAPS diff --git a/src/pathfinder/follow_track.hpp b/src/pathfinder/follow_track.hpp index 01e90b70ec..208983d9c3 100644 --- a/src/pathfinder/follow_track.hpp +++ b/src/pathfinder/follow_track.hpp @@ -27,7 +27,7 @@ template struct CFollowTrackT { - enum ErrorCode { + enum ErrorCode : uint8_t { EC_NONE, EC_OWNER, EC_RAIL_ROAD_TYPE, diff --git a/src/pathfinder/yapf/yapf_type.hpp b/src/pathfinder/yapf/yapf_type.hpp index 327b904664..fee2bbfed5 100644 --- a/src/pathfinder/yapf/yapf_type.hpp +++ b/src/pathfinder/yapf/yapf_type.hpp @@ -17,7 +17,7 @@ #include "../../misc/dbg_helpers.h" /* Enum used in PfCalcCost() to see why was the segment closed. */ -enum EndSegmentReason { +enum EndSegmentReason : uint8_t { /* The following reasons can be saved into cached segment */ ESR_DEAD_END = 0, ///< track ends here ESR_RAIL_TYPE, ///< the next tile has a different rail type than our tiles @@ -40,7 +40,7 @@ enum EndSegmentReason { ESR_NONE = 0xFF, ///< no reason to end the segment here }; -enum EndSegmentReasonBits { +enum EndSegmentReasonBits : uint16_t { ESRB_NONE = 0, ESRB_DEAD_END = 1 << ESR_DEAD_END, diff --git a/src/picker_gui.h b/src/picker_gui.h index 41fbd48f03..167f246d58 100644 --- a/src/picker_gui.h +++ b/src/picker_gui.h @@ -147,13 +147,13 @@ using PickerTypeList = GUIList; class PickerWindow : public PickerWindowBase { public: - enum PickerFilterModes { + enum PickerFilterModes : uint8_t { PFM_ALL = 0, ///< Show all classes. PFM_USED = 1, ///< Show used types. PFM_SAVED = 2, ///< Show saved types. }; - enum PickerFilterInvalidation { + enum PickerFilterInvalidation : uint8_t { PFI_CLASS = 1U << 0, ///< Refresh the class list. PFI_TYPE = 1U << 1, ///< Refresh the type list. PFI_POSITION = 1U << 2, ///< Update scroll positions. @@ -181,7 +181,7 @@ public: void OnEditboxChanged(WidgetID wid) override; /** Enum referring to the Hotkeys in the picker window */ - enum PickerClassWindowHotkeys { + enum PickerClassWindowHotkeys : int32_t { PCWHK_FOCUS_FILTER_BOX, ///< Focus the edit box for editing the filter string }; diff --git a/src/rail.h b/src/rail.h index 149996aae0..59750119aa 100644 --- a/src/rail.h +++ b/src/rail.h @@ -22,7 +22,7 @@ #include "settings_type.h" /** Railtype flag bit numbers. */ -enum RailTypeFlag { +enum RailTypeFlag : uint8_t { RTF_CATENARY = 0, ///< Bit number for drawing a catenary. RTF_NO_LEVEL_CROSSING = 1, ///< Bit number for disallowing level crossings. RTF_HIDDEN = 2, ///< Bit number for hiding from selection. @@ -46,7 +46,7 @@ DECLARE_ENUM_AS_BIT_SET(RailTypeFlags) struct SpriteGroup; /** Sprite groups for a railtype. */ -enum RailTypeSpriteGroup { +enum RailTypeSpriteGroup : uint8_t { RTSG_CURSORS, ///< Cursor and toolbar icon images RTSG_OVERLAY, ///< Images for overlaying track RTSG_GROUND, ///< Main group of ground images @@ -67,7 +67,7 @@ enum RailTypeSpriteGroup { * Offsets for sprites within an overlay/underlay set. * These are the same for overlay and underlay sprites. */ -enum RailTrackOffset { +enum RailTrackOffset : uint8_t { RTO_X, ///< Piece of rail in X direction RTO_Y, ///< Piece of rail in Y direction RTO_N, ///< Piece of rail in northern corner @@ -89,7 +89,7 @@ enum RailTrackOffset { /** * Offsets for sprites within a bridge surface overlay set. */ -enum RailTrackBridgeOffset { +enum RailTrackBridgeOffset : uint8_t { RTBO_X, ///< Piece of rail in X direction RTBO_Y, ///< Piece of rail in Y direction RTBO_SLOPE, ///< Sloped rail pieces, in order NE, SE, SW, NW @@ -99,7 +99,7 @@ enum RailTrackBridgeOffset { * Offsets from base sprite for fence sprites. These are in the order of * the sprites in the original data files. */ -enum RailFenceOffset { +enum RailFenceOffset : uint8_t { RFO_FLAT_X_NW, //!< Slope FLAT, Track X, Fence NW RFO_FLAT_Y_NE, //!< Slope FLAT, Track Y, Fence NE RFO_FLAT_LEFT, //!< Slope FLAT, Track LEFT, Fence E diff --git a/src/rail_map.h b/src/rail_map.h index 1274656a6e..88ea36af7f 100644 --- a/src/rail_map.h +++ b/src/rail_map.h @@ -20,7 +20,7 @@ /** Different types of Rail-related tiles */ -enum RailTileType { +enum RailTileType : uint8_t { RAIL_TILE_NORMAL = 0, ///< Normal rail tile without signals RAIL_TILE_SIGNALS = 1, ///< Normal rail tile with signals RAIL_TILE_DEPOT = 3, ///< Depot (one entrance) @@ -482,7 +482,7 @@ inline bool HasOnewaySignalBlockingTrackdir(Tile tile, Trackdir td) RailType GetTileRailType(Tile tile); /** The ground 'under' the rail */ -enum RailGroundType { +enum RailGroundType : uint8_t { RAIL_GROUND_BARREN = 0, ///< Nothing (dirt) RAIL_GROUND_GRASS = 1, ///< Grassy RAIL_GROUND_FENCE_NW = 2, ///< Grass with a fence at the NW edge diff --git a/src/road.h b/src/road.h index 44f4fcd198..05e14a4855 100644 --- a/src/road.h +++ b/src/road.h @@ -56,7 +56,7 @@ DECLARE_ENUM_AS_BIT_SET(RoadTypeFlags) struct SpriteGroup; /** Sprite groups for a roadtype. */ -enum RoadTypeSpriteGroup { +enum RoadTypeSpriteGroup : uint8_t { ROTSG_CURSORS, ///< Optional: Cursor and toolbar icon images ROTSG_OVERLAY, ///< Optional: Images for overlaying track ROTSG_GROUND, ///< Required: Main group of ground images diff --git a/src/road_map.h b/src/road_map.h index d52c544017..fd827a33aa 100644 --- a/src/road_map.h +++ b/src/road_map.h @@ -19,7 +19,7 @@ /** The different types of road tiles. */ -enum RoadTileType { +enum RoadTileType : uint8_t { ROAD_TILE_NORMAL, ///< Normal road ROAD_TILE_CROSSING, ///< Level crossing ROAD_TILE_DEPOT, ///< Depot (one entrance) diff --git a/src/roadstop_base.h b/src/roadstop_base.h index 1c425549c9..3c0ecf129e 100644 --- a/src/roadstop_base.h +++ b/src/roadstop_base.h @@ -20,7 +20,7 @@ extern RoadStopPool _roadstop_pool; /** A Stop for a Road Vehicle */ struct RoadStop : RoadStopPool::PoolItem<&_roadstop_pool> { - enum RoadStopStatusFlags { + enum RoadStopStatusFlags : uint8_t { RSSFB_BAY0_FREE = 0, ///< Non-zero when bay 0 is free RSSFB_BAY1_FREE = 1, ///< Non-zero when bay 1 is free RSSFB_BASE_ENTRY = 6, ///< Non-zero when the entries on this road stop are the primary, i.e. the ones to delete diff --git a/src/roadveh.h b/src/roadveh.h index 90790b9b51..253606fb4c 100644 --- a/src/roadveh.h +++ b/src/roadveh.h @@ -21,7 +21,7 @@ struct RoadVehicle; /** Road vehicle states */ -enum RoadVehicleStates { +enum RoadVehicleStates : uint8_t { /* * Lower 4 bits are used for vehicle track direction. (Trackdirs) * When in a road stop (bit 5 or bit 6 set) these bits give the diff --git a/src/saveload/oldloader.h b/src/saveload/oldloader.h index a7b1ac988f..5e4ebe8592 100644 --- a/src/saveload/oldloader.h +++ b/src/saveload/oldloader.h @@ -32,7 +32,7 @@ struct LoadgameState { }; /* OldChunk-Type */ -enum OldChunkType { +enum OldChunkType : uint32_t { OC_SIMPLE = 0, OC_NULL = 1, OC_CHUNK = 2, @@ -74,7 +74,7 @@ enum OldChunkType { * Dereference the pointer once before writing to it, * so we do not have to use big static arrays. */ - OC_DEREFERENCE_POINTER = 1 << 31, + OC_DEREFERENCE_POINTER = 1U << 31, OC_END = 0, ///< End of the whole chunk, all 32 bits set to zero }; diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index 7bd2b30845..59a8f14490 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -66,7 +66,7 @@ std::string _savegame_format; ///< how to compress savegames bool _do_autosave; ///< are we doing an autosave at the moment? /** What are we currently doing? */ -enum SaveLoadAction { +enum SaveLoadAction : uint8_t { SLA_LOAD, ///< loading SLA_SAVE, ///< saving SLA_PTRS, ///< fixing pointers @@ -74,7 +74,7 @@ enum SaveLoadAction { SLA_LOAD_CHECK, ///< partial loading into #_load_check_data }; -enum NeedLength { +enum NeedLength : uint8_t { NL_NONE = 0, ///< not working in NeedLength mode NL_WANTLENGTH = 1, ///< writing length and data NL_CALCLENGTH = 2, ///< need to calculate the length diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h index 8caa133ef8..aa23f4b93d 100644 --- a/src/saveload/saveload.h +++ b/src/saveload/saveload.h @@ -400,7 +400,7 @@ enum SaveLoadVersion : uint16_t { }; /** Save or load result codes. */ -enum SaveOrLoadResult { +enum SaveOrLoadResult : uint8_t { SL_OK = 0, ///< completed successfully SL_ERROR = 1, ///< error that was caught before internal structures were modified SL_REINIT = 2, ///< error that was caught in the middle of updating game state, need to clear it. (can only happen during load) @@ -420,7 +420,7 @@ struct FileToSaveLoad { }; /** Types of save games. */ -enum SavegameType { +enum SavegameType : uint8_t { SGT_TTD, ///< TTD savegame (can be detected incorrectly) SGT_TTDP1, ///< TTDP savegame ( -//- ) (data at NW border) SGT_TTDP2, ///< TTDP savegame in new format (data at SE border) @@ -448,7 +448,7 @@ SaveOrLoadResult LoadWithFilter(std::shared_ptr reader); typedef void AutolengthProc(int); /** Type of a chunk. */ -enum ChunkType { +enum ChunkType : uint8_t { CH_RIFF = 0, CH_ARRAY = 1, CH_SPARSE_ARRAY = 2, @@ -597,7 +597,7 @@ public: }; /** Type of reference (#SLE_REF, #SLE_CONDREF). */ -enum SLRefType { +enum SLRefType : uint8_t { REF_ORDER = 0, ///< Load/save a reference to an order. REF_VEHICLE = 1, ///< Load/save a reference to a vehicle. REF_STATION = 2, ///< Load/save a reference to a station. @@ -620,7 +620,7 @@ enum SLRefType { * the first 8 bits (0-3 SLE_FILE, 4-7 SLE_VAR). * Bits 8-15 are reserved for various flags as explained below */ -enum VarTypes { +enum VarTypes : uint16_t { /* 4 bits allocated a maximum of 16 types for NumberType. * NOTE: the SLE_FILE_NNN values are stored in the savegame! */ SLE_FILE_END = 0, ///< Used to mark end-of-header in tables. diff --git a/src/screenshot.h b/src/screenshot.h index f10a80f70d..ea67165ff8 100644 --- a/src/screenshot.h +++ b/src/screenshot.h @@ -15,7 +15,7 @@ void InitializeScreenshotFormats(); const char *GetCurrentScreenshotExtension(); /** Type of requested screenshot */ -enum ScreenshotType { +enum ScreenshotType : uint8_t { SC_VIEWPORT, ///< Screenshot of viewport. SC_CRASHLOG, ///< Raw screenshot from blitter buffer. SC_ZOOMEDIN, ///< Fully zoomed in screenshot of the visible area. diff --git a/src/script/script_config.hpp b/src/script/script_config.hpp index 4f171621de..08d4f14c0a 100644 --- a/src/script/script_config.hpp +++ b/src/script/script_config.hpp @@ -18,7 +18,7 @@ static const int INT32_DIGITS_WITH_SIGN_AND_TERMINATION = 10 + 1 + 1; /** Bitmask of flags for Script settings. */ -enum ScriptConfigFlags { +enum ScriptConfigFlags : uint8_t { SCRIPTCONFIG_NONE = 0x0, ///< No flags set. // Unused flag 0x1. SCRIPTCONFIG_BOOLEAN = 0x2, ///< This value is a boolean (either 0 (false) or 1 (true) ). @@ -90,7 +90,7 @@ public: * Where to get the config from, either default (depends on current game * mode) or force either newgame or normal */ - enum ScriptSettingSource { + enum ScriptSettingSource : uint8_t { SSS_DEFAULT, ///< Get the Script config from the current game mode SSS_FORCE_NEWGAME, ///< Get the newgame Script config SSS_FORCE_GAME, ///< Get the Script config from the current game diff --git a/src/script/script_instance.hpp b/src/script/script_instance.hpp index 342cb822b6..d937e22484 100644 --- a/src/script/script_instance.hpp +++ b/src/script/script_instance.hpp @@ -25,7 +25,7 @@ static const uint SQUIRREL_MAX_DEPTH = 25; ///< The maximum recursive depth for class ScriptInstance { private: /** The type of the data that follows in the savegame. */ - enum SQSaveLoadType { + enum SQSaveLoadType : uint8_t { SQSL_INT = 0x00, ///< The following data is an integer. SQSL_STRING = 0x01, ///< The following data is an string. SQSL_ARRAY = 0x02, ///< The following data is an array. diff --git a/src/script/squirrel.hpp b/src/script/squirrel.hpp index 85b0bd1cf6..b816f81216 100644 --- a/src/script/squirrel.hpp +++ b/src/script/squirrel.hpp @@ -13,7 +13,7 @@ #include /** The type of script we're working with, i.e. for who is it? */ -enum class ScriptType { +enum class ScriptType : uint8_t { AI, ///< The script is for AI scripts. GS, ///< The script is for Game scripts. }; diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index de3628e40e..50d652d091 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1209,7 +1209,7 @@ static int SETTING_HEIGHT = 11; ///< Height of a single setting in the tree v * Flags for #SettingEntry * @note The #SEF_BUTTONS_MASK matches expectations of the formal parameter 'state' of #DrawArrowButtons */ -enum SettingEntryFlags { +enum SettingEntryFlags : uint8_t { SEF_LEFT_DEPRESSED = 0x01, ///< Of a numeric setting entry, the left button is depressed SEF_RIGHT_DEPRESSED = 0x02, ///< Of a numeric setting entry, the right button is depressed SEF_BUTTONS_MASK = (SEF_LEFT_DEPRESSED | SEF_RIGHT_DEPRESSED), ///< Bit-mask for button flags @@ -1219,7 +1219,7 @@ enum SettingEntryFlags { }; /** How the list of advanced settings is filtered. */ -enum RestrictionMode { +enum RestrictionMode : uint8_t { RM_BASIC, ///< Display settings associated to the "basic" list. RM_ADVANCED, ///< Display settings associated to the "advanced" list. RM_ALL, ///< List all settings regardless of the default/newgame/... values. @@ -2298,7 +2298,7 @@ static const StringID _game_settings_restrict_dropdown[] = { static_assert(lengthof(_game_settings_restrict_dropdown) == RM_END); /** Warnings about hidden search results. */ -enum WarnHiddenResult { +enum WarnHiddenResult : uint8_t { WHR_NONE, ///< Nothing was filtering matches away. WHR_CATEGORY, ///< Category setting filtered matches away. WHR_TYPE, ///< Type setting filtered matches away. diff --git a/src/settings_internal.h b/src/settings_internal.h index 083dffab2b..3b40c503ab 100644 --- a/src/settings_internal.h +++ b/src/settings_internal.h @@ -39,7 +39,7 @@ DECLARE_ENUM_AS_BIT_SET(SettingFlag) * The grouping is meant to be inclusive, i.e. all settings in #SC_BASIC also will be included * in the set of settings in #SC_ADVANCED. The group #SC_EXPERT contains all settings. */ -enum SettingCategory { +enum SettingCategory : uint8_t { SC_NONE = 0, /* Filters for the list */ @@ -58,7 +58,7 @@ enum SettingCategory { /** * Type of settings for filtering. */ -enum SettingType { +enum SettingType : uint8_t { ST_GAME, ///< Game setting. ST_COMPANY, ///< Company setting. ST_CLIENT, ///< Client setting. diff --git a/src/settings_type.h b/src/settings_type.h index 8b16d7a1e9..5a0f5069a5 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -35,7 +35,7 @@ const size_t MAX_SLE_INT32 = INT32_MAX; const size_t MAX_SLE_INT = INT_MAX; /** Settings profiles and highscore tables. */ -enum SettingsProfile { +enum SettingsProfile : uint8_t { SP_BEGIN = 0, SP_EASY = SP_BEGIN, ///< Easy difficulty. SP_MEDIUM, ///< Medium difficulty. @@ -51,7 +51,7 @@ enum SettingsProfile { }; /** Available industry map generation densities. */ -enum IndustryDensity { +enum IndustryDensity : uint8_t { ID_FUND_ONLY, ///< The game does not build industries. ID_MINIMAL, ///< Start with just the industries that must be present. ID_VERY_LOW, ///< Very few industries at game start. @@ -118,7 +118,7 @@ struct DifficultySettings { }; /** Settings relating to viewport/smallmap scrolling. */ -enum ViewportScrollMode { +enum ViewportScrollMode : uint8_t { VSM_VIEWPORT_RMB_FIXED, ///< Viewport moves with mouse movement on holding right mouse button, cursor position is fixed. VSM_MAP_RMB_FIXED, ///< Map moves with mouse movement on holding right mouse button, cursor position is fixed. VSM_MAP_RMB, ///< Map moves with mouse movement on holding right mouse button, cursor moves. @@ -127,7 +127,7 @@ enum ViewportScrollMode { }; /** Settings related to scroll wheel behavior. */ -enum ScrollWheelScrollingSetting { +enum ScrollWheelScrollingSetting : uint8_t { SWS_ZOOM_MAP = 0, ///< Scroll wheel zooms the map. SWS_SCROLL_MAP = 1, ///< Scroll wheel scrolls the map. SWS_OFF = 2 ///< Scroll wheel has no effect. diff --git a/src/signal.cpp b/src/signal.cpp index 315d59ab98..eefce2d4e7 100644 --- a/src/signal.cpp +++ b/src/signal.cpp @@ -243,7 +243,7 @@ static inline bool MaybeAddToTodoSet(TileIndex t1, DiagDirection d1, TileIndex t /** Current signal block state flags */ -enum SigFlags { +enum SigFlags : uint16_t { SF_NONE = 0, SF_TRAIN = 1 << 0, ///< train found in segment SF_EXIT = 1 << 1, ///< exitsignal found diff --git a/src/signal_func.h b/src/signal_func.h index 575ab5def6..46807628f7 100644 --- a/src/signal_func.h +++ b/src/signal_func.h @@ -46,7 +46,7 @@ inline uint8_t SignalOnTrack(Track track) } /** State of the signal segment */ -enum SigSegState { +enum SigSegState : uint8_t { SIGSEG_FREE, ///< Free and has no pre-signal exits or at least one green exit SIGSEG_FULL, ///< Occupied by a train SIGSEG_PBS, ///< Segment is a PBS segment diff --git a/src/signal_type.h b/src/signal_type.h index c2cadd66ed..9785d2a004 100644 --- a/src/signal_type.h +++ b/src/signal_type.h @@ -39,7 +39,7 @@ DECLARE_ENUM_AS_ADDABLE(SignalType) * simple boolean logic will do. But do try to compare to this enum instead of * normal boolean evaluation, since that will make future additions easier. */ -enum SignalState { +enum SignalState : uint8_t { SIGNAL_STATE_RED = 0, ///< The signal is red SIGNAL_STATE_GREEN = 1, ///< The signal is green }; diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index e4356efbb6..2f7eb4a720 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -133,7 +133,7 @@ bool SignList::match_case = false; std::string SignList::default_name; /** Enum referring to the Hotkeys in the sign list window */ -enum SignListHotkeys { +enum SignListHotkeys : int32_t { SLHK_FOCUS_FILTER_BOX, ///< Focus the edit box for editing the filter string }; diff --git a/src/slope_type.h b/src/slope_type.h index fa67d073d6..6347bea2ae 100644 --- a/src/slope_type.h +++ b/src/slope_type.h @@ -19,7 +19,7 @@ /** * Enumeration of tile corners */ -enum Corner { +enum Corner : uint8_t { CORNER_W = 0, CORNER_S = 1, CORNER_E = 2, @@ -90,7 +90,7 @@ static const uint32_t VALID_LEVEL_CROSSING_SLOPES = M(SLOPE_SEN) | M(SLOPE_ENW) /** * Enumeration for Foundations. */ -enum Foundation { +enum Foundation : uint8_t { FOUNDATION_NONE, ///< The tile has no foundation, the slope remains unchanged. FOUNDATION_LEVELED, ///< The tile is leveled up to a flat slope. FOUNDATION_INCLINED_X, ///< The tile has an along X-axis inclined foundation. diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 1b480bfad9..8e736c3c8c 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -625,7 +625,7 @@ DECLARE_ENUM_AS_ADDABLE(SmallMapType) class SmallMapWindow : public Window { protected: /** Available kinds of zoomlevel changes. */ - enum ZoomLevelChange { + enum ZoomLevelChange : uint8_t { ZLC_INITIALIZE, ///< Initialize zoom level. ZLC_ZOOM_OUT, ///< Zoom out. ZLC_ZOOM_IN, ///< Zoom in. diff --git a/src/smallmap_gui.h b/src/smallmap_gui.h index 8eb6906e31..d17a468ae4 100644 --- a/src/smallmap_gui.h +++ b/src/smallmap_gui.h @@ -24,7 +24,7 @@ void BuildLandLegend(); void BuildOwnerLegend(); /** Enum for how to include the heightmap pixels/colours in small map related functions */ -enum class IncludeHeightmap { +enum class IncludeHeightmap : uint8_t { Never, ///< Never include the heightmap IfEnabled, ///< Only include the heightmap if its enabled in the gui by the player Always ///< Always include the heightmap diff --git a/src/social_integration.h b/src/social_integration.h index b3c9b092c2..a6ca13f823 100644 --- a/src/social_integration.h +++ b/src/social_integration.h @@ -12,7 +12,7 @@ class SocialIntegrationPlugin { public: - enum State { + enum State : uint8_t { RUNNING, ///< The plugin is successfully loaded and running. FAILED, ///< The plugin failed to initialize. diff --git a/src/sortlist_type.h b/src/sortlist_type.h index 7cc09c7826..e47fc71a08 100644 --- a/src/sortlist_type.h +++ b/src/sortlist_type.h @@ -16,7 +16,7 @@ #include "timer/timer_game_tick.h" /** Flags of the sort list. */ -enum SortListFlags { +enum SortListFlags : uint8_t { VL_NONE = 0, ///< no sort VL_DESC = 1 << 0, ///< sort descending or ascending VL_RESORT = 1 << 1, ///< instruct the code to resort the list in the next loop diff --git a/src/sound_type.h b/src/sound_type.h index 7fb2faf150..8a2fa0140b 100644 --- a/src/sound_type.h +++ b/src/sound_type.h @@ -42,7 +42,7 @@ struct SoundEntry { * - The naming of the enum values includes the position in the baseset. * That is, for sound effects 0x02 to 0x28 the naming is off-by-two. */ -enum SoundFx { +enum SoundFx : uint8_t { SND_BEGIN = 0, SND_02_CONSTRUCTION_WATER = 0, ///< 0 == 0x00 Construction: water infrastructure SND_03_FACTORY, ///< 1 == 0x01 Industry producing: factory: whistle diff --git a/src/spritecache.h b/src/spritecache.h index d608afaeb9..5f4960e22e 100644 --- a/src/spritecache.h +++ b/src/spritecache.h @@ -22,7 +22,7 @@ struct Sprite { uint8_t data[]; ///< Sprite data. }; -enum SpriteCacheCtrlFlags { +enum SpriteCacheCtrlFlags : uint8_t { SCCF_ALLOW_ZOOM_MIN_1X_PAL = 0, ///< Allow use of sprite min zoom setting at 1x in palette mode. SCCF_ALLOW_ZOOM_MIN_1X_32BPP = 1, ///< Allow use of sprite min zoom setting at 1x in 32bpp mode. SCCF_ALLOW_ZOOM_MIN_2X_PAL = 2, ///< Allow use of sprite min zoom setting at 2x in palette mode. diff --git a/src/spriteloader/spriteloader.hpp b/src/spriteloader/spriteloader.hpp index 2ed0191d18..210299f94e 100644 --- a/src/spriteloader/spriteloader.hpp +++ b/src/spriteloader/spriteloader.hpp @@ -18,7 +18,7 @@ struct Sprite; /** The different colour components a sprite can have. */ -enum SpriteColourComponent { +enum SpriteColourComponent : uint8_t { SCC_RGB = 1 << 0, ///< Sprite has RGB. SCC_ALPHA = 1 << 1, ///< Sprite has alpha. SCC_PAL = 1 << 2, ///< Sprite has palette data. diff --git a/src/station_base.h b/src/station_base.h index 42df37c748..8df7d4ab22 100644 --- a/src/station_base.h +++ b/src/station_base.h @@ -165,7 +165,7 @@ public: */ struct GoodsEntry { /** Status of this cargo for the station. */ - enum GoodsEntryStatus { + enum GoodsEntryStatus : uint8_t { /** * Set when the station accepts the cargo currently for final deliveries. * It is updated every STATION_ACCEPTANCE_TICKS ticks by checking surrounding tiles for acceptance >= 8/8. diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index d8f85f15d2..fffbdf737d 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -212,7 +212,7 @@ static bool CMSATree(TileIndex tile) #define M(x) ((x) - STR_SV_STNAME) -enum StationNaming { +enum StationNaming : uint8_t { STATIONNAMING_RAIL, STATIONNAMING_ROAD, STATIONNAMING_AIRPORT, diff --git a/src/station_gui.cpp b/src/station_gui.cpp index a8b3cf206b..eb63bb0f96 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -879,7 +879,7 @@ static void DrawCargoIcons(CargoType i, uint waiting, int left, int right, int y } while (--num); } -enum SortOrder { +enum SortOrder : uint8_t { SO_DESCENDING, SO_ASCENDING }; @@ -1284,7 +1284,7 @@ struct StationViewWindow : public Window { /** * Type of data invalidation. */ - enum Invalidation { + enum Invalidation : uint16_t { INV_FLOWS = 0x100, ///< The planned flows have been recalculated and everything has to be updated. INV_CARGO = 0x200 ///< Some cargo has been added or removed. }; @@ -1292,7 +1292,7 @@ struct StationViewWindow : public Window { /** * Type of grouping used in each of the "columns". */ - enum Grouping { + enum Grouping : uint8_t { GR_SOURCE, ///< Group by source of cargo ("from"). GR_NEXT, ///< Group by next station ("via"). GR_DESTINATION, ///< Group by estimated final destination ("to"). @@ -1302,7 +1302,7 @@ struct StationViewWindow : public Window { /** * Display mode of the cargo view. */ - enum Mode { + enum Mode : uint8_t { MODE_WAITING, ///< Show cargo waiting at the station. MODE_PLANNED ///< Show cargo planned to pass through the station. }; diff --git a/src/station_gui.h b/src/station_gui.h index 9b142d02b6..f2ad490684 100644 --- a/src/station_gui.h +++ b/src/station_gui.h @@ -17,7 +17,7 @@ /** Types of cargo to display for station coverage. */ -enum StationCoverageType { +enum StationCoverageType : uint8_t { SCT_PASSENGERS_ONLY, ///< Draw only passenger class cargoes. SCT_NON_PASSENGERS_ONLY, ///< Draw all non-passenger class cargoes. SCT_ALL, ///< Draw all cargoes. diff --git a/src/statusbar_gui.h b/src/statusbar_gui.h index 26503dbff1..d66e609363 100644 --- a/src/statusbar_gui.h +++ b/src/statusbar_gui.h @@ -11,7 +11,7 @@ #define STATUSBAR_GUI_H /** What of the statusbar must be invalidated? */ -enum StatusBarInvalidate { +enum StatusBarInvalidate : uint8_t { SBI_SAVELOAD_START, ///< started saving SBI_SAVELOAD_FINISH, ///< finished saving SBI_SHOW_TICKER, ///< start scrolling news diff --git a/src/story_gui.cpp b/src/story_gui.cpp index ddc0e365b1..2d9b45a2d6 100644 --- a/src/story_gui.cpp +++ b/src/story_gui.cpp @@ -46,7 +46,7 @@ protected: }; typedef std::vector LayoutCache; - enum class ElementFloat { + enum class ElementFloat : uint8_t { None, Left, Right, diff --git a/src/string_base.h b/src/string_base.h index 6546d3cdae..6936279386 100644 --- a/src/string_base.h +++ b/src/string_base.h @@ -14,7 +14,7 @@ class StringIterator { public: /** Type of the iterator. */ - enum IterType { + enum IterType : uint8_t { ITER_CHARACTER, ///< Iterate over characters (or more exactly grapheme clusters). ITER_WORD, ///< Iterate over words. }; diff --git a/src/string_type.h b/src/string_type.h index df330fc1fc..3222e29d46 100644 --- a/src/string_type.h +++ b/src/string_type.h @@ -21,7 +21,7 @@ /** * Valid filter types for IsValidChar. */ -enum CharSetFilter { +enum CharSetFilter : uint8_t { CS_ALPHANUMERAL, ///< Both numeric and alphabetic and spaces and stuff CS_NUMERAL, ///< Only numeric ones CS_NUMERAL_SPACE, ///< Only numbers and spaces @@ -41,7 +41,7 @@ static const char32_t CHAR_TD_RLO = 0x202E; ///< Force the following characters static const char32_t CHAR_TD_PDF = 0x202C; ///< Restore the text-direction state to before the last LRE, RLE, LRO or RLO. /** Settings for the string validation. */ -enum StringValidationSettings { +enum StringValidationSettings : uint8_t { SVS_NONE = 0, ///< Allow nothing and replace nothing. SVS_REPLACE_WITH_QUESTION_MARK = 1 << 0, ///< Replace the unknown/bad bits with question marks. SVS_ALLOW_NEWLINE = 1 << 1, ///< Allow newlines; replaces '\r\n' with '\n' during processing. diff --git a/src/strings_type.h b/src/strings_type.h index 1c96b90697..534eeacb48 100644 --- a/src/strings_type.h +++ b/src/strings_type.h @@ -21,13 +21,13 @@ static const int MAX_CHAR_LENGTH = 4; ///< Max. length of UTF-8 enco static const uint MAX_LANG = 0x7F; ///< Maximum number of languages supported by the game, and the NewGRF specs /** Directions a text can go to */ -enum TextDirection { +enum TextDirection : uint8_t { TD_LTR, ///< Text is written left-to-right by default TD_RTL, ///< Text is written right-to-left by default }; /** StringTabs to group StringIDs */ -enum StringTab { +enum StringTab : uint8_t { /* Tabs 0..1 for regular strings */ TEXT_TAB_TOWN = 4, TEXT_TAB_INDUSTRY = 9, diff --git a/src/subsidy_base.h b/src/subsidy_base.h index 4ae33caf5d..b4eb62d17e 100644 --- a/src/subsidy_base.h +++ b/src/subsidy_base.h @@ -59,7 +59,7 @@ static const uint SUBSIDY_MAX_DISTANCE = 70; ///< Max. length of subsid static const uint SUBSIDY_TOWN_CARGO_RADIUS = 6; ///< Extent of a tile area around town center when scanning for town cargo acceptance and production (6 ~= min catchmement + min station / 2) /** Types of subsidy news messages, which determine how the date is printed and whether to use singular or plural cargo names */ -enum class SubsidyDecodeParamType { +enum class SubsidyDecodeParamType : uint8_t { NewsOffered = 0, ///< News item for an offered subsidy NewsAwarded = 1, ///< News item for an awarded subsidy NewsWithdrawn = 2, ///< News item for a subsidy offer withdrawn, or expired subsidy diff --git a/src/table/airporttile_ids.h b/src/table/airporttile_ids.h index 73eafc8595..27c2457de0 100644 --- a/src/table/airporttile_ids.h +++ b/src/table/airporttile_ids.h @@ -10,7 +10,7 @@ #ifndef AIRPORTTILE_IDS_H #define AIRPORTTILE_IDS_H -enum AirportTiles { +enum AirportTiles : uint8_t { APT_APRON, APT_APRON_FENCE_NW, APT_APRON_FENCE_SW, diff --git a/src/table/build_industry.h b/src/table/build_industry.h index ff459c51bb..a71ff53381 100644 --- a/src/table/build_industry.h +++ b/src/table/build_industry.h @@ -1043,7 +1043,7 @@ static const std::initializer_list _farm_sounds = { SND_24_FARM_1, SND_ /** Array with... hem... a sound of toyland */ static const std::initializer_list _plastic_mine_sounds = { SND_33_PLASTIC_MINE }; -enum IndustryTypes { +enum IndustryTypes : uint8_t { IT_COAL_MINE = 0, IT_POWER_STATION = 1, IT_SAWMILL = 2, diff --git a/src/table/control_codes.h b/src/table/control_codes.h index d2022c3cec..d98c4a4c87 100644 --- a/src/table/control_codes.h +++ b/src/table/control_codes.h @@ -14,7 +14,7 @@ * List of string control codes used for string formatting, displaying, and * by strgen to generate the language files. */ -enum StringControlCode { +enum StringControlCode : uint16_t { SCC_CONTROL_START = 0xE000, SCC_CONTROL_END = 0xE1FF, diff --git a/src/table/elrail_data.h b/src/table/elrail_data.h index 33dd53493f..4c5ec7f4e3 100644 --- a/src/table/elrail_data.h +++ b/src/table/elrail_data.h @@ -17,7 +17,7 @@ * Tile Location group. * This defines whether the X and or Y coordinate of a tile is even */ -enum TLG { +enum TLG : uint8_t { XEVEN_YEVEN = 0, XEVEN_YODD = 1, XODD_YEVEN = 2, @@ -30,7 +30,7 @@ enum TLG { * into account: the tile being drawn itself (the home tile, the one in * ti->tile), and the neighbouring tile */ -enum TileSource { +enum TileSource : uint8_t { TS_HOME = 0, TS_NEIGHBOUR = 1, @@ -254,7 +254,7 @@ static const int8_t y_ppp_offsets[DIR_END] = {-2, 0, 2, 4, 2, 0, -2, -4}; /** * Offset for pylon sprites from the base pylon sprite. */ -enum PylonSpriteOffset { +enum PylonSpriteOffset : uint8_t { PSO_Y_NE, PSO_Y_SW, PSO_X_NW, @@ -280,7 +280,7 @@ static const uint8_t pylon_sprites[] = { /** * Offset for wire sprites from the base wire sprite. */ -enum WireSpriteOffset { +enum WireSpriteOffset : uint8_t { WSO_X_SHORT, WSO_Y_SHORT, WSO_EW_SHORT, @@ -419,7 +419,7 @@ static const SortableSpriteStruct RailCatenarySpriteData_Tunnel[] = { *
  • Position of the Pylon relative to the track
  • *
  • Position of the Pylon inside the tile
  • */ -enum RailCatenarySprite { +enum RailCatenarySprite : uint8_t { WIRE_X_FLAT_SW, WIRE_X_FLAT_NE, WIRE_X_FLAT_BOTH, diff --git a/src/table/strgen_tables.h b/src/table/strgen_tables.h index 6f9a3310d3..def3a72246 100644 --- a/src/table/strgen_tables.h +++ b/src/table/strgen_tables.h @@ -9,7 +9,7 @@ #include "../core/enum_type.hpp" -enum CmdFlags { +enum CmdFlags : uint8_t { C_NONE = 0x0, ///< Nothing special about this command C_DONTCOUNT = 0x1, ///< These commands aren't counted for comparison C_CASE = 0x2, ///< These commands support cases diff --git a/src/table/townname.h b/src/table/townname.h index 638a838302..778eae931e 100644 --- a/src/table/townname.h +++ b/src/table/townname.h @@ -1696,7 +1696,7 @@ static const char * const _name_czech_real[] = { * with cloning this for your own language. */ /* Sing., pl. */ -enum CzechGender { +enum CzechGender : uint8_t { CZG_SMASC, CZG_SFEM, CZG_SNEUT, @@ -1709,7 +1709,7 @@ enum CzechGender { CZG_NFREE }; -enum CzechPattern { +enum CzechPattern : uint8_t { CZP_JARNI, CZP_MLADY, CZP_PRIVL @@ -1729,22 +1729,22 @@ static const char * const _name_czech_patmod[][3] = { /* This way the substantive can choose only some adjectives/endings: * At least one of these flags must be satisfied: */ -enum CzechAllow { +enum CzechAllow : uint8_t { CZA_SHORT = 1, CZA_MIDDLE = 2, CZA_LONG = 4, - CZA_ALL = ~0 + CZA_ALL = CZA_SHORT | CZA_MIDDLE | CZA_LONG, }; DECLARE_ENUM_AS_BIT_SET(CzechAllow) /* All these flags must be satisfied (in the stem->others direction): */ -enum CzechChoose { +enum CzechChoose : uint8_t { CZC_NONE = 0, // No requirements. CZC_COLOR = 1, CZC_POSTFIX = 2, // Matched if postfix was inserted. CZC_NOPOSTFIX = 4, // Matched if no postfix was inserted. - CZC_ANY = ~0 + CZC_ANY = CZC_COLOR | CZC_POSTFIX | CZC_NOPOSTFIX, }; DECLARE_ENUM_AS_BIT_SET(CzechChoose) diff --git a/src/textbuf_gui.h b/src/textbuf_gui.h index 15776fb680..491b3305dc 100644 --- a/src/textbuf_gui.h +++ b/src/textbuf_gui.h @@ -15,7 +15,7 @@ #include "strings_type.h" /** Flags used in ShowQueryString() call */ -enum QueryStringFlags { +enum QueryStringFlags : uint8_t { QSF_NONE = 0, QSF_ACCEPT_UNCHANGED = 0x01, ///< return success even when the text didn't change QSF_ENABLE_DEFAULT = 0x02, ///< enable the 'Default' button ("\0" is returned) diff --git a/src/textfile_gui.cpp b/src/textfile_gui.cpp index f9c24ef86f..ba9c455c87 100644 --- a/src/textfile_gui.cpp +++ b/src/textfile_gui.cpp @@ -167,7 +167,7 @@ void TextfileWindow::SetupScrollbars(bool force_reflow) static const std::regex _markdown_link_regex{"\\[(.+?)\\]\\((.+?)\\)", std::regex_constants::ECMAScript | std::regex_constants::optimize}; /** Types of link we support in markdown files. */ -enum class HyperlinkType { +enum class HyperlinkType : uint8_t { Internal, ///< Internal link, or "anchor" in HTML language. Web, ///< Link to an external website. File, ///< Link to a local file. diff --git a/src/textfile_type.h b/src/textfile_type.h index 523798e167..8b1a010fe8 100644 --- a/src/textfile_type.h +++ b/src/textfile_type.h @@ -11,7 +11,7 @@ #define TEXTFILE_TYPE_H /** Additional text files accompanying Tar archives */ -enum TextfileType { +enum TextfileType : uint8_t { TFT_CONTENT_BEGIN, TFT_README = TFT_CONTENT_BEGIN, ///< Content readme diff --git a/src/tile_cmd.h b/src/tile_cmd.h index c5f9ebdcbf..37c8b37ff7 100644 --- a/src/tile_cmd.h +++ b/src/tile_cmd.h @@ -18,7 +18,7 @@ #include "timer/timer_game_calendar.h" /** The returned bits of VehicleEnterTile. */ -enum VehicleEnterTileStatus { +enum VehicleEnterTileStatus : uint32_t { VETS_ENTERED_STATION = 1, ///< The vehicle entered a station VETS_ENTERED_WORMHOLE = 2, ///< The vehicle either entered a bridge, tunnel or depot tile (this includes the last tile of the bridge/tunnel) VETS_CANNOT_ENTER = 3, ///< The vehicle cannot enter the tile diff --git a/src/tile_type.h b/src/tile_type.h index d1a7a3eb93..45c948c3bf 100644 --- a/src/tile_type.h +++ b/src/tile_type.h @@ -44,7 +44,7 @@ static const uint DEF_DESERT_COVERAGE = 50; ///< Default dese * * @note A railway with a crossing street is marked as MP_ROAD. */ -enum TileType { +enum TileType : uint8_t { MP_CLEAR, ///< A tile without any structures, i.e. grass, rocks, farm fields etc. MP_RAILWAY, ///< A railway MP_ROAD, ///< A tile with road (or tram tracks) @@ -73,7 +73,7 @@ enum TileType { * TROPICZONE_DESERT: Placed manually. * TROPICZONE_RAINFOREST: Placed if you plant certain rainforest-trees. */ -enum TropicZone { +enum TropicZone : uint8_t { TROPICZONE_NORMAL = 0, ///< Normal tropiczone TROPICZONE_DESERT = 1, ///< Tile is desert TROPICZONE_RAINFOREST = 2, ///< Rainforest tile diff --git a/src/tilehighlight_type.h b/src/tilehighlight_type.h index a19eef5aac..10cc3eeaf2 100644 --- a/src/tilehighlight_type.h +++ b/src/tilehighlight_type.h @@ -16,7 +16,7 @@ #include "viewport_type.h" /** Highlighting draw styles */ -enum HighLightStyle { +enum HighLightStyle : uint16_t { HT_NONE = 0x000, ///< default HT_RECT = 0x010, ///< rectangle (stations, depots, ...) HT_POINT = 0x020, ///< point (lower land, raise land, level land, ...) diff --git a/src/timer/timer_game_common.h b/src/timer/timer_game_common.h index ca6b7e13fa..a2d5491605 100644 --- a/src/timer/timer_game_common.h +++ b/src/timer/timer_game_common.h @@ -94,7 +94,7 @@ public: return Date{(365 * year_as_int) + number_of_leap_years}; } - enum Trigger { + enum Trigger : uint8_t { DAY, WEEK, MONTH, @@ -102,7 +102,7 @@ public: YEAR, }; - enum Priority { + enum Priority : uint8_t { NONE, ///< These timers can be executed in any order; there is no Random() in them, so order is not relevant. /* All other may have a Random() call in them, so order is important. diff --git a/src/timer/timer_game_realtime.h b/src/timer/timer_game_realtime.h index 22432501b3..e17d1fb624 100644 --- a/src/timer/timer_game_realtime.h +++ b/src/timer/timer_game_realtime.h @@ -27,7 +27,7 @@ */ class TimerGameRealtime { public: - enum PeriodFlags { + enum PeriodFlags : uint8_t { ALWAYS, ///< Always run, even when paused. UNPAUSED, ///< Only run when not paused. AUTOSAVE, ///< Only run when not paused or there was a Command executed recently. diff --git a/src/timer/timer_game_tick.h b/src/timer/timer_game_tick.h index 02ae2b16ff..ac901e3e31 100644 --- a/src/timer/timer_game_tick.h +++ b/src/timer/timer_game_tick.h @@ -24,7 +24,7 @@ public: using Ticks = int32_t; ///< The type to store ticks in using TickCounter = uint64_t; ///< The type that the tick counter is stored in - enum Priority { + enum Priority : uint8_t { NONE, ///< These timers can be executed in any order; the order is not relevant. /* For all other priorities, the order is important. diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 2181219aa7..efce1a5116 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -78,14 +78,14 @@ RoadType _last_built_roadtype; RoadType _last_built_tramtype; /** Toobar modes */ -enum ToolbarMode { +enum ToolbarMode : uint8_t { TB_NORMAL, TB_UPPER, TB_LOWER }; /** Callback functions. */ -enum CallBackFunction { +enum CallBackFunction : uint8_t { CBF_NONE, CBF_PLACE_SIGN, CBF_PLACE_LANDINFO, @@ -226,7 +226,7 @@ static CallBackFunction ToolbarFastForwardClick(Window *) /** * Game Option button menu entries. */ -enum OptionMenuEntries { +enum OptionMenuEntries : uint8_t { OME_GAMEOPTIONS, OME_SETTINGS, OME_AI_SETTINGS, @@ -352,7 +352,7 @@ static CallBackFunction MenuClickSettings(int index) /** * SaveLoad entries in scenario editor mode. */ -enum SaveLoadEditorMenuEntries { +enum SaveLoadEditorMenuEntries : uint8_t { SLEME_SAVE_SCENARIO = 0, SLEME_LOAD_SCENARIO, SLEME_SAVE_HEIGHTMAP, @@ -364,7 +364,7 @@ enum SaveLoadEditorMenuEntries { /** * SaveLoad entries in normal game mode. */ -enum SaveLoadNormalMenuEntries { +enum SaveLoadNormalMenuEntries : uint8_t { SLNME_SAVE_GAME = 0, SLNME_LOAD_GAME, SLNME_EXIT_TOINTRO, @@ -428,7 +428,7 @@ static CallBackFunction MenuClickSaveLoad(int index = 0) /* --- Map button menu --- */ -enum MapMenuEntries { +enum MapMenuEntries : uint8_t { MME_SHOW_SMALLMAP = 0, MME_SHOW_EXTRAVIEWPORTS, MME_SHOW_LINKGRAPH, @@ -2300,7 +2300,7 @@ static ToolbarButtonProc * const _scen_toolbar_button_procs[] = { ToolbarSwitchClick, }; -enum MainToolbarEditorHotkeys { +enum MainToolbarEditorHotkeys : int32_t { MTEHK_PAUSE, MTEHK_FASTFORWARD, MTEHK_SETTINGS, diff --git a/src/toolbar_gui.h b/src/toolbar_gui.h index 4c3f4360db..37cc7fb886 100644 --- a/src/toolbar_gui.h +++ b/src/toolbar_gui.h @@ -10,7 +10,7 @@ #ifndef TOOLBAR_GUI_H #define TOOLBAR_GUI_H -enum MainToolbarHotkeys { +enum MainToolbarHotkeys : int32_t { MTHK_PAUSE, MTHK_FASTFORWARD, MTHK_SETTINGS, diff --git a/src/town_gui.cpp b/src/town_gui.cpp index a7e989fa09..2a68d84c8b 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -724,7 +724,7 @@ static constexpr NWidgetPart _nested_town_directory_widgets[] = { }; /** Enum referring to the Hotkeys in the town directory window */ -enum TownDirectoryHotkeys { +enum TownDirectoryHotkeys : int32_t { TDHK_FOCUS_FILTER_BOX, ///< Focus the filter box }; diff --git a/src/train.h b/src/train.h index f46c48d9dd..4be9a3bec3 100644 --- a/src/train.h +++ b/src/train.h @@ -22,7 +22,7 @@ struct Train; /** Rail vehicle flags. */ -enum VehicleRailFlags { +enum VehicleRailFlags : uint8_t { VRF_REVERSING = 0, VRF_POWEREDWAGON = 3, ///< Wagon is powered. VRF_REVERSE_DIRECTION = 4, ///< Reverse the visible direction of the vehicle. @@ -41,7 +41,7 @@ enum TrainForceProceeding : uint8_t { }; /** Flags for Train::ConsistChanged */ -enum ConsistChangeFlags { +enum ConsistChangeFlags : uint8_t { CCF_LENGTH = 0x01, ///< Allow vehicles to change length. CCF_CAPACITY = 0x02, ///< Allow vehicles to change capacity. diff --git a/src/transparency.h b/src/transparency.h index 9274fd4d45..0ebd90475d 100644 --- a/src/transparency.h +++ b/src/transparency.h @@ -19,7 +19,7 @@ * If you change the order, change the order of the ShowTransparencyToolbar() stuff in transparency_gui.cpp too. * If you add or remove an option don't forget to change the transparency 'hot keys' in main_gui.cpp. */ -enum TransparencyOption { +enum TransparencyOption : uint8_t { TO_SIGNS = 0, ///< signs TO_TREES, ///< trees TO_HOUSES, ///< town buildings diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index c4dbbc0f55..a5672ff5eb 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -37,14 +37,14 @@ * * This enumeration defines all possible tree placer algorithm in the game. */ -enum TreePlacer { +enum TreePlacer : uint8_t { TP_NONE, ///< No tree placer algorithm TP_ORIGINAL, ///< The original algorithm TP_IMPROVED, ///< A 'improved' algorithm }; /** Where to place trees while in-game? */ -enum ExtraTreePlacement { +enum ExtraTreePlacement : uint8_t { ETP_NO_SPREAD, ///< Grow trees on tiles that have them but don't spread to new ones ETP_SPREAD_RAINFOREST, ///< Grow trees on tiles that have them, only spread to new ones in rainforests ETP_SPREAD_ALL, ///< Grow trees and spread them without restrictions diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp index efc2a2c5c8..3b6f6b811a 100644 --- a/src/tree_gui.cpp +++ b/src/tree_gui.cpp @@ -82,7 +82,7 @@ class BuildTreesWindow : public Window /** Visual Y offset of tree root from the bottom of the tree type buttons */ static const int BUTTON_BOTTOM_OFFSET = 7; - enum PlantingMode { + enum PlantingMode : uint8_t { PM_NORMAL, PM_FOREST_SM, PM_FOREST_LG, diff --git a/src/tree_map.h b/src/tree_map.h index 25a2e71a0b..9fa0969ed1 100644 --- a/src/tree_map.h +++ b/src/tree_map.h @@ -22,7 +22,7 @@ * the tree list for a landscape. See the TREE_COUNT_* enumerations * for the amount of different trees for a specific landscape. */ -enum TreeType { +enum TreeType : uint8_t { TREE_TEMPERATE = 0x00, ///< temperate tree TREE_SUB_ARCTIC = 0x0C, ///< tree on a sub_arctic landscape TREE_RAINFOREST = 0x14, ///< tree on the 'green part' on a sub-tropical map @@ -49,7 +49,7 @@ static const uint TREE_COUNT_TOYLAND = 9; * * This enumeration defines the ground types for tiles with trees on it. */ -enum TreeGround { +enum TreeGround : uint8_t { TREE_GROUND_GRASS = 0, ///< normal grass TREE_GROUND_ROUGH = 1, ///< some rough tile TREE_GROUND_SNOW_DESERT = 2, ///< a desert or snow tile, depend on landscape @@ -62,7 +62,7 @@ enum TreeGround { * * This enumeration defines the stages of tree growth for tiles with trees on it. */ -enum class TreeGrowthStage : uint { +enum class TreeGrowthStage : uint8_t { Growing1 = 0, ///< First stage of growth Growing2 = 1, ///< Second stage of growth Growing3 = 2, ///< Third stage of growth diff --git a/src/vehicle_base.h b/src/vehicle_base.h index 1a856b366c..2812dd9028 100644 --- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -29,7 +29,7 @@ const uint TILE_AXIAL_DISTANCE = 192; // Logical length of the tile in any Diag const uint TILE_CORNER_DISTANCE = 128; // Logical length of the tile corner crossing in any non-diagonal direction used in vehicle movement. /** Vehicle status bits in #Vehicle::vehstatus. */ -enum VehStatus { +enum VehStatus : uint8_t { VS_HIDDEN = 0x01, ///< Vehicle is not visible. VS_STOPPED = 0x02, ///< Vehicle is stopped by the player. VS_UNCLICKABLE = 0x04, ///< Vehicle is not clickable by the user (shadow vehicles). @@ -41,7 +41,7 @@ enum VehStatus { }; /** Bit numbers in #Vehicle::vehicle_flags. */ -enum VehicleFlags { +enum VehicleFlags : uint8_t { VF_LOADING_FINISHED, ///< Vehicle has finished loading. VF_CARGO_UNLOADING, ///< Vehicle is unloading cargo. VF_BUILT_AS_PROTOTYPE, ///< Vehicle is a prototype (accepted as exclusive preview). @@ -55,7 +55,7 @@ enum VehicleFlags { }; /** Bit numbers used to indicate which of the #NewGRFCache values are valid. */ -enum NewGRFCacheValidValues { +enum NewGRFCacheValidValues : uint8_t { NCVV_POSITION_CONSIST_LENGTH = 0, ///< This bit will be set if the NewGRF var 40 currently stored is valid. NCVV_POSITION_SAME_ID_LENGTH = 1, ///< This bit will be set if the NewGRF var 41 currently stored is valid. NCVV_CONSIST_CARGO_INFORMATION = 2, ///< This bit will be set if the NewGRF var 42 currently stored is valid. @@ -78,7 +78,7 @@ struct NewGRFCache { }; /** Meaning of the various bits of the visual effect. */ -enum VisualEffect { +enum VisualEffect : uint8_t { VE_OFFSET_START = 0, ///< First bit that contains the offset (0 = front, 8 = centre, 15 = rear) VE_OFFSET_COUNT = 4, ///< Number of bits used for the offset VE_OFFSET_CENTRE = 8, ///< Value of offset corresponding to a position above the centre of the vehicle @@ -98,7 +98,7 @@ enum VisualEffect { }; /** Models for spawning visual effects. */ -enum VisualEffectSpawnModel { +enum VisualEffectSpawnModel : uint8_t { VESM_NONE = 0, ///< No visual effect VESM_STEAM, ///< Steam model VESM_DIESEL, ///< Diesel model @@ -112,7 +112,7 @@ enum VisualEffectSpawnModel { * This is defined here instead of at #GroundVehicle because some common function require access to these flags. * Do not access it directly unless you have to. Use the subtype access functions. */ -enum GroundVehicleSubtypeFlags { +enum GroundVehicleSubtypeFlags : uint8_t { GVSF_FRONT = 0, ///< Leading engine of a consist. GVSF_ARTICULATED_PART = 1, ///< Articulated part of an engine. GVSF_WAGON = 2, ///< Wagon (not used for road vehicles). diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index f6b9bf872e..70d671dd2d 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -1934,13 +1934,13 @@ void BaseVehicleListWindow::UpdateVehicleGroupBy(GroupBy group_by) struct VehicleListWindow : public BaseVehicleListWindow { private: /** Enumeration of planes of the button row at the bottom. */ - enum ButtonPlanes { + enum ButtonPlanes : uint8_t { BP_SHOW_BUTTONS, ///< Show the buttons. BP_HIDE_BUTTONS, ///< Show the empty panel. }; /** Enumeration of planes of the title row at the top. */ - enum CaptionPlanes { + enum CaptionPlanes : uint8_t { BP_NORMAL, ///< Show shared orders caption and buttons. BP_SHARED_ORDERS, ///< Show the normal caption. }; @@ -2961,7 +2961,7 @@ static const int VV_INITIAL_VIEWPORT_HEIGHT = 84; static const int VV_INITIAL_VIEWPORT_HEIGHT_TRAIN = 102; /** Command indices for the _vehicle_command_translation_table. */ -enum VehicleCommandTranslation { +enum VehicleCommandTranslation : uint8_t { VCT_CMD_START_STOP = 0, VCT_CMD_CLONE_VEH, VCT_CMD_TURN_AROUND, @@ -3033,7 +3033,7 @@ static bool IsVehicleRefitable(const Vehicle *v) struct VehicleViewWindow : Window { private: /** Display planes available in the vehicle view window. */ - enum PlaneSelections { + enum PlaneSelections : uint8_t { SEL_DC_GOTO_DEPOT, ///< Display 'goto depot' button in #WID_VV_SELECT_DEPOT_CLONE stacked widget. SEL_DC_CLONE, ///< Display 'clone vehicle' button in #WID_VV_SELECT_DEPOT_CLONE stacked widget. diff --git a/src/vehicle_gui.h b/src/vehicle_gui.h index 19a5ea1774..262a04eeeb 100644 --- a/src/vehicle_gui.h +++ b/src/vehicle_gui.h @@ -31,7 +31,7 @@ enum TrainDetailsWindowTabs : uint8_t { DECLARE_ENUM_AS_ADDABLE(TrainDetailsWindowTabs) /** Special values for vehicle-related windows for the data parameter of #InvalidateWindowData. */ -enum VehicleInvalidateWindowData { +enum VehicleInvalidateWindowData : int { VIWD_REMOVE_ALL_ORDERS = -1, ///< Removed / replaced all orders (after deleting / sharing). VIWD_MODIFY_ORDERS = -2, ///< Other order modifications. VIWD_CONSIST_CHANGED = -3, ///< Vehicle composition was changed. diff --git a/src/vehicle_gui_base.h b/src/vehicle_gui_base.h index d7898c2e4a..ef9989c420 100644 --- a/src/vehicle_gui_base.h +++ b/src/vehicle_gui_base.h @@ -88,7 +88,7 @@ struct BaseVehicleListWindow : public Window { typedef GUIVehicleGroupList::SortFunction VehicleGroupSortFunction; typedef GUIVehicleList::SortFunction VehicleIndividualSortFunction; - enum ActionDropdownItem { + enum ActionDropdownItem : uint8_t { ADI_REPLACE, ADI_SERVICE, ADI_DEPOT, diff --git a/src/vehicle_type.h b/src/vehicle_type.h index 05523acdc2..b1aeb6b1cc 100644 --- a/src/vehicle_type.h +++ b/src/vehicle_type.h @@ -69,13 +69,13 @@ static const uint MAX_LENGTH_VEHICLE_NAME_CHARS = 32; ///< The maximum length of static const uint VEHICLE_LENGTH = 8; /** Vehicle acceleration models. */ -enum AccelerationModel { +enum AccelerationModel : uint8_t { AM_ORIGINAL, AM_REALISTIC, }; /** Visualisation contexts of vehicles and engines. */ -enum EngineImageType { +enum EngineImageType : uint8_t { EIT_ON_MAP = 0x00, ///< Vehicle drawn in viewport. EIT_IN_DEPOT = 0x10, ///< Vehicle drawn in depot. EIT_IN_DETAILS = 0x11, ///< Vehicle drawn in vehicle details, refit window, ... diff --git a/src/video/opengl.h b/src/video/opengl.h index 14633c44cd..551e81065d 100644 --- a/src/video/opengl.h +++ b/src/video/opengl.h @@ -115,7 +115,7 @@ public: class OpenGLSprite { private: /** Enum of all used OpenGL texture objects. */ - enum Texture { + enum Texture : uint8_t { TEX_RGBA, ///< RGBA texture part. TEX_REMAP, ///< Remap texture part. NUM_TEX diff --git a/src/viewport.cpp b/src/viewport.cpp index dda99b7507..b8334bb7ec 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -139,7 +139,7 @@ struct ChildScreenSpriteToDraw { }; /** Enumeration of multi-part foundations */ -enum FoundationPart { +enum FoundationPart : uint8_t { FOUNDATION_PART_NONE = 0xFF, ///< Neither foundation nor groundsprite drawn yet. FOUNDATION_PART_NORMAL = 0, ///< First part (normal foundation or no foundation) FOUNDATION_PART_HALFTILE = 1, ///< Second part (halftile foundation) @@ -150,7 +150,7 @@ enum FoundationPart { * Mode of "sprite combining" * @see StartSpriteCombine */ -enum SpriteCombineMode { +enum SpriteCombineMode : uint8_t { SPRITE_COMBINE_NONE, ///< Every #AddSortableSpriteToDraw start its own bounding box SPRITE_COMBINE_PENDING, ///< %Sprite combining will start with the next unclipped sprite. SPRITE_COMBINE_ACTIVE, ///< %Sprite combining is active. #AddSortableSpriteToDraw outputs child sprites. @@ -1005,7 +1005,7 @@ static void DrawAutorailSelection(const TileInfo *ti, uint autorail_type) DrawSelectionSprite(image, _thd.make_square_red ? PALETTE_SEL_TILE_RED : pal, ti, 7, foundation_part); } -enum TileHighlightType { +enum TileHighlightType : uint8_t { THT_NONE, THT_WHITE, THT_BLUE, diff --git a/src/viewport_type.h b/src/viewport_type.h index 1a67197759..e7d0bac157 100644 --- a/src/viewport_type.h +++ b/src/viewport_type.h @@ -84,7 +84,7 @@ struct TrackedViewportSign : ViewportSign { * Directions of zooming. * @see DoZoomInOutWindow */ -enum ZoomStateChange { +enum ZoomStateChange : uint8_t { ZOOM_IN = 0, ///< Zoom in (get more detailed view). ZOOM_OUT = 1, ///< Zoom out (get helicopter view). ZOOM_NONE = 2, ///< Hack, used to update the button status. @@ -100,7 +100,7 @@ static const uint BB_HEIGHT_UNDER_BRIDGE = 6; ///< Everything that can be built static const uint BB_Z_SEPARATOR = 7; ///< Separates the bridge/tunnel from the things under/above it. /** Viewport place method (type of highlighted area and placed objects) */ -enum ViewportPlaceMethod { +enum ViewportPlaceMethod : uint8_t { VPM_X_OR_Y = 0, ///< drag in X or Y direction VPM_FIX_X = 1, ///< drag only in X axis VPM_FIX_Y = 2, ///< drag only in Y axis @@ -119,7 +119,7 @@ DECLARE_ENUM_AS_BIT_SET(ViewportPlaceMethod) * Drag and drop selection process, or, what to do with an area of land when * you've selected it. */ -enum ViewportDragDropSelectionProcess { +enum ViewportDragDropSelectionProcess : uint8_t { DDSP_DEMOLISH_AREA, ///< Clear area DDSP_RAISE_AND_LEVEL_AREA, ///< Raise / level area DDSP_LOWER_AND_LEVEL_AREA, ///< Lower / level area diff --git a/src/water.h b/src/water.h index 323ccd5c53..26dc5986d1 100644 --- a/src/water.h +++ b/src/water.h @@ -16,7 +16,7 @@ /** * Describes the behaviour of a tile during flooding. */ -enum FloodingBehaviour { +enum FloodingBehaviour : uint8_t { FLOOD_NONE, ///< The tile does not flood neighboured tiles. FLOOD_ACTIVE, ///< The tile floods neighboured tiles. FLOOD_PASSIVE, ///< The tile does not actively flood neighboured tiles, but it prevents them from drying up. diff --git a/src/water_map.h b/src/water_map.h index c21029b670..82d532de88 100644 --- a/src/water_map.h +++ b/src/water_map.h @@ -28,7 +28,7 @@ static constexpr uint8_t WBL_DEPOT_PART = 0; ///< Depot part flag. static constexpr uint8_t WBL_DEPOT_AXIS = 1; ///< Depot axis flag. /** Available water tile types. */ -enum WaterTileType { +enum WaterTileType : uint8_t { WATER_TILE_CLEAR, ///< Plain water. WATER_TILE_COAST, ///< Coast. WATER_TILE_LOCK, ///< Water lock. @@ -55,14 +55,14 @@ inline bool IsValidWaterClass(WaterClass wc) } /** Sections of the water depot. */ -enum DepotPart { +enum DepotPart : uint8_t { DEPOT_PART_NORTH = 0, ///< Northern part of a depot. DEPOT_PART_SOUTH = 1, ///< Southern part of a depot. DEPOT_PART_END }; /** Sections of the water lock. */ -enum LockPart { +enum LockPart : uint8_t { LOCK_PART_MIDDLE = 0, ///< Middle part of a lock. LOCK_PART_LOWER = 1, ///< Lower part of a lock. LOCK_PART_UPPER = 2, ///< Upper part of a lock. diff --git a/src/waypoint_base.h b/src/waypoint_base.h index cbf2e1e608..45ec17c00d 100644 --- a/src/waypoint_base.h +++ b/src/waypoint_base.h @@ -15,7 +15,7 @@ /** * Flags for Waypoint::waypoint_flags. */ -enum WaypointFlags { +enum WaypointFlags : uint8_t { WPF_ROAD = 0, ///< This is a road waypoint }; diff --git a/src/widget_type.h b/src/widget_type.h index 15530259d4..f7e50eb860 100644 --- a/src/widget_type.h +++ b/src/widget_type.h @@ -34,7 +34,7 @@ enum ResizeWidgetValues : uint8_t { /** * Window widget types, nested widget types, and nested widget part types. */ -enum WidgetType { +enum WidgetType : uint8_t { /* Window widget types. */ WWT_EMPTY, ///< Empty widget, place holder to reserve space in widget tree. @@ -108,7 +108,7 @@ enum WidgetType { }; /** Different forms of sizing nested widgets, using NWidgetBase::AssignSizePosition() */ -enum SizingType { +enum SizingType : uint8_t { ST_SMALLEST, ///< Initialize nested widget tree to smallest size. Also updates \e current_x and \e current_y. ST_RESIZE, ///< Resize the nested widget tree. }; @@ -324,7 +324,7 @@ public: }; /** Nested widget flags that affect display and interaction with 'real' widgets. */ -enum NWidgetDisplay { +enum NWidgetDisplay : uint16_t { /* Generic. */ NDB_LOWERED = 0, ///< Widget is lowered (pressed down) bit. NDB_DISABLED = 1, ///< Widget is disabled (greyed out) bit. @@ -492,7 +492,7 @@ protected: }; /** Display planes with zero size for #NWidgetStacked. */ -enum StackedZeroSizePlanes { +enum StackedZeroSizePlanes : int { SZSP_VERTICAL = INT_MAX / 2, ///< Display plane with zero size horizontally, and filling and resizing vertically. SZSP_HORIZONTAL, ///< Display plane with zero size vertically, and filling and resizing horizontally. SZSP_NONE, ///< Display plane with zero size in both directions (none filling and resizing). @@ -530,7 +530,7 @@ private: }; /** Nested widget container flags, */ -enum NWidContainerFlags { +enum NWidContainerFlags : uint8_t { NCB_EQUALSIZE = 0, ///< Containers should keep all their (resizing) children equally large. NCB_BIGFIRST = 1, ///< Allocate space to biggest resize first. @@ -719,7 +719,7 @@ private: public: /** Stepping sizes when scrolling */ - enum ScrollbarStepping { + enum ScrollbarStepping : uint8_t { SS_RAW, ///< Step in single units. SS_SMALL, ///< Step in #stepsize units. SS_BIG, ///< Step in #cap units. diff --git a/src/window.cpp b/src/window.cpp index 0ee51b5507..edfd7bf479 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -42,7 +42,7 @@ #include "safeguards.h" /** Values for _settings_client.gui.auto_scrolling */ -enum ViewportAutoscrolling { +enum ViewportAutoscrolling : uint8_t { VA_DISABLED, //!< Do not autoscroll when mouse is at edge of viewport. VA_MAIN_VIEWPORT_FULLSCREEN, //!< Scroll main viewport at edge when using fullscreen. VA_MAIN_VIEWPORT, //!< Scroll main viewport at edge. @@ -1924,7 +1924,7 @@ static void HandleMouseOver() } /** Direction for moving the window. */ -enum PreventHideDirection { +enum PreventHideDirection : uint8_t { PHD_UP, ///< Above v is a safe position. PHD_DOWN, ///< Below v is a safe position. }; @@ -2705,7 +2705,7 @@ static void HandleAutoscroll() } } -enum MouseClick { +enum MouseClick : uint8_t { MC_NONE = 0, MC_LEFT, MC_RIGHT, diff --git a/src/window_gui.h b/src/window_gui.h index 350f8245b4..84ec48a072 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -21,7 +21,7 @@ /** * Flags to describe the look of the frame */ -enum FrameFlags { +enum FrameFlags : uint8_t { FR_NONE = 0, FR_TRANSPARENT = 1 << 0, ///< Makes the background transparent if set FR_BORDERONLY = 1 << 4, ///< Draw border only, no background @@ -142,7 +142,7 @@ extern Window *_focused_window; /** How do we the window to be placed? */ -enum WindowPosition { +enum WindowPosition : uint8_t { WDP_MANUAL, ///< Manually align the window (so no automatic location finding) WDP_AUTO, ///< Find a place automatically WDP_CENTER, ///< Center the window @@ -199,7 +199,7 @@ private: /** * Window default widget/window handling flags */ -enum WindowDefaultFlag { +enum WindowDefaultFlag : uint8_t { WDF_CONSTRUCTION = 1 << 0, ///< This window is used for construction; close it whenever changing company. WDF_MODAL = 1 << 1, ///< The window is a modal child of some other window, meaning the parent is 'inactive' WDF_NO_FOCUS = 1 << 2, ///< This window won't get focus/make any other window lose focus when click @@ -215,7 +215,7 @@ struct ResizeInfo { }; /** State of a sort direction button. */ -enum SortButtonState { +enum SortButtonState : uint8_t { SBS_OFF, ///< Do not sort (with this button). SBS_DOWN, ///< Sort ascending. SBS_UP, ///< Sort descending. @@ -224,7 +224,7 @@ enum SortButtonState { /** * Window flags. */ -enum WindowFlags { +enum WindowFlags : uint16_t { WF_TIMEOUT = 1 << 0, ///< Window timeout counter. WF_DRAGGING = 1 << 3, ///< Window is being dragged. @@ -260,7 +260,7 @@ struct ViewportData : Viewport { struct QueryString; /* misc_gui.cpp */ -enum TooltipCloseCondition { +enum TooltipCloseCondition : uint8_t { TCC_RIGHT_CLICK, TCC_HOVER, TCC_NONE, @@ -1036,7 +1036,7 @@ extern bool _scrolling_viewport; extern bool _mouse_hovering; /** Mouse modes. */ -enum SpecialMouseMode { +enum SpecialMouseMode : uint8_t { WSM_NONE, ///< No special mouse mode. WSM_DRAGDROP, ///< Drag&drop an object. WSM_SIZING, ///< Sizing mode. diff --git a/src/window_type.h b/src/window_type.h index 76cef11f9b..a71602e2a1 100644 --- a/src/window_type.h +++ b/src/window_type.h @@ -18,7 +18,7 @@ using WidgetID = int; /** %Window numbers. */ -enum WindowNumberEnum { +enum WindowNumberEnum : uint8_t { WN_GAME_OPTIONS_AI = 0, ///< AI settings. WN_GAME_OPTIONS_GS, ///< GS settings. WN_GAME_OPTIONS_ABOUT, ///< About window. @@ -41,7 +41,7 @@ enum WindowNumberEnum { }; /** %Window classes. */ -enum WindowClass { +enum WindowClass : uint16_t { WC_NONE, ///< No window, redirects to WC_MAIN_WINDOW. /** @@ -725,7 +725,7 @@ enum WindowClass { }; /** Data value for #Window::OnInvalidateData() of windows with class #WC_GAME_OPTIONS. */ -enum GameOptionsInvalidationData { +enum GameOptionsInvalidationData : uint8_t { GOID_DEFAULT = 0, GOID_NEWGRF_RESCANNED, ///< NewGRFs were just rescanned. GOID_NEWGRF_CURRENT_LOADED, ///< The current list of active NewGRF has been loaded. @@ -740,7 +740,7 @@ struct Window; typedef int32_t WindowNumber; /** State of handling an event. */ -enum EventState { +enum EventState : uint8_t { ES_HANDLED, ///< The passed event is handled. ES_NOT_HANDLED, ///< The passed event is not handled. };