1
0
Fork 0

fixed egngine feed bug

This commit is contained in:
ehofman 2009-10-15 08:18:10 +00:00 committed by Tim Moore
parent 0f0f25512d
commit 5e22f4b563

View file

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