diff --git a/src/Airports/dynamicloader.cxx b/src/Airports/dynamicloader.cxx index 3f3c37d0a..b0caff5e1 100644 --- a/src/Airports/dynamicloader.cxx +++ b/src/Airports/dynamicloader.cxx @@ -190,7 +190,7 @@ void FGGroundNetXMLLoader::startNode(const XMLAttributes &atts) } SGGeod pos(SGGeod::fromDeg(processPosition(lon), processPosition(lat))); - FGTaxiNodeRef node(new FGTaxiNode(index, pos, onRunway, holdPointType)); + FGTaxiNodeRef node(new FGTaxiNode(FGPositioned::TAXI_NODE, index, pos, onRunway, holdPointType)); _indexMap[index] = node; _unreferencedNodes.insert(node); } diff --git a/src/Airports/gnnode.cxx b/src/Airports/gnnode.cxx index 97ddd425e..0e73735e7 100644 --- a/src/Airports/gnnode.cxx +++ b/src/Airports/gnnode.cxx @@ -14,10 +14,10 @@ using namespace flightgear; * FGTaxiNode *************************************************************************/ -FGTaxiNode::FGTaxiNode(int index, const SGGeod& pos, +FGTaxiNode::FGTaxiNode(FGPositioned::Type ty, int index, const SGGeod& pos, bool aOnRunway, int aHoldType, const std::string& ident) : - FGPositioned(TRANSIENT_ID, FGPositioned::PARKING, ident, pos), + FGPositioned(TRANSIENT_ID, ty, ident, pos), m_index(index), isOnRunway(aOnRunway), holdType(aHoldType), @@ -26,10 +26,6 @@ FGTaxiNode::FGTaxiNode(int index, const SGGeod& pos, } -FGTaxiNode::~FGTaxiNode() -{ -} - void FGTaxiNode::setElevation(double val) { // ignored for the moment diff --git a/src/Airports/gnnode.hxx b/src/Airports/gnnode.hxx index 0c2739cfe..009da4ed0 100644 --- a/src/Airports/gnnode.hxx +++ b/src/Airports/gnnode.hxx @@ -26,14 +26,14 @@ class FGTaxiNode : public FGPositioned protected: const int m_index; - bool isOnRunway; - int holdType; + const bool isOnRunway; + const int holdType; bool m_isPushback; public: - FGTaxiNode(int index, const SGGeod& pos, bool aOnRunway, int aHoldType, + FGTaxiNode(FGPositioned::Type ty, int index, const SGGeod& pos, bool aOnRunway, int aHoldType, const std::string& ident = {}); - virtual ~FGTaxiNode(); + virtual ~FGTaxiNode() = default; void setElevation(double val); diff --git a/src/Airports/groundnetwork.cxx b/src/Airports/groundnetwork.cxx index f97496b7c..af71c95e4 100644 --- a/src/Airports/groundnetwork.cxx +++ b/src/Airports/groundnetwork.cxx @@ -20,9 +20,7 @@ // // $Id$ -#ifdef HAVE_CONFIG_H -# include -#endif +#include #include "groundnetwork.hxx" diff --git a/src/Airports/parking.cxx b/src/Airports/parking.cxx index 63565ac23..5fe368429 100644 --- a/src/Airports/parking.cxx +++ b/src/Airports/parking.cxx @@ -22,9 +22,7 @@ // // $Id$ -#ifdef HAVE_CONFIG_H -# include -#endif +#include #include @@ -42,7 +40,7 @@ FGParking::FGParking(int index, const std::string& name, const std::string& aType, const std::string& codes) : - FGTaxiNode(index, pos, false, 0, name), + FGTaxiNode(FGPositioned::PARKING, index, pos, false, 0, name), heading(aHeading), radius(aRadius), type(aType), @@ -50,10 +48,6 @@ FGParking::FGParking(int index, { } -FGParking::~FGParking() -{ -} - void FGParking::setPushBackPoint(const FGTaxiNodeRef &node) { pushBackPoint = node; diff --git a/src/Airports/parking.hxx b/src/Airports/parking.hxx index 21364714a..b440cee33 100644 --- a/src/Airports/parking.hxx +++ b/src/Airports/parking.hxx @@ -25,10 +25,6 @@ #ifndef _PARKING_HXX_ #define _PARKING_HXX_ -#ifndef __cplusplus -# error This library requires C++ -#endif - #include #include @@ -56,7 +52,7 @@ public: double heading, double radius, const std::string& name, const std::string& type, const std::string& codes); - virtual ~FGParking(); + virtual ~FGParking() = default; double getHeading () const { return heading; }; double getRadius () const { return radius; }; diff --git a/test_suite/unit_tests/Main/test_posinit.cxx b/test_suite/unit_tests/Main/test_posinit.cxx index c53b0fd3b..34a4016f1 100644 --- a/test_suite/unit_tests/Main/test_posinit.cxx +++ b/test_suite/unit_tests/Main/test_posinit.cxx @@ -927,3 +927,58 @@ void PosInitTests::testRepositionAtInvalid() auto runway = apt->getRunwayByIdent("36"); checkPosition(runway->threshold()); } + +void PosInitTests::testMPRunwayStart() +{ + { + Options* opts = Options::sharedInstance(); + opts->setShouldLoadDefaultConfig(false); + + // set dummy value to pretend MP is active + fgSetString("/sim/multiplay/txhost", "lalalal"); + + const char* args[] = {"dummypath", "--airport=EDDF", "--runway=07L"}; + opts->init(3, (char**) args, SGPath()); + opts->processOptions(); + + } + + initPosition(); + + CPPUNIT_ASSERT(fgGetBool("/sim/presets/airport-requested")); + CPPUNIT_ASSERT(fgGetBool("/sim/presets/runway-requested")); + CPPUNIT_ASSERT(fgGetBool("/sim/presets/avoided-mp-runway")); + + auto apt = FGAirport::getByIdent("EDDF"); + FGGroundNetwork* groundNet = apt->groundNetwork(); + + auto rwy = apt->getRunwayByIdent("07L"); + FGTaxiNodeRef taxiNode = groundNet->findNearestNodeOffRunway(rwy->threshold(), rwy, 50.0); + checkPosition(taxiNode->geod()); +} + +void PosInitTests::testMPRunwayStartNoGroundnet() +{ + { + Options* opts = Options::sharedInstance(); + opts->setShouldLoadDefaultConfig(false); + + // set dummy value to pretend MP is active + fgSetString("/sim/multiplay/txhost", "lalalal"); + + const char* args[] = {"dummypath", "--airport=EDDS", "--runway=07"}; + opts->init(3, (char**) args, SGPath()); + opts->processOptions(); + } + + initPosition(); + + CPPUNIT_ASSERT(fgGetBool("/sim/presets/airport-requested")); + CPPUNIT_ASSERT(fgGetBool("/sim/presets/runway-requested")); + CPPUNIT_ASSERT(!fgGetBool("/sim/presets/avoided-mp-runway")); + + auto apt = FGAirport::getByIdent("EDDS"); + auto rwy = apt->getRunwayByIdent("07"); + checkPosition(rwy->threshold()); +} + diff --git a/test_suite/unit_tests/Main/test_posinit.hxx b/test_suite/unit_tests/Main/test_posinit.hxx index 3196e1766..53b0e0720 100644 --- a/test_suite/unit_tests/Main/test_posinit.hxx +++ b/test_suite/unit_tests/Main/test_posinit.hxx @@ -72,6 +72,10 @@ class PosInitTests : public CppUnit::TestFixture CPPUNIT_TEST(testRepositionAtOccupied); CPPUNIT_TEST(testRepositionAtInvalid); + // MP tests + CPPUNIT_TEST(testMPRunwayStart); + CPPUNIT_TEST(testMPRunwayStartNoGroundnet); + CPPUNIT_TEST_SUITE_END(); void simulateStartReposition(); @@ -119,6 +123,9 @@ public: void testRepositionAtInvalid(); void testAirportRunwayRepositionAirport(); + // MP tests + void testMPRunwayStart(); + void testMPRunwayStartNoGroundnet(); private: // Helper functions for tests. Return void as they use CPPUNIT_ASSERT void checkAlt(float value);