Changeset - r7813:e50a8d29e5a0
[Not reviewed]
master
0 1 0
belugas - 17 years ago 2007-10-31 18:01:41
belugas@openttd.org
(svn r11363) -Codechange: Remove some magical numbers
1 file changed with 16 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/station_cmd.cpp
Show inline comments
 
@@ -223,12 +223,22 @@ static bool CMSAForest(TileIndex tile)
 

	
 
	return false;
 
}
 

	
 
#define M(x) ((x) - STR_SV_STNAME)
 

	
 
enum StationNaming = {
 
	STATIONNAMING_RAIL = 0,
 
	STATIONNAMING_ROAD = 0,
 
	STATIONNAMING_AIRPORT,
 
	STATIONNAMING_OILRIG,
 
	STATIONNAMING_DOCK,
 
	STATIONNAMING_BUOY,
 
	STATIONNAMING_HELIPORT,
 
}
 

	
 
static bool GenerateStationName(Station *st, TileIndex tile, int flag)
 
{
 
	static const uint32 _gen_station_name_bits[] = {
 
		0,                                      /* 0 */
 
		1 << M(STR_SV_STNAME_AIRPORT),          /* 1 */
 
		1 << M(STR_SV_STNAME_OILFIELD),         /* 2 */
 
@@ -959,13 +969,13 @@ CommandCost CmdBuildRailroadStation(Tile
 
		if (st == NULL) return_cmd_error(STR_3008_TOO_MANY_STATIONS_LOADING);
 

	
 
		/* ensure that in case of error (or no DC_EXEC) the station gets deleted upon return */
 
		st_auto_delete = st;
 

	
 
		st->town = ClosestTownFromTile(tile_org, (uint)-1);
 
		if (!GenerateStationName(st, tile_org, 0)) return CMD_ERROR;
 
		if (!GenerateStationName(st, tile_org, STATIONNAMING_RAIL)) return CMD_ERROR;
 

	
 
		if (IsValidPlayer(_current_player) && (flags & DC_EXEC) != 0) {
 
			SETBIT(st->town->have_ratings, _current_player);
 
		}
 
	}
 

	
 
@@ -1384,13 +1394,13 @@ CommandCost CmdBuildRoadStop(TileIndex t
 

	
 
		/* ensure that in case of error (or no DC_EXEC) the new station gets deleted upon return */
 
		st_auto_delete = st;
 

	
 

	
 
		Town *t = st->town = ClosestTownFromTile(tile, (uint)-1);
 
		if (!GenerateStationName(st, tile, 0)) return CMD_ERROR;
 
		if (!GenerateStationName(st, tile, STATIONNAMING_ROAD)) return CMD_ERROR;
 

	
 
		if (IsValidPlayer(_current_player) && (flags & DC_EXEC) != 0) {
 
			SETBIT(t->have_ratings, _current_player);
 
		}
 

	
 
		st->sign.width_1 = 0;
 
@@ -1692,13 +1702,13 @@ CommandCost CmdBuildAirport(TileIndex ti
 
		}
 

	
 
		st->sign.width_1 = 0;
 

	
 
		/* If only helicopters may use the airport generate a helicopter related (5)
 
		 * station name, otherwise generate a normal airport name (1) */
 
		if (!GenerateStationName(st, tile, !(afc->flags & AirportFTAClass::AIRPLANES) ? 5 : 1)) {
 
		if (!GenerateStationName(st, tile, !(afc->flags & AirportFTAClass::AIRPLANES) ? STATIONNAMING_HELIPORT : STATIONNAMING_AIRPORT)) {
 
			return CMD_ERROR;
 
		}
 
	}
 

	
 
	cost.AddCost(_price.build_airport * w * h);
 

	
 
@@ -1807,13 +1817,13 @@ CommandCost CmdBuildBuoy(TileIndex tile,
 
	/* ensure that in case of error (or no DC_EXEC) the station gets deleted upon return */
 
	AutoPtrT<Station> st_auto_delete(st);
 

	
 
	st->town = ClosestTownFromTile(tile, (uint)-1);
 
	st->sign.width_1 = 0;
 

	
 
	if (!GenerateStationName(st, tile, 4)) return CMD_ERROR;
 
	if (!GenerateStationName(st, tile, STATIONNAMING_BUOY)) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		st->dock_tile = tile;
 
		st->facilities |= FACIL_DOCK;
 
		/* Buoys are marked in the Station struct by this flag. Yes, it is this
 
		 * braindead.. */
 
@@ -1977,13 +1987,13 @@ CommandCost CmdBuildDock(TileIndex tile,
 
		if (IsValidPlayer(_current_player) && (flags & DC_EXEC) != 0) {
 
			SETBIT(t->have_ratings, _current_player);
 
		}
 

	
 
		st->sign.width_1 = 0;
 

	
 
		if (!GenerateStationName(st, tile, 3)) return CMD_ERROR;
 
		if (!GenerateStationName(st, tile, STATIONNAMING_DOCK)) return CMD_ERROR;
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		st->dock_tile = tile;
 
		st->AddFacility(FACIL_DOCK, tile);
 

	
 
@@ -2746,13 +2756,13 @@ void BuildOilRig(TileIndex tile)
 
	Station *st = new Station();
 

	
 
	if (st == NULL) {
 
		DEBUG(misc, 0, "Can't allocate station for oilrig at 0x%X, reverting to oilrig only", tile);
 
		return;
 
	}
 
	if (!GenerateStationName(st, tile, 2)) {
 
	if (!GenerateStationName(st, tile, STATIONNAMING_OILRIG)) {
 
		DEBUG(misc, 0, "Can't allocate station-name for oilrig at 0x%X, reverting to oilrig only", tile);
 
		return;
 
	}
 

	
 
	st->town = ClosestTownFromTile(tile, (uint)-1);
 
	st->sign.width_1 = 0;
0 comments (0 inline, 0 general)