# HG changeset patch # User smatz # Date 2009-09-20 23:11:01 # Node ID 71e9292610379e5347479cc5850dfec2af7885ed # Parent b99d7bea4dd2ad5aa5fb341e80bd0593f95c8266 (svn r17596) -Codechange: constify some tables diff --git a/src/base_media_base.h b/src/base_media_base.h --- a/src/base_media_base.h +++ b/src/base_media_base.h @@ -45,7 +45,7 @@ struct BaseSet { static const size_t NUM_FILES = Tnum_files; /** Internal names of the files in this set. */ - static const char **file_names; + static const char * const *file_names; const char *name; ///< The name of the base set const char *description; ///< Description of the base set diff --git a/src/callback_table.cpp b/src/callback_table.cpp --- a/src/callback_table.cpp +++ b/src/callback_table.cpp @@ -67,7 +67,7 @@ CommandCallback CcCreateGroup; /* ai/ai_core.cpp */ CommandCallback CcAI; -CommandCallback *_callback_table[] = { +CommandCallback * const _callback_table[] = { /* 0x00 */ NULL, /* 0x01 */ CcBuildAircraft, /* 0x02 */ CcBuildAirport, diff --git a/src/callback_table.h b/src/callback_table.h --- a/src/callback_table.h +++ b/src/callback_table.h @@ -14,7 +14,7 @@ #include "command_type.h" -extern CommandCallback *_callback_table[]; +extern CommandCallback * const _callback_table[]; extern const int _callback_table_count; #endif /* CALLBACK_TABLE_H */ diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp --- a/src/clear_cmd.cpp +++ b/src/clear_cmd.cpp @@ -29,7 +29,7 @@ static CommandCost ClearTile_Clear(TileIndex tile, DoCommandFlag flags) { - static const Money *clear_price_table[] = { + static const Money * const clear_price_table[] = { &_price.clear_grass, &_price.clear_roughland, &_price.clear_rocks, diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -1243,7 +1243,7 @@ DEF_CONSOLE_CMD(ConScreenShot) DEF_CONSOLE_CMD(ConInfoVar) { - static const char *_icon_vartypes[] = {"boolean", "byte", "uint16", "uint32", "int16", "int32", "string"}; + static const char * const _icon_vartypes[] = {"boolean", "byte", "uint16", "uint32", "int16", "int32", "string"}; const IConsoleVar *var; if (argc == 0) { @@ -1587,7 +1587,7 @@ bool NetworkChangeCompanyPassword(byte a /** Resolve a string to a content type. */ static ContentType StringToContentType(const char *str) { - static const char *inv_lookup[] = { "", "base", "newgrf", "ai", "ailib", "scenario", "heightmap" }; + static const char * const inv_lookup[] = { "", "base", "newgrf", "ai", "ailib", "scenario", "heightmap" }; for (uint i = 1 /* there is no type 0 */; i < lengthof(inv_lookup); i++) { if (strcasecmp(str, inv_lookup[i]) == 0) return (ContentType)i; } @@ -1670,9 +1670,9 @@ DEF_CONSOLE_CMD(ConContent) if (strcasecmp(argv[1], "state") == 0) { IConsolePrintF(CC_WHITE, "id, type, state, name"); for (ConstContentIterator iter = _network_content_client.Begin(); iter != _network_content_client.End(); iter++) { - static const char *types[] = { "Base graphics", "NewGRF", "AI", "AI library", "Scenario", "Heightmap" }; - static const char *states[] = { "Not selected", "Selected" , "Dep Selected", "Installed", "Unknown" }; - static ConsoleColour state_to_colour[] = { CC_COMMAND, CC_INFO, CC_INFO, CC_WHITE, CC_ERROR }; + static const char * const types[] = { "Base graphics", "NewGRF", "AI", "AI library", "Scenario", "Heightmap" }; + static const char * const states[] = { "Not selected", "Selected" , "Dep Selected", "Installed", "Unknown" }; + static const ConsoleColour state_to_colour[] = { CC_COMMAND, CC_INFO, CC_INFO, CC_WHITE, CC_ERROR }; const ContentInfo *ci = *iter; IConsolePrintF(state_to_colour[ci->state], "%d, %s, %s, %s", ci->id, types[ci->type - 1], states[ci->state], ci->name); diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -175,7 +175,7 @@ uint _block_sizes[4][2]; /* Array to hold the default resize capacities * First part is the vehicle type, while the last is 0 = x, 1 = y */ -const uint _resize_cap[][2] = { +static const uint _resize_cap[][2] = { /* VEH_TRAIN */ {6, 10 * 29}, /* VEH_ROAD */ {5, 5}, /* VEH_SHIP */ {3, 3}, diff --git a/src/gamelog.cpp b/src/gamelog.cpp --- a/src/gamelog.cpp +++ b/src/gamelog.cpp @@ -139,7 +139,7 @@ static void PrintGrfInfo(char *buf, uint /** Text messages for various logged actions */ -static const char *la_text[] = { +static const char * const la_text[] = { "new game started", "game loaded", "GRF config changed", diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp --- a/src/gfxinit.cpp +++ b/src/gfxinit.cpp @@ -252,11 +252,11 @@ MD5File::ChecksumResult MD5File::CheckMD } /** Names corresponding to the GraphicsFileType */ -const char *_graphics_file_names[] = { "base", "logos", "arctic", "tropical", "toyland", "extra" }; +static const char * const _graphics_file_names[] = { "base", "logos", "arctic", "tropical", "toyland", "extra" }; /** Implementation */ template -/* static */ const char **BaseSet::file_names = _graphics_file_names; +/* static */ const char * const *BaseSet::file_names = _graphics_file_names; extern void UpdateNewGRFConfigPalette(); diff --git a/src/ini.cpp b/src/ini.cpp --- a/src/ini.cpp +++ b/src/ini.cpp @@ -98,7 +98,7 @@ void IniGroup::Clear() this->last_item = &this->item; } -IniFile::IniFile(const char **list_group_names) : group(NULL), comment(NULL), list_group_names(list_group_names) +IniFile::IniFile(const char * const *list_group_names) : group(NULL), comment(NULL), list_group_names(list_group_names) { this->last_group = &this->group; } diff --git a/src/ini_type.h b/src/ini_type.h --- a/src/ini_type.h +++ b/src/ini_type.h @@ -80,17 +80,17 @@ struct IniGroup { /** The complete ini file. */ struct IniFile { - IniGroup *group; ///< the first group in the ini - IniGroup **last_group; ///< the last group in the ini - char *comment; ///< last comment in file - const char **list_group_names; ///< NULL terminated list with group names that are lists + IniGroup *group; ///< the first group in the ini + IniGroup **last_group; ///< the last group in the ini + char *comment; ///< last comment in file + const char * const *list_group_names; ///< NULL terminated list with group names that are lists /** * Construct a new in-memory Ini file representation. * @param list_group_names A NULL terminated list with groups that should be * loaded as lists instead of variables. */ - IniFile(const char **list_group_names = NULL); + IniFile(const char * const *list_group_names = NULL); /** Free everything we loaded. */ ~IniFile(); diff --git a/src/map.cpp b/src/map.cpp --- a/src/map.cpp +++ b/src/map.cpp @@ -282,7 +282,7 @@ bool CircularTileSearch(TileIndex *tile, uint x = TileX(*tile) + w + 1; uint y = TileY(*tile); - uint extent[DIAGDIR_END] = { w, h, w, h }; + const uint extent[DIAGDIR_END] = { w, h, w, h }; for (uint n = 0; n < radius; n++) { for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) { diff --git a/src/misc/dbg_helpers.cpp b/src/misc/dbg_helpers.cpp --- a/src/misc/dbg_helpers.cpp +++ b/src/misc/dbg_helpers.cpp @@ -14,7 +14,7 @@ #include "dbg_helpers.h" /** Trackdir & TrackdirBits short names. */ -static const char *trackdir_names[] = { +static const char * const trackdir_names[] = { "NE", "SE", "UE", "LE", "LS", "RS", "rne", "rse", "SW", "NW", "UW", "LW", "LN", "RN", "rsw", "rnw", }; @@ -37,7 +37,7 @@ CStrA ValueStr(TrackdirBits td_bits) /** DiagDirection short names. */ -static const char *diagdir_names[] = { +static const char * const diagdir_names[] = { "NE", "SE", "SW", "NW", }; @@ -51,7 +51,7 @@ CStrA ValueStr(DiagDirection dd) /** SignalType short names. */ -static const char *signal_type_names[] = { +static const char * const signal_type_names[] = { "NORMAL", "ENTRY", "EXIT", "COMBO", "PBS", "NOENTRY", }; diff --git a/src/misc/dbg_helpers.h b/src/misc/dbg_helpers.h --- a/src/misc/dbg_helpers.h +++ b/src/misc/dbg_helpers.h @@ -34,7 +34,7 @@ template struct A * or t_unk when index is out of bounds. */ template -inline typename ArrayT::item_t ItemAtT(E idx, T &t, typename ArrayT::item_t t_unk) +inline typename ArrayT::item_t ItemAtT(E idx, const T &t, typename ArrayT::item_t t_unk) { if ((size_t)idx >= ArrayT::length) { return t_unk; @@ -48,7 +48,7 @@ inline typename ArrayT::item_t ItemAt * or t_unk when index is out of bounds. */ template -inline typename ArrayT::item_t ItemAtT(E idx, T &t, typename ArrayT::item_t t_unk, E idx_inv, typename ArrayT::item_t t_inv) +inline typename ArrayT::item_t ItemAtT(E idx, const T &t, typename ArrayT::item_t t_unk, E idx_inv, typename ArrayT::item_t t_inv) { if ((size_t)idx < ArrayT::length) { return t[idx]; diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -348,7 +348,7 @@ static const WindowDesc _about_desc( NULL, _nested_about_widgets, lengthof(_nested_about_widgets) ); -static const char *_credits[] = { +static const char * const _credits[] = { "Original design by Chris Sawyer", "Original graphics by Simon Foster", "", diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -824,7 +824,7 @@ static const Widget _network_game_window * display_flags and/or left/right side for the overlapping widgets * NGWW_CLIENTS through NGWW_YEARS. */ -NWidgetPart _nested_network_game_widgets[] = { +static const NWidgetPart _nested_network_game_widgets[] = { /* TOP */ NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE, NGWW_CLOSE), diff --git a/src/newgrf.cpp b/src/newgrf.cpp --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -5644,7 +5644,7 @@ static const CargoLabel _default_refitma 'TOYS', 'BATT', 'SWET', 'TOFF', 'COLA', 'CTCD', 'BUBL', 'PLST', 'FZDR', 0 }; -static const CargoLabel *_default_refitmasks[] = { +static const CargoLabel * const _default_refitmasks[] = { _default_refitmasks_rail, _default_refitmasks_road, _default_refitmasks_ships, diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -53,7 +53,7 @@ void ResetRailTypes() memcpy(_railtypes, _original_railtypes, sizeof(_original_railtypes)); } -const byte _track_sloped_sprites[14] = { +static const byte _track_sloped_sprites[14] = { 14, 15, 22, 13, 0, 21, 17, 12, 23, 0, 18, 20, @@ -2292,7 +2292,7 @@ static void GetTileDesc_Track(TileIndex break; case RAIL_TILE_SIGNALS: { - const StringID signal_type[6][6] = { + static const StringID signal_type[6][6] = { { STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_NORMAL_SIGNALS, STR_LAI_RAIL_DESCRIPTION_TRACK_WITH_NORMAL_PRESIGNALS, @@ -2378,7 +2378,7 @@ static void ChangeTileOwner_Track(TileIn static const byte _fractcoords_behind[4] = { 0x8F, 0x8, 0x80, 0xF8 }; static const byte _fractcoords_enter[4] = { 0x8A, 0x48, 0x84, 0xA8 }; -static const signed char _deltacoord_leaveoffset[8] = { +static const int8 _deltacoord_leaveoffset[8] = { -1, 0, 1, 0, /* x */ 0, 1, 0, -1 /* y */ }; diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -1309,7 +1309,7 @@ static Trackdir FollowPreviousRoadVehicl * going over the trackdirs used for turning 90 degrees, i.e. * TRACKDIR_{UPPER,RIGHT,LOWER,LEFT}_{N,E,S,W}. */ - Trackdir reversed_turn_lookup[2][DIAGDIR_END] = { + static const Trackdir reversed_turn_lookup[2][DIAGDIR_END] = { { TRACKDIR_UPPER_W, TRACKDIR_RIGHT_N, TRACKDIR_LEFT_N, TRACKDIR_UPPER_E }, { TRACKDIR_RIGHT_S, TRACKDIR_LOWER_W, TRACKDIR_LOWER_E, TRACKDIR_LEFT_S }}; dir = reversed_turn_lookup[prev->tile < tile ? 0 : 1][ReverseDiagDir(entry_dir)]; diff --git a/src/saveload/gamelog_sl.cpp b/src/saveload/gamelog_sl.cpp --- a/src/saveload/gamelog_sl.cpp +++ b/src/saveload/gamelog_sl.cpp @@ -87,7 +87,7 @@ static const SaveLoad _glog_emergency_de SLE_END() }; -static const SaveLoad *_glog_desc[] = { +static const SaveLoad * const _glog_desc[] = { _glog_mode_desc, _glog_revision_desc, _glog_oldver_desc, diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp --- a/src/saveload/vehicle_sl.cpp +++ b/src/saveload/vehicle_sl.cpp @@ -669,7 +669,7 @@ const SaveLoad *GetVehicleDescription(Ve }; - static const SaveLoad *_veh_descs[] = { + static const SaveLoad * const _veh_descs[] = { _train_desc, _roadveh_desc, _ship_desc, diff --git a/src/settings.cpp b/src/settings.cpp --- a/src/settings.cpp +++ b/src/settings.cpp @@ -86,7 +86,7 @@ static bool IsSignedVarMemType(VarType v /** * Groups in openttd.cfg that are actually lists. */ -static const char *_list_group_names[] = { +static const char * const _list_group_names[] = { "bans", "newgrf", "servers", @@ -1256,7 +1256,7 @@ static void SaveVersionInConfig(IniFile char version[9]; snprintf(version, lengthof(version), "%08X", _openttd_newgrf_version); - const char *versions[][2] = { + const char * const versions[][2] = { { "version_string", _openttd_revision }, { "version_number", version } }; diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -519,7 +519,7 @@ static const uint32 _smallmap_mask_right /* each tile has 4 x pixels and 1 y pixel */ -static GetSmallMapPixels *_smallmap_draw_procs[] = { +static GetSmallMapPixels * const _smallmap_draw_procs[] = { GetSmallMapContoursPixels, GetSmallMapVehiclesPixels, GetSmallMapIndustriesPixels, diff --git a/src/sound.cpp b/src/sound.cpp --- a/src/sound.cpp +++ b/src/sound.cpp @@ -271,11 +271,11 @@ void SndPlayFx(SoundID sound) INSTANTIATE_BASE_MEDIA_METHODS(BaseMedia, SoundsSet) /** Names corresponding to the sound set's files */ -const char *_sound_file_names[] = { "samples" }; +static const char * const _sound_file_names[] = { "samples" }; template -/* static */ const char **BaseSet::file_names = _sound_file_names; +/* static */ const char * const *BaseSet::file_names = _sound_file_names; template /* static */ const char *BaseMedia::GetExtension() diff --git a/src/spritecache.cpp b/src/spritecache.cpp --- a/src/spritecache.cpp +++ b/src/spritecache.cpp @@ -498,7 +498,7 @@ void *AllocSprite(size_t mem_req) * @note this function will do usererror() in the case the fallback sprite isn't available */ static void *HandleInvalidSpriteRequest(SpriteID sprite, SpriteType requested, SpriteCache *sc) { - static const char *sprite_types[] = { + static const char * const sprite_types[] = { "normal", // ST_NORMAL "map generator", // ST_MAPGEN "character", // ST_FONT diff --git a/src/table/elrail_data.h b/src/table/elrail_data.h --- a/src/table/elrail_data.h +++ b/src/table/elrail_data.h @@ -38,7 +38,7 @@ enum { }; /** Which PPPs are possible at all on a given PCP */ -static byte AllowedPPPonPCP[DIAGDIR_END] = { +static const byte AllowedPPPonPCP[DIAGDIR_END] = { 1 << DIR_N | 1 << DIR_E | 1 << DIR_SE | 1 << DIR_S | 1 << DIR_W | 1 << DIR_NW, 1 << DIR_N | 1 << DIR_NE | 1 << DIR_E | 1 << DIR_S | 1 << DIR_SW | 1 << DIR_W, 1 << DIR_N | 1 << DIR_E | 1 << DIR_SE | 1 << DIR_S | 1 << DIR_W | 1 << DIR_NW, @@ -48,7 +48,7 @@ static byte AllowedPPPonPCP[DIAGDIR_END] /** Which of the PPPs are inside the tile. For the two PPPs on the tile border * the following system is used: if you rotate the PCP so that it is in the * north, the eastern PPP belongs to the tile. */ -static byte OwnedPPPonPCP[DIAGDIR_END] = { +static const byte OwnedPPPonPCP[DIAGDIR_END] = { 1 << DIR_SE | 1 << DIR_S | 1 << DIR_SW | 1 << DIR_W, 1 << DIR_N | 1 << DIR_SW | 1 << DIR_W | 1 << DIR_NW, 1 << DIR_N | 1 << DIR_NE | 1 << DIR_E | 1 << DIR_NW, @@ -70,7 +70,7 @@ static const DiagDirection PCPpositions[ * track, plus the point in extension of the track (to mark end-of-track). PCPs * which are not on either end of the track are fully preferred. * @see PCPpositions */ -static byte PreferredPPPofTrackAtPCP[TRACK_END][DIAGDIR_END] = { +static const byte PreferredPPPofTrackAtPCP[TRACK_END][DIAGDIR_END] = { { // X 1 << DIR_NE | 1 << DIR_SE | 1 << DIR_NW, // NE PCP_NOT_ON_TRACK, // SE @@ -111,7 +111,7 @@ static byte PreferredPPPofTrackAtPCP[TRA /** In case we have a staight line, we place pylon only every two tiles, * so there are certain tiles which we ignore. A straight line is found if * we have exactly two PPPs. */ -static byte IgnoredPCP[NUM_IGNORE_GROUPS][TLG_END][DIAGDIR_END] = { +static const byte IgnoredPCP[NUM_IGNORE_GROUPS][TLG_END][DIAGDIR_END] = { { // Ignore group 1, X and Y tracks { // X even, Y even IGNORE_NONE, @@ -186,7 +186,7 @@ static byte IgnoredPCP[NUM_IGNORE_GROUPS #undef NO_IGNORE /** Which pylons can definately NOT be built */ -static byte DisallowedPPPofTrackAtPCP[TRACK_END][DIAGDIR_END] = { +static const byte DisallowedPPPofTrackAtPCP[TRACK_END][DIAGDIR_END] = { {1 << DIR_SW | 1 << DIR_NE, 0, 1 << DIR_SW | 1 << DIR_NE, 0 }, // X {0, 1 << DIR_NW | 1 << DIR_SE, 0, 1 << DIR_NW | 1 << DIR_SE}, // Y {1 << DIR_W | 1 << DIR_E, 0, 0, 1 << DIR_W | 1 << DIR_E }, // UPPER diff --git a/src/table/pricebase.h b/src/table/pricebase.h --- a/src/table/pricebase.h +++ b/src/table/pricebase.h @@ -9,7 +9,7 @@ /** @file pricebase.h Price Bases */ -static PriceBaseSpec _price_base_specs[NUM_PRICES] = { +static const PriceBaseSpec _price_base_specs[NUM_PRICES] = { { 100, PCAT_NONE }, ///< station_value { 100, PCAT_CONSTRUCTION}, ///< build_rail { 95, PCAT_CONSTRUCTION}, ///< build_road diff --git a/src/table/station_land.h b/src/table/station_land.h --- a/src/table/station_land.h +++ b/src/table/station_land.h @@ -967,7 +967,7 @@ static const DrawTileSprites _station_di #undef TILE_SPRITE_LINE -static const DrawTileSprites *_station_display_datas[] = { +static const DrawTileSprites * const _station_display_datas[] = { _station_display_datas_rail, _station_display_datas_airport, _station_display_datas_truck, diff --git a/src/table/strgen_tables.h b/src/table/strgen_tables.h --- a/src/table/strgen_tables.h +++ b/src/table/strgen_tables.h @@ -184,7 +184,7 @@ static const PluralForm _plural_forms[] * a = array, i.e. list of strings */ /** All pragmas used */ -static const char *_pragmas[][4] = { +static const char * const _pragmas[][4] = { /* name flags default description */ { "name", "0", "", "English name for the language" }, { "ownname", "t", "", "Localised name for the language" }, diff --git a/src/table/unicode.h b/src/table/unicode.h --- a/src/table/unicode.h +++ b/src/table/unicode.h @@ -24,7 +24,7 @@ enum { * exist, or are in the wrong place, in the standard sprite fonts. * This is not used for FreeType rendering */ -static DefaultUnicodeMapping _default_unicode_map[] = { +static const DefaultUnicodeMapping _default_unicode_map[] = { { 0x00A0, 0x20 }, // Non-breaking space / Up arrow { 0x00A4, CLRL }, // Currency sign { 0x00A6, CLRL }, // Broken bar diff --git a/src/table/unmovable_land.h b/src/table/unmovable_land.h --- a/src/table/unmovable_land.h +++ b/src/table/unmovable_land.h @@ -100,10 +100,10 @@ static const DrawTileSprites _unmovable_ #undef TILE_SPRITE_LINE -const UnmovableSpec _original_unmovable[] = { +static const UnmovableSpec _original_unmovable[] = { {STR_LAI_UNMOVABLE_DESCRIPTION_TRANSMITTER, 1, 1}, {STR_LAI_UNMOVABLE_DESCRIPTION_LIGHTHOUSE, 1, 1}, - {STR_TOWN_BUILDING_NAME_STATUE_1, 1, 1}, + {STR_TOWN_BUILDING_NAME_STATUE_1, 1, 1}, {STR_LAI_UNMOVABLE_DESCRIPTION_COMPANY_OWNED_LAND, 10, 2}, {STR_LAI_UNMOVABLE_DESCRIPTION_COMPANY_HEADQUARTERS, 1, 1}, }; diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -935,7 +935,7 @@ static void SplitToolbar(Window *w) 0, 1, 3, 4, 7, 8, 9, 10, 12, 25, 19, 20, 21, 22, 23, 26, 17, 18, 27, }; - static const byte *arrangements[] = { arrange14, arrange15, arrange16, arrange17, arrange18, arrange19 }; + static const byte * const arrangements[] = { arrange14, arrange15, arrange16, arrange17, arrange18, arrange19 }; uint max_icons = max(TBP_TOOLBAR_MINBUTTON, (ToolBarProperties)((w->width + TBP_BUTTONWIDTH / 2) / TBP_BUTTONWIDTH)); diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -322,13 +322,13 @@ CommandCost CmdBuildBridge(TileIndex end if (transport_type == TRANSPORT_WATER && (tileh_start == SLOPE_FLAT || tileh_end == SLOPE_FLAT)) return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION); - TileIndex Heads[] = {tile_start, tile_end}; + const TileIndex heads[] = {tile_start, tile_end}; for (int i = 0; i < 2; i++) { - if (MayHaveBridgeAbove(Heads[i])) { - if (IsBridgeAbove(Heads[i])) { - TileIndex north_head = GetNorthernBridgeEnd(Heads[i]); + if (MayHaveBridgeAbove(heads[i])) { + if (IsBridgeAbove(heads[i])) { + TileIndex north_head = GetNorthernBridgeEnd(heads[i]); - if (direction == GetBridgeAxis(Heads[i])) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST); + if (direction == GetBridgeAxis(heads[i])) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST); if (z_start + TILE_HEIGHT == GetBridgeHeight(north_head)) { return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST); diff --git a/src/yapf/yapf_common.hpp b/src/yapf/yapf_common.hpp --- a/src/yapf/yapf_common.hpp +++ b/src/yapf/yapf_common.hpp @@ -150,8 +150,8 @@ public: * adds it to the actual cost from origin and stores the sum to the Node::m_estimate */ inline bool PfCalcEstimate(Node& n) { - static int dg_dir_to_x_offs[] = {-1, 0, 1, 0}; - static int dg_dir_to_y_offs[] = {0, 1, 0, -1}; + static const int dg_dir_to_x_offs[] = {-1, 0, 1, 0}; + static const int dg_dir_to_y_offs[] = {0, 1, 0, -1}; if (PfDetectDestination(n)) { n.m_estimate = n.m_cost; return true; diff --git a/src/yapf/yapf_destrail.hpp b/src/yapf/yapf_destrail.hpp --- a/src/yapf/yapf_destrail.hpp +++ b/src/yapf/yapf_destrail.hpp @@ -176,8 +176,8 @@ public: * adds it to the actual cost from origin and stores the sum to the Node::m_estimate */ FORCEINLINE bool PfCalcEstimate(Node& n) { - static int dg_dir_to_x_offs[] = {-1, 0, 1, 0}; - static int dg_dir_to_y_offs[] = {0, 1, 0, -1}; + static const int dg_dir_to_x_offs[] = {-1, 0, 1, 0}; + static const int dg_dir_to_y_offs[] = {0, 1, 0, -1}; if (PfDetectDestination(n)) { n.m_estimate = n.m_cost; return true; diff --git a/src/yapf/yapf_node_rail.hpp b/src/yapf/yapf_node_rail.hpp --- a/src/yapf/yapf_node_rail.hpp +++ b/src/yapf/yapf_node_rail.hpp @@ -119,7 +119,7 @@ DECLARE_ENUM_AS_BIT_SET(EndSegmentReason inline CStrA ValueStr(EndSegmentReasonBits bits) { - static const char *end_segment_reason_names[] = { + static const char * const end_segment_reason_names[] = { "DEAD_END", "RAIL_TYPE", "INFINITE_LOOP", "SEGMENT_TOO_LONG", "CHOICE_FOLLOWS", "DEPOT", "WAYPOINT", "STATION", "SAFE_TILE", "PATH_TOO_LONG", "FIRST_TWO_WAY_RED", "LOOK_AHEAD_END", "TARGET_REACHED" diff --git a/src/yapf/yapf_road.cpp b/src/yapf/yapf_road.cpp --- a/src/yapf/yapf_road.cpp +++ b/src/yapf/yapf_road.cpp @@ -304,8 +304,8 @@ public: * adds it to the actual cost from origin and stores the sum to the Node::m_estimate */ inline bool PfCalcEstimate(Node& n) { - static int dg_dir_to_x_offs[] = {-1, 0, 1, 0}; - static int dg_dir_to_y_offs[] = {0, 1, 0, -1}; + static const int dg_dir_to_x_offs[] = {-1, 0, 1, 0}; + static const int dg_dir_to_y_offs[] = {0, 1, 0, -1}; if (PfDetectDestination(n)) { n.m_estimate = n.m_cost; return true;