1
0
Fork 0

GroundNet: try to reduce crashes with bad routes

Throw an exception in the condition encountered in FLIGHTGEAR-NJN
This commit is contained in:
James Turner 2021-06-04 16:59:00 +01:00
parent 7935d5d97c
commit 2895ea8b77
2 changed files with 23 additions and 9 deletions

View file

@ -130,16 +130,35 @@ void FGTaxiSegment::unblock(time_t now)
/***************************************************************************
* FGTaxiRoute
**************************************************************************/
bool FGTaxiRoute::next(FGTaxiNodeRef& node, int *rte)
FGTaxiRoute::FGTaxiRoute(const FGTaxiNodeVector& nds, const intVec& rts, double dist, int /* dpth */) : nodes(nds),
routes(rts),
distance(dist)
{
currNode = nodes.begin();
currRoute = routes.begin();
if (nodes.size() != (routes.size()) + 1) {
SG_LOG(SG_GENERAL, SG_ALERT, "ALERT: Misconfigured TaxiRoute : " << nodes.size() << " " << routes.size());
}
};
bool FGTaxiRoute::next(FGTaxiNodeRef& node, int* rte)
{
if (nodes.size() != (routes.size()) + 1) {
throw sg_range_exception("Misconfigured taxi route");
}
if (currNode == nodes.end())
return false;
node = *(currNode);
if (currNode != nodes.begin()) {
// work-around for FLIGHTGEAR-NJN: throw an exception here
// instead of crashing, to aid debugging
if (currRoute == routes.end()) {
throw sg_range_exception("Misconfigured taxi route");
}
*rte = *(currRoute);
currRoute++;
} else {

View file

@ -125,14 +125,9 @@ public:
currNode = nodes.begin();
currRoute = routes.begin();
};
FGTaxiRoute(const FGTaxiNodeVector& nds, intVec rts, double dist, int dpth) {
nodes = nds;
routes = rts;
distance = dist;
currNode = nodes.begin();
currRoute = routes.begin();
};
FGTaxiRoute(const FGTaxiNodeVector& nds, const intVec& rts, double dist, int dpth);
FGTaxiRoute& operator= (const FGTaxiRoute &other) {
nodes = other.nodes;