Mercurial > hg > openttd
changeset 15183:43a5d37b45c4 draft
(svn r19812) -Codechange: give some unnamed enums a name or, in case they consisted of unrelated values use static const (u)int
line wrap: on
line diff
--- a/src/airport.h +++ b/src/airport.h @@ -26,7 +26,7 @@ }; /** Airport types */ -enum { +enum AirportTypes { AT_SMALL = 0, AT_LARGE = 1, AT_HELIPORT = 2, @@ -43,7 +43,7 @@ AT_DUMMY = 255 }; -enum { +enum AirportMovingDataFlags { AMED_NOSPDCLAMP = 1 << 0, AMED_TAKEOFF = 1 << 1, AMED_SLOWTURN = 1 << 2, @@ -56,7 +56,7 @@ }; /* Movement States on Airports (headings target) */ -enum { +enum AirportMovementStates { TO_ALL = 0, HANGAR = 1, TERM1 = 2,
--- a/src/bridge.h +++ b/src/bridge.h @@ -32,9 +32,7 @@ DECLARE_POSTFIX_INCREMENT(BridgePieces) -enum { - MAX_BRIDGES = 13 -}; +static const uint MAX_BRIDGES = 13; typedef uint BridgeType;
--- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -93,10 +93,8 @@ }; /** Special cargo filter criteria */ -enum { - CF_ANY = CT_NO_REFIT, ///< Show all vehicles independent of carried cargo (i.e. no filtering) - CF_NONE = CT_INVALID, ///< Show only vehicles which do not carry cargo (e.g. train engines) -}; +static const CargoID CF_ANY = CT_NO_REFIT; ///< Show all vehicles independent of carried cargo (i.e. no filtering) +static const CargoID CF_NONE = CT_INVALID; ///< Show only vehicles which do not carry cargo (e.g. train engines) static bool _internal_sort_order; // descending/ascending static byte _last_sort_criteria[] = {0, 0, 0, 0};
--- a/src/command_type.h +++ b/src/command_type.h @@ -139,7 +139,7 @@ * * @see _command_proc_table */ -enum { +enum Commands { 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 @@ -322,7 +322,7 @@ * * This enumeration defines some flags which are binary-or'ed on a command. */ -enum { +enum FlaggedCommands { CMD_NETWORK_COMMAND = 0x0100, ///< execute the command without sending it on the network CMD_NO_TEST_IF_IN_NETWORK = 0x0200, ///< When enabled, the command will bypass the no-DC_EXEC round if in network CMD_FLAGS_MASK = 0xFF00, ///< mask for all command flags @@ -334,7 +334,7 @@ * * This enumeration defines flags for the _command_proc_table. */ -enum { +enum CommandFlags { CMD_SERVER = 0x01, ///< the command can only be initiated by the server CMD_SPECTATOR = 0x02, ///< the command may be initiated by a spectator CMD_OFFLINE = 0x04, ///< the command cannot be executed in a multiplayer game; single-player only
--- a/src/company_type.h +++ b/src/company_type.h @@ -37,16 +37,12 @@ }; DECLARE_POSTFIX_INCREMENT(Owner) -enum { - MAX_LENGTH_PRESIDENT_NAME_BYTES = 31, ///< The maximum length of a president name in bytes including '\0' - MAX_LENGTH_PRESIDENT_NAME_PIXELS = 94, ///< The maximum length of a president name in pixels - MAX_LENGTH_COMPANY_NAME_BYTES = 31, ///< The maximum length of a company name in bytes including '\0' - MAX_LENGTH_COMPANY_NAME_PIXELS = 150, ///< The maximum length of a company name in pixels -}; +static const uint MAX_LENGTH_PRESIDENT_NAME_BYTES = 31; ///< The maximum length of a president name in bytes including '\0' +static const uint MAX_LENGTH_PRESIDENT_NAME_PIXELS = 94; ///< The maximum length of a president name in pixels +static const uint MAX_LENGTH_COMPANY_NAME_BYTES = 31; ///< The maximum length of a company name in bytes including '\0' +static const uint MAX_LENGTH_COMPANY_NAME_PIXELS = 150; ///< The maximum length of a company name in pixels -enum { - MAX_HISTORY_MONTHS = 24, ///< The maximum number of months kept as performance's history -}; +static const uint MAX_HISTORY_MONTHS = 24; ///< The maximum number of months kept as performance's history /** Define basic enum properties */ template <> struct EnumPropsT<Owner> : MakeEnumPropsT<Owner, byte, OWNER_BEGIN, OWNER_END, INVALID_OWNER> {};
--- a/src/console_internal.h +++ b/src/console_internal.h @@ -14,10 +14,8 @@ #include "console_type.h" -enum { - ICON_CMDLN_SIZE = 1024, ///< maximum length of a typed in command - ICON_MAX_STREAMSIZE = 2048, ///< maximum length of a totally expanded command -}; +static const uint ICON_CMDLN_SIZE = 1024; ///< maximum length of a typed in command +static const uint ICON_MAX_STREAMSIZE = 2048; ///< maximum length of a totally expanded command /** Return values of console hooks (#IConsoleHook). */ enum ConsoleHookResult {
--- a/src/currency.h +++ b/src/currency.h @@ -15,12 +15,10 @@ #include "date_type.h" #include "strings_type.h" -enum { - CF_NOEURO = 0, - CF_ISEURO = 1, - NUM_CURRENCY = 29, - CUSTOM_CURRENCY_ID = NUM_CURRENCY - 1 -}; +static const int CF_NOEURO = 0; +static const int CF_ISEURO = 1; +static const uint NUM_CURRENCY = 29; +static const int CUSTOM_CURRENCY_ID = NUM_CURRENCY - 1; struct CurrencySpec { uint16 rate;
--- a/src/date_type.h +++ b/src/date_type.h @@ -12,17 +12,24 @@ #ifndef DATE_TYPE_H #define DATE_TYPE_H + +typedef int32 Date; ///< The type to store our dates in +typedef uint16 DateFract; ///< The fraction of a date we're in, i.e. the number of ticks since the last date changeover +typedef int32 Ticks; ///< The type to store ticks in + +typedef int32 Year; ///< Type for the year, note: 0 based, i.e. starts at the year 0. +typedef uint8 Month; ///< Type for the month, note: 0 based, i.e. 0 = January, 11 = December. +typedef uint8 Day; ///< Type for the day of the month, note: 1 based, first day of a month is 1. + /** * 1 day is 74 ticks; _date_fract used to be uint16 and incremented by 885. On * an overflow the new day begun and 65535 / 885 = 74. * 1 tick is approximately 30 ms. * 1 day is thus about 2 seconds (74 * 30 = 2220) on a machine that can run OpenTTD normally */ -enum { - DAY_TICKS = 74, ///< ticks per day - DAYS_IN_YEAR = 365, ///< days per year - DAYS_IN_LEAP_YEAR = 366, ///< sometimes, you need one day more... -}; +static const int DAY_TICKS = 74; ///< ticks per day +static const int DAYS_IN_YEAR = 365; ///< days per year +static const int DAYS_IN_LEAP_YEAR = 366; ///< sometimes, you need one day more... /* * ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR and DAYS_TILL_ORIGINAL_BASE_YEAR are @@ -32,11 +39,11 @@ */ /** The minimum starting year/base year of the original TTD */ -#define ORIGINAL_BASE_YEAR 1920 +static const Year ORIGINAL_BASE_YEAR = 1920; /** The original ending year */ -#define ORIGINAL_END_YEAR 2051 +static const Year ORIGINAL_END_YEAR = 2051; /** The maximum year of the original TTD */ -#define ORIGINAL_MAX_YEAR 2090 +static const Year ORIGINAL_MAX_YEAR = 2090; /** * Calculate the number of leap years till a given year. @@ -66,28 +73,20 @@ #define DAYS_TILL_ORIGINAL_BASE_YEAR DAYS_TILL(ORIGINAL_BASE_YEAR) /** The absolute minimum & maximum years in OTTD */ -#define MIN_YEAR 0 +static const Year MIN_YEAR = 0; /** The default starting year */ -#define DEF_START_YEAR 1950 +static const Year DEF_START_YEAR = 1950; /** * MAX_YEAR, nicely rounded value of the number of years that can * be encoded in a single 32 bits date, about 2^31 / 366 years. */ -#define MAX_YEAR 5000000 +static const Year MAX_YEAR = 5000000; /** The number of days till the last day */ #define MAX_DAY (DAYS_TILL(MAX_YEAR + 1) - 1) -typedef int32 Date; ///< The type to store our dates in -typedef uint16 DateFract; ///< The fraction of a date we're in, i.e. the number of ticks since the last date changeover -typedef int32 Ticks; ///< The type to store ticks in - -typedef int32 Year; ///< Type for the year, note: 0 based, i.e. starts at the year 0. -typedef uint8 Month; ///< Type for the month, note: 0 based, i.e. 0 = January, 11 = December. -typedef uint8 Day; ///< Type for the day of the month, note: 1 based, first day of a month is 1. - /** * Data structure to convert between Date and triplet (year, month, and day). * @see ConvertDateToYMD(), ConvertYMDToDate()
--- a/src/economy_type.h +++ b/src/economy_type.h @@ -196,11 +196,9 @@ * Increasing base prices by factor 65536 should be enough. * @see MAX_INFLATION */ -enum { - MIN_PRICE_MODIFIER = -8, - MAX_PRICE_MODIFIER = 16, - INVALID_PRICE_MODIFIER = MIN_PRICE_MODIFIER - 1, -}; +static const int MIN_PRICE_MODIFIER = -8; +static const int MAX_PRICE_MODIFIER = 16; +static const int INVALID_PRICE_MODIFIER = MIN_PRICE_MODIFIER - 1; struct CargoPayment; typedef uint32 CargoPaymentID;
--- a/src/engine_type.h +++ b/src/engine_type.h @@ -71,7 +71,7 @@ /* AircraftVehicleInfo subtypes, bitmask type. * 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 { +enum AircraftSubTypeBits { AIR_HELI = 0, AIR_CTOL = 1, ///< Conventional Take Off and Landing, i.e. planes AIR_FAST = 2 @@ -125,7 +125,7 @@ /** * EngineInfo.misc_flags is a bitmask, with the following values */ -enum { +enum EngineMiscFlags { 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 @@ -135,17 +135,15 @@ /** * Engine.flags is a bitmask, with the following values. */ -enum { +enum EngineFlags { 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. ENGINE_OFFER_WINDOW_OPEN = 4, ///< The exclusive offer window is currently open for a company. }; -enum { - NUM_VEHICLE_TYPES = 6, - MAX_LENGTH_ENGINE_NAME_BYTES = 31, ///< The maximum length of an engine name in bytes including '\0' - MAX_LENGTH_ENGINE_NAME_PIXELS = 160, ///< The maximum length of an engine name in pixels -}; +static const uint NUM_VEHICLE_TYPES = 6; +static const uint MAX_LENGTH_ENGINE_NAME_BYTES = 31; ///< The maximum length of an engine name in bytes including '\0' +static const uint MAX_LENGTH_ENGINE_NAME_PIXELS = 160; ///< The maximum length of an engine name in pixels static const EngineID INVALID_ENGINE = 0xFFFF;
--- a/src/fios.h +++ b/src/fios.h @@ -15,7 +15,7 @@ #include "strings_type.h" #include "core/smallvec_type.hpp" -enum { +enum FileSlots { /** * Slot used for the GRF scanning and such. This slot cannot be reused * as it will otherwise cause issues when pressing "rescan directories". @@ -80,7 +80,7 @@ char title[255]; ///< internal name of the game }; -enum { +enum SortingBits { SORT_ASCENDING = 0, SORT_DESCENDING = 1, SORT_BY_DATE = 0,
--- a/src/genworld.h +++ b/src/genworld.h @@ -15,16 +15,15 @@ #include "company_type.h" /** Constants related to world generation */ -enum { +enum LandscapeGenerator { /* 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 LG_TERRAGENESIS = 1, ///< TerraGenesis Perlin landscape generator - - GENERATE_NEW_SEED = UINT_MAX, ///< Create a new random seed +}; - GENWORLD_REDRAW_TIMEOUT = 200, ///< Timeout between redraws -}; +static const uint GENERATE_NEW_SEED = UINT_MAX; ///< Create a new random seed +static const uint GENWORLD_REDRAW_TIMEOUT = 200; ///< Timeout between redraws /** Modes for GenerateWorld */ enum GenWorldMode {
--- a/src/gfx_func.h +++ b/src/gfx_func.h @@ -82,10 +82,8 @@ void GameSizeChanged(); void UndrawMouseCursor(); -enum { - /* Size of the buffer used for drawing strings. */ - DRAW_STRING_BUFFER = 2048, -}; +/** Size of the buffer used for drawing strings. */ +static const int DRAW_STRING_BUFFER = 2048; void RedrawScreenRect(int left, int top, int right, int bottom); void GfxScroll(int left, int top, int width, int height, int xo, int yo);
--- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -175,14 +175,12 @@ struct BaseGraphWindow : Window { protected: - enum { - GRAPH_MAX_DATASETS = 32, - GRAPH_AXIS_LINE_COLOUR = 215, - GRAPH_NUM_MONTHS = 24, ///< Number of months displayed in the graph. + static const int GRAPH_MAX_DATASETS = 32; + static const int GRAPH_AXIS_LINE_COLOUR = 215; + static const int GRAPH_NUM_MONTHS = 24; ///< Number of months displayed in the graph. - MIN_GRAPH_NUM_LINES_Y = 9, ///< Minimal number of horizontal lines to draw. - MIN_GRID_PIXEL_SIZE = 20, ///< Minimum distance between graph lines. - }; + static const int MIN_GRAPH_NUM_LINES_Y = 9; ///< Minimal number of horizontal lines to draw. + static const int MIN_GRID_PIXEL_SIZE = 20; ///< Minimum distance between graph lines. uint excluded_data; ///< bitmask of the datasets that shouldn't be displayed. byte num_dataset;
--- a/src/group_type.h +++ b/src/group_type.h @@ -14,14 +14,12 @@ typedef uint16 GroupID; -enum { - ALL_GROUP = 0xFFFD, - DEFAULT_GROUP = 0xFFFE, ///< ungrouped vehicles are in this group. - INVALID_GROUP = 0xFFFF, +static const GroupID ALL_GROUP = 0xFFFD; +static const GroupID DEFAULT_GROUP = 0xFFFE; ///< ungrouped vehicles are in this group. +static const GroupID INVALID_GROUP = 0xFFFF; - MAX_LENGTH_GROUP_NAME_BYTES = 31, ///< The maximum length of a group name in bytes including '\0' - MAX_LENGTH_GROUP_NAME_PIXELS = 150, ///< The maximum length of a group name in pixels -}; +static const uint MAX_LENGTH_GROUP_NAME_BYTES = 31; ///< The maximum length of a group name in bytes including '\0' +static const uint MAX_LENGTH_GROUP_NAME_PIXELS = 150; ///< The maximum length of a group name in pixels struct Group;
--- 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 { +enum HeightmapRotation { HM_COUNTER_CLOCKWISE, ///< Rotate the map counter clockwise 45 degrees HM_CLOCKWISE, ///< Rotate the map clockwise 45 degrees };
--- a/src/house.h +++ b/src/house.h @@ -22,16 +22,14 @@ * construction. */ static const byte TOWN_HOUSE_COMPLETED = 3; -enum { - HOUSE_NO_CLASS = 0, - NEW_HOUSE_OFFSET = 110, - HOUSE_MAX = 512, - INVALID_HOUSE_ID = 0xFFFF, +static const uint HOUSE_NO_CLASS = 0; +static const HouseID NEW_HOUSE_OFFSET = 110; +static const HouseID HOUSE_MAX = 512; +static const HouseID INVALID_HOUSE_ID = 0xFFFF; - /* There can only be as many classes as there are new houses, plus one for - * NO_CLASS, as the original houses don't have classes. */ - HOUSE_CLASS_MAX = HOUSE_MAX - NEW_HOUSE_OFFSET + 1, -}; +/** There can only be as many classes as there are new houses, plus one for + * NO_CLASS, as the original houses don't have classes. */ +static const uint HOUSE_CLASS_MAX = HOUSE_MAX - NEW_HOUSE_OFFSET + 1; enum BuildingFlags { TILE_NO_FLAG = 0,
--- a/src/industry_map.h +++ b/src/industry_map.h @@ -21,7 +21,7 @@ * They all are pointing toward array _industry_draw_tile_data, in table/industry_land.h * How to calculate the correct position ? GFXid << 2 | IndustryStage (0 to 3) */ -enum { +enum IndustryGraphics { GFX_COAL_MINE_TOWER_NOT_ANIMATED = 0, GFX_COAL_MINE_TOWER_ANIMATED = 1, GFX_POWERPLANT_CHIMNEY = 8,
--- a/src/industry_type.h +++ b/src/industry_type.h @@ -22,15 +22,15 @@ static const IndustryID INVALID_INDUSTRY = 0xFFFF; -enum { - NEW_INDUSTRYOFFSET = 37, ///< original number of industries - NUM_INDUSTRYTYPES = 64, ///< total number of industries, new and old - INDUSTRYTILE_NOANIM = 0xFF, ///< flag to mark industry tiles as having no animation - NEW_INDUSTRYTILEOFFSET = 175, ///< original number of tiles - INVALID_INDUSTRYTYPE = NUM_INDUSTRYTYPES, ///< one above amount is considered invalid - NUM_INDUSTRYTILES = 512, ///< total number of industry tiles, new and old - INVALID_INDUSTRYTILE = NUM_INDUSTRYTILES, ///< one above amount is considered invalid - INDUSTRY_COMPLETED = 3, ///< final stage of industry construction. -}; +static const IndustryType NEW_INDUSTRYOFFSET = 37; ///< original number of industries +static const IndustryType NUM_INDUSTRYTYPES = 64; ///< total number of industries, new and old +static const IndustryType INVALID_INDUSTRYTYPE = NUM_INDUSTRYTYPES; ///< one above amount is considered invalid + +static const IndustryGfx INDUSTRYTILE_NOANIM = 0xFF; ///< flag to mark industry tiles as having no animation +static const IndustryGfx NEW_INDUSTRYTILEOFFSET = 175; ///< original number of tiles +static const IndustryGfx NUM_INDUSTRYTILES = 512; ///< total number of industry tiles, new and old +static const IndustryGfx INVALID_INDUSTRYTILE = NUM_INDUSTRYTILES; ///< one above amount is considered invalid + +static const int INDUSTRY_COMPLETED = 3; ///< final stage of industry construction. #endif /* INDUSTRY_TYPE_H */
--- a/src/industrytype.h +++ b/src/industrytype.h @@ -21,7 +21,7 @@ #include "cargo_type.h" #include "newgrf_commons.h" -enum { +enum IndustryCleanupType { CLEAN_RANDOMSOUNDS, ///< Free the dynamically allocated sounds table CLEAN_TILELAYOUT, ///< Free the dynamically allocated tile layout structure };
--- a/src/landscape.h +++ b/src/landscape.h @@ -15,10 +15,8 @@ #include "core/geometry_type.hpp" #include "tile_cmd.h" -enum { - SNOW_LINE_MONTHS = 12, ///< Number of months in the snow line table. - SNOW_LINE_DAYS = 32, ///< Number of days in each month in the snow line table. -}; +static const uint SNOW_LINE_MONTHS = 12; ///< Number of months in the snow line table. +static const uint SNOW_LINE_DAYS = 32; ///< Number of days in each month in the snow line table. /** Structure describing the height of the snow line each day of the year * @ingroup SnowLineGroup */
--- a/src/map_type.h +++ b/src/map_type.h @@ -58,12 +58,10 @@ }; /** Minimal and maximal map width and height */ -enum { - MIN_MAP_SIZE_BITS = 6, ///< Minimal size of map is equal to 2 ^ MIN_MAP_SIZE_BITS - MAX_MAP_SIZE_BITS = 11, ///< Maximal size of map is equal to 2 ^ MAX_MAP_SIZE_BITS - MIN_MAP_SIZE = 1 << MIN_MAP_SIZE_BITS, ///< Minimal map size = 64 - MAX_MAP_SIZE = 1 << MAX_MAP_SIZE_BITS, ///< Maximal map size = 2048 -}; +static const uint MIN_MAP_SIZE_BITS = 6; ///< Minimal size of map is equal to 2 ^ MIN_MAP_SIZE_BITS +static const uint MAX_MAP_SIZE_BITS = 11; ///< Maximal size of map is equal to 2 ^ MAX_MAP_SIZE_BITS +static const uint MIN_MAP_SIZE = 1 << MIN_MAP_SIZE_BITS; ///< Minimal map size = 64 +static const uint MAX_MAP_SIZE = 1 << MAX_MAP_SIZE_BITS; ///< Maximal map size = 2048 /** * Approximation of the length of a straight track, relative to a diagonal
--- a/src/newgrf.h +++ b/src/newgrf.h @@ -127,7 +127,7 @@ RailType railtype_map[RAILTYPE_END]; int traininfo_vehicle_pitch; ///< Vertical offset for draing train images in depot GUI and vehicle details - int traininfo_vehicle_width; ///< Width (in pixels) of a 8/8 train vehicle in depot GUI and vehicle details + uint traininfo_vehicle_width; ///< Width (in pixels) of a 8/8 train vehicle in depot GUI and vehicle details uint32 grf_features; ///< Bitset of GrfSpecFeature the grf uses PriceMultipliers price_base_multipliers; ///< Price base multipliers as set by the grf.
--- a/src/newgrf_callbacks.h +++ b/src/newgrf_callbacks.h @@ -341,9 +341,7 @@ /** * Different values for Callback result evaluations */ -enum { - CALLBACK_FAILED = 0xFFFF, ///< Result of a failed callback. - CALLBACK_HOUSEPRODCARGO_END = 0x20FF, ///< Sentinel indicating that the loop for CBID_HOUSE_PRODUCE_CARGO has ended -}; +static const uint CALLBACK_FAILED = 0xFFFF; ///< Result of a failed callback. +static const uint CALLBACK_HOUSEPRODCARGO_END = 0x20FF; ///< Sentinel indicating that the loop for CBID_HOUSE_PRODUCE_CARGO has ended #endif /* NEWGRF_CALLBACKS_H */
--- a/src/newgrf_engine.h +++ b/src/newgrf_engine.h @@ -19,11 +19,9 @@ #include "engine_type.h" #include "gfx_type.h" -enum { - TRAININFO_DEFAULT_VEHICLE_WIDTH = 29, - ROADVEHINFO_DEFAULT_VEHICLE_WIDTH = 28, - VEHICLEINFO_FULL_VEHICLE_WIDTH = 32, -}; +static const uint TRAININFO_DEFAULT_VEHICLE_WIDTH = 29; +static const uint ROADVEHINFO_DEFAULT_VEHICLE_WIDTH = 28; +static const uint VEHICLEINFO_FULL_VEHICLE_WIDTH = 32; void SetWagonOverrideSprites(EngineID engine, CargoID cargo, const struct SpriteGroup *group, EngineID *train_id, uint trains); const SpriteGroup *GetWagonOverrideSpriteSet(EngineID engine, CargoID cargo, EngineID overriding_engine);
--- a/src/openttd.h +++ b/src/openttd.h @@ -36,7 +36,7 @@ }; /* Display Options */ -enum { +enum DisplayOptions { DO_SHOW_TOWN_NAMES = 0, DO_SHOW_STATION_NAMES = 1, DO_SHOW_SIGNS = 2,
--- a/src/order_type.h +++ b/src/order_type.h @@ -163,7 +163,7 @@ /* Possible clone options */ -enum { +enum CloneOptions { CO_SHARE = 0, CO_COPY = 1, CO_UNSHARE = 2
--- a/src/pathfinder/npf/aystar.h +++ b/src/pathfinder/npf/aystar.h @@ -23,7 +23,7 @@ #include "../../track_type.h" //#define AYSTAR_DEBUG -enum { +enum AystarStatus { AYSTAR_FOUND_END_NODE, AYSTAR_EMPTY_OPENLIST, AYSTAR_STILL_BUSY, @@ -32,9 +32,7 @@ AYSTAR_DONE }; -enum { - AYSTAR_INVALID_NODE = -1, -}; +static const int AYSTAR_INVALID_NODE = -1; struct AyStarNode { TileIndex tile;
--- a/src/roadveh.h +++ b/src/roadveh.h @@ -55,24 +55,22 @@ }; /** State information about the Road Vehicle controller */ -enum { - RDE_NEXT_TILE = 0x80, ///< We should enter the next tile - RDE_TURNED = 0x40, ///< We just finished turning +static const uint RDE_NEXT_TILE = 0x80; ///< We should enter the next tile +static const uint RDE_TURNED = 0x40; ///< We just finished turning - /* Start frames for when a vehicle enters a tile/changes its state. - * The start frame is different for vehicles that turned around or - * are leaving the depot as the do not start at the edge of the tile. - * For trams there are a few different start frames as there are two - * places where trams can turn. */ - RVC_DEFAULT_START_FRAME = 0, - RVC_TURN_AROUND_START_FRAME = 1, - RVC_DEPOT_START_FRAME = 6, - RVC_START_FRAME_AFTER_LONG_TRAM = 21, - RVC_TURN_AROUND_START_FRAME_SHORT_TRAM = 16, - /* Stop frame for a vehicle in a drive-through stop */ - RVC_DRIVE_THROUGH_STOP_FRAME = 11, - RVC_DEPOT_STOP_FRAME = 11, -}; +/* Start frames for when a vehicle enters a tile/changes its state. + * The start frame is different for vehicles that turned around or + * are leaving the depot as the do not start at the edge of the tile. + * For trams there are a few different start frames as there are two + * places where trams can turn. */ +static const uint RVC_DEFAULT_START_FRAME = 0; +static const uint RVC_TURN_AROUND_START_FRAME = 1; +static const uint RVC_DEPOT_START_FRAME = 6; +static const uint RVC_START_FRAME_AFTER_LONG_TRAM = 21; +static const uint RVC_TURN_AROUND_START_FRAME_SHORT_TRAM = 16; +/* Stop frame for a vehicle in a drive-through stop */ +static const uint RVC_DRIVE_THROUGH_STOP_FRAME = 11; +static const uint RVC_DEPOT_STOP_FRAME = 11; enum RoadVehicleSubType { RVST_FRONT,
--- a/src/saveload/map_sl.cpp +++ b/src/saveload/map_sl.cpp @@ -38,9 +38,7 @@ AllocateMap(_map_dim_x, _map_dim_y); } -enum { - MAP_SL_BUF_SIZE = 4096 -}; +static const uint MAP_SL_BUF_SIZE = 4096; static void Load_MAPT() {
--- a/src/saveload/oldloader.cpp +++ b/src/saveload/oldloader.cpp @@ -22,10 +22,8 @@ #include "saveload_internal.h" #include "oldloader.h" -enum { - TTO_HEADER_SIZE = 41, - TTD_HEADER_SIZE = 49, -}; +static const int TTO_HEADER_SIZE = 41; +static const int TTD_HEADER_SIZE = 49; uint32 _bump_assert_value;
--- a/src/saveload/oldloader.h +++ b/src/saveload/oldloader.h @@ -15,10 +15,8 @@ #include "saveload.h" #include "../tile_type.h" -enum { - BUFFER_SIZE = 4096, - OLD_MAP_SIZE = 256 * 256, -}; +static const uint BUFFER_SIZE = 4096; +static const uint OLD_MAP_SIZE = 256 * 256; struct LoadgameState { FILE *file;
--- a/src/saveload/saveload.h +++ b/src/saveload/saveload.h @@ -81,11 +81,7 @@ #define SL_MAX_VERSION 255 -enum { - INC_VEHICLE_COMMON = 0, -}; - -enum { +enum ChunkType { CH_RIFF = 0, CH_ARRAY = 1, CH_SPARSE_ARRAY = 2,
--- a/src/signs_type.h +++ b/src/signs_type.h @@ -15,11 +15,9 @@ typedef uint16 SignID; struct Sign; -enum { - INVALID_SIGN = 0xFFFF, +static const SignID INVALID_SIGN = 0xFFFF; - MAX_LENGTH_SIGN_NAME_BYTES = 31, ///< The maximum length of a sign name in bytes including '\0' - MAX_LENGTH_SIGN_NAME_PIXELS = 255, ///< The maximum length of a sign name in pixels -}; +static const uint MAX_LENGTH_SIGN_NAME_BYTES = 31; ///< The maximum length of a sign name in bytes including '\0' +static const uint MAX_LENGTH_SIGN_NAME_PIXELS = 255; ///< The maximum length of a sign name in pixels #endif /* SIGNS_TYPE_H */
--- a/src/station_map.h +++ b/src/station_map.h @@ -33,10 +33,8 @@ } -enum { - GFX_DOCK_BASE_WATER_PART = 4, - GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET = 4, -}; +static const int GFX_DOCK_BASE_WATER_PART = 4; +static const int GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET = 4; /** * Get the station type of this tile
--- a/src/station_type.h +++ b/src/station_type.h @@ -86,10 +86,8 @@ MAX_CATCHMENT = 10, ///< Maximum catchment for airports with "modified catchment" enabled }; -enum { - MAX_LENGTH_STATION_NAME_BYTES = 31, ///< The maximum length of a station name in bytes including '\0' - MAX_LENGTH_STATION_NAME_PIXELS = 180, ///< The maximum length of a station name in pixels -}; +static const uint MAX_LENGTH_STATION_NAME_BYTES = 31; ///< The maximum length of a station name in bytes including '\0' +static const uint MAX_LENGTH_STATION_NAME_PIXELS = 180; ///< The maximum length of a station name in pixels /** List of stations */ typedef SmallVector<Station *, 2> StationList;
--- a/src/strings_type.h +++ b/src/strings_type.h @@ -16,12 +16,9 @@ * Numeric value that represents a string, independent of the selected language. */ typedef uint16 StringID; -static const StringID INVALID_STRING_ID = 0xFFFF; ///< Constant representing an invalid string -static const int MAX_CHAR_LENGTH = 4; ///< Max. length of UTF-8 encoded unicode character - -enum { - MAX_LANG = 64, ///< Maximal number of languages supported by the game -}; +static const StringID INVALID_STRING_ID = 0xFFFF; ///< Constant representing an invalid string +static const int MAX_CHAR_LENGTH = 4; ///< Max. length of UTF-8 encoded unicode character +static const uint MAX_LANG = 64; ///< Maximum number of languages supported by the game /** Directions a text can go to */ enum TextDirection {
--- a/src/subsidy.cpp +++ b/src/subsidy.cpp @@ -205,7 +205,7 @@ if (i == NULL) return NULL; CargoID cargo; - int trans, total; + uint trans, total; /* Randomize cargo type */ if (i->produced_cargo[1] != CT_INVALID && HasBit(Random(), 0)) {
--- a/src/subsidy_base.h +++ b/src/subsidy_base.h @@ -53,14 +53,12 @@ }; /** Constants related to subsidies */ -enum { - SUBSIDY_OFFER_MONTHS = 12, ///< Duration of subsidy offer - SUBSIDY_CONTRACT_MONTHS = 12, ///< Duration of subsidy after awarding - SUBSIDY_PAX_MIN_POPULATION = 400, ///< Min. population of towns for subsidised pax route - SUBSIDY_CARGO_MIN_POPULATION = 900, ///< Min. population of destination town for cargo route - SUBSIDY_MAX_PCT_TRANSPORTED = 42, ///< Subsidy will be created only for towns/industries with less % transported - SUBSIDY_MAX_DISTANCE = 70, ///< Max. length of subsidised route (DistanceManhattan) -}; +static const uint SUBSIDY_OFFER_MONTHS = 12; ///< Duration of subsidy offer +static const uint SUBSIDY_CONTRACT_MONTHS = 12; ///< Duration of subsidy after awarding +static const uint SUBSIDY_PAX_MIN_POPULATION = 400; ///< Min. population of towns for subsidised pax route +static const uint SUBSIDY_CARGO_MIN_POPULATION = 900; ///< Min. population of destination town for cargo route +static const uint SUBSIDY_MAX_PCT_TRANSPORTED = 42; ///< Subsidy will be created only for towns/industries with less % transported +static const uint SUBSIDY_MAX_DISTANCE = 70; ///< Max. length of subsidised route (DistanceManhattan) #define FOR_ALL_SUBSIDIES_FROM(var, start) FOR_ALL_ITEMS_FROM(Subsidy, subsidy_index, var, start) #define FOR_ALL_SUBSIDIES(var) FOR_ALL_SUBSIDIES_FROM(var, 0)
--- a/src/table/build_industry.h +++ b/src/table/build_industry.h @@ -1098,7 +1098,7 @@ /** Array with... hem... a sound of toyland */ static const uint8 _plastic_mine_sounds[] = { SND_33_PLASTIC_MINE }; -enum { +enum IndustryTypes { IT_COAL_MINE = 0, IT_POWER_STATION = 1, IT_SAWMILL = 2,
--- a/src/table/elrail_data.h +++ b/src/table/elrail_data.h @@ -33,9 +33,7 @@ TS_END }; -enum { - NUM_TRACKS_AT_PCP = 6 -}; +static const uint NUM_TRACKS_AT_PCP = 6; /** Which PPPs are possible at all on a given PCP */ static const byte AllowedPPPonPCP[DIAGDIR_END] = { @@ -316,12 +314,10 @@ int8 z_offset; }; -enum { - /** Distance between wire and rail */ - ELRAIL_ELEVATION = 10, - /** Wires that a draw one level higher than the north corner. */ - ELRAIL_ELEVRAISE = ELRAIL_ELEVATION + TILE_HEIGHT -}; +/** Distance between wire and rail */ +static const uint ELRAIL_ELEVATION = 10; +/** Wires that a draw one level higher than the north corner. */ +static const uint ELRAIL_ELEVRAISE = ELRAIL_ELEVATION + TILE_HEIGHT; static const SortableSpriteStruct CatenarySpriteData[] = { /* X direction
--- a/src/table/landscape_sprite.h +++ b/src/table/landscape_sprite.h @@ -9,9 +9,7 @@ /** @file landscape_sprite.h Offsets of sprites to replace for non-temperate landscapes. */ -enum { - END = 0xFFFF -}; +static const SpriteID END = 0xFFFF; static const SpriteID _landscape_spriteindexes_1[] = { 0xF67, 0xF9F,
--- a/src/table/palettes.h +++ b/src/table/palettes.h @@ -154,13 +154,11 @@ #define GET_PALETTE(x) _palettes[x] /** Description of the length of the palette cycle animations */ -enum { - EPV_CYCLES_DARK_WATER = 5, ///< length of the dark blue water animation - EPV_CYCLES_LIGHTHOUSE = 4, ///< length of the lighthouse/stadium animation - EPV_CYCLES_OIL_REFINERY = 7, ///< length of the oil refinery's fire animation - EPV_CYCLES_FIZZY_DRINK = 5, ///< length of the fizzy drinks animation - EPV_CYCLES_GLITTER_WATER = 15, ///< length of the glittery water animation -}; +static const uint EPV_CYCLES_DARK_WATER = 5; ///< length of the dark blue water animation +static const uint EPV_CYCLES_LIGHTHOUSE = 4; ///< length of the lighthouse/stadium animation +static const uint EPV_CYCLES_OIL_REFINERY = 7; ///< length of the oil refinery's fire animation +static const uint EPV_CYCLES_FIZZY_DRINK = 5; ///< length of the fizzy drinks animation +static const uint EPV_CYCLES_GLITTER_WATER = 15; ///< length of the glittery water animation /** Description of tables for the palette animation */ struct ExtraPaletteValues {
--- a/src/table/unicode.h +++ b/src/table/unicode.h @@ -14,10 +14,8 @@ byte key; ///< Character index of sprite }; -enum { - CLRA = 0, ///< Identifier to clear all glyphs at this codepoint - CLRL = 1, ///< Identifier to clear glyphs for large font at this codepoint -}; +static const byte CLRA = 0; ///< Identifier to clear all glyphs at this codepoint +static const byte CLRL = 1; ///< Identifier to clear glyphs for large font at this codepoint /* Default unicode mapping table for sprite based glyphs. * This table allows us use unicode characters even though the glyphs don't
--- a/src/town.h +++ b/src/town.h @@ -173,7 +173,7 @@ * per town, NO MATTER the population of it. * And there are 5 more bits available on flags... */ -enum { +enum TownFlags { TOWN_IS_FUNDED = 0, ///< Town has received some funds for TOWN_HAS_CHURCH = 1, ///< There can be only one church by town. TOWN_HAS_STADIUM = 2 ///< There can be only one stadium by town.
--- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -312,9 +312,7 @@ Town *town; ///< Town displayed by the window. public: - enum { - TVW_HEIGHT_NORMAL = 150, - }; + static const int TVW_HEIGHT_NORMAL = 150; TownViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window() {
--- a/src/town_type.h +++ b/src/town_type.h @@ -28,7 +28,7 @@ }; template <> struct EnumPropsT<TownSize> : MakeEnumPropsT<TownSize, byte, TSZ_SMALL, TSZ_END, TSZ_END, 2> {}; -enum { +enum Ratings { /* These refer to the maximums, so Appalling is -1000 to -400 * MAXIMUM RATINGS BOUNDARIES */ RATING_MINIMUM = -1000, @@ -105,9 +105,7 @@ /** It needs to be 8bits, because we save and load it as such */ typedef SimpleTinyEnumT<TownFounding, byte> TownFoundingByte; -enum { - MAX_LENGTH_TOWN_NAME_BYTES = 31, ///< The maximum length of a town name in bytes including '\0' - MAX_LENGTH_TOWN_NAME_PIXELS = 130, ///< The maximum length of a town name in pixels -}; +static const uint MAX_LENGTH_TOWN_NAME_BYTES = 31; ///< The maximum length of a town name in bytes including '\0' +static const uint MAX_LENGTH_TOWN_NAME_PIXELS = 130; ///< The maximum length of a town name in pixels #endif /* TOWN_TYPE_H */
--- a/src/tree_map.h +++ b/src/tree_map.h @@ -40,13 +40,11 @@ * 5 entries instead of 4 (as there are only 4 landscape types) as the sub tropic landscape * got two types of area, one for normal trees and one only for cacti. */ -enum { - TREE_COUNT_TEMPERATE = TREE_SUB_ARCTIC - TREE_TEMPERATE, ///< number of treetypes on a temperate map - TREE_COUNT_SUB_ARCTIC = TREE_RAINFOREST - TREE_SUB_ARCTIC, ///< number of treetypes on a sub arctic map - TREE_COUNT_RAINFOREST = TREE_CACTUS - TREE_RAINFOREST, ///< number of treetypes for the 'rainforrest part' of a sub-tropic map - TREE_COUNT_SUB_TROPICAL = TREE_TOYLAND - TREE_SUB_TROPICAL, ///< number of treetypes for the 'sub-tropic part' of a sub-tropic map - TREE_COUNT_TOYLAND = 9 ///< number of treetypes on a toyland map -}; +static const uint TREE_COUNT_TEMPERATE = TREE_SUB_ARCTIC - TREE_TEMPERATE; ///< number of treetypes on a temperate map +static const uint TREE_COUNT_SUB_ARCTIC = TREE_RAINFOREST - TREE_SUB_ARCTIC; ///< number of treetypes on a sub arctic map +static const uint TREE_COUNT_RAINFOREST = TREE_CACTUS - TREE_RAINFOREST; ///< number of treetypes for the 'rainforrest part' of a sub-tropic map +static const uint TREE_COUNT_SUB_TROPICAL = TREE_TOYLAND - TREE_SUB_TROPICAL; ///< number of treetypes for the 'sub-tropic part' of a sub-tropic map +static const uint TREE_COUNT_TOYLAND = 9; ///< number of treetypes on a toyland map /** * Enumeration for ground types of tiles with trees.
--- a/src/vehicle_gui.h +++ b/src/vehicle_gui.h @@ -47,7 +47,7 @@ }; /** Vehicle List Window type flags */ -enum { +enum VehicleListWindowType { VLW_STANDARD = 0 << 8, VLW_SHARED_ORDERS = 1 << 8, VLW_STATION_LIST = 2 << 8,
--- a/src/vehicle_type.h +++ b/src/vehicle_type.h @@ -48,7 +48,7 @@ static const VehicleID INVALID_VEHICLE = 0xFFFF; ///< Constant representing a non-existing vehicle. /** Pathfinding option states */ -enum { +enum VehiclePathFinders { VPF_OPF = 0, ///< The Original PathFinder (only for ships) VPF_NPF = 1, ///< New PathFinder VPF_YAPF = 2, ///< Yet Another PathFinder @@ -64,10 +64,8 @@ DEPOT_COMMAND_MASK = 0xF, }; -enum { - MAX_LENGTH_VEHICLE_NAME_BYTES = 31, ///< The maximum length of a vehicle name in bytes including '\0' - MAX_LENGTH_VEHICLE_NAME_PIXELS = 150, ///< The maximum length of a vehicle name in pixels -}; +static const uint MAX_LENGTH_VEHICLE_NAME_BYTES = 31; ///< The maximum length of a vehicle name in bytes including '\0' +static const uint MAX_LENGTH_VEHICLE_NAME_PIXELS = 150; ///< The maximum length of a vehicle name in pixels /** Vehicle acceleration models. */ enum AccelerationModel {
--- a/src/viewport_type.h +++ b/src/viewport_type.h @@ -63,10 +63,8 @@ * z=6 reserved, currently unused. * z=7 Z separator between bridge/tunnel and the things under/above it. */ -enum { - BB_HEIGHT_UNDER_BRIDGE = 6, ///< Everything that can be built under low bridges, must not exceed this Z height. - BB_Z_SEPARATOR = 7, ///< Separates the bridge/tunnel from the things under/above it. -}; +static const uint BB_HEIGHT_UNDER_BRIDGE = 6; ///< Everything that can be built under low bridges, must not exceed this Z height. +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 {
--- a/src/widget_type.h +++ b/src/widget_type.h @@ -18,9 +18,7 @@ #include "gfx_type.h" #include "window_type.h" -enum { - WIDGET_LIST_END = -1, ///< indicate the end of widgets' list for vararg functions -}; +static const int WIDGET_LIST_END = -1; ///< indicate the end of widgets' list for vararg functions /** Bits of the #WWT_MATRIX widget data. */ enum MatrixWidgetValues {