]> git.mxchange.org Git - flightgear.git/commitdiff
#348 related: More places where missing files were not reported properly
authorThorstenB <brehmt@gmail.com>
Sun, 3 Jul 2011 11:06:41 +0000 (13:06 +0200)
committerThorstenB <brehmt@gmail.com>
Sun, 3 Jul 2011 11:06:41 +0000 (13:06 +0200)
Whenever resolving a (relative) path to an absolute path with
'resolve_maybe_aircraft_path', check if the result is empty and report original
(relative) path as missing. Otherwise no or a meaningless message is
issued ("File '' not found.").

src/Autopilot/autopilotgroup.cxx
src/Instrumentation/HUD/HUD.cxx
src/Main/fg_commands.cxx
src/Main/splash.cxx
src/Scripting/NasalSys.cxx

index 347a39e0e7c567134f6545057954b5e3b09eb249..cf06bb4b422133b9a5c33e155eada34d40abf432 100644 (file)
@@ -119,23 +119,29 @@ void FGXMLAutopilotGroupImplementation::initFrom( SGPropertyNode_ptr rootNode, c
         }
 
         SGPath config = globals->resolve_maybe_aircraft_path(pathNode->getStringValue());
-
-        SG_LOG( SG_ALL, SG_INFO, "Reading property-rule configuration from " << config.str() );
-
-        try {
-            SGPropertyNode_ptr root = new SGPropertyNode();
-            readProperties( config.str(), root );
-
-            SG_LOG( SG_AUTOPILOT, SG_INFO, "adding  property-rule subsystem " << apName );
-            FGXMLAutopilot::Autopilot * ap = new FGXMLAutopilot::Autopilot( autopilotNodes[i], root );
-            ap->set_name( apName );
-            set_subsystem( apName, ap );
-            _autopilotNames.push_back( apName );
-
-        } catch (const sg_exception& e) {
-            SG_LOG( SG_AUTOPILOT, SG_ALERT, "Failed to load property-rule configuration: "
-                    << config.str() << ":" << e.getMessage() );
-            continue;
+        if (config.isNull())
+        {
+            SG_LOG( SG_ALL, SG_ALERT, "Cannot find property-rule configuration file '" << pathNode->getStringValue() << "'." );
+        }
+        else
+        {
+            SG_LOG( SG_ALL, SG_INFO, "Reading property-rule configuration from " << config.str() );
+
+            try {
+                SGPropertyNode_ptr root = new SGPropertyNode();
+                readProperties( config.str(), root );
+
+                SG_LOG( SG_AUTOPILOT, SG_INFO, "adding  property-rule subsystem " << apName );
+                FGXMLAutopilot::Autopilot * ap = new FGXMLAutopilot::Autopilot( autopilotNodes[i], root );
+                ap->set_name( apName );
+                set_subsystem( apName, ap );
+                _autopilotNames.push_back( apName );
+
+            } catch (const sg_exception& e) {
+                SG_LOG( SG_AUTOPILOT, SG_ALERT, "Failed to load property-rule configuration: "
+                        << config.str() << ":" << e.getMessage() );
+                continue;
+            }
         }
     }
 }
index eace97cc00e4a2a6746b093c298e607a5459b8d6..6d9e0bd90134185c74741fa934b19af6bc19f620 100644 (file)
@@ -346,6 +346,11 @@ int HUD::load(const char *file, float x, float y, int level, const string& inden
     const int MAXNEST = 10;
 
     SGPath path(globals->resolve_maybe_aircraft_path(file));
+    if (path.isNull())
+    {
+        SG_LOG(SG_INPUT, SG_ALERT, "HUD: Cannot find configuration file '" << file << "'.");
+        return 0x2;
+    }
 
     if (!level) {
         SG_LOG(SG_INPUT, TREE, endl << "load " << file);
@@ -362,7 +367,7 @@ int HUD::load(const char *file, float x, float y, int level, const string& inden
     int ret = 0;
     ifstream input(path.c_str());
     if (!input.good()) {
-        SG_LOG(SG_INPUT, SG_ALERT, "HUD: Cannot read configuration from " << path.str());
+        SG_LOG(SG_INPUT, SG_ALERT, "HUD: Cannot read configuration from '" << path.c_str() << "'");
         return 0x4;
     }
 
index f9933243d055cf6598b802ea37950e9a181ee085..7711f6b4f0acc194326f5f109e98d871cd7e6fcb 100644 (file)
@@ -1229,7 +1229,15 @@ do_load_xml_to_proptree(const SGPropertyNode * arg)
     std::string icao = arg->getStringValue("icao");
     if (icao.empty()) {
         if (file.isRelative()) {
-          file = globals->resolve_maybe_aircraft_path(file.str());
+          SGPath absPath = globals->resolve_maybe_aircraft_path(file.str());
+          if (!absPath.isNull())
+              file = absPath;
+          else
+          {
+              SG_LOG(SG_IO, SG_ALERT, "loadxml: Cannot find XML property file '"  
+                          << file.str() << "'.");
+              return false;
+          }
         }
     } else {
         if (!XMLLoader::findAirportData(icao, file.str(), file)) {
index 36cc603260b8870b4562ad68f24ca3cd1c789cdb..a21064cabadba863f19fe85cc87d02b5cce791e4 100644 (file)
@@ -187,8 +187,19 @@ static osg::Node* fgCreateSplashCamera()
   fgSetString("/sim/startup/program-name", namestring);
   delete[] namestring;
 
-  SGPath tpath( globals->get_fg_root() );
-  if (splash_texture == NULL || !strcmp(splash_texture, "")) {
+  SGPath tpath;
+  if (splash_texture  && strcmp(splash_texture, "")) {
+      tpath = globals->resolve_maybe_aircraft_path(splash_texture);
+      if (tpath.isNull())
+      {
+          SG_LOG( SG_GENERAL, SG_ALERT, "Cannot find splash screen file '" << splash_texture
+                  << "'. Using default." );
+      }
+  }
+
+  if (tpath.isNull()) {
+    // no splash screen specified - select random image
+    tpath = globals->get_fg_root();
     // load in the texture data
     int num = (int)(sg_random() * 5.0 + 1.0);
     char num_str[5];
@@ -197,10 +208,8 @@ static osg::Node* fgCreateSplashCamera()
     tpath.append( "Textures/Splash" );
     tpath.concat( num_str );
     tpath.concat( ".png" );
-  } else {
-    tpath = globals->resolve_maybe_aircraft_path(splash_texture);
   }
-  
+
   osg::Texture2D* splashTexture = new osg::Texture2D;
   splashTexture->setImage(osgDB::readImageFile(tpath.c_str()));
 
index 9542c5d55a790e080bdcf97307e471f63b49f3a2..e2bc88619c5e8c2dafea66b679eacd0ff10a4de1 100644 (file)
@@ -880,8 +880,13 @@ void FGNasalSys::loadPropertyScripts(SGPropertyNode* n)
             if (!p.isAbsolute() || !p.exists())
             {
                 p = globals->resolve_maybe_aircraft_path(file);
+                if (p.isNull())
+                {
+                    SG_LOG(SG_NASAL, SG_ALERT, "Cannot find Nasal script '" <<
+                            file << "' for module '" << module << "'.");
+                }
             }
-            ok &= loadModule(p, module);
+            ok &= p.isNull() ? false : loadModule(p, module);
             j++;
         }