]> git.mxchange.org Git - flightgear.git/commitdiff
Fix 3d tables.
authorehofman <ehofman>
Mon, 20 Mar 2006 20:19:16 +0000 (20:19 +0000)
committerehofman <ehofman>
Mon, 20 Mar 2006 20:19:16 +0000 (20:19 +0000)
src/FDM/JSBSim/math/FGTable.cpp
src/FDM/JSBSim/models/propulsion/FGEngine.cpp

index 542b1390c1ff4118ed6b7c7ae442c67acc20340c..584d57fb9a839386956d4bb4d39b5e9910fca5f0 100644 (file)
@@ -104,10 +104,11 @@ FGTable::FGTable(FGPropertyManager* propMan, Element* el) : PropertyManager(prop
   string lookup_axis;
   string call_type;
   string parent_type;
+  string brkpt_string;
   FGPropertyManager* node;
-  Element *tableData;
-  Element *parent_element;
-  Element *axisElement;
+  Element *tableData=0;
+  Element *parent_element=0;
+  Element *axisElement=0;
   string operation_types = "function, product, sum, difference, quotient,"
                            "pow, abs, sin, cos, asin, acos, tan, atan, table";
 
@@ -195,13 +196,23 @@ FGTable::FGTable(FGPropertyManager* propMan, Element* el) : PropertyManager(prop
       }
     }
 
-  } else { // no independentVars found, and table is not marked as internal
-    cerr << endl << fgred << "No independent variable found for table." << fgdef << endl << endl;
-    abort();
+  } else {
+    brkpt_string = el->GetAttributeValue("breakPoint");
+    if (brkpt_string.empty()) {
+     // no independentVars found, and table is not marked as internal, nor is it a 3D table
+      cerr << endl << fgred << "No independent variable found for table."  << fgdef << endl << endl;
+      abort();
+    }
   }
   // end lookup property code
 
-  tableData = el->FindElement("tableData");
+  if (brkpt_string.empty()) {                  // Not a 3D table "table element"
+    tableData = el->FindElement("tableData");
+  } else {                                     // This is a table in a 3D table
+    tableData = el;
+    dimension = 2;                             // Currently, infers 2D table
+  }
+
   for (i=0; i<tableData->GetNumDataLines(); i++) {
     buf << tableData->GetDataLine(i) << string(" ");
   }
@@ -241,6 +252,7 @@ FGTable::FGTable(FGPropertyManager* propMan, Element* el) : PropertyManager(prop
     Type = tt3D;
     colCounter = 1;
     rowCounter = 1;
+    lastRowIndex = lastColumnIndex = 2;
 
     Data = Allocate(); // this data array will contain the keys for the associated tables
     Tables.reserve(nTables); // necessary?
index a385088ae8a08a7fc354c11a63e74062b3821c06..27390de7be700f8723ef4a90b7091d51e43afdac 100644 (file)
@@ -175,7 +175,10 @@ void FGEngine::ConsumeFuel(void)
       if (Tank->GetContents() > 0.0) ++TanksWithOxidizer;
     }
   }
-  if (TanksWithFuel==0 || (haveOxTanks && TanksWithOxidizer==0)) return;
+  if (TanksWithFuel==0 || (haveOxTanks && TanksWithOxidizer==0)) {
+    Starved = true;
+    return;
+  }
 
   for (i=0; i<SourceTanks.size(); i++) {
     Tank = Propulsion->GetTank(SourceTanks[i]);