Boris Koenig:
After applying the attached patches (based on latest CVS) you should have a new option available within your version that should also show up using fgfs --help, the syntax is: fgfs --min-status={level} --show-aircraft whereas "level" can be anything between "alpha","beta","early-production" and "production" Of course running something like fgfs --min-status=alpha --show-aircraft should not return any aircraft right now, as none of the current aircraft definition files in your base-package is using the required <status></status> tag - but you can easily give it a try by adding something like <status>alpha</status> The tag should be placed as a sub-tag within <sim> - so directly behind the <description> tag would be just fine and straight-forward.
This commit is contained in:
parent
4668174848
commit
73313ed0e1
1 changed files with 53 additions and 6 deletions
|
@ -1333,6 +1333,7 @@ struct OptionDesc {
|
|||
{"nav2", true, OPTION_FUNC, "", false, "", fgOptNAV2 },
|
||||
{"adf", true, OPTION_FUNC, "", false, "", fgOptADF },
|
||||
{"dme", true, OPTION_FUNC, "", false, "", fgOptDME },
|
||||
{"min-status", true, OPTION_STRING, "/sim/aircraft-min-status", false, "all", 0 },
|
||||
{0}
|
||||
};
|
||||
|
||||
|
@ -1683,9 +1684,26 @@ fgUsage (bool verbose)
|
|||
#endif
|
||||
}
|
||||
|
||||
// A simple function to return an integer depending on the position
|
||||
// of the status string within the array in order to determine the hierarchy.
|
||||
unsigned int getNumMaturity(const char * str)
|
||||
{
|
||||
// changes should also be reflected in $FG_ROOT/data/options.xml &
|
||||
// $FG_ROOT/data/Translations/string-default.xml
|
||||
const char levels[][20]= {"alpha","beta","early-production","production",0};
|
||||
|
||||
for (int i=0; i<(sizeof(levels)/sizeof(levels[0])-1);i++)
|
||||
if (strcmp(str,levels[i])==0)
|
||||
return i;
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
|
||||
static void fgSearchAircraft(const SGPath &path, string_list &aircraft,
|
||||
bool recursive)
|
||||
{
|
||||
{
|
||||
|
||||
ulDirEnt* dire;
|
||||
ulDir *dirp = ulOpenDir(path.str().c_str());
|
||||
if (dirp == NULL) {
|
||||
|
@ -1720,29 +1738,58 @@ static void fgSearchAircraft(const SGPath &path, string_list &aircraft,
|
|||
}
|
||||
|
||||
SGPropertyNode *desc = NULL;
|
||||
SGPropertyNode *status = NULL;
|
||||
|
||||
SGPropertyNode *node = root.getNode("sim");
|
||||
if (node) {
|
||||
desc = node->getNode("description");
|
||||
// if a status tag is found, read it in
|
||||
if (node->hasValue("status"))
|
||||
status = node->getNode("status");
|
||||
}
|
||||
|
||||
char cstr[96];
|
||||
//additionally display status information where it is available
|
||||
char *status_level = (status) ? status->getStringValue() : "";
|
||||
|
||||
if (strlen(dire->d_name) <= 27) {
|
||||
snprintf(cstr, 96, " %-27s %s", dire->d_name,
|
||||
(desc) ? desc->getStringValue() : "" );
|
||||
(desc) ? desc->getStringValue() : "");
|
||||
|
||||
} else {
|
||||
snprintf(cstr, 96, " %-27s\n%32c%s", dire->d_name, ' ',
|
||||
(desc) ? desc->getStringValue() : "" );
|
||||
(desc) ? desc->getStringValue() : "");
|
||||
}
|
||||
|
||||
aircraft.push_back(cstr);
|
||||
}
|
||||
SGPropertyNode * required_status
|
||||
= fgGetNode ("/sim/aircraft-min-status", true);
|
||||
|
||||
// If the node holds the value "all", then there wasn't any status
|
||||
// level specified, so we simply go ahead and output ALL aircraft
|
||||
if (strcmp(required_status->getStringValue(),"all")==0) {
|
||||
aircraft.push_back(cstr);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the node doesn't hold "all" as its value, then we are supposed
|
||||
// to show only aircraft meeting specific status (development status)
|
||||
// requirements:
|
||||
|
||||
if (node->hasValue("status")) {
|
||||
//Compare (minimally) required status level with actual aircraft status:
|
||||
if ( getNumMaturity(status->getStringValue() ) >=
|
||||
getNumMaturity(required_status->getStringValue() ) )
|
||||
aircraft.push_back(cstr); }
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ulCloseDir(dirp);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Search in the current directory, and in on directory deeper
|
||||
* for <aircraft>-set.xml configuration files and show the aircaft name
|
||||
|
|
Loading…
Reference in a new issue