Changeset - r14611:79a9ea376bde
[Not reviewed]
master
0 12 0
yexo - 14 years ago 2010-02-22 14:17:07
yexo@openttd.org
(svn r19198) -Codechange: store the size of stations in savegames
12 files changed with 60 insertions and 56 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_order.cpp
Show inline comments
 
@@ -194,16 +194,15 @@ static const Order *ResolveOrder(Vehicle
 
			} else if (st->dock_tile != INVALID_TILE) {
 
				return st->dock_tile;
 
			} else if (st->bus_stops != NULL) {
 
				return st->bus_stops->xy;
 
			} else if (st->truck_stops != NULL) {
 
				return st->truck_stops->xy;
 
			} else if (st->airport_tile != INVALID_TILE) {
 
				const AirportSpec *as = st->GetAirportSpec();
 
				TILE_LOOP(tile, as->size_x, as->size_y, st->airport_tile) {
 
					if (!::IsHangar(tile)) return tile;
 
			} else if (st->airport.tile != INVALID_TILE) {
 
				TILE_AREA_LOOP(tile, st->airport) {
 
					if (st->TileBelongsToAirport(tile) && !::IsHangar(tile)) return tile;
 
				}
 
			}
 
			return INVALID_TILE;
 
		}
 

	
 
		case OT_GOTO_WAYPOINT: {
src/aircraft_cmd.cpp
Show inline comments
 
@@ -124,13 +124,13 @@ static StationID FindNearestHangar(const
 
					(avi->subtype & AIR_FAST) &&
 
					!_cheats.no_jetcrash.value)) {
 
			continue;
 
		}
 

	
 
		/* v->tile can't be used here, when aircraft is flying v->tile is set to 0 */
 
		uint distance = DistanceSquare(vtile, st->airport_tile);
 
		uint distance = DistanceSquare(vtile, st->airport.tile);
 
		if (distance < best || index == INVALID_STATION) {
 
			best = distance;
 
			index = st->index;
 
		}
 
	}
 
	return index;
 
@@ -803,13 +803,13 @@ static byte AircraftGetEntryPoint(const 
 
	 * or it will simply crash in next tick */
 
	TileIndex tile = 0;
 

	
 
	const Station *st = Station::GetIfValid(v->targetairport);
 
	if (st != NULL) {
 
		/* Make sure we don't go to INVALID_TILE if the airport has been removed. */
 
		tile = (st->airport_tile != INVALID_TILE) ? st->airport_tile : st->xy;
 
		tile = (st->airport.tile != INVALID_TILE) ? st->airport.tile : st->xy;
 
	}
 

	
 
	int delta_x = v->x_pos - TileX(tile) * TILE_SIZE;
 
	int delta_y = v->y_pos - TileY(tile) * TILE_SIZE;
 

	
 
	DiagDirection dir;
 
@@ -839,19 +839,19 @@ static bool AircraftController(Aircraft 
 

	
 
	/* NULL if station is invalid */
 
	const Station *st = Station::GetIfValid(v->targetairport);
 
	/* INVALID_TILE if there is no station */
 
	TileIndex tile = INVALID_TILE;
 
	if (st != NULL) {
 
		tile = (st->airport_tile != INVALID_TILE) ? st->airport_tile : st->xy;
 
		tile = (st->airport.tile != INVALID_TILE) ? st->airport.tile : st->xy;
 
	}
 
	/* DUMMY if there is no station or no airport */
 
	const AirportFTAClass *afc = tile == INVALID_TILE ? GetAirport(AT_DUMMY) : st->Airport();
 

	
 
	/* prevent going to INVALID_TILE if airport is deleted. */
 
	if (st == NULL || st->airport_tile == INVALID_TILE) {
 
	if (st == NULL || st->airport.tile == INVALID_TILE) {
 
		/* Jump into our "holding pattern" state machine if possible */
 
		if (v->pos >= afc->nofelements) {
 
			v->pos = v->previous_pos = AircraftGetEntryPoint(v, afc);
 
		} else if (v->targetairport != v->current_order.GetDestination()) {
 
			/* If not possible, just get out of here fast */
 
			v->state = FLYING;
 
@@ -985,14 +985,14 @@ static bool AircraftController(Aircraft 
 
					v->x_pos + ((x + amd->x > v->x_pos) ? 1 : -1) :
 
					v->x_pos;
 
			gp.y = (v->y_pos != (y + amd->y)) ?
 
					v->y_pos + ((y + amd->y > v->y_pos) ? 1 : -1) :
 
					v->y_pos;
 

	
 
			/* Oilrigs must keep v->tile as st->airport_tile, since the landing pad is in a non-airport tile */
 
			gp.new_tile = (st->airport_type == AT_OILRIG) ? st->airport_tile : TileVirtXY(gp.x, gp.y);
 
			/* Oilrigs must keep v->tile as st->airport.tile, since the landing pad is in a non-airport tile */
 
			gp.new_tile = (st->airport_type == AT_OILRIG) ? st->airport.tile : TileVirtXY(gp.x, gp.y);
 

	
 
		} else {
 

	
 
			/* Turn. Do it slowly if in the air. */
 
			Direction newdir = GetDirectionTowards(v, x + amd->x, y + amd->y);
 
			if (newdir != v->direction) {
 
@@ -1041,13 +1041,13 @@ static bool AircraftController(Aircraft 
 
			z = min(z + 2, GetAircraftFlyingAltitude(v));
 
		}
 

	
 
		if ((amd->flag & AMED_HOLD) && (z > 150)) z--;
 

	
 
		if (amd->flag & AMED_LAND) {
 
			if (st->airport_tile == INVALID_TILE) {
 
			if (st->airport.tile == INVALID_TILE) {
 
				/* Airport has been removed, abort the landing procedure */
 
				v->state = FLYING;
 
				UpdateAircraftCache(v);
 
				AircraftNextAirportPos_and_Order(v);
 
				/* get aircraft back on running altitude */
 
				SetAircraftPosition(v, gp.x, gp.y, GetAircraftFlyingAltitude(v));
 
@@ -1523,13 +1523,13 @@ static void AircraftEventHandler_HeliTak
 
static void AircraftEventHandler_Flying(Aircraft *v, const AirportFTAClass *apc)
 
{
 
	Station *st = Station::Get(v->targetairport);
 

	
 
	/* runway busy or not allowed to use this airstation, circle */
 
	if ((apc->flags & (v->subtype == AIR_HELICOPTER ? AirportFTAClass::HELICOPTERS : AirportFTAClass::AIRPLANES)) &&
 
			st->airport_tile != INVALID_TILE &&
 
			st->airport.tile != INVALID_TILE &&
 
			(st->owner == OWNER_NONE || st->owner == v->owner)) {
 
		/* {32,FLYING,NOTHING_block,37}, {32,LANDING,N,33}, {32,HELILANDING,N,41},
 
		 * if it is an airplane, look for LANDING, for helicopter HELILANDING
 
		 * it is possible to choose from multiple landing runways, so loop until a free one is found */
 
		byte landingtype = (v->subtype == AIR_HELICOPTER) ? HELILANDING : LANDING;
 
		const AirportFTA *current = apc->layout[v->pos].next;
 
@@ -1961,13 +1961,13 @@ Station *GetTargetAirportIfValid(const A
 
{
 
	assert(v->type == VEH_AIRCRAFT);
 

	
 
	Station *st = Station::GetIfValid(v->targetairport);
 
	if (st == NULL) return NULL;
 

	
 
	return st->airport_tile == INVALID_TILE ? NULL : st;
 
	return st->airport.tile == INVALID_TILE ? NULL : st;
 
}
 

	
 
/**
 
 * Updates the status of the Aircraft heading or in the station
 
 * @param st Station been updated
 
 */
src/disaster_cmd.cpp
Show inline comments
 
@@ -677,14 +677,14 @@ static void Disaster_Zeppeliner_Init()
 

	
 
	/* Pick a random place, unless we find a small airport */
 
	int x = TileX(Random()) * TILE_SIZE + TILE_SIZE / 2;
 

	
 
	Station *st;
 
	FOR_ALL_STATIONS(st) {
 
		if (st->airport_tile != INVALID_TILE && (st->airport_type == AT_SMALL || st->airport_type == AT_LARGE)) {
 
			x = (TileX(st->airport_tile) + 2) * TILE_SIZE;
 
		if (st->airport.tile != INVALID_TILE && (st->airport_type == AT_SMALL || st->airport_type == AT_LARGE)) {
 
			x = (TileX(st->airport.tile) + 2) * TILE_SIZE;
 
			break;
 
		}
 
	}
 

	
 
	DisasterVehicle *v = new DisasterVehicle();
 
	InitializeDisasterVehicle(v, x, 0, 135, DIR_SE, ST_ZEPPELINER);
src/newgrf_airporttiles.cpp
Show inline comments
 
@@ -177,13 +177,13 @@ static uint32 AirportTileGetVariable(con
 
		case 0x41: return GetTerrainType(tile);
 

	
 
		/* Current town zone of the tile in the nearest town */
 
		case 0x42: return GetTownRadiusGroup(ClosestTownFromTile(tile, UINT_MAX), tile);
 

	
 
		/* Position relative to most northern airport tile. */
 
		case 0x43: return GetRelativePosition(tile, st->airport_tile);
 
		case 0x43: return GetRelativePosition(tile, st->airport.tile);
 

	
 
		/* Animation frame of tile */
 
		case 0x44: return GetStationAnimationFrame(tile);
 

	
 
		/* Land info of nearby tiles */
 
		case 0x60: return GetNearbyAirportTileInformation(parameter, tile, st->index);
 
@@ -387,17 +387,15 @@ void AirportTileAnimationTrigger(Station
 
	ChangeAirportTileAnimationFrame(ats, tile, trigger, gfx, st);
 
	return;
 
}
 

	
 
void AirportAnimationTrigger(Station *st, AirpAnimationTrigger trigger, CargoID cargo_type)
 
{
 
	if (st->airport_tile == INVALID_TILE) return;
 
	if (st->airport.tile == INVALID_TILE) return;
 

	
 
	const AirportSpec *as = st->GetAirportSpec();
 
	int w = as->size_x;
 
	int h = as->size_y;
 

	
 
	TILE_LOOP(tile, w, h, st->airport_tile) {
 
	TILE_AREA_LOOP(tile, st->airport) {
 
		if (st->TileBelongsToAirport(tile)) AirportTileAnimationTrigger(st, tile, trigger, cargo_type);
 
	}
 
}
 

	
src/saveload/afterload.cpp
Show inline comments
 
@@ -522,13 +522,13 @@ bool AfterLoadGame()
 
	ResetOldNames();
 

	
 
	if (CheckSavegameVersion(106)) {
 
		/* no station is determined by 'tile == INVALID_TILE' now (instead of '0') */
 
		Station *st;
 
		FOR_ALL_STATIONS(st) {
 
			if (st->airport_tile       == 0) st->airport_tile = INVALID_TILE;
 
			if (st->airport.tile       == 0) st->airport.tile = INVALID_TILE;
 
			if (st->dock_tile          == 0) st->dock_tile    = INVALID_TILE;
 
			if (st->train_station.tile == 0) st->train_station.tile   = INVALID_TILE;
 
		}
 

	
 
		/* the same applies to Company::location_of_HQ */
 
		Company *c;
 
@@ -2060,12 +2060,22 @@ bool AfterLoadGame()
 
					offset += atc[i].num_frames - 1;
 
				}
 
			}
 
		}
 
	}
 

	
 
	if (CheckSavegameVersion(139)) {
 
		Station *st;
 
		FOR_ALL_STATIONS(st) {
 
			if (st->airport.tile != INVALID_TILE) {
 
				st->airport.w = st->GetAirportSpec()->size_x;
 
				st->airport.h = st->GetAirportSpec()->size_y;
 
			}
 
		}
 
	}
 

	
 
	/* Road stops is 'only' updating some caches */
 
	AfterLoadRoadStops();
 
	AfterLoadLabelMaps();
 

	
 
	GamelogPrintDebug(1);
 

	
src/saveload/oldloader_sl.cpp
Show inline comments
 
@@ -709,13 +709,13 @@ static bool LoadOldGood(LoadgameState *l
 
static const OldChunks station_chunk[] = {
 
	OCL_SVAR(   OC_TILE, Station, xy ),
 
	OCL_VAR ( OC_UINT32,   1, &_old_town_index ),
 

	
 
	OCL_NULL( 4 ), ///< bus/lorry tile
 
	OCL_SVAR(   OC_TILE, Station, train_station.tile ),
 
	OCL_SVAR(   OC_TILE, Station, airport_tile ),
 
	OCL_SVAR(   OC_TILE, Station, airport.tile ),
 
	OCL_SVAR(   OC_TILE, Station, dock_tile ),
 
	OCL_SVAR(  OC_UINT8, Station, train_station.w ),
 

	
 
	OCL_NULL( 1 ),         ///< sort-index, no longer in use
 
	OCL_NULL( 2 ),         ///< sign-width, no longer in use
 

	
src/saveload/station_sl.cpp
Show inline comments
 
@@ -148,14 +148,16 @@ static const SaveLoad _roadstop_desc[] =
 
static const SaveLoad _old_station_desc[] = {
 
	SLE_CONDVAR(Station, xy,                         SLE_FILE_U16 | SLE_VAR_U32,  0, 5),
 
	SLE_CONDVAR(Station, xy,                         SLE_UINT32,                  6, SL_MAX_VERSION),
 
	SLE_CONDNULL(4, 0, 5),  ///< bus/lorry tile
 
	SLE_CONDVAR(Station, train_station.tile,         SLE_FILE_U16 | SLE_VAR_U32,  0, 5),
 
	SLE_CONDVAR(Station, train_station.tile,         SLE_UINT32,                  6, SL_MAX_VERSION),
 
	SLE_CONDVAR(Station, airport_tile,               SLE_FILE_U16 | SLE_VAR_U32,  0, 5),
 
	SLE_CONDVAR(Station, airport_tile,               SLE_UINT32,                  6, SL_MAX_VERSION),
 
	SLE_CONDVAR(Station, airport.tile,               SLE_FILE_U16 | SLE_VAR_U32,  0, 5),
 
	SLE_CONDVAR(Station, airport.tile,               SLE_UINT32,                  6, SL_MAX_VERSION),
 
	SLE_CONDVAR(Station, airport.w,                  SLE_UINT8,                   139, SL_MAX_VERSION),
 
	SLE_CONDVAR(Station, airport.h,                  SLE_UINT8,                   139, SL_MAX_VERSION),
 
	SLE_CONDVAR(Station, dock_tile,                  SLE_FILE_U16 | SLE_VAR_U32,  0, 5),
 
	SLE_CONDVAR(Station, dock_tile,                  SLE_UINT32,                  6, SL_MAX_VERSION),
 
	    SLE_REF(Station, town,                       REF_TOWN),
 
	    SLE_VAR(Station, train_station.w,            SLE_UINT8),
 
	SLE_CONDVAR(Station, train_station.h,            SLE_UINT8,                   2, SL_MAX_VERSION),
 

	
 
@@ -328,13 +330,13 @@ static const SaveLoad _station_desc[] = 
 
	      SLE_VAR(Station, train_station.w,            SLE_UINT8),
 
	      SLE_VAR(Station, train_station.h,            SLE_UINT8),
 

	
 
	      SLE_REF(Station, bus_stops,                  REF_ROADSTOPS),
 
	      SLE_REF(Station, truck_stops,                REF_ROADSTOPS),
 
	      SLE_VAR(Station, dock_tile,                  SLE_UINT32),
 
	      SLE_VAR(Station, airport_tile,               SLE_UINT32),
 
	      SLE_VAR(Station, airport.tile,               SLE_UINT32),
 
	      SLE_VAR(Station, airport_type,               SLE_UINT8),
 
	      SLE_VAR(Station, airport_flags,              SLE_UINT64),
 

	
 
	      SLE_VAR(Station, indtype,                    SLE_UINT8),
 

	
 
	      SLE_VAR(Station, time_since_load,            SLE_UINT8),
src/station.cpp
Show inline comments
 
@@ -37,13 +37,13 @@ BaseStation::~BaseStation()
 
}
 

	
 
Station::Station(TileIndex tile) :
 
	SpecializedStation<Station, false>(tile),
 
	bus_station(INVALID_TILE, 0, 0),
 
	truck_station(INVALID_TILE, 0, 0),
 
	airport_tile(INVALID_TILE),
 
	airport(INVALID_TILE, 0, 0),
 
	dock_tile(INVALID_TILE),
 
	indtype(IT_INVALID),
 
	time_since_load(255),
 
	time_since_unload(255),
 
	last_vehicle_type(VEH_INVALID)
 
{
 
@@ -220,15 +220,15 @@ uint Station::GetCatchmentRadius() const
 

	
 
	if (_settings_game.station.modified_catchment) {
 
		if (this->bus_stops          != NULL)         ret = max<uint>(ret, CA_BUS);
 
		if (this->truck_stops        != NULL)         ret = max<uint>(ret, CA_TRUCK);
 
		if (this->train_station.tile != INVALID_TILE) ret = max<uint>(ret, CA_TRAIN);
 
		if (this->dock_tile          != INVALID_TILE) ret = max<uint>(ret, CA_DOCK);
 
		if (this->airport_tile       != INVALID_TILE) ret = max<uint>(ret, this->GetAirportSpec()->catchment);
 
		if (this->airport.tile       != INVALID_TILE) ret = max<uint>(ret, this->GetAirportSpec()->catchment);
 
	} else {
 
		if (this->bus_stops != NULL || this->truck_stops != NULL || this->train_station.tile != INVALID_TILE || this->dock_tile != INVALID_TILE || this->airport_tile != INVALID_TILE) {
 
		if (this->bus_stops != NULL || this->truck_stops != NULL || this->train_station.tile != INVALID_TILE || this->dock_tile != INVALID_TILE || this->airport.tile != INVALID_TILE) {
 
			ret = CA_UNMODIFIED;
 
		}
 
	}
 

	
 
	return ret;
 
}
src/station_base.h
Show inline comments
 
@@ -56,28 +56,28 @@ public:
 
	}
 

	
 
	RoadStop *GetPrimaryRoadStop(const struct RoadVehicle *v) const;
 

	
 
	const AirportFTAClass *Airport() const
 
	{
 
		if (airport_tile == INVALID_TILE) return GetAirport(AT_DUMMY);
 
		if (airport.tile == INVALID_TILE) return GetAirport(AT_DUMMY);
 
		return GetAirport(airport_type);
 
	}
 

	
 
	const AirportSpec *GetAirportSpec() const
 
	{
 
		if (airport_tile == INVALID_TILE) return &AirportSpec::dummy;
 
		if (airport.tile == INVALID_TILE) return &AirportSpec::dummy;
 
		return AirportSpec::Get(this->airport_type);
 
	}
 

	
 
	RoadStop *bus_stops;    ///< All the road stops
 
	TileArea bus_station;   ///< Tile area the bus 'station' part covers
 
	RoadStop *truck_stops;  ///< All the truck stops
 
	TileArea truck_station; ///< Tile area the truck 'station' part covers
 

	
 
	TileIndex airport_tile; ///< The location of the airport
 
	TileArea airport;       ///< Tile area the airport covers
 
	TileIndex dock_tile;    ///< The location of the dock
 

	
 
	IndustryType indtype;   ///< Industry type to get the name from
 

	
 
	StationHadVehicleOfTypeByte had_vehicle_of_type;
 

	
 
@@ -125,15 +125,15 @@ public:
 
	{
 
		return IsAirportTile(tile) && GetStationIndex(tile) == this->index;
 
	}
 

	
 
	FORCEINLINE TileIndex GetHangarTile(uint hangar_num) const
 
	{
 
		assert(this->airport_tile != INVALID_TILE);
 
		assert(this->airport.tile != INVALID_TILE);
 
		assert(hangar_num < this->GetAirportSpec()->nof_depots);
 
		return this->airport_tile + ToTileIndexDiff(this->GetAirportSpec()->depot_table[hangar_num]);
 
		return this->airport.tile + ToTileIndexDiff(this->GetAirportSpec()->depot_table[hangar_num]);
 
	}
 

	
 
	/* virtual */ uint32 GetNewGRFVariable(const ResolverObject *object, byte variable, byte parameter, bool *available) const;
 

	
 
	/* virtual */ void GetTileArea(TileArea *ta, StationType type) const;
 
};
src/station_cmd.cpp
Show inline comments
 
@@ -380,15 +380,13 @@ void Station::GetTileArea(TileArea *ta, 
 
	switch (type) {
 
		case STATION_RAIL:
 
			*ta = this->train_station;
 
			return;
 

	
 
		case STATION_AIRPORT:
 
			ta->tile = this->airport_tile;
 
			ta->w    = this->GetAirportSpec()->size_x;
 
			ta->h    = this->GetAirportSpec()->size_y;
 
			*ta = this->airport;
 
			return;
 

	
 
		case STATION_TRUCK:
 
			*ta = this->truck_station;
 
			return;
 

	
 
@@ -1845,13 +1843,13 @@ CommandCost CmdRemoveRoadStop(TileIndex 
 
}
 

	
 
/**
 
 * Computes the minimal distance from town's xy to any airport's tile.
 
 * @param as airport's description
 
 * @param town_tile town's tile (t->xy)
 
 * @param airport_tile st->airport_tile
 
 * @param airport_tile st->airport.tile
 
 * @return minimal manhattan distance from town_tile to any airport's tile
 
 */
 
static uint GetMinimalAirportDistanceToTile(const AirportSpec *as, TileIndex town_tile, TileIndex airport_tile)
 
{
 
	uint ttx = TileX(town_tile); // X, Y of town
 
	uint tty = TileY(town_tile);
 
@@ -1903,13 +1901,13 @@ uint8 GetAirportNoiseLevelForTown(const 
 
}
 

	
 
/**
 
 * Finds the town nearest to given airport. Based on minimal manhattan distance to any airport's tile.
 
 * If two towns have the same distance, town with lower index is returned.
 
 * @param as airport's description
 
 * @param airport_tile st->airport_tile
 
 * @param airport_tile st->airport.tile
 
 * @return nearest town to airport
 
 */
 
Town *AirportGetNearestTown(const AirportSpec *as, TileIndex airport_tile)
 
{
 
	Town *t, *nearest = NULL;
 
	uint add = as->size_x + as->size_y - 2; // GetMinimalAirportDistanceToTile can differ from DistanceManhattan by this much
 
@@ -1934,16 +1932,16 @@ void UpdateAirportsNoise()
 
	Town *t;
 
	const Station *st;
 

	
 
	FOR_ALL_TOWNS(t) t->noise_reached = 0;
 

	
 
	FOR_ALL_STATIONS(st) {
 
		if (st->airport_tile != INVALID_TILE) {
 
		if (st->airport.tile != INVALID_TILE) {
 
			const AirportSpec *as = st->GetAirportSpec();
 
			Town *nearest = AirportGetNearestTown(as, st->airport_tile);
 
			nearest->noise_reached += GetAirportNoiseLevelForTown(as, nearest->xy, st->airport_tile);
 
			Town *nearest = AirportGetNearestTown(as, st->airport.tile);
 
			nearest->noise_reached += GetAirportNoiseLevelForTown(as, nearest->xy, st->airport.tile);
 
		}
 
	}
 
}
 

	
 
/** Place an Airport.
 
 * @param tile tile where airport will be built
 
@@ -2029,13 +2027,13 @@ CommandCost CmdBuildAirport(TileIndex ti
 
		if (st->owner != _current_company) {
 
			return_cmd_error(STR_ERROR_TOO_CLOSE_TO_ANOTHER_STATION);
 
		}
 

	
 
		if (!st->rect.BeforeAddRect(tile, w, h, StationRect::ADD_TEST)) return CMD_ERROR;
 

	
 
		if (st->airport_tile != INVALID_TILE) {
 
		if (st->airport.tile != INVALID_TILE) {
 
			return_cmd_error(STR_ERROR_TOO_CLOSE_TO_ANOTHER_AIRPORT);
 
		}
 
	} else {
 
		airport_upgrade = false;
 

	
 
		/* allocate and initialize new station */
 
@@ -2056,13 +2054,12 @@ CommandCost CmdBuildAirport(TileIndex ti
 
	cost.AddCost(_price[PR_BUILD_STATION_AIRPORT] * w * h);
 

	
 
	if (flags & DC_EXEC) {
 
		/* Always add the noise, so there will be no need to recalculate when option toggles */
 
		nearest->noise_reached += newnoise_level;
 

	
 
		st->airport_tile = tile;
 
		st->AddFacility(FACIL_AIRPORT, tile);
 
		st->airport_type = (byte)p1;
 
		st->airport_flags = 0;
 

	
 
		st->rect.BeforeAddRect(tile, w, h, StationRect::ADD_TRY);
 

	
 
@@ -2076,12 +2073,13 @@ CommandCost CmdBuildAirport(TileIndex ti
 
		if (airport_upgrade) UpdateAirplanesOnNewStation(st);
 

	
 
		const AirportTileTable *it = as->table[0];
 
		do {
 
			TileIndex cur_tile = tile + ToTileIndexDiff(it->ti);
 
			MakeAirport(cur_tile, st->owner, st->index, it->gfx);
 
			st->airport.Add(cur_tile);
 

	
 
			if (AirportTileSpec::Get(GetTranslatedAirportTileID(it->gfx))->animation_info != 0xFFFF) AddAnimatedTile(cur_tile);
 
		} while ((++it)->ti.x != -0x80);
 

	
 
		/* Only call the animation trigger after all tiles have been built */
 
		it = as->table[0];
 
@@ -2116,13 +2114,13 @@ static CommandCost RemoveAirport(TileInd
 
	Station *st = Station::GetByTile(tile);
 

	
 
	if (_current_company != OWNER_WATER && !CheckOwnership(st->owner)) {
 
		return CMD_ERROR;
 
	}
 

	
 
	tile = st->airport_tile;
 
	tile = st->airport.tile;
 

	
 
	const AirportSpec *as = st->GetAirportSpec();
 
	int w = as->size_x;
 
	int h = as->size_y;
 

	
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 
@@ -2130,17 +2128,17 @@ static CommandCost RemoveAirport(TileInd
 
	const Aircraft *a;
 
	FOR_ALL_AIRCRAFT(a) {
 
		if (!a->IsNormalAircraft()) continue;
 
		if (a->targetairport == st->index && a->state != FLYING) return CMD_ERROR;
 
	}
 

	
 
	TILE_LOOP(tile_cur, w, h, tile) {
 
	TILE_AREA_LOOP(tile_cur, st->airport) {
 
		if (!st->TileBelongsToAirport(tile_cur)) continue;
 

	
 
		if (!EnsureNoVehicleOnGround(tile_cur)) return CMD_ERROR;
 

	
 
		if (!st->TileBelongsToAirport(tile_cur)) continue;
 

	
 
		cost.AddCost(_price[PR_CLEAR_STATION_AIRPORT]);
 

	
 
		if (flags & DC_EXEC) {
 
			DeleteAnimatedTile(tile_cur);
 
			DoClearSquare(tile_cur);
 
		}
 
@@ -2158,13 +2156,13 @@ static CommandCost RemoveAirport(TileInd
 
		 * need of recalculation */
 
		Town *nearest = AirportGetNearestTown(as, tile);
 
		nearest->noise_reached -= GetAirportNoiseLevelForTown(as, nearest->xy, tile);
 

	
 
		st->rect.AfterRemoveRect(st, tile, w, h);
 

	
 
		st->airport_tile = INVALID_TILE;
 
		st->airport.Clear();
 
		st->facilities &= ~FACIL_AIRPORT;
 

	
 
		SetWindowWidgetDirty(WC_STATION_VIEW, st->index, SVW_PLANES);
 

	
 
		if (_settings_game.economy.station_noise_level) {
 
			SetWindowDirty(WC_TOWN_VIEW, st->town->index);
 
@@ -3203,13 +3201,13 @@ void BuildOilRig(TileIndex tile)
 
	assert(IsTileType(tile, MP_INDUSTRY));
 
	DeleteAnimatedTile(tile);
 
	MakeOilrig(tile, st->index, GetWaterClass(tile));
 

	
 
	st->owner = OWNER_NONE;
 
	st->airport_type = AT_OILRIG;
 
	st->airport_tile = tile;
 
	st->airport.Add(tile);
 
	st->dock_tile = tile;
 
	st->facilities = FACIL_AIRPORT | FACIL_DOCK;
 
	st->build_date = _date;
 

	
 
	st->rect.BeforeAddTile(tile, StationRect::ADD_FORCE);
 

	
 
@@ -3231,13 +3229,13 @@ void DeleteOilRig(TileIndex tile)
 
	Station *st = Station::GetByTile(tile);
 

	
 
	MakeWaterKeepingClass(tile, OWNER_NONE);
 
	MarkTileDirtyByTile(tile);
 

	
 
	st->dock_tile = INVALID_TILE;
 
	st->airport_tile = INVALID_TILE;
 
	st->airport.Clear();
 
	st->facilities &= ~(FACIL_AIRPORT | FACIL_DOCK);
 
	st->airport_flags = 0;
 

	
 
	st->rect.AfterRemoveTile(st, tile);
 

	
 
	st->UpdateVirtCoord();
src/town_gui.cpp
Show inline comments
 
@@ -479,13 +479,13 @@ public:
 
		const Station *st;
 
		FOR_ALL_STATIONS(st) {
 
			if (st->town == this->town) {
 
				/* Non-oil rig stations are always a problem. */
 
				if (!(st->facilities & FACIL_AIRPORT) || st->airport_type != AT_OILRIG) return false;
 
				/* We can only automatically delete oil rigs *if* there's no vehicle on them. */
 
				if (DoCommand(st->airport_tile, 0, 0, DC_NONE, CMD_LANDSCAPE_CLEAR).Failed()) return false;
 
				if (DoCommand(st->airport.tile, 0, 0, DC_NONE, CMD_LANDSCAPE_CLEAR).Failed()) return false;
 
			}
 
		}
 

	
 
		/* Depots refer to towns. */
 
		const Depot *d;
 
		FOR_ALL_DEPOTS(d) {
src/water_cmd.cpp
Show inline comments
 
@@ -725,17 +725,14 @@ static void FloodVehicles(TileIndex tile
 
	byte z = 0;
 

	
 
	if (IsAirportTile(tile)) {
 
		const Station *st = Station::GetByTile(tile);
 
		const AirportSpec *as = st->GetAirportSpec();
 
		z = 1 + st->Airport()->delta_z;
 
		for (uint x = 0; x < as->size_x; x++) {
 
			for (uint y = 0; y < as->size_y; y++) {
 
				tile = TILE_ADDXY(st->airport_tile, x, y);
 
				FindVehicleOnPos(tile, &z, &FloodVehicleProc);
 
			}
 
		TILE_AREA_LOOP(tile, st->airport) {
 
			if (st->TileBelongsToAirport(tile)) FindVehicleOnPos(tile, &z, &FloodVehicleProc);
 
		}
 

	
 
		/* No vehicle could be flooded on this airport anymore */
 
		return;
 
	}
 

	
0 comments (0 inline, 0 general)