]> git.mxchange.org Git - flightgear.git/commitdiff
fixed egngine feed bug
authorehofman <ehofman>
Thu, 15 Oct 2009 08:18:10 +0000 (08:18 +0000)
committerTim Moore <timoore@redhat.com>
Fri, 16 Oct 2009 09:22:47 +0000 (11:22 +0200)
src/FDM/JSBSim/models/propulsion/FGEngine.cpp

index b46830aef47fcee1a188e8ecc0423cfc17e96b66..fb2c5226e24de14e02e29370425f776dc2e02078 100644 (file)
@@ -172,35 +172,40 @@ void FGEngine::ConsumeFuel(void)
   if (TrimMode) return;
 
   unsigned int i;
-  double Fshortage, TanksWithFuel, FuelNeeded;
+  double Fshortage, FuelNeeded;
   FGTank* Tank;
-  Fshortage = TanksWithFuel = FuelNeeded = 0.0;
-  double FuelToBurn = CalcFuelNeed();
+  unsigned int TanksWithFuel = 0;
+  Fshortage = FuelNeeded = 0.0;
+  double FuelToBurn;
   unsigned int CurrentPriority = 1;
   vector <int> FeedList;
   Starved = false;
 
+  FuelToBurn = CalcFuelNeed();
+
   while (FuelToBurn > 0.0) {
 
     // Count how many fuel tanks with the current priority level have fuel.
     // If none, then try next lower priority.  Build the feed list.
     while ((TanksWithFuel == 0.0) && (CurrentPriority <= Propulsion->GetNumTanks())) {
       for (i=0; i<Propulsion->GetNumTanks(); i++) {
-        Tank = Propulsion->GetTank(i);
-        if (Tank->GetType() == FGTank::ttFUEL) {
-          if ((Tank->GetContents() > 0.0) && ((unsigned int)Tank->GetPriority() == CurrentPriority)) {
-             ++TanksWithFuel;
-             FeedList.push_back(i);
-           } 
-        } else {
-           cerr << "No oxidizer tanks should be used for this engine type." << endl;
+        if (SourceTanks[i] != 0) {
+          Tank = Propulsion->GetTank(i);
+          if (Tank->GetType() == FGTank::ttFUEL) {
+            if ((Tank->GetContents() > 0.0) && ((unsigned int)Tank->GetPriority() == CurrentPriority)) {
+               ++TanksWithFuel;
+               FeedList.push_back(i);
+             } 
+          } else {
+             cerr << "No oxidizer tanks should be used for this engine type." << endl;
+          }
         }
       }
-      if (TanksWithFuel == 0.0) CurrentPriority++;
+      if (TanksWithFuel == 0) CurrentPriority++;
     }
 
     // No fuel found at any priority!
-    if (TanksWithFuel == 0.0) {
+    if (TanksWithFuel == 0) {
       Starved = true;
       return;
     }
@@ -216,7 +221,7 @@ void FGEngine::ConsumeFuel(void)
     // check if we were not able to burn all the fuel we needed to at this priority level
     if (FuelToBurn > 0.001) {
       CurrentPriority++;
-      TanksWithFuel = 0.0;
+      TanksWithFuel = 0;
       FeedList.clear();
     }