summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2010-03-18 21:02:20 +0000
committeryexo <yexo@openttd.org>2010-03-18 21:02:20 +0000
commitc4a88ce0225a57243a79e28d133c2ecd884bee68 (patch)
tree766e1e5469d2c9d2956f5d6c79fd5bba787cf2ca /src
parent0eb5709c86f8dbfdcf7f91a178e46be4a1bc53d0 (diff)
downloadopenttd-c4a88ce0225a57243a79e28d133c2ecd884bee68.tar.xz
(svn r19455) -Codechange: split all airport information in Station to a seperate class
Diffstat (limited to 'src')
-rw-r--r--src/ai/api/ai_airport.cpp4
-rw-r--r--src/ai/api/ai_depotlist.cpp2
-rw-r--r--src/ai/api/ai_order.cpp2
-rw-r--r--src/ai/api/ai_town.cpp2
-rw-r--r--src/aircraft_cmd.cpp48
-rw-r--r--src/airport.cpp2
-rw-r--r--src/airport.h2
-rw-r--r--src/disaster_cmd.cpp6
-rw-r--r--src/newgrf_airporttiles.cpp2
-rw-r--r--src/newgrf_engine.cpp4
-rw-r--r--src/newgrf_station.cpp6
-rw-r--r--src/order_cmd.cpp2
-rw-r--r--src/saveload/afterload.cpp10
-rw-r--r--src/saveload/oldloader_sl.cpp16
-rw-r--r--src/saveload/station_sl.cpp12
-rw-r--r--src/saveload/vehicle_sl.cpp2
-rw-r--r--src/station.cpp3
-rw-r--r--src/station_base.h40
-rw-r--r--src/station_cmd.cpp18
-rw-r--r--src/table/airport_movement.h2
-rw-r--r--src/town_gui.cpp2
-rw-r--r--src/vehicle.cpp6
-rw-r--r--src/water_cmd.cpp4
23 files changed, 100 insertions, 97 deletions
diff --git a/src/ai/api/ai_airport.cpp b/src/ai/api/ai_airport.cpp
index 7b1119765..8f3b5430b 100644
--- a/src/ai/api/ai_airport.cpp
+++ b/src/ai/api/ai_airport.cpp
@@ -96,7 +96,7 @@
if (st->owner != _current_company) return -1;
if ((st->facilities & FACIL_AIRPORT) == 0) return -1;
- return st->GetAirportSpec()->nof_depots;
+ return st->airport.GetSpec()->nof_depots;
}
/* static */ TileIndex AIAirport::GetHangarOfAirport(TileIndex tile)
@@ -120,7 +120,7 @@
if (!AIStation::HasStationType(station_id, AIStation::STATION_AIRPORT)) return AT_INVALID;
- return (AirportType)::Station::Get(station_id)->airport_type;
+ return (AirportType)::Station::Get(station_id)->airport.type;
}
diff --git a/src/ai/api/ai_depotlist.cpp b/src/ai/api/ai_depotlist.cpp
index a40c13a31..3a58c2c45 100644
--- a/src/ai/api/ai_depotlist.cpp
+++ b/src/ai/api/ai_depotlist.cpp
@@ -29,7 +29,7 @@ AIDepotList::AIDepotList(AITile::TransportType transport_type)
const Station *st;
FOR_ALL_STATIONS(st) {
if (st->owner == ::_current_company) {
- const AirportSpec *as = st->GetAirportSpec();
+ const AirportSpec *as = st->airport.GetSpec();
for (uint i = 0; i < as->nof_depots; i++) {
this->AddItem(st->GetHangarTile(i));
}
diff --git a/src/ai/api/ai_order.cpp b/src/ai/api/ai_order.cpp
index 71b111f8a..6290525d5 100644
--- a/src/ai/api/ai_order.cpp
+++ b/src/ai/api/ai_order.cpp
@@ -181,7 +181,7 @@ static const Order *ResolveOrder(VehicleID vehicle_id, AIOrder::OrderPosition or
if (v->type != VEH_AIRCRAFT) return ::Depot::Get(order->GetDestination())->xy;
/* Aircraft's hangars are referenced by StationID, not DepotID */
const Station *st = ::Station::Get(order->GetDestination());
- if (st->GetAirportSpec()->nof_depots == 0) return INVALID_TILE;
+ if (st->airport.GetSpec()->nof_depots == 0) return INVALID_TILE;
return st->GetHangarTile(0);
}
diff --git a/src/ai/api/ai_town.cpp b/src/ai/api/ai_town.cpp
index 7f8dc3090..a11e374e8 100644
--- a/src/ai/api/ai_town.cpp
+++ b/src/ai/api/ai_town.cpp
@@ -188,7 +188,7 @@
int num = 0;
const Station *st;
FOR_ALL_STATIONS(st) {
- if (st->town == t && (st->facilities & FACIL_AIRPORT) && st->airport_type != AT_OILRIG) num++;
+ if (st->town == t && (st->facilities & FACIL_AIRPORT) && st->airport.type != AT_OILRIG) num++;
}
return max(0, 2 - num);
}
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index cce161e15..df7690a2c 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -116,8 +116,8 @@ static StationID FindNearestHangar(const Aircraft *v)
FOR_ALL_STATIONS(st) {
if (st->owner != v->owner || !(st->facilities & FACIL_AIRPORT)) continue;
- const AirportFTAClass *afc = st->Airport();
- const AirportSpec *as = st->GetAirportSpec();
+ const AirportFTAClass *afc = st->airport.GetFTA();
+ const AirportSpec *as = st->airport.GetSpec();
if (as->nof_depots == 0 || (
/* don't crash the plane if we know it can't land at the airport */
(afc->flags & AirportFTAClass::SHORT_STRIP) &&
@@ -415,7 +415,7 @@ bool Aircraft::FindClosestDepot(TileIndex *location, DestinationID *destination,
{
const Station *st = GetTargetAirportIfValid(this);
/* If the station is not a valid airport or if it has no hangars */
- if (st == NULL || st->GetAirportSpec()->nof_depots == 0) {
+ if (st == NULL || st->airport.GetSpec()->nof_depots == 0) {
/* the aircraft has to search for a hangar on its own */
StationID station = FindNearestHangar(this);
@@ -515,7 +515,7 @@ static void CheckIfAircraftNeedsService(Aircraft *v)
assert(st != NULL);
/* only goto depot if the target airport has a depot */
- if (st->GetAirportSpec()->nof_depots > 0 && CanVehicleUseStation(v, st)) {
+ if (st->airport.GetSpec()->nof_depots > 0 && CanVehicleUseStation(v, st)) {
v->current_order.MakeGoToDepot(st->index, ODTFB_SERVICE);
SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
} else if (v->current_order.IsType(OT_GOTO_DEPOT)) {
@@ -841,7 +841,7 @@ static bool AircraftController(Aircraft *v)
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();
+ const AirportFTAClass *afc = tile == INVALID_TILE ? GetAirport(AT_DUMMY) : st->airport.GetFTA();
/* prevent going to INVALID_TILE if airport is deleted. */
if (st == NULL || st->airport.tile == INVALID_TILE) {
@@ -989,7 +989,7 @@ static bool AircraftController(Aircraft *v)
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);
+ gp.new_tile = (st->airport.type == AT_OILRIG) ? st->airport.tile : TileVirtXY(gp.x, gp.y);
} else {
@@ -1125,9 +1125,9 @@ static bool HandleCrashedAircraft(Aircraft *v)
* small airports use AIRPORT_BUSY, city airports use RUNWAY_IN_OUT_block, etc.
* but they all share the same number */
if (st != NULL) {
- CLRBITS(st->airport_flags, RUNWAY_IN_block);
- CLRBITS(st->airport_flags, RUNWAY_IN_OUT_block); // commuter airport
- CLRBITS(st->airport_flags, RUNWAY_IN2_block); // intercontinental
+ CLRBITS(st->airport.flags, RUNWAY_IN_block);
+ CLRBITS(st->airport.flags, RUNWAY_IN_OUT_block); // commuter airport
+ CLRBITS(st->airport.flags, RUNWAY_IN2_block); // intercontinental
}
delete v;
@@ -1281,7 +1281,7 @@ static void MaybeCrashAirplane(Aircraft *v)
/* FIXME -- MaybeCrashAirplane -> increase crashing chances of very modern airplanes on smaller than AT_METROPOLITAN airports */
uint32 prob = (0x4000 << _settings_game.vehicle.plane_crashes);
- if ((st->Airport()->flags & AirportFTAClass::SHORT_STRIP) &&
+ if ((st->airport.GetFTA()->flags & AirportFTAClass::SHORT_STRIP) &&
(AircraftVehInfo(v->engine_type)->subtype & AIR_FAST) &&
!_cheats.no_jetcrash.value) {
prob /= 20;
@@ -1343,7 +1343,7 @@ void AircraftNextAirportPos_and_Order(Aircraft *v)
}
const Station *st = GetTargetAirportIfValid(v);
- const AirportFTAClass *apc = st == NULL ? GetAirport(AT_DUMMY) : st->Airport();
+ const AirportFTAClass *apc = st == NULL ? GetAirport(AT_DUMMY) : st->airport.GetFTA();
v->pos = v->previous_pos = AircraftGetEntryPoint(v, apc);
}
@@ -1468,7 +1468,7 @@ static void AircraftEventHandler_AtTerminal(Aircraft *v, const AirportFTAClass *
return;
default: // orders have been deleted (no orders), goto depot and don't bother us
v->current_order.Free();
- go_to_hangar = Station::Get(v->targetairport)->GetAirportSpec()->nof_depots != 0;
+ go_to_hangar = Station::Get(v->targetairport)->airport.GetSpec()->nof_depots != 0;
}
if (go_to_hangar) {
@@ -1546,7 +1546,7 @@ static void AircraftEventHandler_Flying(Aircraft *v, const AirportFTAClass *apc)
* if there are multiple runways, plane won't know which one it took (because
* they all have heading LANDING). And also occupy that block! */
v->pos = current->next_position;
- SETBITS(st->airport_flags, apc->layout[v->pos].block);
+ SETBITS(st->airport.flags, apc->layout[v->pos].block);
return;
}
v->cur_speed = tcur_speed;
@@ -1609,7 +1609,7 @@ static void AircraftEventHandler_HeliEndLanding(Aircraft *v, const AirportFTACla
if (v->current_order.IsType(OT_GOTO_STATION)) {
if (AirportFindFreeHelipad(v, apc)) return;
}
- const AirportSpec *as = Station::Get(v->targetairport)->GetAirportSpec();
+ const AirportSpec *as = Station::Get(v->targetairport)->airport.GetSpec();
v->state = (as->nof_depots != 0) ? HANGAR : HELITAKEOFF;
}
@@ -1646,7 +1646,7 @@ static void AirportClearBlock(const Aircraft *v, const AirportFTAClass *apc)
if (apc->layout[v->previous_pos].block != apc->layout[v->pos].block) {
Station *st = Station::Get(v->targetairport);
- CLRBITS(st->airport_flags, apc->layout[v->previous_pos].block);
+ CLRBITS(st->airport.flags, apc->layout[v->previous_pos].block);
}
}
@@ -1655,7 +1655,7 @@ static void AirportGoToNextPosition(Aircraft *v)
/* if aircraft is not in position, wait until it is */
if (!AircraftController(v)) return;
- const AirportFTAClass *apc = Station::Get(v->targetairport)->Airport();
+ const AirportFTAClass *apc = Station::Get(v->targetairport)->airport.GetFTA();
AirportClearBlock(v, apc);
AirportMove(v, apc); // move aircraft to next position
@@ -1725,7 +1725,7 @@ static bool AirportHasBlock(Aircraft *v, const AirportFTA *current_pos, const Ai
airport_flags |= current_pos->block;
}
- if (st->airport_flags & airport_flags) {
+ if (st->airport.flags & airport_flags) {
v->cur_speed = 0;
v->subspeed = 0;
return true;
@@ -1766,14 +1766,14 @@ static bool AirportSetBlocks(Aircraft *v, const AirportFTA *current_pos, const A
if (current_pos->block == next->block) airport_flags ^= next->block;
Station *st = Station::Get(v->targetairport);
- if (st->airport_flags & airport_flags) {
+ if (st->airport.flags & airport_flags) {
v->cur_speed = 0;
v->subspeed = 0;
return false;
}
if (next->block != NOTHING_block) {
- SETBITS(st->airport_flags, airport_flags); // occupy next block
+ SETBITS(st->airport.flags, airport_flags); // occupy next block
}
}
return true;
@@ -1783,10 +1783,10 @@ static bool FreeTerminal(Aircraft *v, byte i, byte last_terminal)
{
Station *st = Station::Get(v->targetairport);
for (; i < last_terminal; i++) {
- if (!HasBit(st->airport_flags, _airport_terminal_flag[i])) {
+ if (!HasBit(st->airport.flags, _airport_terminal_flag[i])) {
/* TERMINAL# HELIPAD# */
v->state = _airport_terminal_state[i]; // start moving to that terminal/helipad
- SetBit(st->airport_flags, _airport_terminal_flag[i]); // occupy terminal/helipad
+ SetBit(st->airport.flags, _airport_terminal_flag[i]); // occupy terminal/helipad
return true;
}
}
@@ -1820,7 +1820,7 @@ static bool AirportFindFreeTerminal(Aircraft *v, const AirportFTAClass *apc)
while (temp != NULL) {
if (temp->heading == 255) {
- if (!(st->airport_flags & temp->block)) {
+ if (!(st->airport.flags & temp->block)) {
/* read which group do we want to go to?
* (the first free group) */
uint target_group = temp->next_position + 1;
@@ -1871,7 +1871,7 @@ static bool AirportFindFreeHelipad(Aircraft *v, const AirportFTAClass *apc)
while (temp != NULL) {
if (temp->heading == 255) {
- if (!(st->airport_flags & temp->block)) {
+ if (!(st->airport.flags & temp->block)) {
/* read which group do we want to go to?
* (the first free group) */
@@ -1974,7 +1974,7 @@ Station *GetTargetAirportIfValid(const Aircraft *v)
void UpdateAirplanesOnNewStation(const Station *st)
{
/* only 1 station is updated per function call, so it is enough to get entry_point once */
- const AirportFTAClass *ap = st->Airport();
+ const AirportFTAClass *ap = st->airport.GetFTA();
Aircraft *v;
FOR_ALL_AIRCRAFT(v) {
diff --git a/src/airport.cpp b/src/airport.cpp
index e84250282..d0b810a1d 100644
--- a/src/airport.cpp
+++ b/src/airport.cpp
@@ -391,7 +391,7 @@ const AirportFTAClass *GetAirport(const byte airport_type)
byte GetVehiclePosOnBuild(TileIndex hangar_tile)
{
const Station *st = Station::GetByTile(hangar_tile);
- const AirportFTAClass *apc = st->Airport();
+ const AirportFTAClass *apc = st->airport.GetFTA();
/* When we click on hangar we know the tile it is on. By that we know
* its position in the array of depots the airport has.....we can search
* layout for #th position of depot. Since layout must start with a listing
diff --git a/src/airport.h b/src/airport.h
index 1422d3886..2ab2e2c5f 100644
--- a/src/airport.h
+++ b/src/airport.h
@@ -180,7 +180,7 @@ DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags)
/** Internal structure used in openttd - Finite sTate mAchine --> FTA */
struct AirportFTA {
AirportFTA *next; ///< possible extra movement choices from this position
- uint64 block; ///< 64 bit blocks (st->airport_flags), should be enough for the most complex airports
+ uint64 block; ///< 64 bit blocks (st->airport.flags), should be enough for the most complex airports
byte position; ///< the position that an airplane is at
byte next_position; ///< next position from this position
byte heading; ///< heading (current orders), guiding an airplane to its target on an airport
diff --git a/src/disaster_cmd.cpp b/src/disaster_cmd.cpp
index d2f34f2cc..c4b00e458 100644
--- a/src/disaster_cmd.cpp
+++ b/src/disaster_cmd.cpp
@@ -234,7 +234,7 @@ static bool DisasterTick_Zeppeliner(DisasterVehicle *v)
if (IsValidTile(v->tile) && IsAirportTile(v->tile)) {
Station *st = Station::GetByTile(v->tile);
- CLRBITS(st->airport_flags, RUNWAY_IN_block);
+ CLRBITS(st->airport.flags, RUNWAY_IN_block);
AI::NewEvent(GetTileOwner(v->tile), new AIEventDisasterZeppelinerCleared(st->index));
}
@@ -271,7 +271,7 @@ static bool DisasterTick_Zeppeliner(DisasterVehicle *v)
}
if (IsValidTile(v->tile) && IsAirportTile(v->tile)) {
- SETBITS(Station::GetByTile(v->tile)->airport_flags, RUNWAY_IN_block);
+ SETBITS(Station::GetByTile(v->tile)->airport.flags, RUNWAY_IN_block);
}
return true;
@@ -680,7 +680,7 @@ static void Disaster_Zeppeliner_Init()
Station *st;
FOR_ALL_STATIONS(st) {
- if (st->airport.tile != INVALID_TILE && (st->airport_type == AT_SMALL || st->airport_type == AT_LARGE)) {
+ 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;
}
diff --git a/src/newgrf_airporttiles.cpp b/src/newgrf_airporttiles.cpp
index 881dd8e09..ec85c26fb 100644
--- a/src/newgrf_airporttiles.cpp
+++ b/src/newgrf_airporttiles.cpp
@@ -225,7 +225,7 @@ static void AirportTileResolver(ResolverObject *res, StationGfx gfx, TileIndex t
assert(st != NULL);
res->psa = NULL;
- res->u.airport.airport_id = st->airport_type;
+ res->u.airport.airport_id = st->airport.type;
res->u.airport.st = st;
res->u.airport.tile = tile;
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index 741d52a8d..e3852fe80 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -196,7 +196,7 @@ static byte MapAircraftMovementState(const Aircraft *v)
const Station *st = GetTargetAirportIfValid(v);
if (st == NULL) return AMS_TTDP_FLIGHT_TO_TOWER;
- const AirportFTAClass *afc = st->Airport();
+ const AirportFTAClass *afc = st->airport.GetFTA();
uint16 amdflag = afc->MovingData(v->pos)->flag;
switch (v->state) {
@@ -600,7 +600,7 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
const Station *st = GetTargetAirportIfValid(Aircraft::From(v));
if (st != NULL && st->airport.tile != INVALID_TILE) {
- airporttype = st->GetAirportSpec()->ttd_airport_type;
+ airporttype = st->airport.GetSpec()->ttd_airport_type;
}
return (altitude << 8) | airporttype;
diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp
index 8dafa629f..0f4973da4 100644
--- a/src/newgrf_station.cpp
+++ b/src/newgrf_station.cpp
@@ -524,11 +524,11 @@ uint32 Station::GetNewGRFVariable(const ResolverObject *object, byte variable, b
}
case 0x8A: return this->had_vehicle_of_type;
- case 0xF1: return (this->airport.tile != INVALID_TILE) ? this->GetAirportSpec()->ttd_airport_type : ATP_TTDP_LARGE;
+ case 0xF1: return (this->airport.tile != INVALID_TILE) ? this->airport.GetSpec()->ttd_airport_type : ATP_TTDP_LARGE;
case 0xF2: return (this->truck_stops != NULL) ? this->truck_stops->status : 0;
case 0xF3: return (this->bus_stops != NULL) ? this->bus_stops->status : 0;
- case 0xF6: return this->airport_flags;
- case 0xF7: return GB(this->airport_flags, 8, 8);
+ case 0xF6: return this->airport.flags;
+ case 0xF7: return GB(this->airport.flags, 8, 8);
}
/* Handle cargo variables with parameter, 0x60 to 0x65 */
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index bd84015d2..953a9d980 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -535,7 +535,7 @@ CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
- if (!CanVehicleUseStation(v, st) || st->GetAirportSpec()->nof_depots == 0) {
+ if (!CanVehicleUseStation(v, st) || st->airport.GetSpec()->nof_depots == 0) {
return CMD_ERROR;
}
} else {
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 15777af79..abe4013ee 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -594,8 +594,8 @@ bool AfterLoadGame()
if (CheckSavegameVersion(139)) {
Station *st;
FOR_ALL_STATIONS(st) {
- if (st->airport.tile != INVALID_TILE && st->airport_type == 15) {
- st->airport_type = AT_OILRIG;
+ if (st->airport.tile != INVALID_TILE && st->airport.type == 15) {
+ st->airport.type = AT_OILRIG;
}
}
}
@@ -734,7 +734,7 @@ bool AfterLoadGame()
* It was 3 (till 2.2) and later 5 (till 5.1).
* Setting it unconditionally does not hurt.
*/
- Station::GetByTile(t)->airport_type = AT_OILRIG;
+ Station::GetByTile(t)->airport.type = AT_OILRIG;
} else {
DeleteOilRig(t);
}
@@ -2095,8 +2095,8 @@ bool AfterLoadGame()
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;
+ st->airport.w = st->airport.GetSpec()->size_x;
+ st->airport.h = st->airport.GetSpec()->size_y;
}
}
}
diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp
index f745808c0..e6dc18660 100644
--- a/src/saveload/oldloader_sl.cpp
+++ b/src/saveload/oldloader_sl.cpp
@@ -732,11 +732,11 @@ static const OldChunks station_chunk[] = {
OCL_SVAR( OC_UINT8, Station, delete_ctr ),
OCL_SVAR( OC_UINT8, Station, owner ),
OCL_SVAR( OC_UINT8, Station, facilities ),
- OCL_SVAR( OC_TTD | OC_UINT8, Station, airport_type ),
- OCL_SVAR( OC_TTO | OC_FILE_U16 | OC_VAR_U64, Station, airport_flags ),
+ OCL_SVAR( OC_TTD | OC_UINT8, Station, airport.type ),
+ OCL_SVAR( OC_TTO | OC_FILE_U16 | OC_VAR_U64, Station, airport.flags ),
OCL_NULL( 3 ), ///< bus/truck status, blocked months, no longer in use
OCL_CNULL( OC_TTD, 1 ), ///< unknown
- OCL_SVAR( OC_TTD | OC_FILE_U16 | OC_VAR_U64, Station, airport_flags ),
+ OCL_SVAR( OC_TTD | OC_FILE_U16 | OC_VAR_U64, Station, airport.flags ),
OCL_CNULL( OC_TTD, 2 ), ///< last_vehicle. now last_vehicle_type
OCL_CNULL( OC_TTD, 4 ), ///< junk at end of chunk
@@ -760,12 +760,12 @@ static bool LoadOldStation(LoadgameState *ls, int num)
st->string_id = _old_string_id + 0x2800; // custom name
}
- if (HasBit(st->airport_flags, 8)) {
- st->airport_type = 1; // large airport
- } else if (HasBit(st->airport_flags, 6)) {
- st->airport_type = 3; // oil rig
+ if (HasBit(st->airport.flags, 8)) {
+ st->airport.type = 1; // large airport
+ } else if (HasBit(st->airport.flags, 6)) {
+ st->airport.type = 3; // oil rig
} else {
- st->airport_type = 0; // small airport
+ st->airport.type = 0; // small airport
}
} else {
st->string_id = RemapOldStringID(_old_string_id);
diff --git a/src/saveload/station_sl.cpp b/src/saveload/station_sl.cpp
index c705e2b61..a1f12ab44 100644
--- a/src/saveload/station_sl.cpp
+++ b/src/saveload/station_sl.cpp
@@ -172,14 +172,14 @@ static const SaveLoad _old_station_desc[] = {
SLE_VAR(Station, delete_ctr, SLE_UINT8),
SLE_VAR(Station, owner, SLE_UINT8),
SLE_VAR(Station, facilities, SLE_UINT8),
- SLE_VAR(Station, airport_type, SLE_UINT8),
+ SLE_VAR(Station, airport.type, SLE_UINT8),
SLE_CONDNULL(2, 0, 5), ///< Truck/bus stop status
SLE_CONDNULL(1, 0, 4), ///< Blocked months
- SLE_CONDVAR(Station, airport_flags, SLE_VAR_U64 | SLE_FILE_U16, 0, 2),
- SLE_CONDVAR(Station, airport_flags, SLE_VAR_U64 | SLE_FILE_U32, 3, 45),
- SLE_CONDVAR(Station, airport_flags, SLE_UINT64, 46, SL_MAX_VERSION),
+ SLE_CONDVAR(Station, airport.flags, SLE_VAR_U64 | SLE_FILE_U16, 0, 2),
+ SLE_CONDVAR(Station, airport.flags, SLE_VAR_U64 | SLE_FILE_U32, 3, 45),
+ SLE_CONDVAR(Station, airport.flags, SLE_UINT64, 46, SL_MAX_VERSION),
SLE_CONDNULL(2, 0, 25), ///< last-vehicle
SLE_CONDVAR(Station, last_vehicle_type, SLE_UINT8, 26, SL_MAX_VERSION),
@@ -334,8 +334,8 @@ static const SaveLoad _station_desc[] = {
SLE_VAR(Station, airport.tile, SLE_UINT32),
SLE_CONDVAR(Station, airport.w, SLE_FILE_U8 | SLE_VAR_U16, 140, SL_MAX_VERSION),
SLE_CONDVAR(Station, airport.h, SLE_FILE_U8 | SLE_VAR_U16, 140, SL_MAX_VERSION),
- SLE_VAR(Station, airport_type, SLE_UINT8),
- SLE_VAR(Station, airport_flags, SLE_UINT64),
+ SLE_VAR(Station, airport.type, SLE_UINT8),
+ SLE_VAR(Station, airport.flags, SLE_UINT64),
SLE_VAR(Station, indtype, SLE_UINT8),
diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp
index d3f3e44d7..e45e7114c 100644
--- a/src/saveload/vehicle_sl.cpp
+++ b/src/saveload/vehicle_sl.cpp
@@ -165,7 +165,7 @@ void UpdateOldAircraft()
/* set airport_flags to 0 for all airports just to be sure */
Station *st;
FOR_ALL_STATIONS(st) {
- st->airport_flags = 0; // reset airport
+ st->airport.flags = 0; // reset airport
}
Aircraft *a;
diff --git a/src/station.cpp b/src/station.cpp
index 320d6412a..0dcc6daa0 100644
--- a/src/station.cpp
+++ b/src/station.cpp
@@ -40,7 +40,6 @@ Station::Station(TileIndex tile) :
SpecializedStation<Station, false>(tile),
bus_station(INVALID_TILE, 0, 0),
truck_station(INVALID_TILE, 0, 0),
- airport(INVALID_TILE, 0, 0),
dock_tile(INVALID_TILE),
indtype(IT_INVALID),
time_since_load(255),
@@ -223,7 +222,7 @@ uint Station::GetCatchmentRadius() const
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->airport.GetSpec()->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) {
ret = CA_UNMODIFIED;
diff --git a/src/station_base.h b/src/station_base.h
index e3aa8b726..bee8c6986 100644
--- a/src/station_base.h
+++ b/src/station_base.h
@@ -45,6 +45,25 @@ struct GoodsEntry {
StationCargoList cargo; ///< The cargo packets of cargo waiting in this station
};
+/** All airport-related information. Only valid if tile != INVALID_TILE. */
+struct Airport : public TileArea {
+ Airport() : TileArea(INVALID_TILE, 0, 0) {}
+
+ uint64 flags; ///< stores which blocks on the airport are taken. was 16 bit earlier on, then 32
+ byte type;
+
+ const AirportSpec *GetSpec() const
+ {
+ if (this->tile == INVALID_TILE) return &AirportSpec::dummy;
+ return AirportSpec::Get(this->type);
+ }
+
+ const AirportFTAClass *GetFTA() const
+ {
+ if (this->tile == INVALID_TILE) return GetAirport(AT_DUMMY);
+ return this->GetSpec()->fsm;
+ }
+};
typedef SmallVector<Industry *, 2> IndustryVector;
@@ -58,24 +77,12 @@ public:
RoadStop *GetPrimaryRoadStop(const struct RoadVehicle *v) const;
- const AirportFTAClass *Airport() const
- {
- 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;
- 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
- TileArea airport; ///< Tile area the airport covers
+ Airport airport; ///< Tile area the airport covers
TileIndex dock_tile; ///< The location of the dock
IndustryType indtype; ///< Industry type to get the name from
@@ -84,9 +91,6 @@ public:
byte time_since_load;
byte time_since_unload;
- byte airport_type;
-
- uint64 airport_flags; ///< stores which blocks on the airport are taken. was 16 bit earlier on, then 32
byte last_vehicle_type;
std::list<Vehicle *> loading_vehicles;
@@ -130,8 +134,8 @@ public:
FORCEINLINE TileIndex GetHangarTile(uint hangar_num) const
{
assert(this->airport.tile != INVALID_TILE);
- assert(hangar_num < this->GetAirportSpec()->nof_depots);
- return this->airport.tile + ToTileIndexDiff(this->GetAirportSpec()->depot_table[hangar_num]);
+ assert(hangar_num < this->airport.GetSpec()->nof_depots);
+ return this->airport.tile + ToTileIndexDiff(this->airport.GetSpec()->depot_table[hangar_num]);
}
/* virtual */ uint32 GetNewGRFVariable(const ResolverObject *object, byte variable, byte parameter, bool *available) const;
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 6006a9420..99f7e7fd6 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -66,7 +66,7 @@ bool IsHangar(TileIndex t)
if (!IsAirport(t)) return false;
const Station *st = Station::GetByTile(t);
- const AirportSpec *as = st->GetAirportSpec();
+ const AirportSpec *as = st->airport.GetSpec();
for (uint i = 0; i < as->nof_depots; i++) {
if (st->GetHangarTile(i) == t) return true;
@@ -413,7 +413,7 @@ void Station::UpdateVirtCoord()
Point pt = RemapCoords2(TileX(this->xy) * TILE_SIZE, TileY(this->xy) * TILE_SIZE);
pt.y -= 32;
- if ((this->facilities & FACIL_AIRPORT) && this->airport_type == AT_OILRIG) pt.y -= 16;
+ if ((this->facilities & FACIL_AIRPORT) && this->airport.type == AT_OILRIG) pt.y -= 16;
SetDParam(0, this->index);
SetDParam(1, this->facilities);
@@ -2074,7 +2074,7 @@ void UpdateAirportsNoise()
FOR_ALL_STATIONS(st) {
if (st->airport.tile != INVALID_TILE) {
- const AirportSpec *as = st->GetAirportSpec();
+ const AirportSpec *as = st->airport.GetSpec();
Town *nearest = AirportGetNearestTown(as, st->airport.tile);
nearest->noise_reached += GetAirportNoiseLevelForTown(as, nearest->xy, st->airport.tile);
}
@@ -2142,7 +2142,7 @@ CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
uint num = 0;
const Station *st;
FOR_ALL_STATIONS(st) {
- if (st->town == t && (st->facilities & FACIL_AIRPORT) && st->airport_type != AT_OILRIG) num++;
+ if (st->town == t && (st->facilities & FACIL_AIRPORT) && st->airport.type != AT_OILRIG) num++;
}
if (num >= 2) {
authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_AIRPORT;
@@ -2205,8 +2205,8 @@ CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
nearest->noise_reached += newnoise_level;
st->AddFacility(FACIL_AIRPORT, tile);
- st->airport_type = (byte)p1;
- st->airport_flags = 0;
+ st->airport.type = (byte)p1;
+ st->airport.flags = 0;
st->rect.BeforeAddRect(tile, w, h, StationRect::ADD_TRY);
@@ -2293,7 +2293,7 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags)
}
if (flags & DC_EXEC) {
- const AirportSpec *as = st->GetAirportSpec();
+ const AirportSpec *as = st->airport.GetSpec();
for (uint i = 0; i < as->nof_depots; ++i) {
DeleteWindowById(
WC_VEHICLE_DEPOT, st->GetHangarTile(i)
@@ -3375,7 +3375,7 @@ void BuildOilRig(TileIndex tile)
MakeOilrig(tile, st->index, GetWaterClass(tile));
st->owner = OWNER_NONE;
- st->airport_type = AT_OILRIG;
+ st->airport.type = AT_OILRIG;
st->airport.Add(tile);
st->dock_tile = tile;
st->facilities = FACIL_AIRPORT | FACIL_DOCK;
@@ -3406,7 +3406,7 @@ void DeleteOilRig(TileIndex tile)
st->dock_tile = INVALID_TILE;
st->airport.Clear();
st->facilities &= ~(FACIL_AIRPORT | FACIL_DOCK);
- st->airport_flags = 0;
+ st->airport.flags = 0;
st->rect.AfterRemoveTile(st, tile);
diff --git a/src/table/airport_movement.h b/src/table/airport_movement.h
index 426a04c9e..2bcd94536 100644
--- a/src/table/airport_movement.h
+++ b/src/table/airport_movement.h
@@ -18,7 +18,7 @@
struct AirportFTAbuildup {
byte position; // the position that an airplane is at
byte heading; // the current orders (eg. TAKEOFF, HANGAR, ENDLANDING, etc.)
- uint64 block; // the block this position is on on the airport (st->airport_flags)
+ uint64 block; // the block this position is on on the airport (st->airport.flags)
byte next; // next position from this position
};
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index c479939bf..a21a669af 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -480,7 +480,7 @@ public:
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;
+ 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;
}
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 0797ee131..bb48813a1 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -626,8 +626,8 @@ void Vehicle::PreDestructor()
Aircraft *a = Aircraft::From(this);
Station *st = GetTargetAirportIfValid(a);
if (st != NULL) {
- const AirportFTA *layout = st->Airport()->layout;
- CLRBITS(st->airport_flags, layout[a->previous_pos].block | layout[a->pos].block);
+ const AirportFTA *layout = st->airport.GetFTA()->layout;
+ CLRBITS(st->airport.flags, layout[a->previous_pos].block | layout[a->pos].block);
}
}
@@ -1874,7 +1874,7 @@ bool CanVehicleUseStation(EngineID engine_type, const Station *st)
case VEH_AIRCRAFT:
return (st->facilities & FACIL_AIRPORT) != 0 &&
- (st->Airport()->flags & (e->u.air.subtype & AIR_CTOL ? AirportFTAClass::AIRPLANES : AirportFTAClass::HELICOPTERS)) != 0;
+ (st->airport.GetFTA()->flags & (e->u.air.subtype & AIR_CTOL ? AirportFTAClass::AIRPLANES : AirportFTAClass::HELICOPTERS)) != 0;
default:
return false;
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index fecec0c86..dd472320b 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -739,7 +739,7 @@ static void FloodVehicles(TileIndex tile)
if (IsAirportTile(tile)) {
const Station *st = Station::GetByTile(tile);
- z = 1 + st->Airport()->delta_z;
+ z = 1 + st->airport.GetFTA()->delta_z;
TILE_AREA_LOOP(tile, st->airport) {
if (st->TileBelongsToAirport(tile)) FindVehicleOnPos(tile, &z, &FloodVehicleProc);
}
@@ -784,7 +784,7 @@ static void FloodVehicle(Vehicle *v)
* that station has a big z_offset for the aircraft. */
if (!IsAirportTile(v->tile) || GetTileMaxZ(v->tile) != 0) return;
const Station *st = Station::GetByTile(v->tile);
- const AirportFTAClass *airport = st->Airport();
+ const AirportFTAClass *airport = st->airport.GetFTA();
if (v->z_pos != airport->delta_z + 1) return;
} else {