From 1eb5de245b78214bf16dc60c8d3b80164adaa0fb Mon Sep 17 00:00:00 2001 From: mfranz Date: Mon, 2 Apr 2007 23:19:36 +0000 Subject: [PATCH] fgFindAircraftPath(): put the MAX_DEPTH check at a place where it makes sense --- src/Main/fg_init.cxx | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index cc4556733..fcdc6274f 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -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); + if (dire->d_isdir) { + if (depth > MAXDEPTH) + continue; - result = fgFindAircraftPath( next, aircraft, depth + 1 ); - if ( ! result.empty() ) { - break; - } + 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;