diff --git a/src/FDM/JSBSim/models/propulsion/FGEngine.cpp b/src/FDM/JSBSim/models/propulsion/FGEngine.cpp index b46830aef..fb2c5226e 100644 --- a/src/FDM/JSBSim/models/propulsion/FGEngine.cpp +++ b/src/FDM/JSBSim/models/propulsion/FGEngine.cpp @@ -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 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; iGetNumTanks(); 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(); }