From: frohlich Date: Sun, 24 May 2009 06:38:58 +0000 (+0000) Subject: When loading stg files honour the original path if given. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2c66081fa4917f2bef24c275d2bc553fc22fc0d8;p=simgear.git When loading stg files honour the original path if given. Modified Files: simgear/scene/tgdb/ReaderWriterSTG.cxx simgear/scene/tgdb/TileEntry.cxx simgear/scene/tgdb/TileEntry.hxx --- diff --git a/simgear/scene/tgdb/ReaderWriterSTG.cxx b/simgear/scene/tgdb/ReaderWriterSTG.cxx index ac4f1059..f79638bb 100644 --- a/simgear/scene/tgdb/ReaderWriterSTG.cxx +++ b/simgear/scene/tgdb/ReaderWriterSTG.cxx @@ -56,10 +56,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterSTG::readNode(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const { - std::string tileName = osgDB::getNameLessExtension(fileName); - tileName = osgDB::getSimpleFileName(tileName); - - osg::Node* result = TileEntry::loadTileByName(tileName, options); + osg::Node* result = TileEntry::loadTileByFileName(fileName, options); // For debugging race conditions #ifdef SLOW_PAGER sleep(5); diff --git a/simgear/scene/tgdb/TileEntry.cxx b/simgear/scene/tgdb/TileEntry.cxx index 510fb976..41f9dedd 100644 --- a/simgear/scene/tgdb/TileEntry.cxx +++ b/simgear/scene/tgdb/TileEntry.cxx @@ -242,9 +242,12 @@ struct Object { // what we'll want to do with the database pager. osg::Node* -TileEntry::loadTileByName(const string& index_str, - const osgDB::ReaderWriter::Options* options) +TileEntry::loadTileByFileName(const string& fileName, + const osgDB::ReaderWriter::Options* options) { + std::string index_str = osgDB::getNameLessExtension(fileName); + index_str = osgDB::getSimpleFileName(index_str); + long tileIndex; { std::istringstream idxStream(index_str); @@ -261,6 +264,8 @@ TileEntry::loadTileByName(const string& index_str, SG_LOG( SG_TERRAIN, SG_INFO, "Loading tile " << index_str ); osgDB::FilePathList path_list=options->getDatabasePathList(); + // Make sure we find the original filename here... + path_list.push_front(osgDB::getFilePath(fileName)); // scan and parse all files and store information for (unsigned int i = 0; i < path_list.size(); i++) { diff --git a/simgear/scene/tgdb/TileEntry.hxx b/simgear/scene/tgdb/TileEntry.hxx index 3cd9e39d..d12fa920 100644 --- a/simgear/scene/tgdb/TileEntry.hxx +++ b/simgear/scene/tgdb/TileEntry.hxx @@ -118,8 +118,8 @@ public: /** * Transition to OSG database pager */ - static osg::Node* loadTileByName(const std::string& index_str, - const osgDB::ReaderWriter::Options*); + static osg::Node* loadTileByFileName(const std::string& index_str, + const osgDB::ReaderWriter::Options*); /** * Return true if the tile entry is loaded, otherwise return false * indicating that the loading thread is still working on this.