From 449c7bf7ef7097a86f1c08026f3d3a78228d12d4 Mon Sep 17 00:00:00 2001 From: andy Date: Sat, 27 Mar 2004 18:26:55 +0000 Subject: [PATCH] Oops. A last minute change broke piston engines. The "phantom" fuel tanks created by the C++ code look empty, and were causing the fuel code to detect out of fuel conditions. Since there is no way to tell a "FDM" tank from a "C++" tank, I just filter them by capacity. Very ugly hack, we need to fix the code to report only the tanks created by the aircraft/FDM configuration. --- Nasal/fuel.nas | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Nasal/fuel.nas b/Nasal/fuel.nas index 2d615a998..a213c089a 100644 --- a/Nasal/fuel.nas +++ b/Nasal/fuel.nas @@ -35,11 +35,17 @@ fuelUpdate = func { AllTanks = props.globals.getNode("consumables/fuel").getChildren("tank"); - # Build a list of selected tanks + # Build a list of selected tanks. Note the filtering for + # "zero-capacity" tanks. The FlightGear code likes to define + # zombie tanks that have no meaning to the FDM, so we have to take + # measures to ignore them here. selectedTanks = []; foreach(t; AllTanks) { - if(t.getNode("selected", 1).getBoolValue()) { - append(selectedTanks, t); + cap = t.getNode("capacity-gal_us", 1).getValue(); + if(cap != nil and cap > 0.01) { + if(t.getNode("selected", 1).getBoolValue()) { + append(selectedTanks, t); + } } } @@ -94,7 +100,7 @@ initialize = func { foreach(t; AllTanks) { initDoubleProp(t, "level-gal_us", 0); initDoubleProp(t, "level-lbs", 0); - initDoubleProp(t, "capacity-gal_us", 1); # Not zero (div/zero issue) + initDoubleProp(t, "capacity-gal_us", 0.01); # Not zero (div/zero issue) initDoubleProp(t, "density-ppg", 6.0); # gasoline if(t.getNode("selected") == nil) {