FlightGear version check: Difference between revisions

Jump to navigation Jump to search
Cleanup
(→‎For aircraft developers: Small fix for the {{Non-stable}} template.)
(Cleanup)
Line 1: Line 1:
{{Stub}}
{{Stub}}
{{-}}
{{note|When installing/using aircraft the FlightGear version and the aircraft version must match. Otherwise strange bugs should be expected and the version-mismatch combination will not be supported by the FlightGear community.}}


[[File:Version-mismatch-dialog.png|thumb|[[PUI]] dialog showing a version conflict between the FlightGear version and aircraft version]]
[[File:Version-mismatch-dialog-via-pui2canvas.png|thumb|The same dialog as processed by [[Howto:Processing legacy PUI dialogs using Canvas|pui2canvas]]]]


{{caution|When installing/using aircraft the FlightGear version and the aircraft version must match. Otherwise strange bugs should be expected and the version-mismatch combination will not be supported by the FlightGear community.}}
If in doubt, people should check the [[about dialog]] or <code>/sim/version/</code> in the [[property tree]] using the [[property browser]].
 
[[File:Version-mismatch-dialog.png|thumb|pui/xml dialog showing a version conflict between fgfs binary and aircraft version]]
 
If in doubt, people should check the [[About dialog]] or even /sim/version in the property tree using the proeperty brwoser.
 


== For aircraft developers ==
== For aircraft developers ==
{{Non-stable}}
{{Non-stable}}
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
  <minimum-flightgear-version>4.0.0</minimum-flightgear-version>
<minimum-flightgear-version>4.0.0</minimum-flightgear-version>
</syntaxhighlight>
</syntaxhighlight>


Minimum FlightGear version required for this aircraft [http://forum.flightgear.org/viewtopic.php?f=4&t=28010&p=264797#p264788], note that this is a "soft" requirement - i.e. it will not terminate fg or trigger an error, but only show a warning in the console/fg window using a Nasal script that checks if the property is set. This is mainly intended to make compatibility issues more obvious, i.e. end-users downloading new aircraft and wanting to use them in conjunction with an old version of FlightGear, which is causing quite a bit of workload on the support forum.
Minimum FlightGear version required for this aircraft, note that this is a "soft" requirement i.e., it will not terminate FlightGear or trigger an error, but will only show a warning in the console using a Nasal script that checks if the property is set. This is mainly intended to make compatibility issues more obvious, such as end-users downloading new aircraft and wanting to use them in conjunction with an old version of FlightGear, which is causing quite a bit of workload on the support forum.
We are hoping to also display this info in the [[About dialog]]
We are hoping to also display this info in the [[about dialog]].
 
The [[Saab JA-37 Viggen]] is a good example of using Nasal and properties to provide backwards-compatibility. See [{{github url|NikolaiVChr/flightgear-saab-ja-37-viggen|Aircraft/JA37/Nasal/ja37.nas|l=1105/1203}} ja37.nas] for the relevant code.


== Fgdata ==
== Fgdata ==
[[File:Property-browser-showing-version-info.png|thumb|property browser showing /sim/version info]]
{{Note|This is currently just proof-of-concept code which will need to be refined/reviewed and committed to FGData.}}


[[File:Property-browser-showing-version-info.png|thumb|Property browser showing the <code>/sim/version</code> properties.]]


{{Note|This is currently just proof-of-concept code which will need to be refined/reviewed and committed to fgdata.}}
This script ensures that the check will be executed for each loaded aircraft, without having to touch any [[aircraft-set.xml]] files, and it will also work with [[reset & re-init]].
[[$FG_ROOT]]/Nasal/version.nas (this ensures that the check will be executed for each loaded aircraft, without having to touch any -set.xml files, and it will also work with [[Reset & re-init]]).
<syntaxhighlight lang="nasal">
<syntaxhighlight lang="nasal">
# $FG_ROOT/Nasal/version.nas
# anonymous function that will be called directly
# anonymous function that will be called directly
(func() {
(func() {
##
    # get current aircraft
# current aircraft
    var ac = getprop("/sim/aircraft");
var ac = getprop("/sim/aircraft");
    var url = 'http://wiki.flightgear.org/FlightGear_Version_Check';
var url = "http://wiki.flightgear.org/FlightGear_Version_Check";
    var fgversion = getprop("/sim/version/flightgear");
var fgversion = getprop("/sim/version/flightgear");
 
logprint(3,"FlightGear v."~ fgversion);
    logprint(3, "FlightGear v" ~ fgversion);
 
    var acversion = getprop("/sim/minimum-flightgear-version");


var acversion = getprop("/sim/minimum-flightgear-version");
    if (acversion == nil) {
        logprint(4, ac ~ "-set.xml file missing version info, see " ~ url);
        return; # version not specified
    }


if (acversion == nil) {
    logprint(3, "Aircraft requires FlightGear v" ~ acversion);
logprint(4,ac~"-set.xml file missing version info, see: "~url);
return; # version not specified
}
logprint(3,"Aircraft requires FlightGear v."~acversion);


# parse the version number into major/minor and patch level
    # parse the version number into major/minor and patch level
# http://plausible.org/nasal/lib.html
    # http://wiki.flightgear.org/Nasal_library#split.28.29
var (major, minor, patch) = split(".", acversion);
    var (major, minor, patch) = split(".", acversion);
}
})();
)();
</syntaxhighlight>
</syntaxhighlight>


[[File:Version-mismatch-dialog-via-pui2canvas.png|thumb|version mismatch dialog created/processed by Canvas via pui2canvas]]
== Related content ==
=== Forum topics ===
* [http://forum.flightgear.org/viewtopic.php?f=6&t=28020 version checking for matching fgfs and -set.xml files]

Navigation menu