From 9a3bb5216d9f01558eaa5508be795b652d7d25f3 Mon Sep 17 00:00:00 2001 From: cirdan Date: Sun, 4 Feb 2018 09:16:02 +0100 Subject: [PATCH] Redefine enum StationNaming values Define the constants in enum StationNaming with the values that GenerateStationName needs to avoid having to look them up. --- src/station_cmd.cpp | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index bfb2564a3..b99a5d4fd 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -134,25 +134,16 @@ static bool CMSAMine(TileIndex tile) #define M(x) ((x) - STR_SV_STNAME) enum StationNaming { - STATIONNAMING_RAIL, - STATIONNAMING_ROAD, - STATIONNAMING_AIRPORT, - STATIONNAMING_OILRIG, - STATIONNAMING_DOCK, - STATIONNAMING_HELIPORT, + STATIONNAMING_RAIL = 0, + STATIONNAMING_ROAD = 0, + STATIONNAMING_AIRPORT = 1U << M(STR_SV_STNAME_AIRPORT), + STATIONNAMING_OILRIG = 1U << M(STR_SV_STNAME_OILFIELD), + STATIONNAMING_DOCK = 1U << M(STR_SV_STNAME_DOCKS), + STATIONNAMING_HELIPORT = 1U << M(STR_SV_STNAME_HELIPORT), }; static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming name_class) { - static const uint32 _gen_station_name_bits[] = { - 0, // STATIONNAMING_RAIL - 0, // STATIONNAMING_ROAD - 1U << M(STR_SV_STNAME_AIRPORT), // STATIONNAMING_AIRPORT - 1U << M(STR_SV_STNAME_OILFIELD), // STATIONNAMING_OILRIG - 1U << M(STR_SV_STNAME_DOCKS), // STATIONNAMING_DOCK - 1U << M(STR_SV_STNAME_HELIPORT), // STATIONNAMING_HELIPORT - }; - const Town *t = st->town; uint32 free_names = UINT32_MAX; @@ -209,7 +200,7 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n } /* check default names */ - uint32 tmp = free_names & _gen_station_name_bits[name_class]; + uint32 tmp = free_names & name_class; if (tmp != 0) return STR_SV_STNAME + FindFirstBit(tmp); TileArea around (tile); -- 2.11.4.GIT