25 #include "core/random_func.hpp" |
25 #include "core/random_func.hpp" |
26 #include "direction_func.h" |
26 #include "direction_func.h" |
27 #include "rail_map.h" |
27 #include "rail_map.h" |
28 #include "rail.h" |
28 #include "rail.h" |
29 #include "settings_type.h" |
29 #include "settings_type.h" |
|
30 #include "aircraft.h" |
30 #include <map> |
31 #include <map> |
31 |
32 |
32 |
33 |
33 int _traininfo_vehicle_pitch = 0; |
34 int _traininfo_vehicle_pitch = 0; |
34 int _traininfo_vehicle_width = 29; |
35 int _traininfo_vehicle_width = 29; |
188 * Map OTTD aircraft movement states to TTDPatch style movement states |
189 * Map OTTD aircraft movement states to TTDPatch style movement states |
189 * (VarAction 2 Variable 0xE2) |
190 * (VarAction 2 Variable 0xE2) |
190 */ |
191 */ |
191 static byte MapAircraftMovementState(const Vehicle *v) |
192 static byte MapAircraftMovementState(const Vehicle *v) |
192 { |
193 { |
193 const Station *st = GetStation(v->u.air.targetairport); |
194 const Station *st = GetTargetAirportIfValid(v); |
194 if (st->airport_tile == 0) return AMS_TTDP_FLIGHT_TO_TOWER; |
195 if (st == NULL) return AMS_TTDP_FLIGHT_TO_TOWER; |
195 |
196 |
196 const AirportFTAClass *afc = st->Airport(); |
197 const AirportFTAClass *afc = st->Airport(); |
197 uint16 amdflag = afc->MovingData(v->u.air.pos)->flag; |
198 uint16 amdflag = afc->MovingData(v->u.air.pos)->flag; |
198 |
199 |
199 switch (v->u.air.state) { |
200 switch (v->u.air.state) { |
548 if (v->type != VEH_AIRCRAFT) return UINT_MAX; |
549 if (v->type != VEH_AIRCRAFT) return UINT_MAX; |
549 |
550 |
550 { |
551 { |
551 const Vehicle *w = v->Next(); |
552 const Vehicle *w = v->Next(); |
552 uint16 altitude = v->z_pos - w->z_pos; // Aircraft height - shadow height |
553 uint16 altitude = v->z_pos - w->z_pos; // Aircraft height - shadow height |
553 byte airporttype; |
554 byte airporttype = ATP_TTDP_LARGE; |
554 |
555 |
555 switch (GetStation(v->u.air.targetairport)->airport_type) { |
556 const Station *st = GetTargetAirportIfValid(v); |
556 /* Note, Helidepot and Helistation are treated as small airports |
557 |
557 * as they are at ground level. */ |
558 if (st != NULL) { |
558 case AT_HELIDEPOT: |
559 switch (st->airport_type) { |
559 case AT_HELISTATION: |
560 /* Note, Helidepot and Helistation are treated as small airports |
560 case AT_COMMUTER: |
561 * as they are at ground level. */ |
561 case AT_SMALL: airporttype = ATP_TTDP_SMALL; break; |
562 case AT_HELIDEPOT: |
562 case AT_METROPOLITAN: |
563 case AT_HELISTATION: |
563 case AT_INTERNATIONAL: |
564 case AT_COMMUTER: |
564 case AT_INTERCON: |
565 case AT_SMALL: airporttype = ATP_TTDP_SMALL; break; |
565 case AT_LARGE: airporttype = ATP_TTDP_LARGE; break; |
566 case AT_METROPOLITAN: |
566 case AT_HELIPORT: airporttype = ATP_TTDP_HELIPORT; break; |
567 case AT_INTERNATIONAL: |
567 case AT_OILRIG: airporttype = ATP_TTDP_OILRIG; break; |
568 case AT_INTERCON: |
568 default: airporttype = ATP_TTDP_LARGE; break; |
569 case AT_LARGE: airporttype = ATP_TTDP_LARGE; break; |
|
570 case AT_HELIPORT: airporttype = ATP_TTDP_HELIPORT; break; |
|
571 case AT_OILRIG: airporttype = ATP_TTDP_OILRIG; break; |
|
572 default: airporttype = ATP_TTDP_LARGE; break; |
|
573 } |
569 } |
574 } |
570 |
575 |
571 return (altitude << 8) | airporttype; |
576 return (altitude << 8) | airporttype; |
572 } |
577 } |
573 |
578 |