GroundNet: try to reduce crashes with bad routes
Throw an exception in the condition encountered in FLIGHTGEAR-NJN
This commit is contained in:
parent
7935d5d97c
commit
2895ea8b77
2 changed files with 23 additions and 9 deletions
|
@ -130,16 +130,35 @@ void FGTaxiSegment::unblock(time_t now)
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* FGTaxiRoute
|
* 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) {
|
if (nodes.size() != (routes.size()) + 1) {
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "ALERT: Misconfigured TaxiRoute : " << nodes.size() << " " << routes.size());
|
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");
|
throw sg_range_exception("Misconfigured taxi route");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currNode == nodes.end())
|
if (currNode == nodes.end())
|
||||||
return false;
|
return false;
|
||||||
node = *(currNode);
|
node = *(currNode);
|
||||||
if (currNode != nodes.begin()) {
|
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);
|
*rte = *(currRoute);
|
||||||
currRoute++;
|
currRoute++;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -125,14 +125,9 @@ public:
|
||||||
currNode = nodes.begin();
|
currNode = nodes.begin();
|
||||||
currRoute = routes.begin();
|
currRoute = routes.begin();
|
||||||
};
|
};
|
||||||
|
|
||||||
FGTaxiRoute(const FGTaxiNodeVector& nds, intVec rts, double dist, int dpth) {
|
FGTaxiRoute(const FGTaxiNodeVector& nds, const intVec& rts, double dist, int dpth);
|
||||||
nodes = nds;
|
|
||||||
routes = rts;
|
|
||||||
distance = dist;
|
|
||||||
currNode = nodes.begin();
|
|
||||||
currRoute = routes.begin();
|
|
||||||
};
|
|
||||||
|
|
||||||
FGTaxiRoute& operator= (const FGTaxiRoute &other) {
|
FGTaxiRoute& operator= (const FGTaxiRoute &other) {
|
||||||
nodes = other.nodes;
|
nodes = other.nodes;
|
||||||
|
|
Loading…
Reference in a new issue