(svn r8743) -Fix

-Codechange: Add a Z adjustment attribute for helicopter pads to AirportFTAClass to get rid of some special cases for oilrigs and heliports
This commit is contained in:
tron 2007-02-15 07:43:06 +00:00
parent ac95825b92
commit f6b917f609
4 changed files with 41 additions and 49 deletions

View File

@ -969,7 +969,8 @@ static bool AircraftController(Vehicle *v)
} }
// get airport moving data // get airport moving data
const AirportMovingData *amd = GetAirport(st->airport_type)->MovingData(v->u.air.pos); const AirportFTAClass *afc = GetAirport(st->airport_type);
const AirportMovingData *amd = afc->MovingData(v->u.air.pos);
// Helicopter raise // Helicopter raise
if (amd->flag & AMED_HELI_RAISE) { if (amd->flag & AMED_HELI_RAISE) {
@ -1011,9 +1012,7 @@ static bool AircraftController(Vehicle *v)
v->tile = st->airport_tile; v->tile = st->airport_tile;
// Find altitude of landing position. // Find altitude of landing position.
z = GetSlopeZ(x, y) + 1; z = GetSlopeZ(x, y) + 1 + afc->delta_z;
if (st->airport_type == AT_OILRIG) z += 54;
if (st->airport_type == AT_HELIPORT) z += 60;
if (z == v->z_pos) { if (z == v->z_pos) {
u = v->next->next; u = v->next->next;

View File

@ -41,7 +41,8 @@ void InitializeAirports(void)
_airport_fta_country, _airport_fta_country,
_airport_depots_country, _airport_depots_country,
lengthof(_airport_depots_country), lengthof(_airport_depots_country),
4, 3 4, 3,
0
); );
CityAirport = new AirportFTAClass( CityAirport = new AirportFTAClass(
@ -53,7 +54,8 @@ void InitializeAirports(void)
_airport_fta_city, _airport_fta_city,
_airport_depots_city, _airport_depots_city,
lengthof(_airport_depots_city), lengthof(_airport_depots_city),
6, 6 6, 6,
0
); );
MetropolitanAirport = new AirportFTAClass( MetropolitanAirport = new AirportFTAClass(
@ -65,7 +67,8 @@ void InitializeAirports(void)
_airport_fta_metropolitan, _airport_fta_metropolitan,
_airport_depots_metropolitan, _airport_depots_metropolitan,
lengthof(_airport_depots_metropolitan), lengthof(_airport_depots_metropolitan),
6, 6 6, 6,
0
); );
InternationalAirport = new AirportFTAClass( InternationalAirport = new AirportFTAClass(
@ -77,7 +80,8 @@ void InitializeAirports(void)
_airport_fta_international, _airport_fta_international,
_airport_depots_international, _airport_depots_international,
lengthof(_airport_depots_international), lengthof(_airport_depots_international),
7, 7 7, 7,
0
); );
IntercontinentalAirport = new AirportFTAClass( IntercontinentalAirport = new AirportFTAClass(
@ -89,7 +93,8 @@ void InitializeAirports(void)
_airport_fta_intercontinental, _airport_fta_intercontinental,
_airport_depots_intercontinental, _airport_depots_intercontinental,
lengthof(_airport_depots_intercontinental), lengthof(_airport_depots_intercontinental),
9,11 9, 11,
0
); );
Heliport = new AirportFTAClass( Heliport = new AirportFTAClass(
@ -101,7 +106,8 @@ void InitializeAirports(void)
_airport_fta_heliport_oilrig, _airport_fta_heliport_oilrig,
NULL, NULL,
0, 0,
1, 1 1, 1,
60
); );
Oilrig = new AirportFTAClass( Oilrig = new AirportFTAClass(
@ -113,7 +119,8 @@ void InitializeAirports(void)
_airport_fta_heliport_oilrig, _airport_fta_heliport_oilrig,
NULL, NULL,
0, 0,
1, 1 1, 1,
54
); );
CommuterAirport = new AirportFTAClass( CommuterAirport = new AirportFTAClass(
@ -125,7 +132,8 @@ void InitializeAirports(void)
_airport_fta_commuter, _airport_fta_commuter,
_airport_depots_commuter, _airport_depots_commuter,
lengthof(_airport_depots_commuter), lengthof(_airport_depots_commuter),
5,4 5, 4,
0
); );
HeliDepot = new AirportFTAClass( HeliDepot = new AirportFTAClass(
@ -137,7 +145,8 @@ void InitializeAirports(void)
_airport_fta_helidepot, _airport_fta_helidepot,
_airport_depots_helidepot, _airport_depots_helidepot,
lengthof(_airport_depots_helidepot), lengthof(_airport_depots_helidepot),
2,2 2, 2,
0
); );
HeliStation = new AirportFTAClass( HeliStation = new AirportFTAClass(
@ -149,7 +158,8 @@ void InitializeAirports(void)
_airport_fta_helistation, _airport_fta_helistation,
_airport_depots_helistation, _airport_depots_helistation,
lengthof(_airport_depots_helistation), lengthof(_airport_depots_helistation),
4,2 4, 2,
0
); );
} }
@ -187,7 +197,8 @@ AirportFTAClass::AirportFTAClass(
const TileIndexDiffC *depots_, const TileIndexDiffC *depots_,
const byte nof_depots_, const byte nof_depots_,
uint size_x_, uint size_x_,
uint size_y_ uint size_y_,
byte delta_z_
) : ) :
moving_data(moving_data_), moving_data(moving_data_),
terminals(terminals_), terminals(terminals_),
@ -197,7 +208,8 @@ AirportFTAClass::AirportFTAClass(
nofelements(AirportGetNofElements(apFA)), nofelements(AirportGetNofElements(apFA)),
entry_point(entry_point_), entry_point(entry_point_),
size_x(size_x_), size_x(size_x_),
size_y(size_y_) size_y(size_y_),
delta_z(delta_z_)
{ {
byte nofterminalgroups, nofhelipadgroups; byte nofterminalgroups, nofhelipadgroups;

View File

@ -143,7 +143,8 @@ typedef struct AirportFTAClass {
const TileIndexDiffC *depots, const TileIndexDiffC *depots,
byte nof_depots, byte nof_depots,
uint size_x, uint size_x,
uint size_y uint size_y,
byte delta_z
); );
~AirportFTAClass(); ~AirportFTAClass();
@ -165,6 +166,7 @@ typedef struct AirportFTAClass {
AcceptPlanesByte acc_planes; // accept airplanes or helicopters or both AcceptPlanesByte acc_planes; // accept airplanes or helicopters or both
byte size_x; byte size_x;
byte size_y; byte size_y;
byte delta_z; // Z adjustment for helicopter pads
} AirportFTAClass; } AirportFTAClass;
// internal structure used in openttd - Finite sTate mAchine --> FTA // internal structure used in openttd - Finite sTate mAchine --> FTA

View File

@ -288,7 +288,8 @@ 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);
byte amdflag = GetAirport(st->airport_type)->MovingData(v->u.air.pos)->flag; const AirportFTAClass *afc = GetAirport(st->airport_type);
byte amdflag = afc->MovingData(v->u.air.pos)->flag;
switch (v->u.air.state) { switch (v->u.air.state) {
case HANGAR: case HANGAR:
@ -347,26 +348,11 @@ static byte MapAircraftMovementState(const Vehicle *v)
return AMS_TTDP_CLIMBING; return AMS_TTDP_CLIMBING;
case HELITAKEOFF: // Helicopter is moving to take off position. case HELITAKEOFF: // Helicopter is moving to take off position.
switch (st->airport_type) { if (afc->delta_z == 0) {
case AT_SMALL: return amdflag & AMED_HELI_RAISE ?
case AT_LARGE: AMS_TTDP_HELI_TAKEOFF_AIRPORT : AMS_TTDP_TO_JUNCTION;
case AT_METROPOLITAN: } else {
case AT_INTERNATIONAL:
case AT_COMMUTER:
case AT_INTERCON:
/* Note, Helidepot and Helistation are treated as airports as
* helicopters are taking off from ground level. */
case AT_HELIDEPOT:
case AT_HELISTATION:
if (amdflag & AMED_HELI_RAISE) return AMS_TTDP_HELI_TAKEOFF_AIRPORT;
return AMS_TTDP_TO_JUNCTION;
case AT_HELIPORT:
case AT_OILRIG:
return AMS_TTDP_HELI_TAKEOFF_HELIPORT; return AMS_TTDP_HELI_TAKEOFF_HELIPORT;
default:
return AMS_TTDP_HELI_TAKEOFF_AIRPORT;
} }
case FLYING: case FLYING:
@ -383,18 +369,11 @@ static byte MapAircraftMovementState(const Vehicle *v)
case HELILANDING: case HELILANDING:
case HELIENDLANDING: // Helicoptor is decending. case HELIENDLANDING: // Helicoptor is decending.
if (amdflag & AMED_HELI_LOWER) { if (amdflag & AMED_HELI_LOWER) {
switch (st->airport_type) { return afc->delta_z == 0 ?
case AT_HELIPORT: AMS_TTDP_HELI_LAND_AIRPORT : AMS_TTDP_HELI_LAND_HELIPORT;
case AT_OILRIG: } else {
return AMS_TTDP_HELI_LAND_HELIPORT;
default:
/* Note, Helidepot and Helistation are treated as airports as
* helicopters are landing at ground level. */
return AMS_TTDP_HELI_LAND_AIRPORT;
}
}
return AMS_TTDP_FLIGHT_TO_TOWER; return AMS_TTDP_FLIGHT_TO_TOWER;
}
default: default:
return AMS_TTDP_HANGAR; return AMS_TTDP_HANGAR;