diff --git a/src/aircraft.h b/src/aircraft.h index 417542bf0f..5e1f32899b 100644 --- a/src/aircraft.h +++ b/src/aircraft.h @@ -145,4 +145,6 @@ void GetRotorImage(const Aircraft *v, EngineImageType image_type, VehicleSpriteS Station *GetTargetAirportIfValid(const Aircraft *v); void HandleMissingAircraftOrders(Aircraft *v); +const char *AirportMovementStateToString(byte state); + #endif /* AIRCRAFT_H */ diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index 0a24ad208e..7d1fa31ecb 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -2303,3 +2303,37 @@ void UpdateAirplanesOnNewStation(const Station *st) /* Heliports don't have a hangar. Invalidate all go to hangar orders from all aircraft. */ if (!st->airport.HasHangar()) RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, st->index, true); } + +const char *AirportMovementStateToString(byte state) +{ +#define AMS(s) case s: return #s; + switch (state) { + AMS(TO_ALL) + AMS(HANGAR) + AMS(TERM1) + AMS(TERM2) + AMS(TERM3) + AMS(TERM4) + AMS(TERM5) + AMS(TERM6) + AMS(HELIPAD1) + AMS(HELIPAD2) + AMS(TAKEOFF) + AMS(STARTTAKEOFF) + AMS(ENDTAKEOFF) + AMS(HELITAKEOFF) + AMS(FLYING) + AMS(LANDING) + AMS(ENDLANDING) + AMS(HELILANDING) + AMS(HELIENDLANDING) + AMS(TERM7) + AMS(TERM8) + AMS(HELIPAD3) + AMS(TERMGROUP) + + default: + return "???"; + } +#undef AMS +} diff --git a/src/table/newgrf_debug_data.h b/src/table/newgrf_debug_data.h index 6b56d29a9e..7c85bd3f13 100644 --- a/src/table/newgrf_debug_data.h +++ b/src/table/newgrf_debug_data.h @@ -343,9 +343,15 @@ class NIHVehicle : public NIHelper { } if (v->type == VEH_AIRCRAFT) { const Aircraft *a = Aircraft::From(v); - seprintf(buffer, lastof(buffer), " Pos: %u, prev pos: %u, state: %u, flags: 0x%X", - a->pos, a->previous_pos, a->state, a->flags); + b = buffer + seprintf(buffer, lastof(buffer), " Pos: %u, prev pos: %u, state: %u", + a->pos, a->previous_pos, a->state); + if (a->IsPrimaryVehicle()) b += seprintf(b, lastof(buffer), " (%s)", AirportMovementStateToString(a->state)); + b += seprintf(b, lastof(buffer), ", flags: 0x%X", a->flags); output.print(buffer); + if (BaseStation::IsValidID(a->targetairport)) { + seprintf(buffer, lastof(buffer), " Target airport: %u, %s", a->targetairport, BaseStation::Get(a->targetairport)->GetCachedName()); + output.print(buffer); + } } seprintf(buffer, lastof(buffer), " Cached sprite bounds: (%d, %d) to (%d, %d), offs: (%d, %d)",