1
0
Fork 0

Potential fixes for #548, #572, groundnetwork related segfaults

Add some pointer checks - so we at least get some error message naming the
airport with the broken network.
This commit is contained in:
ThorstenB 2012-01-08 12:31:18 +01:00
parent 484d3c61f8
commit 277ba10b39

View file

@ -580,9 +580,23 @@ FGTaxiRoute FGGroundNetwork::findShortestRoute(int start, int end,
} }
FGTaxiNode *firstNode = findNode(start); FGTaxiNode *firstNode = findNode(start);
if (!firstNode)
{
SG_LOG(SG_GENERAL, SG_ALERT,
"Error in ground network. Failed to find first waypoint: " << start
<< " at " << ((parent) ? parent->getId() : "<unknown>"));
return FGTaxiRoute();
}
firstNode->setPathScore(0); firstNode->setPathScore(0);
FGTaxiNode *lastNode = findNode(end); FGTaxiNode *lastNode = findNode(end);
if (!lastNode)
{
SG_LOG(SG_GENERAL, SG_ALERT,
"Error in ground network. Failed to find last waypoint: " << end
<< " at " << ((parent) ? parent->getId() : "<unknown>"));
return FGTaxiRoute();
}
FGTaxiNodeVector unvisited(*currNodesSet); // working copy FGTaxiNodeVector unvisited(*currNodesSet); // working copy
@ -606,6 +620,13 @@ FGTaxiRoute FGGroundNetwork::findShortestRoute(int start, int end,
seg != best->getEndRoute(); seg++) { seg != best->getEndRoute(); seg++) {
if (fullSearch || (*seg)->isPushBack()) { if (fullSearch || (*seg)->isPushBack()) {
FGTaxiNode *tgt = (*seg)->getEnd(); FGTaxiNode *tgt = (*seg)->getEnd();
if (!tgt)
{
SG_LOG(SG_GENERAL, SG_ALERT,
"Error in ground network. Found empty segment "
<< " at " << ((parent) ? parent->getId() : "<unknown>"));
return FGTaxiRoute();
}
double alt = double alt =
best->getPathScore() + (*seg)->getLength() + best->getPathScore() + (*seg)->getLength() +
(*seg)->getPenalty(nParkings); (*seg)->getPenalty(nParkings);