From 79094e8c3615c01f1bf1933d18ebb6324c215c2c Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Mon, 29 Nov 2010 22:48:37 +0100 Subject: [PATCH] Fix bug #187: check if path cache matches fg-aircraft dirs Check if any fg-aircraft dir changed - sequence also matters. --- src/Main/fg_init.cxx | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index e9592c14e..8f66da05d 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -589,7 +589,7 @@ public: bool loadAircraft() { - std::string aircraft = fgGetString( "/sim/aircraft", ""); + std::string aircraft = fgGetString( "/sim/aircraft", ""); if (aircraft.empty()) { SG_LOG(SG_GENERAL, SG_ALERT, "no aircraft specified"); return false; @@ -601,6 +601,9 @@ public: SGPropertyNode *n = _cache->getNode("fg-root", true); n->setStringValue(globals->get_fg_root().c_str()); n->setAttribute(SGPropertyNode::USERARCHIVE, true); + n = _cache->getNode("fg-aircraft", true); + n->setStringValue(getAircraftPaths().c_str()); + n->setAttribute(SGPropertyNode::USERARCHIVE, true); _cache->removeChildren("aircraft"); fgFindAircraft(this, &FindAndCacheAircraft::checkAircraft); @@ -629,11 +632,29 @@ public: } private: + SGPath getAircraftPaths() { + string_list pathList = globals->get_aircraft_paths(); + SGPath aircraftPaths; + string_list::const_iterator it = pathList.begin(); + if (it != pathList.end()) { + aircraftPaths.set(*it); + it++; + } + for (; it != pathList.end(); ++it) { + aircraftPaths.add(*it); + } + return aircraftPaths; + } + bool checkCache() { if (globals->get_fg_root() != _cache->getStringValue("fg-root", "")) { return false; // cache mismatch } + + if (getAircraftPaths().str() != _cache->getStringValue("fg-aircraft", "")) { + return false; // cache mismatch + } vector cache = _cache->getChildren("aircraft"); for (unsigned int i = 0; i < cache.size(); i++) {