// Update pit data and strategy. void Pit::update() { if (mypit != NULL) { if (isBetween(car->_distFromStartLine)) { if (getPitstop()) { setInPit(true); } } else { setInPit(false); } if (getPitstop()) { car->_raceCmd = RM_CMD_PIT_ASKED; } } }
/* update pit data and strategy */ void Pit::update() { if (mypit != NULL) { if (isBetween(car->_distFromStartLine)) { if (getPitstop()) { setInPit(true); } } else { setInPit(false); } /* check for damage */ if (car->_dammage > PIT_DAMMAGE) { setPitstop(true); } /* fuel update */ int id = car->_trkPos.seg->id; if (id >= 0 && id < 5 && !fuelchecked) { if (car->race.laps > 0) { fuelperlap = MAX(fuelperlap, (lastfuel+lastpitfuel-car->priv.fuel)); } lastfuel = car->priv.fuel; lastpitfuel = 0.0; fuelchecked = true; } else if (id > 5) { fuelchecked = false; } int laps = car->_remainingLaps-car->_lapsBehindLeader; if (!getPitstop() && laps > 0) { if (car->_fuel < 1.5*fuelperlap && car->_fuel < laps*fuelperlap) { setPitstop(true); } } if (getPitstop()) car->_raceCmd = RM_CMD_PIT_ASKED; } }