Improve handling of the pushBackRoute attribute in groundnet's Parking nodes
- Don't ignore pushbackRoute="0". - Stricter parsing with precise log messages when the input is incorrect. - Add missing includes in src/Airports/dynamicloader.cxx. See <https://sourceforge.net/p/flightgear/mailman/message/35788373/> for the discussion about this change.
This commit is contained in:
parent
df2a98d245
commit
2ad164e80f
1 changed files with 19 additions and 5 deletions
|
@ -17,6 +17,7 @@
|
|||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <cstdlib>
|
||||
#include <cstring> // for strcmp
|
||||
|
||||
|
@ -26,6 +27,9 @@
|
|||
#include <Airports/airport.hxx>
|
||||
#include <Airports/dynamics.hxx>
|
||||
#include <Airports/groundnetwork.hxx>
|
||||
#include <simgear/misc/strutils.hxx>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/structure/exception.hxx>
|
||||
|
||||
using std::string;
|
||||
|
||||
|
@ -92,7 +96,9 @@ void FGGroundNetXMLLoader::startParking(const XMLAttributes &atts)
|
|||
double heading = 0.0;
|
||||
double radius = 1.0;
|
||||
string airlineCodes;
|
||||
int pushBackRoute = 0;
|
||||
int pushBackRoute = -1; // signals unseen attribute
|
||||
|
||||
savePosition(); // allows to retrieve the line number
|
||||
|
||||
for (int i = 0; i < atts.size(); i++)
|
||||
{
|
||||
|
@ -120,7 +126,15 @@ void FGGroundNetXMLLoader::startParking(const XMLAttributes &atts)
|
|||
else if (attname == "airlineCodes")
|
||||
airlineCodes = atts.getValue(i);
|
||||
else if (attname == "pushBackRoute") {
|
||||
pushBackRoute = std::atoi(atts.getValue(i));
|
||||
const string attrVal = atts.getValue(i);
|
||||
try {
|
||||
pushBackRoute = simgear::strutils::readNonNegativeInt<int>(attrVal);
|
||||
} catch (const sg_exception& e) {
|
||||
SG_LOG(SG_NAVAID, SG_DEV_WARN,
|
||||
getPath() << ":" << getLine() << ": " <<
|
||||
"invalid value for 'pushBackRoute': " << e.what());
|
||||
pushBackRoute = -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,7 +144,7 @@ void FGGroundNetXMLLoader::startParking(const XMLAttributes &atts)
|
|||
pos, heading, radius,
|
||||
gateName + gateNumber,
|
||||
type, airlineCodes));
|
||||
if (pushBackRoute > 0) {
|
||||
if (pushBackRoute >= 0) {
|
||||
_parkingPushbacks[parking] = pushBackRoute;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue