From 2c66081fa4917f2bef24c275d2bc553fc22fc0d8 Mon Sep 17 00:00:00 2001 From: frohlich Date: Sun, 24 May 2009 06:38:58 +0000 Subject: [PATCH] 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 --- simgear/scene/tgdb/ReaderWriterSTG.cxx | 5 +---- simgear/scene/tgdb/TileEntry.cxx | 9 +++++++-- simgear/scene/tgdb/TileEntry.hxx | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) 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. -- 2.39.5