globals.cxx -- FGGlobals::set_fg_scenery():
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.
This commit is contained in:
parent
24e9bb6ce8
commit
72f46a4a6f
2 changed files with 29 additions and 13 deletions
|
@ -157,6 +157,10 @@ void FGGlobals::set_fg_scenery (const string &scenery) {
|
||||||
ulCloseDir( od );
|
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("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -670,7 +670,7 @@ typedef enum {
|
||||||
|
|
||||||
// storage class for deferred object processing in FGTileEntry::load()
|
// storage class for deferred object processing in FGTileEntry::load()
|
||||||
struct Object {
|
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)
|
: type(t), path(p)
|
||||||
{
|
{
|
||||||
in >> name;
|
in >> name;
|
||||||
|
@ -679,10 +679,10 @@ struct Object {
|
||||||
in >> ::skipeol;
|
in >> ::skipeol;
|
||||||
|
|
||||||
if (type == OBJECT)
|
if (type == OBJECT)
|
||||||
SG_LOG(SG_TERRAIN, SG_INFO, token << " " << name);
|
SG_LOG(SG_TERRAIN, SG_INFO, " " << token << " " << name);
|
||||||
else
|
else
|
||||||
SG_LOG(SG_TERRAIN, SG_INFO, token << " " << name << " lon=" << lon
|
SG_LOG(SG_TERRAIN, SG_INFO, " " << token << " " << name << " lon=" <<
|
||||||
<< " lat=" << lat << " elev=" << elev << " hdg=" << hdg);
|
lon << " lat=" << lat << " elev=" << elev << " hdg=" << hdg);
|
||||||
}
|
}
|
||||||
object_type type;
|
object_type type;
|
||||||
string name;
|
string name;
|
||||||
|
@ -699,21 +699,31 @@ FGTileEntry::load( const string_list &path_list, bool is_base )
|
||||||
SGPath object_base;
|
SGPath object_base;
|
||||||
vector<const Object*> objects;
|
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
|
// 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;
|
bool has_base = false;
|
||||||
|
|
||||||
// Generate names for later use
|
|
||||||
string index_str = tile_bucket.gen_index_str();
|
|
||||||
|
|
||||||
SGPath tile_path = path_list[i];
|
SGPath tile_path = path_list[i];
|
||||||
tile_path.append( tile_bucket.gen_base_path() );
|
tile_path.append( tile_bucket.gen_base_path() );
|
||||||
|
|
||||||
SGPath basename = tile_path;
|
SGPath basename = tile_path;
|
||||||
basename.append( index_str );
|
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
|
// 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" ) {
|
if ( token == "OBJECT_BASE" ) {
|
||||||
string name;
|
string name;
|
||||||
in >> name >> ::skipws;
|
in >> name >> ::skipws;
|
||||||
SG_LOG( SG_TERRAIN, SG_INFO, token << " " << name );
|
SG_LOG( SG_TERRAIN, SG_INFO, " " << token << " " << name );
|
||||||
|
|
||||||
if (!found_tile_base) {
|
if (!found_tile_base) {
|
||||||
found_tile_base = true;
|
found_tile_base = true;
|
||||||
|
@ -746,7 +756,7 @@ FGTileEntry::load( const string_list &path_list, bool is_base )
|
||||||
object_base.append(name);
|
object_base.append(name);
|
||||||
|
|
||||||
} else
|
} else
|
||||||
SG_LOG(SG_TERRAIN, SG_INFO, " (skipped)");
|
SG_LOG(SG_TERRAIN, SG_INFO, " (skipped)");
|
||||||
|
|
||||||
// Load only if base is not in another file
|
// Load only if base is not in another file
|
||||||
} else if ( token == "OBJECT" ) {
|
} else if ( token == "OBJECT" ) {
|
||||||
|
@ -755,7 +765,8 @@ FGTileEntry::load( const string_list &path_list, bool is_base )
|
||||||
else {
|
else {
|
||||||
string name;
|
string name;
|
||||||
in >> name >> ::skipeol;
|
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
|
// Always OK to load
|
||||||
|
@ -800,6 +811,7 @@ FGTileEntry::load( const string_list &path_list, bool is_base )
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// ... or generate an ocean tile on the fly
|
// ... or generate an ocean tile on the fly
|
||||||
|
SG_LOG(SG_TERRAIN, SG_INFO, " Generating ocean tile");
|
||||||
ssgBranch *geometry = new ssgBranch;
|
ssgBranch *geometry = new ssgBranch;
|
||||||
Point3D c;
|
Point3D c;
|
||||||
double br;
|
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
|
// 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];
|
const Object *obj = objects[j];
|
||||||
|
|
||||||
if (obj->type == OBJECT) {
|
if (obj->type == OBJECT) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue