]> git.mxchange.org Git - flightgear.git/blobdiff - src/Scenery/FGTileLoader.cxx
Make use of the ground material types
[flightgear.git] / src / Scenery / FGTileLoader.cxx
index bb89d746cccc889ee10c6f715519b5d8d9646551..e8fee269a1e105902b516b583e86de91b2faaa3e 100644 (file)
@@ -16,7 +16,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 // $Id$
 
@@ -25,6 +25,7 @@
 #endif
 
 #include <simgear/compiler.h>
+#include <simgear/structure/exception.hxx>
 
 #include <Main/globals.hxx>
 #include "FGTileLoader.hxx"
@@ -40,12 +41,12 @@ extern ssgBranch *ground;
  */
 FGTileLoader::FGTileLoader()
 {
-#if defined(ENABLE_THREADS) && ENABLE_THREADS
+#if defined(ENABLE_THREADS)
     // Create and start the loader threads.
     for (int i = 0; i < MAX_THREADS; ++i)
     {
        threads[i] = new LoaderThread(this);
-       threads[i]->start();
+       threads[i]->start( 1 );
     }
 #endif // ENABLE_THREADS
 }
@@ -55,7 +56,7 @@ FGTileLoader::FGTileLoader()
  */
 FGTileLoader::~FGTileLoader()
 {
-#if defined(ENABLE_THREADS) && ENABLE_THREADS
+#if defined(ENABLE_THREADS)
     // Wake up its time to die.
     // queue_cond.broadcast();
 
@@ -88,27 +89,15 @@ FGTileLoader::add( FGTileEntry* tile )
 {
     /**
      * Initialise tile_path here and not in ctor to avoid problems
-     * with the initialastion order of global objects.
+     * with the initialisation order of global objects.
      */
     static bool beenhere = false;
-    if (!beenhere)
-    {
-       if ( !globals->get_fg_scenery().empty() ) {
-            tile_path = globals->get_fg_scenery();
-       } else {
-            SGPath tmp;
-           tmp.set( globals->get_fg_root() );
-            tmp.append( "Scenery/Terrain" );
-#ifdef _MSC_VER
-            tmp.append( ";");
-#else
-            tmp.append( ":");
-#endif
-            tmp.append(globals->get_fg_root() );
-            tmp.append( "Scenery/Objects" );
-            tile_path = tmp.str();
-       }
-       beenhere = true;
+    if (!beenhere) {
+        tile_path = globals->get_fg_scenery();
+        if (!tile_path.size())
+            throw sg_throwable(string("No valid scenery path defined!"));
+
+        beenhere = true;
     }
 
     tile_load_queue.push( tile );
@@ -132,7 +121,7 @@ void
 FGTileLoader::update()
 {
 
-#if defined(ENABLE_THREADS) && ENABLE_THREADS
+#if defined(ENABLE_THREADS)
     // send a signal to the pager thread that it is allowed to load
     // another tile
     mutex.lock();
@@ -166,7 +155,17 @@ FGTileLoader::update()
 }
 
 
-#if defined(ENABLE_THREADS) && ENABLE_THREADS
+#if defined(ENABLE_THREADS)
+/**
+ * Ensure mutex is unlocked.
+ */
+void 
+cleanup_handler( void* arg )
+{
+    FGTileLoader* loader = (FGTileLoader*) arg;
+    loader->mutex.unlock();
+}
+
 /**
  * 
  */
@@ -203,14 +202,4 @@ FGTileLoader::LoaderThread::run()
     }
     pthread_cleanup_pop(1);
 }
-
-/**
- * Ensure mutex is unlocked.
- */
-void 
-cleanup_handler( void* arg )
-{
-    FGTileLoader* loader = (FGTileLoader*) arg;
-    loader->mutex.unlock();
-}
 #endif // ENABLE_THREADS