Re #341.
Moved fuel calculation to separate function. Tweaked initial fuel handling. git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@3378 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: a8751e9166c3fde951b42688367312fb92b5b353 Former-commit-id: 243b130a275bfe05f819d4c18b4681063422a12f
This commit is contained in:
parent
b7cbc0da89
commit
4a83d44ad2
1 changed files with 23 additions and 19 deletions
|
@ -1342,25 +1342,29 @@ pitcmd(int index, tCarElt* car, tSituation *s)
|
|||
// fill in as much fuel as required for the whole race,
|
||||
// or if the tank is too small, fill the tank completely.
|
||||
static void SetFuelAtRaceStart(tTrack* track, void **carParmHandle,
|
||||
tSituation *s, int idx) {
|
||||
// Load and set parameters.
|
||||
tdble fuel_per_lap = track->length * MaxFuelPerMeter;
|
||||
tdble fuel_for_race = fuel_per_lap * (s->_totLaps + 1.0f)
|
||||
+ fuel_per_lap / 60.0 * MAX(s->_totTime, 0); //aimed at timed sessions
|
||||
tSituation *s, int idx) {
|
||||
tdble fuel_requested;
|
||||
tdble initial_fuel = GfParmGetNum(*carParmHandle, SECT_CAR, PRM_FUEL,
|
||||
NULL, 0.0f);
|
||||
if (initial_fuel) {
|
||||
// If starting fuel is set up explicitely,
|
||||
// no use computing anything...
|
||||
fuel_requested = initial_fuel;
|
||||
} else {
|
||||
// We must load and calculate parameters.
|
||||
tdble fuel_per_lap = track->length * MaxFuelPerMeter;
|
||||
tdble fuel_for_race = fuel_per_lap * (s->_totLaps + 1.0f);
|
||||
fuel_for_race += fuel_per_lap / 60.0 * MAX(s->_totTime, 0);
|
||||
// aimed at timed sessions
|
||||
fuel_for_race /= (1.0 + ((tdble)HCtx[idx]->nbPitStopProg));
|
||||
// divide qty byt planned pitstops
|
||||
//fuel_for_race += FuelReserve;
|
||||
// Add some reserve
|
||||
|
||||
fuel_for_race /= (1.0 + ((tdble)HCtx[idx]->nbPitStopProg));
|
||||
fuel_for_race += FuelReserve;
|
||||
|
||||
const tdble tank_capacity = GfParmGetNum(*carParmHandle, SECT_CAR, PRM_TANK,
|
||||
NULL, 100.0f);
|
||||
float initial_fuel = 0;//GfParmGetNum(*carParmHandle, SECT_PRIVATE, PRV_MAX_FUEL,
|
||||
// NULL, 0.0f);
|
||||
tdble fuel_requested;
|
||||
if (initial_fuel) {
|
||||
fuel_requested = initial_fuel;
|
||||
} else {
|
||||
fuel_requested = MIN(fuel_for_race, tank_capacity);
|
||||
}
|
||||
const tdble tank_capacity = GfParmGetNum(*carParmHandle, SECT_CAR, PRM_TANK,
|
||||
NULL, 100.0f);
|
||||
fuel_requested = MIN(fuel_for_race, tank_capacity);
|
||||
}
|
||||
|
||||
GfParmSetNum(*carParmHandle, SECT_CAR, PRM_FUEL, NULL, fuel_requested);
|
||||
GfParmSetNum(*carParmHandle, SECT_CAR, PRM_FUEL, NULL, fuel_requested);
|
||||
} // SetFuelAtRaceStart
|
||||
|
|
Loading…
Reference in a new issue