Melchior FRANZ:
Wouldn't it be better to prepare the whole list of paths (or two separate ones for Terrain/Objects if necessary) in FGGlobals::set_fg_scenery, and to pass the vector<string>s to FGTileEntry::load? It doesn't seem to make a lot of sense to split the path up, modify it, mount it together to one string again, and then let FGTileEntry::load split it up again. Here we go: Main/globals.cxx ================ As fg_scenery is now a string_list, we don't need initialization. Furthermore, this list is cleared with every set_fg_scenery() call. ctor: create default dir from fg_root if necessary. Otherwise check all paths of --fg-scenery/FG_SCENERY: If the path doesn't exist, ignore it. If it contains a dir Terrain and/or Objects, then only add that to the list. If it contains neither, then use the path as is. Scenery/tileentry.cxx ===================== Trivial: don't split a "base path", but use the given path_list as is. (I considered a variable name "path_list" better suited than "search".) Scenery/FGTileLoader.cxx ======================== No more fiddling with sub-paths. This has to be delivered by get_fg_scenery already.
This commit is contained in:
parent
43df8a9cc0
commit
ff9258528c
6 changed files with 46 additions and 54 deletions
|
@ -46,7 +46,6 @@ FGGlobals::FGGlobals() :
|
|||
event_mgr( new SGEventMgr ),
|
||||
sim_time_sec( 0.0 ),
|
||||
fg_root( "" ),
|
||||
fg_scenery( "" ),
|
||||
#if defined(FX) && defined(XMESA)
|
||||
fullscreen( true ),
|
||||
#endif
|
||||
|
@ -118,34 +117,42 @@ void FGGlobals::set_fg_root (const string &root) {
|
|||
}
|
||||
|
||||
void FGGlobals::set_fg_scenery (const string &scenery) {
|
||||
if (scenery.empty())
|
||||
return;
|
||||
SGPath s;
|
||||
if (scenery.empty()) {
|
||||
s.set( fg_root );
|
||||
s.append( "Scenery" );
|
||||
} else
|
||||
s.set( scenery );
|
||||
|
||||
// TODO: Split the scenery path up into separate
|
||||
// paths (taking into account the search path separator
|
||||
// and test them individually.
|
||||
// -EMH-
|
||||
SGPath pt( scenery ), po( scenery );
|
||||
pt.append("Terrain");
|
||||
po.append("Objects");
|
||||
string_list path_list = sgPathSplit( s.str() );
|
||||
fg_scenery.clear();
|
||||
|
||||
ulDir *td = ulOpenDir(pt.c_str());
|
||||
ulDir *od = ulOpenDir(po.c_str());
|
||||
for (unsigned i = 0; i < path_list.size(); i++) {
|
||||
|
||||
if (td == NULL) {
|
||||
if (od == NULL) {
|
||||
fg_scenery = scenery;
|
||||
} else {
|
||||
fg_scenery = po.str();
|
||||
ulCloseDir(od);
|
||||
ulDir *d = ulOpenDir( path_list[0].c_str() );
|
||||
if (d == NULL)
|
||||
continue;
|
||||
ulCloseDir( d );
|
||||
|
||||
SGPath pt( path_list[i] ), po( path_list[i] );
|
||||
pt.append("Terrain");
|
||||
po.append("Objects");
|
||||
|
||||
ulDir *td = ulOpenDir( pt.c_str() );
|
||||
ulDir *od = ulOpenDir( po.c_str() );
|
||||
|
||||
if (td == NULL && od == NULL)
|
||||
fg_scenery.push_back( path_list[i] );
|
||||
else {
|
||||
if (td != NULL) {
|
||||
fg_scenery.push_back( pt.str() );
|
||||
ulCloseDir( td );
|
||||
}
|
||||
if (od != NULL) {
|
||||
fg_scenery.push_back( po.str() );
|
||||
ulCloseDir( od );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (od != NULL) {
|
||||
pt.add(po.str());
|
||||
ulCloseDir(od);
|
||||
}
|
||||
fg_scenery = pt.str();
|
||||
ulCloseDir(td);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -106,8 +106,8 @@ private:
|
|||
// Root of FlightGear data tree
|
||||
string fg_root;
|
||||
|
||||
// Root of FlightGear scenery tree
|
||||
string fg_scenery;
|
||||
// Roots of FlightGear scenery tree
|
||||
string_list fg_scenery;
|
||||
|
||||
// Fullscreen mode for old 3DFX cards.
|
||||
#if defined(FX) && defined(XMESA)
|
||||
|
@ -236,7 +236,7 @@ public:
|
|||
inline const string &get_fg_root () const { return fg_root; }
|
||||
void set_fg_root (const string &root);
|
||||
|
||||
inline const string &get_fg_scenery () const { return fg_scenery; }
|
||||
inline const string_list &get_fg_scenery () const { return fg_scenery; }
|
||||
void set_fg_scenery (const string &scenery);
|
||||
|
||||
#if defined(FX) && defined(XMESA)
|
||||
|
|
|
@ -88,22 +88,12 @@ 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" );
|
||||
tmp.add(globals->get_fg_root() );
|
||||
tmp.append( "Scenery/Objects" );
|
||||
tile_path = tmp.str();
|
||||
}
|
||||
beenhere = true;
|
||||
if (!beenhere) {
|
||||
tile_path = globals->get_fg_scenery();
|
||||
beenhere = true;
|
||||
}
|
||||
|
||||
tile_load_queue.push( tile );
|
||||
|
|
|
@ -109,9 +109,9 @@ private:
|
|||
#endif
|
||||
|
||||
/**
|
||||
* Base name of directory containing tile data file.
|
||||
* Base names of directories containing tile data files.
|
||||
*/
|
||||
string tile_path;
|
||||
string_list tile_path;
|
||||
|
||||
#if defined(ENABLE_THREADS) && ENABLE_THREADS
|
||||
/**
|
||||
|
|
|
@ -662,29 +662,24 @@ bool FGTileEntry::obj_load( const string& path,
|
|||
|
||||
|
||||
void
|
||||
FGTileEntry::load( const string &base_path, bool is_base )
|
||||
FGTileEntry::load( const string_list &path_list, bool is_base )
|
||||
{
|
||||
SG_LOG( SG_TERRAIN, SG_INFO, "load() base search path = "
|
||||
<< base_path );
|
||||
|
||||
bool found_tile_base = false;
|
||||
|
||||
string_list search = sgPathSplit( base_path );
|
||||
|
||||
// obj_load() will generate ground lighting for us ...
|
||||
ssgVertexArray *light_pts = new ssgVertexArray( 100 );
|
||||
|
||||
ssgBranch* new_tile = new ssgBranch;
|
||||
|
||||
unsigned int i = 0;
|
||||
while ( i < search.size() ) {
|
||||
while ( i < path_list.size() ) {
|
||||
|
||||
bool has_base = false;
|
||||
|
||||
// Generate names for later use
|
||||
string index_str = tile_bucket.gen_index_str();
|
||||
|
||||
SGPath tile_path = search[i];
|
||||
SGPath tile_path = path_list[i];
|
||||
tile_path.append( tile_bucket.gen_base_path() );
|
||||
|
||||
SGPath basename = tile_path;
|
||||
|
@ -918,7 +913,7 @@ FGTileEntry::load( const string &base_path, bool is_base )
|
|||
ssgBranch *geometry = new ssgBranch;
|
||||
Point3D c;
|
||||
double br;
|
||||
if ( sgGenTile( search[0], tile_bucket, &c, &br,
|
||||
if ( sgGenTile( path_list[0], tile_bucket, &c, &br,
|
||||
globals->get_matlib(), geometry ) )
|
||||
{
|
||||
center = c;
|
||||
|
|
|
@ -227,7 +227,7 @@ public:
|
|||
* @param base name of directory containing tile data file.
|
||||
* @param is_base is this a base terrain object for which we should generate
|
||||
* random ground light points */
|
||||
void load( const string &base_path, bool is_base );
|
||||
void load( const string_list &base_path, bool is_base );
|
||||
|
||||
/**
|
||||
* Return true if the tile entry is loaded, otherwise return false
|
||||
|
|
Loading…
Add table
Reference in a new issue