1
0
Fork 0

Stuart Buchanan:

1) The chat menu will now select the runway closest to the aircraft
   when the aircraft is on the ground, or very low (< 100ft). This
   handles the case where the user has selected a runway explicitly,
   e.g. 01R for KSFO take-offs for noise abatement. My thanks for
   AnMaster for pointing this out on IRC. Note that above 100 ft, the
   wind-appropriate runway will still be used.
2) Change to keyboard description for the - key, as pointed out by
   Melchior.
This commit is contained in:
martin 2007-12-11 15:20:00 +00:00
parent f4131eb6f2
commit 33277e0730
2 changed files with 52 additions and 18 deletions

View file

@ -179,27 +179,61 @@
};
}
# Determine the active runway.
var wind_speed = getprop("/environment/wind-speed-kt");
var wind_from = wind_speed ? getprop("/environment/wind-from-heading-deg") : 270;
var max = -1;
# Determine the active runway. We have two ways to do this:
# - If the aircraft is on the ground (or very close to it), we'll try to determine
# the runway it is closest to.
# - If the aircraft is in the air, we'll work out the active runway based on the wind.
var active_runway = "";
foreach (var r; keys(airport.runways)) {
var curr = airport.runways[r];
var on_ground = (getprop("/position/altitude-agl-ft") < 100);
if (on_ground)
{
# To find out the closest runway to the aircrafts position, we'll look at the heading
# required to go from the aircraft's current position to the center of each runway.
# The closer this is to the runways real heading, the more likely this is the runway
# we're on. Note that we can't rely on /sim/atc/runway, as this is only set on
# initialization.
var max = 360;
var loc = geo.aircraft_position();
var wind = wind_from - curr.heading;
while (wind >= 180) wind -= 360;
while (wind < -180) wind += 360;
var deviation = math.abs(wind) + 1e-20;
var v = (0.01 * curr.length + 0.01 * curr.width) / deviation;
if (v > max) {
max = v;
active_runway = r;
foreach (var r; keys(airport.runways)) {
var curr = airport.runways[r];
var p = geo.Coord.new();
p.set_latlon(curr.lat, curr.lon, airport.elevation);
var course = loc.course_to(p);
var deviation = math.abs(course - curr.heading);
if (deviation < max)
{
active_runway = r;
max = deviation;
}
}
}
else
{
var wind_speed = getprop("/environment/wind-speed-kt");
var wind_from = wind_speed ? getprop("/environment/wind-from-heading-deg") : 270;
var max = -1;
foreach (var r; keys(airport.runways)) {
var curr = airport.runways[r];
var wind = wind_from - curr.heading;
while (wind >= 180) wind -= 360;
while (wind < -180) wind += 360;
var deviation = math.abs(wind) + 1e-20;
var v = (0.01 * curr.length + 0.01 * curr.width) / deviation;
if (v > max) {
max = v;
active_runway = r;
}
}
}
# Find our distance and cardinal direction to the airport.
var directions = split(",", "North,North East,East,South East,South,South West,West,North West");

View file

@ -355,7 +355,7 @@ top down before the key bindings are parsed.
<key n="45">
<name>-</name>
<repeatable type="bool">false</repeatable>
<desc>Compose Chat</desc>
<desc>Chat Menu</desc>
<binding>
<command>dialog-show</command>
<dialog-name>chat-menu</dialog-name>