diff --git a/src/Scripting/NasalPositioned.cxx b/src/Scripting/NasalPositioned.cxx index 759629fd3..df633a282 100644 --- a/src/Scripting/NasalPositioned.cxx +++ b/src/Scripting/NasalPositioned.cxx @@ -820,6 +820,14 @@ static const char* flightplanGhostGetMember(naContext c, void* g, naRef field, n else if (!strcmp(fieldName, "remarks")) *out = stringToNasal(c, fp->remarks()); else if (!strcmp(fieldName, "callsign")) *out = stringToNasal(c, fp->callsign()); else if (!strcmp(fieldName, "estimatedDurationMins")) *out = naNum(fp->estimatedDurationMinutes()); + else if (!strcmp(fieldName, "firstNonDepartureLeg")) + *out = naNum(fp->indexOfFirstNonDepartureWaypoint()); + else if (!strcmp(fieldName, "firstArrivalLeg")) + *out = naNum(fp->indexOfFirstArrivalWaypoint()); + else if (!strcmp(fieldName, "firstApproachLeg")) + *out = naNum(fp->indexOfFirstApproachWaypoint()); + else if (!strcmp(fieldName, "destination_runway_leg")) + *out = naNum(fp->indexOfDestinationRunwayWaypoint()); else { return nullptr; diff --git a/test_suite/unit_tests/Navaids/test_routeManager.cxx b/test_suite/unit_tests/Navaids/test_routeManager.cxx index 05029edcd..9bf9a2ccc 100644 --- a/test_suite/unit_tests/Navaids/test_routeManager.cxx +++ b/test_suite/unit_tests/Navaids/test_routeManager.cxx @@ -730,4 +730,25 @@ void RouteManagerTests::testRouteWithProcedures() auto firstMiss = f->legAtIndex(f->indexOfDestinationRunwayWaypoint() + 1); CPPUNIT_ASSERT_EQUAL(firstMiss->waypoint()->ident(), string{"(461)"}); + + // check it in Nasal too + bool ok = FGTestApi::executeNasal( + R"( + var f = flightplan(); + var depEnd = f.getWP(f.firstNonDepartureLeg - 1); + var firstArrival = f.getWP(f.firstArrivalLeg); + var firstApproach = f.getWP(f.firstApproachLeg); + var destRunway = f.getWP(f.destination_runway_leg); + + unitTest.assert_equal(depEnd.id, 'CANDR'); + + var firstEnroute = f.getWP(f.firstNonDepartureLeg ); + unitTest.assert_equal(firstEnroute.id, 'TOMYE'); + + unitTest.assert_equal(firstArrival.id, 'BEDUM'); + unitTest.assert_equal(firstApproach.id, 'D070O'); + unitTest.assert_equal(destRunway.id, '18R'); + )"); + + CPPUNIT_ASSERT(ok); }