1
0
Fork 0

Bug 1137, handle single-digit runways.

rwyprefs.xml sometimes specify runways without a leading '0', which
confuses the ident lookup. Print a message, and fix up such idents at
load time, so '8' -> '08', '3L' -> '03L' which matches our internal
scheme.
This commit is contained in:
James Turner 2013-07-04 10:29:47 +01:00
parent a65f24c137
commit ebfe2ee6f5

View file

@ -29,15 +29,20 @@
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <simgear/compiler.h> #include <boost/foreach.hpp>
#include <simgear/compiler.h>
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>
#include <simgear/misc/strutils.hxx>
#include <Main/globals.hxx> #include <Main/globals.hxx>
#include <Airports/runways.hxx> #include <Airports/runways.hxx>
#include "runwayprefs.hxx" #include "runwayprefs.hxx"
#include "airport.hxx" #include "airport.hxx"
using namespace simgear;
/****************************************************************************** /******************************************************************************
* ScheduleTime * ScheduleTime
***************e*************************************************************/ ***************e*************************************************************/
@ -142,19 +147,20 @@ void RunwayList::set(const std::string & tp, const std::string & lst)
// timeOffsetInDays = weekday - currTimeDate->getGmt()->tm_wday; // timeOffsetInDays = weekday - currTimeDate->getGmt()->tm_wday;
// timeCopy = timeCopy.substr(2,timeCopy.length()); // timeCopy = timeCopy.substr(2,timeCopy.length());
type = tp; type = tp;
std::string rwys = lst;
std::string rwy;
while (rwys.find(",") != std::string::npos) {
rwy = rwys.substr(0, rwys.find(",", 0)); BOOST_FOREACH(std::string s, strutils::split(lst, ",")) {
//cerr << "adding runway [" << rwy << "] to the list " << endl; std::string ident = strutils::strip(s);
preferredRunways.push_back(rwy);
rwys.erase(0, rwys.find(",", 0) + 1); // erase until after the first whitspace // http://code.google.com/p/flightgear-bugs/issues/detail?id=1137
while (rwys[0] == ' ') if ((ident.size() < 2) || !isdigit(ident[1])) {
rwys.erase(0, 1); // Erase any leading whitespaces. SG_LOG(SG_GENERAL, SG_INFO, "RunwayList::set: padding runway ident '" << ident << "'");
//cerr << "Remaining runway list " << rwys; ident = "0" + ident;
}
preferredRunways.push_back(ident);
} }
preferredRunways.push_back(rwys);
//exit(1);
} }
void RunwayList::clear() void RunwayList::clear()