summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-07-19 15:58:47 +0000
committerrubidium <rubidium@openttd.org>2009-07-19 15:58:47 +0000
commit42e1bdacbc700fe9b5c0ef6c7298efda182bef1d (patch)
treefb98712dcd4a5d8d114f0e5076da3b4a95528fb8
parentd509ad3213c652ff58128bb783dcfdd7f91d5abb (diff)
downloadopenttd-42e1bdacbc700fe9b5c0ef6c7298efda182bef1d.tar.xz
(svn r16880) -Codechange: replace magic numbers with their enums and use a clearer variable name than 'flag' in the station naming function.
-rw-r--r--src/station_cmd.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 603bfea93..877e705b6 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -192,8 +192,8 @@ static bool CMSAForest(TileIndex tile)
#define M(x) ((x) - STR_SV_STNAME)
enum StationNaming {
- STATIONNAMING_RAIL = 0,
- STATIONNAMING_ROAD = 0,
+ STATIONNAMING_RAIL,
+ STATIONNAMING_ROAD,
STATIONNAMING_AIRPORT,
STATIONNAMING_OILRIG,
STATIONNAMING_DOCK,
@@ -231,15 +231,16 @@ static bool FindNearIndustryName(TileIndex tile, void *user_data)
return !sni->indtypes[indtype];
}
-static StringID GenerateStationName(Station *st, TileIndex tile, int flag)
+static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming name_class)
{
static const uint32 _gen_station_name_bits[] = {
- 0, // 0
- 1U << M(STR_SV_STNAME_AIRPORT), // 1
- 1U << M(STR_SV_STNAME_OILFIELD), // 2
- 1U << M(STR_SV_STNAME_DOCKS), // 3
- 0x1FFU << M(STR_SV_STNAME_BUOY_1), // 4
- 1U << M(STR_SV_STNAME_HELIPORT), // 5
+ 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
+ 0x1FFU << M(STR_SV_STNAME_BUOY_1), // STATIONNAMING_BUOY
+ 1U << M(STR_SV_STNAME_HELIPORT), // STATIONNAMING_HELIPORT
};
const Town *t = st->town;
@@ -265,7 +266,7 @@ static StringID GenerateStationName(Station *st, TileIndex tile, int flag)
}
}
- if (flag != STATIONNAMING_BUOY) {
+ if (name_class != STATIONNAMING_BUOY) {
TileIndex indtile = tile;
StationNameInformation sni = { free_names, indtypes };
if (CircularTileSearch(&indtile, 7, FindNearIndustryName, &sni)) {
@@ -284,7 +285,7 @@ static StringID GenerateStationName(Station *st, TileIndex tile, int flag)
}
/* check default names */
- uint32 tmp = free_names & _gen_station_name_bits[flag];
+ uint32 tmp = free_names & _gen_station_name_bits[name_class];
if (tmp != 0) return STR_SV_STNAME + FindFirstBit(tmp);
/* check mine? */