]> git.mxchange.org Git - flightgear.git/commitdiff
globals.cxx -- FGGlobals::set_fg_scenery():
authormfranz <mfranz>
Sat, 3 Dec 2005 10:20:35 +0000 (10:20 +0000)
committermfranz <mfranz>
Sat, 3 Dec 2005 10:20:35 +0000 (10:20 +0000)
    Insert empty string as marker between FG_SCENERY path elements.
    FG_SCENERY=A:B expands to [A/Terrain, A/Objects, "", B/Terrain, B/Objects, ""]
    (assuming that both A/ and B/ have Terrain/ and Objects/ subdirs).

tileentry.cxx -- FGTileEntry::load():
    Check all tile dirs in FG_SCENERY from left to right: add all objects
    to the scenery until a terrain tile was found: In this case read the
    rest of that group (i.e. the Objects/ twin dir) and then stop scanning.

    Better structuring of log messages & fix warnings.

src/Main/globals.cxx
src/Scenery/tileentry.cxx

index 077a65a03d911bd5679514425911693610605d47..8b8a6a853c2d52c4a3bed4e51880390378adf566 100644 (file)
@@ -157,6 +157,10 @@ void FGGlobals::set_fg_scenery (const string &scenery) {
                 ulCloseDir( od );
             }
         }
+        // insert a marker for FGTileEntry::load(), so that
+        // FG_SCENERY=A:B becomes list ["A/Terrain", "A/Objects", "",
+        // "B/Terrain", "B/Objects", ""]
+        fg_scenery.push_back("");
     }
 }
 
index 2f723843893cc53d9968c0848ebb8e19b4e0de9d..329ae43454a6846a3c79add624675b3941cee252 100644 (file)
@@ -670,7 +670,7 @@ typedef enum {
 
 // storage class for deferred object processing in FGTileEntry::load()
 struct Object {
-    Object(object_type t, string& token, const SGPath& p, istream& in)
+    Object(object_type t, const string& token, const SGPath& p, istream& in)
         : type(t), path(p)
     {
         in >> name;
@@ -679,10 +679,10 @@ struct Object {
         in >> ::skipeol;
 
         if (type == OBJECT)
-            SG_LOG(SG_TERRAIN, SG_INFO, token << "  " << name);
+            SG_LOG(SG_TERRAIN, SG_INFO, "    " << token << "  " << name);
         else
-            SG_LOG(SG_TERRAIN, SG_INFO, token << "  " << name << "  lon=" << lon
-                    << "  lat=" << lat << "  elev=" << elev << "  hdg=" << hdg);
+            SG_LOG(SG_TERRAIN, SG_INFO, "    " << token << "  " << name << "  lon=" <<
+                    lon << "  lat=" << lat << "  elev=" << elev << "  hdg=" << hdg);
     }
     object_type type;
     string name;
@@ -699,21 +699,31 @@ FGTileEntry::load( const string_list &path_list, bool is_base )
     SGPath object_base;
     vector<const Object*> objects;
 
+    string index_str = tile_bucket.gen_index_str();
+    SG_LOG( SG_TERRAIN, SG_INFO, "Loading tile " << index_str );
+
     // scan and parse all files and store information
-    for (int i = 0; i < path_list.size(); i++) {
+    for (unsigned int i = 0; i < path_list.size(); i++) {
+        // If we found a terrain tile in Terrain/, we have to process the
+        // Objects/ dir in the same group, too, before we can stop scanning.
+        // FGGlobals::set_fg_scenery() inserts an empty string to path_list
+        // as marker.
+        if (path_list[i].empty()) {
+            if (found_tile_base)
+                break;
+            else
+                continue;
+        }
 
         bool has_base = false;
 
-        // Generate names for later use
-        string index_str = tile_bucket.gen_index_str();
-
         SGPath tile_path = path_list[i];
         tile_path.append( tile_bucket.gen_base_path() );
 
         SGPath basename = tile_path;
         basename.append( index_str );
 
-        SG_LOG( SG_TERRAIN, SG_INFO, "Loading tile " << basename.str() );
+        SG_LOG( SG_TERRAIN, SG_INFO, "  Trying " << basename.str() );
 
 
         // Check for master .stg (scene terra gear) file
@@ -736,7 +746,7 @@ FGTileEntry::load( const string_list &path_list, bool is_base )
             if ( token == "OBJECT_BASE" ) {
                 string name;
                 in >> name >> ::skipws;
-                SG_LOG( SG_TERRAIN, SG_INFO, token << "  " << name );
+                SG_LOG( SG_TERRAIN, SG_INFO, "    " << token << " " << name );
 
                 if (!found_tile_base) {
                     found_tile_base = true;
@@ -746,7 +756,7 @@ FGTileEntry::load( const string_list &path_list, bool is_base )
                     object_base.append(name);
 
                 } else
-                    SG_LOG(SG_TERRAIN, SG_INFO, " (skipped)");
+                    SG_LOG(SG_TERRAIN, SG_INFO, "    (skipped)");
 
                             // Load only if base is not in another file
             } else if ( token == "OBJECT" ) {
@@ -755,7 +765,8 @@ FGTileEntry::load( const string_list &path_list, bool is_base )
                 else {
                     string name;
                     in >> name >> ::skipeol;
-                    SG_LOG(SG_TERRAIN, SG_INFO, token << "  " << name << "  (skipped)");
+                    SG_LOG(SG_TERRAIN, SG_INFO, "    " << token << "  "
+                            << name << "  (skipped)");
                 }
 
                             // Always OK to load
@@ -800,6 +811,7 @@ FGTileEntry::load( const string_list &path_list, bool is_base )
 
     } else {
         // ... or generate an ocean tile on the fly
+        SG_LOG(SG_TERRAIN, SG_INFO, "  Generating ocean tile");
         ssgBranch *geometry = new ssgBranch;
         Point3D c;
         double br;
@@ -817,7 +829,7 @@ FGTileEntry::load( const string_list &path_list, bool is_base )
 
 
     // now that we have a valid center, process all the objects
-    for (int j = 0; j < objects.size(); j++) {
+    for (unsigned int j = 0; j < objects.size(); j++) {
         const Object *obj = objects[j];
 
         if (obj->type == OBJECT) {