From f236a438b8c0efb0d6e17d7fd73c3235de8fe536 Mon Sep 17 00:00:00 2001 From: mfranz Date: Thu, 29 Mar 2007 18:25:48 +0000 Subject: [PATCH] Fix redundant elsif, fix and simplify broken fill-up code. (Pointed out by Csaba HALASZ) --- Aircraft/Generic/aar.nas | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Aircraft/Generic/aar.nas b/Aircraft/Generic/aar.nas index dad5b5cd1..e13038bfc 100644 --- a/Aircraft/Generic/aar.nas +++ b/Aircraft/Generic/aar.nas @@ -125,7 +125,7 @@ var update_loop = func { t.getNode("level-lbs").setDoubleValue(lbs); } - } elsif (consumed < 0) { + } else { #find the number of tanks which can accept fuel var available = 0; @@ -140,7 +140,7 @@ var update_loop = func { } if (available > 0) { - var fuel_per_tank = consumed / available; + var fuel_per_tank = -consumed / available; # add fuel to each available tank foreach (var t; selected_tanks) { @@ -148,9 +148,8 @@ var update_loop = func { var capacity = t.getNode("capacity-gal_us").getValue() * ppg; var lbs = t.getNode("level-gal_us").getValue() * ppg; - if (capacity - lbs >= fuel_per_tank) { - lbs -= fuel_per_tank; - } elsif (capacity - lbs < fuel_per_tank) { + lbs += fuel_per_tank; + if (lbs > capacity) { lbs = capacity; }