]> git.mxchange.org Git - flightgear.git/commitdiff
fgFindAircraftPath(): put the MAX_DEPTH check at a place where it makes sense
authormfranz <mfranz>
Mon, 2 Apr 2007 23:19:36 +0000 (23:19 +0000)
committermfranz <mfranz>
Mon, 2 Apr 2007 23:19:36 +0000 (23:19 +0000)
src/Main/fg_init.cxx

index cc4556733a65c186d68e967a7cf5f4549623ddab..fcdc6274f877f679ed0a514dce56164893e4f112 100644 (file)
@@ -517,18 +517,22 @@ static string fgFindAircraftPath( const SGPath &path, const string &aircraft, in
 
     string result;
     while ((dire = ulReadDir(dirp)) != NULL) {
-        if (dire->d_isdir && depth < MAXDEPTH) {
-            if ( strcmp("CVS", dire->d_name) && strcmp(".", dire->d_name)
-                 && strcmp("..", dire->d_name) && strcmp("AI", dire->d_name))
-            {
-                SGPath next = path;
-                next.append(dire->d_name);
-
-                result = fgFindAircraftPath( next, aircraft, depth + 1 );
-                if ( ! result.empty() ) {
-                    break;
-                }
+        if (dire->d_isdir) {
+            if (depth > MAXDEPTH)
+                continue;
+
+            if (!strcmp("CVS", dire->d_name) || !strcmp(".", dire->d_name)
+                    || !strcmp("..", dire->d_name) || !strcmp("AI", dire->d_name))
+                continue;
+
+            SGPath next = path;
+            next.append(dire->d_name);
+
+            result = fgFindAircraftPath( next, aircraft, depth + 1 );
+            if ( ! result.empty() ) {
+                break;
             }
+
         } else if ( !strcmp(dire->d_name, aircraft.c_str()) ) {
             result = path.str();
             break;