- check for availability of MP models (add 'available' member)
- display "??? foo" if "foo" isn't available on the system - make sure x/y/z are never nil (I think I had such a case)
This commit is contained in:
parent
5ac4c13406
commit
158c7ea800
1 changed files with 19 additions and 6 deletions
|
@ -267,13 +267,13 @@ var dialog = {
|
||||||
foreach (var mp; model.list) {
|
foreach (var mp; model.list) {
|
||||||
var n = mp.node;
|
var n = mp.node;
|
||||||
var ac = geo.Coord.new().set_xyz(
|
var ac = geo.Coord.new().set_xyz(
|
||||||
n.getNode("position/global-x").getValue(),
|
n.getNode("position/global-x").getValue() or 0,
|
||||||
n.getNode("position/global-y").getValue(),
|
n.getNode("position/global-y").getValue() or 0,
|
||||||
n.getNode("position/global-z").getValue());
|
n.getNode("position/global-z").getValue() or 0);
|
||||||
var distance = self.distance_to(ac);
|
var distance = self.distance_to(ac);
|
||||||
|
|
||||||
n.setValues({
|
n.setValues({
|
||||||
"model-short": mp.model,
|
"model-short": mp.available ? mp.model : "??? " ~ mp.model,
|
||||||
"bearing-to": self.course_to(ac),
|
"bearing-to": self.course_to(ac),
|
||||||
"distance-to-km": distance / 1000.0,
|
"distance-to-km": distance / 1000.0,
|
||||||
"distance-to-nm": distance * M2NM,
|
"distance-to-nm": distance * M2NM,
|
||||||
|
@ -360,6 +360,8 @@ var model = {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
me.data = {};
|
me.data = {};
|
||||||
|
me.callsign = {};
|
||||||
|
var root = string.normpath(getprop("/sim/fg-root")) ~ '/';
|
||||||
foreach (var n; props.globals.getNode("ai/models", 1).getChildren("multiplayer")) {
|
foreach (var n; props.globals.getNode("ai/models", 1).getChildren("multiplayer")) {
|
||||||
if (!n.getNode("valid", 1).getValue())
|
if (!n.getNode("valid", 1).getValue())
|
||||||
continue;
|
continue;
|
||||||
|
@ -368,13 +370,24 @@ var model = {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var model = n.getNode("sim/model/path").getValue();
|
var model = n.getNode("sim/model/path").getValue();
|
||||||
|
var available = 0;
|
||||||
|
if (io.stat(string.normpath(root ~ "AI/" ~ model)) != nil)
|
||||||
|
available = 1;
|
||||||
|
elsif (io.stat(string.normpath(root ~ model)) != nil)
|
||||||
|
available = 2;
|
||||||
|
else
|
||||||
|
print("Multiplayer model not available: ", model);
|
||||||
|
|
||||||
model = split(".", split("/", model)[-1])[0];
|
model = split(".", split("/", model)[-1])[0];
|
||||||
model = me.remove_suffix(model, "-model");
|
model = me.remove_suffix(model, "-model");
|
||||||
model = me.remove_suffix(model, "-anim");
|
model = me.remove_suffix(model, "-anim");
|
||||||
|
|
||||||
var path = n.getPath();
|
var path = n.getPath();
|
||||||
me.data[path] = { node: n, callsign: callsign, model: model,
|
var data = { node: n, callsign: callsign, model: model, path: path,
|
||||||
path: path, sort: string.lc(callsign)};
|
sort: string.lc(callsign), available: available };
|
||||||
|
|
||||||
|
me.data[path] = data;
|
||||||
|
me.callsign[callsign] = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
me.list = sort(keys(me.data), func(a, b) cmp(me.data[a].sort, me.data[b].sort));
|
me.list = sort(keys(me.data), func(a, b) cmp(me.data[a].sort, me.data[b].sort));
|
||||||
|
|
Loading…
Reference in a new issue