mirror of https://github.com/OpenTTD/OpenTTD
(svn r19455) -Codechange: split all airport information in Station to a seperate class
parent
0eb5709c86
commit
c4a88ce022
|
@ -96,7 +96,7 @@
|
||||||
if (st->owner != _current_company) return -1;
|
if (st->owner != _current_company) return -1;
|
||||||
if ((st->facilities & FACIL_AIRPORT) == 0) 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)
|
/* static */ TileIndex AIAirport::GetHangarOfAirport(TileIndex tile)
|
||||||
|
@ -120,7 +120,7 @@
|
||||||
|
|
||||||
if (!AIStation::HasStationType(station_id, AIStation::STATION_AIRPORT)) return AT_INVALID;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ AIDepotList::AIDepotList(AITile::TransportType transport_type)
|
||||||
const Station *st;
|
const Station *st;
|
||||||
FOR_ALL_STATIONS(st) {
|
FOR_ALL_STATIONS(st) {
|
||||||
if (st->owner == ::_current_company) {
|
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++) {
|
for (uint i = 0; i < as->nof_depots; i++) {
|
||||||
this->AddItem(st->GetHangarTile(i));
|
this->AddItem(st->GetHangarTile(i));
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
if (v->type != VEH_AIRCRAFT) return ::Depot::Get(order->GetDestination())->xy;
|
||||||
/* Aircraft's hangars are referenced by StationID, not DepotID */
|
/* Aircraft's hangars are referenced by StationID, not DepotID */
|
||||||
const Station *st = ::Station::Get(order->GetDestination());
|
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);
|
return st->GetHangarTile(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -188,7 +188,7 @@
|
||||||
int num = 0;
|
int num = 0;
|
||||||
const Station *st;
|
const Station *st;
|
||||||
FOR_ALL_STATIONS(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);
|
return max(0, 2 - num);
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,8 +116,8 @@ static StationID FindNearestHangar(const Aircraft *v)
|
||||||
FOR_ALL_STATIONS(st) {
|
FOR_ALL_STATIONS(st) {
|
||||||
if (st->owner != v->owner || !(st->facilities & FACIL_AIRPORT)) continue;
|
if (st->owner != v->owner || !(st->facilities & FACIL_AIRPORT)) continue;
|
||||||
|
|
||||||
const AirportFTAClass *afc = st->Airport();
|
const AirportFTAClass *afc = st->airport.GetFTA();
|
||||||
const AirportSpec *as = st->GetAirportSpec();
|
const AirportSpec *as = st->airport.GetSpec();
|
||||||
if (as->nof_depots == 0 || (
|
if (as->nof_depots == 0 || (
|
||||||
/* don't crash the plane if we know it can't land at the airport */
|
/* don't crash the plane if we know it can't land at the airport */
|
||||||
(afc->flags & AirportFTAClass::SHORT_STRIP) &&
|
(afc->flags & AirportFTAClass::SHORT_STRIP) &&
|
||||||
|
@ -415,7 +415,7 @@ bool Aircraft::FindClosestDepot(TileIndex *location, DestinationID *destination,
|
||||||
{
|
{
|
||||||
const Station *st = GetTargetAirportIfValid(this);
|
const Station *st = GetTargetAirportIfValid(this);
|
||||||
/* If the station is not a valid airport or if it has no hangars */
|
/* 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 */
|
/* the aircraft has to search for a hangar on its own */
|
||||||
StationID station = FindNearestHangar(this);
|
StationID station = FindNearestHangar(this);
|
||||||
|
|
||||||
|
@ -515,7 +515,7 @@ static void CheckIfAircraftNeedsService(Aircraft *v)
|
||||||
assert(st != NULL);
|
assert(st != NULL);
|
||||||
|
|
||||||
/* only goto depot if the target airport has a depot */
|
/* 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);
|
v->current_order.MakeGoToDepot(st->index, ODTFB_SERVICE);
|
||||||
SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
|
SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
|
||||||
} else if (v->current_order.IsType(OT_GOTO_DEPOT)) {
|
} 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;
|
tile = (st->airport.tile != INVALID_TILE) ? st->airport.tile : st->xy;
|
||||||
}
|
}
|
||||||
/* DUMMY if there is no station or no airport */
|
/* 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. */
|
/* 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) {
|
||||||
|
@ -989,7 +989,7 @@ static bool AircraftController(Aircraft *v)
|
||||||
v->y_pos;
|
v->y_pos;
|
||||||
|
|
||||||
/* Oilrigs must keep v->tile as st->airport.tile, since the landing pad is in a non-airport tile */
|
/* 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 {
|
} else {
|
||||||
|
|
||||||
|
@ -1125,9 +1125,9 @@ static bool HandleCrashedAircraft(Aircraft *v)
|
||||||
* small airports use AIRPORT_BUSY, city airports use RUNWAY_IN_OUT_block, etc.
|
* small airports use AIRPORT_BUSY, city airports use RUNWAY_IN_OUT_block, etc.
|
||||||
* but they all share the same number */
|
* but they all share the same number */
|
||||||
if (st != NULL) {
|
if (st != NULL) {
|
||||||
CLRBITS(st->airport_flags, RUNWAY_IN_block);
|
CLRBITS(st->airport.flags, RUNWAY_IN_block);
|
||||||
CLRBITS(st->airport_flags, RUNWAY_IN_OUT_block); // commuter airport
|
CLRBITS(st->airport.flags, RUNWAY_IN_OUT_block); // commuter airport
|
||||||
CLRBITS(st->airport_flags, RUNWAY_IN2_block); // intercontinental
|
CLRBITS(st->airport.flags, RUNWAY_IN2_block); // intercontinental
|
||||||
}
|
}
|
||||||
|
|
||||||
delete v;
|
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 */
|
/* FIXME -- MaybeCrashAirplane -> increase crashing chances of very modern airplanes on smaller than AT_METROPOLITAN airports */
|
||||||
uint32 prob = (0x4000 << _settings_game.vehicle.plane_crashes);
|
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) &&
|
(AircraftVehInfo(v->engine_type)->subtype & AIR_FAST) &&
|
||||||
!_cheats.no_jetcrash.value) {
|
!_cheats.no_jetcrash.value) {
|
||||||
prob /= 20;
|
prob /= 20;
|
||||||
|
@ -1343,7 +1343,7 @@ void AircraftNextAirportPos_and_Order(Aircraft *v)
|
||||||
}
|
}
|
||||||
|
|
||||||
const Station *st = GetTargetAirportIfValid(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);
|
v->pos = v->previous_pos = AircraftGetEntryPoint(v, apc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1468,7 +1468,7 @@ static void AircraftEventHandler_AtTerminal(Aircraft *v, const AirportFTAClass *
|
||||||
return;
|
return;
|
||||||
default: // orders have been deleted (no orders), goto depot and don't bother us
|
default: // orders have been deleted (no orders), goto depot and don't bother us
|
||||||
v->current_order.Free();
|
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) {
|
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
|
* if there are multiple runways, plane won't know which one it took (because
|
||||||
* they all have heading LANDING). And also occupy that block! */
|
* they all have heading LANDING). And also occupy that block! */
|
||||||
v->pos = current->next_position;
|
v->pos = current->next_position;
|
||||||
SETBITS(st->airport_flags, apc->layout[v->pos].block);
|
SETBITS(st->airport.flags, apc->layout[v->pos].block);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
v->cur_speed = tcur_speed;
|
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 (v->current_order.IsType(OT_GOTO_STATION)) {
|
||||||
if (AirportFindFreeHelipad(v, apc)) return;
|
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;
|
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) {
|
if (apc->layout[v->previous_pos].block != apc->layout[v->pos].block) {
|
||||||
Station *st = Station::Get(v->targetairport);
|
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 aircraft is not in position, wait until it is */
|
||||||
if (!AircraftController(v)) return;
|
if (!AircraftController(v)) return;
|
||||||
|
|
||||||
const AirportFTAClass *apc = Station::Get(v->targetairport)->Airport();
|
const AirportFTAClass *apc = Station::Get(v->targetairport)->airport.GetFTA();
|
||||||
|
|
||||||
AirportClearBlock(v, apc);
|
AirportClearBlock(v, apc);
|
||||||
AirportMove(v, apc); // move aircraft to next position
|
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;
|
airport_flags |= current_pos->block;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (st->airport_flags & airport_flags) {
|
if (st->airport.flags & airport_flags) {
|
||||||
v->cur_speed = 0;
|
v->cur_speed = 0;
|
||||||
v->subspeed = 0;
|
v->subspeed = 0;
|
||||||
return true;
|
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;
|
if (current_pos->block == next->block) airport_flags ^= next->block;
|
||||||
|
|
||||||
Station *st = Station::Get(v->targetairport);
|
Station *st = Station::Get(v->targetairport);
|
||||||
if (st->airport_flags & airport_flags) {
|
if (st->airport.flags & airport_flags) {
|
||||||
v->cur_speed = 0;
|
v->cur_speed = 0;
|
||||||
v->subspeed = 0;
|
v->subspeed = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (next->block != NOTHING_block) {
|
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;
|
return true;
|
||||||
|
@ -1783,10 +1783,10 @@ static bool FreeTerminal(Aircraft *v, byte i, byte last_terminal)
|
||||||
{
|
{
|
||||||
Station *st = Station::Get(v->targetairport);
|
Station *st = Station::Get(v->targetairport);
|
||||||
for (; i < last_terminal; i++) {
|
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# */
|
/* TERMINAL# HELIPAD# */
|
||||||
v->state = _airport_terminal_state[i]; // start moving to that 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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1820,7 +1820,7 @@ static bool AirportFindFreeTerminal(Aircraft *v, const AirportFTAClass *apc)
|
||||||
|
|
||||||
while (temp != NULL) {
|
while (temp != NULL) {
|
||||||
if (temp->heading == 255) {
|
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?
|
/* read which group do we want to go to?
|
||||||
* (the first free group) */
|
* (the first free group) */
|
||||||
uint target_group = temp->next_position + 1;
|
uint target_group = temp->next_position + 1;
|
||||||
|
@ -1871,7 +1871,7 @@ static bool AirportFindFreeHelipad(Aircraft *v, const AirportFTAClass *apc)
|
||||||
|
|
||||||
while (temp != NULL) {
|
while (temp != NULL) {
|
||||||
if (temp->heading == 255) {
|
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?
|
/* read which group do we want to go to?
|
||||||
* (the first free group) */
|
* (the first free group) */
|
||||||
|
@ -1974,7 +1974,7 @@ Station *GetTargetAirportIfValid(const Aircraft *v)
|
||||||
void UpdateAirplanesOnNewStation(const Station *st)
|
void UpdateAirplanesOnNewStation(const Station *st)
|
||||||
{
|
{
|
||||||
/* only 1 station is updated per function call, so it is enough to get entry_point once */
|
/* 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;
|
Aircraft *v;
|
||||||
FOR_ALL_AIRCRAFT(v) {
|
FOR_ALL_AIRCRAFT(v) {
|
||||||
|
|
|
@ -391,7 +391,7 @@ const AirportFTAClass *GetAirport(const byte airport_type)
|
||||||
byte GetVehiclePosOnBuild(TileIndex hangar_tile)
|
byte GetVehiclePosOnBuild(TileIndex hangar_tile)
|
||||||
{
|
{
|
||||||
const Station *st = Station::GetByTile(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
|
/* 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
|
* 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
|
* layout for #th position of depot. Since layout must start with a listing
|
||||||
|
|
|
@ -180,7 +180,7 @@ DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags)
|
||||||
/** Internal structure used in openttd - Finite sTate mAchine --> FTA */
|
/** Internal structure used in openttd - Finite sTate mAchine --> FTA */
|
||||||
struct AirportFTA {
|
struct AirportFTA {
|
||||||
AirportFTA *next; ///< possible extra movement choices from this position
|
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 position; ///< the position that an airplane is at
|
||||||
byte next_position; ///< next position from this position
|
byte next_position; ///< next position from this position
|
||||||
byte heading; ///< heading (current orders), guiding an airplane to its target on an airport
|
byte heading; ///< heading (current orders), guiding an airplane to its target on an airport
|
||||||
|
|
|
@ -234,7 +234,7 @@ static bool DisasterTick_Zeppeliner(DisasterVehicle *v)
|
||||||
|
|
||||||
if (IsValidTile(v->tile) && IsAirportTile(v->tile)) {
|
if (IsValidTile(v->tile) && IsAirportTile(v->tile)) {
|
||||||
Station *st = Station::GetByTile(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));
|
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)) {
|
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;
|
return true;
|
||||||
|
@ -680,7 +680,7 @@ static void Disaster_Zeppeliner_Init()
|
||||||
|
|
||||||
Station *st;
|
Station *st;
|
||||||
FOR_ALL_STATIONS(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;
|
x = (TileX(st->airport.tile) + 2) * TILE_SIZE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,7 +225,7 @@ static void AirportTileResolver(ResolverObject *res, StationGfx gfx, TileIndex t
|
||||||
|
|
||||||
assert(st != NULL);
|
assert(st != NULL);
|
||||||
res->psa = 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.st = st;
|
||||||
res->u.airport.tile = tile;
|
res->u.airport.tile = tile;
|
||||||
|
|
||||||
|
|
|
@ -196,7 +196,7 @@ static byte MapAircraftMovementState(const Aircraft *v)
|
||||||
const Station *st = GetTargetAirportIfValid(v);
|
const Station *st = GetTargetAirportIfValid(v);
|
||||||
if (st == NULL) return AMS_TTDP_FLIGHT_TO_TOWER;
|
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;
|
uint16 amdflag = afc->MovingData(v->pos)->flag;
|
||||||
|
|
||||||
switch (v->state) {
|
switch (v->state) {
|
||||||
|
@ -600,7 +600,7 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
|
||||||
const Station *st = GetTargetAirportIfValid(Aircraft::From(v));
|
const Station *st = GetTargetAirportIfValid(Aircraft::From(v));
|
||||||
|
|
||||||
if (st != NULL && st->airport.tile != INVALID_TILE) {
|
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;
|
return (altitude << 8) | airporttype;
|
||||||
|
|
|
@ -524,11 +524,11 @@ uint32 Station::GetNewGRFVariable(const ResolverObject *object, byte variable, b
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x8A: return this->had_vehicle_of_type;
|
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 0xF2: return (this->truck_stops != NULL) ? this->truck_stops->status : 0;
|
||||||
case 0xF3: return (this->bus_stops != NULL) ? this->bus_stops->status : 0;
|
case 0xF3: return (this->bus_stops != NULL) ? this->bus_stops->status : 0;
|
||||||
case 0xF6: return this->airport_flags;
|
case 0xF6: return this->airport.flags;
|
||||||
case 0xF7: return GB(this->airport_flags, 8, 8);
|
case 0xF7: return GB(this->airport.flags, 8, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle cargo variables with parameter, 0x60 to 0x65 */
|
/* Handle cargo variables with parameter, 0x60 to 0x65 */
|
||||||
|
|
|
@ -535,7 +535,7 @@ CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||||
ret.SetGlobalErrorMessage();
|
ret.SetGlobalErrorMessage();
|
||||||
if (ret.Failed()) return ret;
|
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;
|
return CMD_ERROR;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -594,8 +594,8 @@ bool AfterLoadGame()
|
||||||
if (CheckSavegameVersion(139)) {
|
if (CheckSavegameVersion(139)) {
|
||||||
Station *st;
|
Station *st;
|
||||||
FOR_ALL_STATIONS(st) {
|
FOR_ALL_STATIONS(st) {
|
||||||
if (st->airport.tile != INVALID_TILE && st->airport_type == 15) {
|
if (st->airport.tile != INVALID_TILE && st->airport.type == 15) {
|
||||||
st->airport_type = AT_OILRIG;
|
st->airport.type = AT_OILRIG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -734,7 +734,7 @@ bool AfterLoadGame()
|
||||||
* It was 3 (till 2.2) and later 5 (till 5.1).
|
* It was 3 (till 2.2) and later 5 (till 5.1).
|
||||||
* Setting it unconditionally does not hurt.
|
* Setting it unconditionally does not hurt.
|
||||||
*/
|
*/
|
||||||
Station::GetByTile(t)->airport_type = AT_OILRIG;
|
Station::GetByTile(t)->airport.type = AT_OILRIG;
|
||||||
} else {
|
} else {
|
||||||
DeleteOilRig(t);
|
DeleteOilRig(t);
|
||||||
}
|
}
|
||||||
|
@ -2095,8 +2095,8 @@ bool AfterLoadGame()
|
||||||
Station *st;
|
Station *st;
|
||||||
FOR_ALL_STATIONS(st) {
|
FOR_ALL_STATIONS(st) {
|
||||||
if (st->airport.tile != INVALID_TILE) {
|
if (st->airport.tile != INVALID_TILE) {
|
||||||
st->airport.w = st->GetAirportSpec()->size_x;
|
st->airport.w = st->airport.GetSpec()->size_x;
|
||||||
st->airport.h = st->GetAirportSpec()->size_y;
|
st->airport.h = st->airport.GetSpec()->size_y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -732,11 +732,11 @@ static const OldChunks station_chunk[] = {
|
||||||
OCL_SVAR( OC_UINT8, Station, delete_ctr ),
|
OCL_SVAR( OC_UINT8, Station, delete_ctr ),
|
||||||
OCL_SVAR( OC_UINT8, Station, owner ),
|
OCL_SVAR( OC_UINT8, Station, owner ),
|
||||||
OCL_SVAR( OC_UINT8, Station, facilities ),
|
OCL_SVAR( OC_UINT8, Station, facilities ),
|
||||||
OCL_SVAR( OC_TTD | OC_UINT8, Station, airport_type ),
|
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_TTO | OC_FILE_U16 | OC_VAR_U64, Station, airport.flags ),
|
||||||
OCL_NULL( 3 ), ///< bus/truck status, blocked months, no longer in use
|
OCL_NULL( 3 ), ///< bus/truck status, blocked months, no longer in use
|
||||||
OCL_CNULL( OC_TTD, 1 ), ///< unknown
|
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, 2 ), ///< last_vehicle. now last_vehicle_type
|
||||||
OCL_CNULL( OC_TTD, 4 ), ///< junk at end of chunk
|
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
|
st->string_id = _old_string_id + 0x2800; // custom name
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HasBit(st->airport_flags, 8)) {
|
if (HasBit(st->airport.flags, 8)) {
|
||||||
st->airport_type = 1; // large airport
|
st->airport.type = 1; // large airport
|
||||||
} else if (HasBit(st->airport_flags, 6)) {
|
} else if (HasBit(st->airport.flags, 6)) {
|
||||||
st->airport_type = 3; // oil rig
|
st->airport.type = 3; // oil rig
|
||||||
} else {
|
} else {
|
||||||
st->airport_type = 0; // small airport
|
st->airport.type = 0; // small airport
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
st->string_id = RemapOldStringID(_old_string_id);
|
st->string_id = RemapOldStringID(_old_string_id);
|
||||||
|
|
|
@ -172,14 +172,14 @@ static const SaveLoad _old_station_desc[] = {
|
||||||
SLE_VAR(Station, delete_ctr, SLE_UINT8),
|
SLE_VAR(Station, delete_ctr, SLE_UINT8),
|
||||||
SLE_VAR(Station, owner, SLE_UINT8),
|
SLE_VAR(Station, owner, SLE_UINT8),
|
||||||
SLE_VAR(Station, facilities, 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(2, 0, 5), ///< Truck/bus stop status
|
||||||
SLE_CONDNULL(1, 0, 4), ///< Blocked months
|
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_U16, 0, 2),
|
||||||
SLE_CONDVAR(Station, airport_flags, SLE_VAR_U64 | SLE_FILE_U32, 3, 45),
|
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_UINT64, 46, SL_MAX_VERSION),
|
||||||
|
|
||||||
SLE_CONDNULL(2, 0, 25), ///< last-vehicle
|
SLE_CONDNULL(2, 0, 25), ///< last-vehicle
|
||||||
SLE_CONDVAR(Station, last_vehicle_type, SLE_UINT8, 26, SL_MAX_VERSION),
|
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_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.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_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.type, SLE_UINT8),
|
||||||
SLE_VAR(Station, airport_flags, SLE_UINT64),
|
SLE_VAR(Station, airport.flags, SLE_UINT64),
|
||||||
|
|
||||||
SLE_VAR(Station, indtype, SLE_UINT8),
|
SLE_VAR(Station, indtype, SLE_UINT8),
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,7 @@ void UpdateOldAircraft()
|
||||||
/* set airport_flags to 0 for all airports just to be sure */
|
/* set airport_flags to 0 for all airports just to be sure */
|
||||||
Station *st;
|
Station *st;
|
||||||
FOR_ALL_STATIONS(st) {
|
FOR_ALL_STATIONS(st) {
|
||||||
st->airport_flags = 0; // reset airport
|
st->airport.flags = 0; // reset airport
|
||||||
}
|
}
|
||||||
|
|
||||||
Aircraft *a;
|
Aircraft *a;
|
||||||
|
|
|
@ -40,7 +40,6 @@ Station::Station(TileIndex tile) :
|
||||||
SpecializedStation<Station, false>(tile),
|
SpecializedStation<Station, false>(tile),
|
||||||
bus_station(INVALID_TILE, 0, 0),
|
bus_station(INVALID_TILE, 0, 0),
|
||||||
truck_station(INVALID_TILE, 0, 0),
|
truck_station(INVALID_TILE, 0, 0),
|
||||||
airport(INVALID_TILE, 0, 0),
|
|
||||||
dock_tile(INVALID_TILE),
|
dock_tile(INVALID_TILE),
|
||||||
indtype(IT_INVALID),
|
indtype(IT_INVALID),
|
||||||
time_since_load(255),
|
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->truck_stops != NULL) ret = max<uint>(ret, CA_TRUCK);
|
||||||
if (this->train_station.tile != INVALID_TILE) ret = max<uint>(ret, CA_TRAIN);
|
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->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 {
|
} 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;
|
ret = CA_UNMODIFIED;
|
||||||
|
|
|
@ -45,6 +45,25 @@ struct GoodsEntry {
|
||||||
StationCargoList cargo; ///< The cargo packets of cargo waiting in this station
|
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;
|
typedef SmallVector<Industry *, 2> IndustryVector;
|
||||||
|
|
||||||
|
@ -58,24 +77,12 @@ public:
|
||||||
|
|
||||||
RoadStop *GetPrimaryRoadStop(const struct RoadVehicle *v) const;
|
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
|
RoadStop *bus_stops; ///< All the road stops
|
||||||
TileArea bus_station; ///< Tile area the bus 'station' part covers
|
TileArea bus_station; ///< Tile area the bus 'station' part covers
|
||||||
RoadStop *truck_stops; ///< All the truck stops
|
RoadStop *truck_stops; ///< All the truck stops
|
||||||
TileArea truck_station; ///< Tile area the truck 'station' part covers
|
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
|
TileIndex dock_tile; ///< The location of the dock
|
||||||
|
|
||||||
IndustryType indtype; ///< Industry type to get the name from
|
IndustryType indtype; ///< Industry type to get the name from
|
||||||
|
@ -84,9 +91,6 @@ public:
|
||||||
|
|
||||||
byte time_since_load;
|
byte time_since_load;
|
||||||
byte time_since_unload;
|
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;
|
byte last_vehicle_type;
|
||||||
std::list<Vehicle *> loading_vehicles;
|
std::list<Vehicle *> loading_vehicles;
|
||||||
|
@ -130,8 +134,8 @@ public:
|
||||||
FORCEINLINE TileIndex GetHangarTile(uint hangar_num) const
|
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);
|
assert(hangar_num < this->airport.GetSpec()->nof_depots);
|
||||||
return this->airport.tile + ToTileIndexDiff(this->GetAirportSpec()->depot_table[hangar_num]);
|
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;
|
/* virtual */ uint32 GetNewGRFVariable(const ResolverObject *object, byte variable, byte parameter, bool *available) const;
|
||||||
|
|
|
@ -66,7 +66,7 @@ bool IsHangar(TileIndex t)
|
||||||
if (!IsAirport(t)) return false;
|
if (!IsAirport(t)) return false;
|
||||||
|
|
||||||
const Station *st = Station::GetByTile(t);
|
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++) {
|
for (uint i = 0; i < as->nof_depots; i++) {
|
||||||
if (st->GetHangarTile(i) == t) return true;
|
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);
|
Point pt = RemapCoords2(TileX(this->xy) * TILE_SIZE, TileY(this->xy) * TILE_SIZE);
|
||||||
|
|
||||||
pt.y -= 32;
|
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(0, this->index);
|
||||||
SetDParam(1, this->facilities);
|
SetDParam(1, this->facilities);
|
||||||
|
@ -2074,7 +2074,7 @@ void UpdateAirportsNoise()
|
||||||
|
|
||||||
FOR_ALL_STATIONS(st) {
|
FOR_ALL_STATIONS(st) {
|
||||||
if (st->airport.tile != INVALID_TILE) {
|
if (st->airport.tile != INVALID_TILE) {
|
||||||
const AirportSpec *as = st->GetAirportSpec();
|
const AirportSpec *as = st->airport.GetSpec();
|
||||||
Town *nearest = AirportGetNearestTown(as, st->airport.tile);
|
Town *nearest = AirportGetNearestTown(as, st->airport.tile);
|
||||||
nearest->noise_reached += GetAirportNoiseLevelForTown(as, nearest->xy, 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;
|
uint num = 0;
|
||||||
const Station *st;
|
const Station *st;
|
||||||
FOR_ALL_STATIONS(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) {
|
if (num >= 2) {
|
||||||
authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_AIRPORT;
|
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;
|
nearest->noise_reached += newnoise_level;
|
||||||
|
|
||||||
st->AddFacility(FACIL_AIRPORT, tile);
|
st->AddFacility(FACIL_AIRPORT, tile);
|
||||||
st->airport_type = (byte)p1;
|
st->airport.type = (byte)p1;
|
||||||
st->airport_flags = 0;
|
st->airport.flags = 0;
|
||||||
|
|
||||||
st->rect.BeforeAddRect(tile, w, h, StationRect::ADD_TRY);
|
st->rect.BeforeAddRect(tile, w, h, StationRect::ADD_TRY);
|
||||||
|
|
||||||
|
@ -2293,7 +2293,7 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
const AirportSpec *as = st->GetAirportSpec();
|
const AirportSpec *as = st->airport.GetSpec();
|
||||||
for (uint i = 0; i < as->nof_depots; ++i) {
|
for (uint i = 0; i < as->nof_depots; ++i) {
|
||||||
DeleteWindowById(
|
DeleteWindowById(
|
||||||
WC_VEHICLE_DEPOT, st->GetHangarTile(i)
|
WC_VEHICLE_DEPOT, st->GetHangarTile(i)
|
||||||
|
@ -3375,7 +3375,7 @@ void BuildOilRig(TileIndex tile)
|
||||||
MakeOilrig(tile, st->index, GetWaterClass(tile));
|
MakeOilrig(tile, st->index, GetWaterClass(tile));
|
||||||
|
|
||||||
st->owner = OWNER_NONE;
|
st->owner = OWNER_NONE;
|
||||||
st->airport_type = AT_OILRIG;
|
st->airport.type = AT_OILRIG;
|
||||||
st->airport.Add(tile);
|
st->airport.Add(tile);
|
||||||
st->dock_tile = tile;
|
st->dock_tile = tile;
|
||||||
st->facilities = FACIL_AIRPORT | FACIL_DOCK;
|
st->facilities = FACIL_AIRPORT | FACIL_DOCK;
|
||||||
|
@ -3406,7 +3406,7 @@ void DeleteOilRig(TileIndex tile)
|
||||||
st->dock_tile = INVALID_TILE;
|
st->dock_tile = INVALID_TILE;
|
||||||
st->airport.Clear();
|
st->airport.Clear();
|
||||||
st->facilities &= ~(FACIL_AIRPORT | FACIL_DOCK);
|
st->facilities &= ~(FACIL_AIRPORT | FACIL_DOCK);
|
||||||
st->airport_flags = 0;
|
st->airport.flags = 0;
|
||||||
|
|
||||||
st->rect.AfterRemoveTile(st, tile);
|
st->rect.AfterRemoveTile(st, tile);
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
struct AirportFTAbuildup {
|
struct AirportFTAbuildup {
|
||||||
byte position; // the position that an airplane is at
|
byte position; // the position that an airplane is at
|
||||||
byte heading; // the current orders (eg. TAKEOFF, HANGAR, ENDLANDING, etc.)
|
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
|
byte next; // next position from this position
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -480,7 +480,7 @@ public:
|
||||||
FOR_ALL_STATIONS(st) {
|
FOR_ALL_STATIONS(st) {
|
||||||
if (st->town == this->town) {
|
if (st->town == this->town) {
|
||||||
/* Non-oil rig stations are always a problem. */
|
/* 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. */
|
/* 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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -626,8 +626,8 @@ void Vehicle::PreDestructor()
|
||||||
Aircraft *a = Aircraft::From(this);
|
Aircraft *a = Aircraft::From(this);
|
||||||
Station *st = GetTargetAirportIfValid(a);
|
Station *st = GetTargetAirportIfValid(a);
|
||||||
if (st != NULL) {
|
if (st != NULL) {
|
||||||
const AirportFTA *layout = st->Airport()->layout;
|
const AirportFTA *layout = st->airport.GetFTA()->layout;
|
||||||
CLRBITS(st->airport_flags, layout[a->previous_pos].block | layout[a->pos].block);
|
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:
|
case VEH_AIRCRAFT:
|
||||||
return (st->facilities & FACIL_AIRPORT) != 0 &&
|
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:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -739,7 +739,7 @@ static void FloodVehicles(TileIndex tile)
|
||||||
|
|
||||||
if (IsAirportTile(tile)) {
|
if (IsAirportTile(tile)) {
|
||||||
const Station *st = Station::GetByTile(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) {
|
TILE_AREA_LOOP(tile, st->airport) {
|
||||||
if (st->TileBelongsToAirport(tile)) FindVehicleOnPos(tile, &z, &FloodVehicleProc);
|
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. */
|
* that station has a big z_offset for the aircraft. */
|
||||||
if (!IsAirportTile(v->tile) || GetTileMaxZ(v->tile) != 0) return;
|
if (!IsAirportTile(v->tile) || GetTileMaxZ(v->tile) != 0) return;
|
||||||
const Station *st = Station::GetByTile(v->tile);
|
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;
|
if (v->z_pos != airport->delta_z + 1) return;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue