event_mgr( new SGEventMgr ),
sim_time_sec( 0.0 ),
fg_root( "" ),
- fg_scenery( "" ),
#if defined(FX) && defined(XMESA)
fullscreen( true ),
#endif
}
void FGGlobals::set_fg_scenery (const string &scenery) {
- if (scenery.empty())
- return;
-
- // 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");
-
- ulDir *td = ulOpenDir(pt.c_str());
- ulDir *od = ulOpenDir(po.c_str());
-
- if (td == NULL) {
- if (od == NULL) {
- fg_scenery = scenery;
- } else {
- fg_scenery = po.str();
- ulCloseDir(od);
- }
- } else {
- if (od != NULL) {
- pt.add(po.str());
- ulCloseDir(od);
+ SGPath s;
+ if (scenery.empty()) {
+ s.set( fg_root );
+ s.append( "Scenery" );
+ } else
+ s.set( scenery );
+
+ string_list path_list = sgPathSplit( s.str() );
+ fg_scenery.clear();
+
+ for (unsigned i = 0; i < path_list.size(); i++) {
+
+ 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 );
+ }
}
- fg_scenery = pt.str();
- ulCloseDir(td);
}
}
// 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)
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)
{
/**
* 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 );
#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
/**
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;
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;
* @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