From 0d7769ae724986397205fbe9bf188f4bb5d49386 Mon Sep 17 00:00:00 2001 From: James Turner Date: Wed, 20 Oct 2010 00:07:54 +0100 Subject: [PATCH] Search aircraft dirs when loading AI models. Thanks to Thorsten Brehm for the catch. --- src/AIModel/AIBase.cxx | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/AIModel/AIBase.cxx b/src/AIModel/AIBase.cxx index 8a073eb6d..514c6abb0 100644 --- a/src/AIModel/AIBase.cxx +++ b/src/AIModel/AIBase.cxx @@ -194,18 +194,27 @@ void FGAIBase::Transform() { } bool FGAIBase::init(bool search_in_AI_path) { - osg::ref_ptr opt= - new osgDB::ReaderWriter::Options(*osgDB::Registry::instance()->getOptions()); - + + string f; if(search_in_AI_path) { - SGPath ai_path(globals->get_fg_root()); - ai_path.append("AI"); - opt->getDatabasePathList().push_front(ai_path.str()); + // setup a modified Options strucutre, with only the $fg-root/AI defined; + // we'll check that first, then give the normal search logic a chance. + // this ensures that models in AI/ are preferred to normal models, where + // both exist. + osg::ref_ptr + opt(osg::clone(osgDB::Registry::instance()->getOptions(), osg::CopyOp::SHALLOW_COPY)); + + SGPath ai_path(globals->get_fg_root(), "AI"); + opt->setDatabasePath(ai_path.str()); + + f = osgDB::findDataFile(model_path, opt.get()); } - string f = osgDB::findDataFile(model_path, opt.get()); - + if (f.empty()) { + f = simgear::SGModelLib::findDataFile(model_path); + } + if(f.empty()) f = fgGetString("/sim/multiplay/default-model", default_model); -- 2.39.5