]> git.mxchange.org Git - flightgear.git/commitdiff
Drop ground-nets cache on scenery path change.
authorJames Turner <zakalawe@mac.com>
Thu, 13 Nov 2014 21:02:58 +0000 (21:02 +0000)
committerJames Turner <zakalawe@mac.com>
Tue, 2 Dec 2014 16:31:34 +0000 (16:31 +0000)
Unfortunately we can’t drop loaded ones, since the in-memory structures don’t have ref-counting, and we don’t
know what AI plans may be referencing them.

src/Main/fg_commands.cxx
src/Navaids/NavDataCache.cxx
src/Navaids/NavDataCache.hxx

index 175a9dd86b064048157b321de77efbe7abca93b7..2d2767a5536d375db813093d8edb6fac0267d128 100644 (file)
@@ -39,6 +39,7 @@
 #include <Viewer/viewmgr.hxx>
 #include <Viewer/viewer.hxx>
 #include <Environment/presets.hxx>
+#include <Navaids/NavDataCache.hxx>
 
 #include "fg_init.hxx"
 #include "fg_io.hxx"
@@ -1451,6 +1452,12 @@ do_set_scenery_paths(const SGPropertyNode* arg)
     root.append("Scenery");
     globals->append_fg_scenery(root.str());
   }
+
+    // might need to drop ground-nets from the DB. Also need to drop
+    // them from memory, but this is tricky since FGAirportDynamics holds
+    // an instance directly, and AI code may have pointers to ground-net
+    // nodes. For now we'll leave-in memory versions untouched.
+    flightgear::NavDataCache::instance()->dropGroundnetsIfRequired();
   
   return true;
 }
index 4c5a030babacded1214a3320806c2e8a16fdf08c..f6756613bd6c19130d5c308b44c36282add9852f 100644 (file)
@@ -1161,17 +1161,25 @@ bool NavDataCache::isRebuildRequired()
     SG_LOG(SG_NAVCACHE, SG_INFO, "NavCache: main cache rebuild required");
     return true;
   }
-  
-  string sceneryPaths = simgear::strutils::join(globals->get_fg_scenery(), ";");
-  if (readStringProperty("scenery_paths") != sceneryPaths) {
-    SG_LOG(SG_NAVCACHE, SG_INFO, "NavCache: scenery paths changed,dropping ground net");
-    dropAllGroundnets();
-    writeStringProperty("scenery_paths", sceneryPaths);
-  }
+
+  dropGroundnetsIfRequired();
   
   SG_LOG(SG_NAVCACHE, SG_INFO, "NavCache: no main cache rebuild required");
   return false;
 }
+
+bool NavDataCache::dropGroundnetsIfRequired()
+{
+    string sceneryPaths = simgear::strutils::join(globals->get_fg_scenery(), ";");
+    if (readStringProperty("scenery_paths") != sceneryPaths) {
+        SG_LOG(SG_NAVCACHE, SG_INFO, "NavCache: scenery paths changed, dropping ground nets");
+        dropAllGroundnets();
+        writeStringProperty("scenery_paths", sceneryPaths);
+        return true;
+    }
+
+    return false;
+}
   
 bool NavDataCache::rebuild()
 {
index 3a6ef313c85449f3b8277de447e887fd4f5299da..e5d9e7c06f3a01fc1d5ffedd78e2396f6e91abba 100644 (file)
@@ -64,7 +64,13 @@ public:
    ** global input files is changed.
    */
   bool isRebuildRequired();
-  
+
+    /**
+     * check if cached scenery paths have changed, and if so, drop scenery-
+     * dependant data such as ground-nets.
+     */
+  bool dropGroundnetsIfRequired();
+
   /**
    * run the cache rebuild - returns true if rebuild is complete,
    * otherwise keep going.