mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-07 06:46:43 +00:00
(svn r8755) -Fix
Abbreviate GetAirport(st->airport_type) to st->Airport()
This commit is contained in:
parent
6c17cd4c46
commit
87e03c7aa8
@ -3267,7 +3267,7 @@ static void AiStateAirportStuff(Player *p)
|
|||||||
// Do we own the airport? (Oilrigs aren't owned, though.)
|
// Do we own the airport? (Oilrigs aren't owned, though.)
|
||||||
if (st->owner != OWNER_NONE && st->owner != _current_player) continue;
|
if (st->owner != OWNER_NONE && st->owner != _current_player) continue;
|
||||||
|
|
||||||
AirportFTAClass::Flags flags = GetAirport(st->airport_type)->flags;
|
AirportFTAClass::Flags flags = st->Airport()->flags;
|
||||||
|
|
||||||
if (!(flags & (p->ai.build_kind == 1 && i == 0 ? AirportFTAClass::HELICOPTERS : AirportFTAClass::AIRPLANES))) {
|
if (!(flags & (p->ai.build_kind == 1 && i == 0 ? AirportFTAClass::HELICOPTERS : AirportFTAClass::AIRPLANES))) {
|
||||||
continue;
|
continue;
|
||||||
@ -3469,7 +3469,7 @@ static void AiStateBuildAircraftVehicles(Player *p)
|
|||||||
|
|
||||||
/* XXX - Have the AI pick the hangar terminal in an airport. Eg get airport-type
|
/* XXX - Have the AI pick the hangar terminal in an airport. Eg get airport-type
|
||||||
* and offset to the FIRST depot because the AI picks the st->xy tile */
|
* and offset to the FIRST depot because the AI picks the st->xy tile */
|
||||||
tile += ToTileIndexDiff(GetAirport(GetStationByTile(tile)->airport_type)->airport_depots[0]);
|
tile += ToTileIndexDiff(GetStationByTile(tile)->Airport()->airport_depots[0]);
|
||||||
if (CmdFailed(DoCommand(tile, veh, 0, DC_EXEC, CMD_BUILD_AIRCRAFT))) return;
|
if (CmdFailed(DoCommand(tile, veh, 0, DC_EXEC, CMD_BUILD_AIRCRAFT))) return;
|
||||||
loco_id = _new_vehicle_id;
|
loco_id = _new_vehicle_id;
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ static StationID FindNearestHangar(const Vehicle *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 = GetAirport(st->airport_type);
|
const AirportFTAClass *afc = st->Airport();
|
||||||
if (afc->nof_depots == 0 || (
|
if (afc->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 &&
|
||||||
@ -106,7 +106,7 @@ static bool HaveHangarInOrderList(Vehicle *v)
|
|||||||
const Station *st = GetStation(order->station);
|
const Station *st = GetStation(order->station);
|
||||||
if (st->owner == v->owner && st->facilities & FACIL_AIRPORT) {
|
if (st->owner == v->owner && st->facilities & FACIL_AIRPORT) {
|
||||||
// If an airport doesn't have a hangar, skip it
|
// If an airport doesn't have a hangar, skip it
|
||||||
if (GetAirport(st->airport_type)->nof_depots != 0)
|
if (st->Airport()->nof_depots != 0)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -250,7 +250,7 @@ int32 CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||||||
|
|
||||||
// Prevent building aircraft types at places which can't handle them
|
// Prevent building aircraft types at places which can't handle them
|
||||||
const Station* st = GetStationByTile(tile);
|
const Station* st = GetStationByTile(tile);
|
||||||
const AirportFTAClass* apc = GetAirport(st->airport_type);
|
const AirportFTAClass* apc = st->Airport();
|
||||||
if (!(apc->flags & (avi->subtype & AIR_CTOL ? AirportFTAClass::AIRPLANES : AirportFTAClass::HELICOPTERS))) {
|
if (!(apc->flags & (avi->subtype & AIR_CTOL ? AirportFTAClass::AIRPLANES : AirportFTAClass::HELICOPTERS))) {
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
}
|
}
|
||||||
@ -559,7 +559,7 @@ int32 CmdSendAircraftToHangar(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
|
|||||||
StationID next_airport_index = v->u.air.targetairport;
|
StationID next_airport_index = v->u.air.targetairport;
|
||||||
const Station *st = GetStation(next_airport_index);
|
const Station *st = GetStation(next_airport_index);
|
||||||
/* 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->IsValid() || st->airport_tile == 0 || GetAirport(st->airport_type)->nof_depots == 0) {
|
if (!st->IsValid() || st->airport_tile == 0 || st->Airport()->nof_depots == 0) {
|
||||||
StationID station;
|
StationID station;
|
||||||
|
|
||||||
// the aircraft has to search for a hangar on its own
|
// the aircraft has to search for a hangar on its own
|
||||||
@ -696,7 +696,7 @@ static void CheckIfAircraftNeedsService(Vehicle *v)
|
|||||||
|
|
||||||
st = GetStation(v->current_order.dest);
|
st = GetStation(v->current_order.dest);
|
||||||
// only goto depot if the target airport has terminals (eg. it is airport)
|
// only goto depot if the target airport has terminals (eg. it is airport)
|
||||||
if (st->IsValid() && st->airport_tile != 0 && GetAirport(st->airport_type)->terminals != NULL) {
|
if (st->IsValid() && st->airport_tile != 0 && st->Airport()->terminals != NULL) {
|
||||||
// printf("targetairport = %d, st->index = %d\n", v->u.air.targetairport, st->index);
|
// printf("targetairport = %d, st->index = %d\n", v->u.air.targetairport, st->index);
|
||||||
// v->u.air.targetairport = st->index;
|
// v->u.air.targetairport = st->index;
|
||||||
v->current_order.type = OT_GOTO_DEPOT;
|
v->current_order.type = OT_GOTO_DEPOT;
|
||||||
@ -970,7 +970,7 @@ static bool AircraftController(Vehicle *v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get airport moving data
|
// get airport moving data
|
||||||
const AirportFTAClass *afc = GetAirport(st->airport_type);
|
const AirportFTAClass *afc = st->Airport();
|
||||||
const AirportMovingData *amd = afc->MovingData(v->u.air.pos);
|
const AirportMovingData *amd = afc->MovingData(v->u.air.pos);
|
||||||
|
|
||||||
// Helicopter raise
|
// Helicopter raise
|
||||||
@ -1369,7 +1369,7 @@ static void MaybeCrashAirplane(Vehicle *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
|
||||||
prob = 0x10000 / 1500;
|
prob = 0x10000 / 1500;
|
||||||
if (GetAirport(st->airport_type)->flags & AirportFTAClass::SHORT_STRIP &&
|
if (st->Airport()->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 = 0x10000 / 20;
|
prob = 0x10000 / 20;
|
||||||
@ -1446,15 +1446,11 @@ static void AircraftLandAirplane(Vehicle *v)
|
|||||||
// set the right pos when heading to other airports after takeoff
|
// set the right pos when heading to other airports after takeoff
|
||||||
static void AircraftNextAirportPos_and_Order(Vehicle *v)
|
static void AircraftNextAirportPos_and_Order(Vehicle *v)
|
||||||
{
|
{
|
||||||
const Station* st;
|
|
||||||
const AirportFTAClass *apc;
|
|
||||||
|
|
||||||
if (v->current_order.type == OT_GOTO_STATION ||
|
if (v->current_order.type == OT_GOTO_STATION ||
|
||||||
v->current_order.type == OT_GOTO_DEPOT)
|
v->current_order.type == OT_GOTO_DEPOT)
|
||||||
v->u.air.targetairport = v->current_order.dest;
|
v->u.air.targetairport = v->current_order.dest;
|
||||||
|
|
||||||
st = GetStation(v->u.air.targetairport);
|
const AirportFTAClass *apc = GetStation(v->u.air.targetairport)->Airport();
|
||||||
apc = GetAirport(st->airport_type);
|
|
||||||
v->u.air.pos = v->u.air.previous_pos = apc->entry_point;
|
v->u.air.pos = v->u.air.previous_pos = apc->entry_point;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2048,10 +2044,7 @@ static void AircraftEventHandler(Vehicle *v, int loop)
|
|||||||
|
|
||||||
if (v->current_order.type >= OT_LOADING) return;
|
if (v->current_order.type >= OT_LOADING) return;
|
||||||
|
|
||||||
// pass the right airport structure to the functions
|
AirportGoToNextPosition(v, GetStation(v->u.air.targetairport)->Airport());
|
||||||
// DEREF_STATION gets target airport (Station *st), its type is passed to GetAirport
|
|
||||||
// that returns the correct layout depending on type
|
|
||||||
AirportGoToNextPosition(v, GetAirport(GetStation(v->u.air.targetairport)->airport_type));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Aircraft_Tick(Vehicle *v)
|
void Aircraft_Tick(Vehicle *v)
|
||||||
@ -2117,7 +2110,7 @@ void UpdateAirplanesOnNewStation(Station *st)
|
|||||||
byte takeofftype;
|
byte takeofftype;
|
||||||
uint16 cnt;
|
uint16 cnt;
|
||||||
// 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 = GetAirport(st->airport_type);
|
const AirportFTAClass *ap = st->Airport();
|
||||||
FOR_ALL_VEHICLES(v) {
|
FOR_ALL_VEHICLES(v) {
|
||||||
if (v->type == VEH_Aircraft && IsNormalAircraft(v)) {
|
if (v->type == VEH_Aircraft && IsNormalAircraft(v)) {
|
||||||
if (v->u.air.targetairport == st->index) { // if heading to this airport
|
if (v->u.air.targetairport == st->index) { // if heading to this airport
|
||||||
|
@ -985,7 +985,7 @@ void ShowBuildVehicleWindow(TileIndex tile, byte type)
|
|||||||
break;
|
break;
|
||||||
case VEH_Aircraft:
|
case VEH_Aircraft:
|
||||||
bv->filter.flags =
|
bv->filter.flags =
|
||||||
tile == 0 ? AirportFTAClass::ALL : GetAirport(GetStationByTile(tile)->airport_type)->flags;
|
tile == 0 ? AirportFTAClass::ALL : GetStationByTile(tile)->Airport()->flags;
|
||||||
ResizeWindow(w, 12, 0);
|
ResizeWindow(w, 12, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,7 @@ enum {
|
|||||||
static byte MapAircraftMovementState(const Vehicle *v)
|
static byte MapAircraftMovementState(const Vehicle *v)
|
||||||
{
|
{
|
||||||
const Station *st = GetStation(v->u.air.targetairport);
|
const Station *st = GetStation(v->u.air.targetairport);
|
||||||
const AirportFTAClass *afc = GetAirport(st->airport_type);
|
const AirportFTAClass *afc = st->Airport();
|
||||||
byte amdflag = afc->MovingData(v->u.air.pos)->flag;
|
byte amdflag = afc->MovingData(v->u.air.pos)->flag;
|
||||||
|
|
||||||
switch (v->u.air.state) {
|
switch (v->u.air.state) {
|
||||||
|
@ -261,7 +261,7 @@ int32 CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||||||
|
|
||||||
if (!CheckOwnership(st->owner) ||
|
if (!CheckOwnership(st->owner) ||
|
||||||
!(st->facilities & FACIL_AIRPORT) ||
|
!(st->facilities & FACIL_AIRPORT) ||
|
||||||
GetAirport(st->airport_type)->nof_depots == 0) {
|
st->Airport()->nof_depots == 0) {
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#ifndef STATION_H
|
#ifndef STATION_H
|
||||||
#define STATION_H
|
#define STATION_H
|
||||||
|
|
||||||
|
#include "airport.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "oldpool.h"
|
#include "oldpool.h"
|
||||||
#include "sprite.h"
|
#include "sprite.h"
|
||||||
@ -112,6 +113,12 @@ struct Station {
|
|||||||
return type == RoadStop::BUS ? bus_stops : truck_stops;
|
return type == RoadStop::BUS ? bus_stops : truck_stops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const AirportFTAClass *Airport() const
|
||||||
|
{
|
||||||
|
assert(airport_tile != 0);
|
||||||
|
return GetAirport(airport_type);
|
||||||
|
}
|
||||||
|
|
||||||
TileIndex xy;
|
TileIndex xy;
|
||||||
RoadStop *bus_stops;
|
RoadStop *bus_stops;
|
||||||
RoadStop *truck_stops;
|
RoadStop *truck_stops;
|
||||||
|
@ -557,7 +557,7 @@ static void UpdateStationAcceptance(Station *st, bool show_msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (st->airport_tile != 0) {
|
if (st->airport_tile != 0) {
|
||||||
const AirportFTAClass* afc = GetAirport(st->airport_type);
|
const AirportFTAClass* afc = st->Airport();
|
||||||
|
|
||||||
MergePoint(&rect, st->airport_tile);
|
MergePoint(&rect, st->airport_tile);
|
||||||
MergePoint(&rect,
|
MergePoint(&rect,
|
||||||
@ -1679,14 +1679,13 @@ static int32 RemoveAirport(Station *st, uint32 flags)
|
|||||||
TileIndex tile;
|
TileIndex tile;
|
||||||
int w,h;
|
int w,h;
|
||||||
int32 cost;
|
int32 cost;
|
||||||
const AirportFTAClass* afc;
|
|
||||||
|
|
||||||
if (_current_player != OWNER_WATER && !CheckOwnership(st->owner))
|
if (_current_player != OWNER_WATER && !CheckOwnership(st->owner))
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
|
|
||||||
tile = st->airport_tile;
|
tile = st->airport_tile;
|
||||||
|
|
||||||
afc = GetAirport(st->airport_type);
|
const AirportFTAClass *afc = st->Airport();
|
||||||
w = afc->size_x;
|
w = afc->size_x;
|
||||||
h = afc->size_y;
|
h = afc->size_y;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user