Add tests for MP-runway start, and fix behaviour.
Fix a bug in how taxi-nodes were classified, which meant that MP start on a runway was not applied correctly.
This commit is contained in:
parent
84f95fe3c2
commit
81df48b858
8 changed files with 73 additions and 27 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -20,9 +20,7 @@
|
|||
//
|
||||
// $Id$
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include <config.h>
|
||||
|
||||
#include "groundnetwork.hxx"
|
||||
|
||||
|
|
|
@ -22,9 +22,7 @@
|
|||
//
|
||||
// $Id$
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include <config.h>
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -25,10 +25,6 @@
|
|||
#ifndef _PARKING_HXX_
|
||||
#define _PARKING_HXX_
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error This library requires C++
|
||||
#endif
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/sg_inlines.h>
|
||||
|
||||
|
@ -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; };
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue