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;
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();
}