Changeset - r12436:2ed142ada292
[Not reviewed]
master
0 1 0
rubidium - 15 years ago 2009-07-19 15:58:47
rubidium@openttd.org
(svn r16880) -Codechange: replace magic numbers with their enums and use a clearer variable name than 'flag' in the station naming function.
1 file changed with 12 insertions and 11 deletions:
0 comments (0 inline, 0 general)
src/station_cmd.cpp
Show inline comments
 
@@ -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(TileInd
 
	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(Stat
 
		}
 
	}
 

	
 
	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(Stat
 
	}
 

	
 
	/* 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? */
0 comments (0 inline, 0 general)