From 6810809170b45689cdb9a2f38b2a57f1fe401f03 Mon Sep 17 00:00:00 2001 From: James Turner Date: Wed, 24 Jul 2013 08:52:59 +0100 Subject: [PATCH] Bug #1166, tweaking POI.dat parsing. (Doesn't fix the bug alas, but slightly cleaner) --- src/Navaids/poidb.cxx | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/Navaids/poidb.cxx b/src/Navaids/poidb.cxx index bfc7c81ef..15da16813 100644 --- a/src/Navaids/poidb.cxx +++ b/src/Navaids/poidb.cxx @@ -22,6 +22,8 @@ # include "config.h" #endif +#include "poidb.hxx" + #include #include #include @@ -30,7 +32,7 @@ #include #include -#include "poidb.hxx" + using std::string; @@ -47,22 +49,24 @@ mapPOITypeToFGPType(int aTy) } } - - namespace flightgear { -static PositionedID readPOIFromStream(std::istream& aStream, +static PositionedID readPOIFromStream(std::istream& aStream, NavDataCache* cache, FGPositioned::Type type = FGPositioned::INVALID) { - NavDataCache* cache = NavDataCache::instance(); + if (aStream.eof()) { + return 0; + } + aStream >> skipws; + if (aStream.peek() == '#') { + aStream >> skipeol; + return 0; + } + int rawType; aStream >> rawType; - if (aStream.eof() || (rawType == '#')) { - return 0; - } - double lat, lon; std::string name; aStream >> lat >> lon; @@ -80,8 +84,7 @@ static PositionedID readPOIFromStream(std::istream& aStream, return 0; } - PositionedID r = cache->createPOI(type, name, pos); - return r; + return cache->createPOI(type, name, pos); } // load and initialize the POI database @@ -93,14 +96,12 @@ bool poiDBInit(const SGPath& path) return false; } - in >> skipcomment; - + NavDataCache* cache = NavDataCache::instance(); while (!in.eof()) { - readPOIFromStream(in); - in >> skipcomment; + readPOIFromStream(in, cache); } // of stream data loop - return true; + return true; } } // of namespace flightgear -- 2.39.5