// 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; } } }
// Computes offset to track middle for trajectory. float Pit::getPitOffset(float offset, float fromstart) { if (mypit != NULL) { if (getInPit() || (getPitstop() && isBetween(fromstart))) { fromstart = toSplineCoord(fromstart); return spline->evaluate(fromstart); } } return offset; }
/* 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; } }
// Checks if we stay too long without getting captured by the pit. // Distance is the distance to the pit along the track, when the pit is // ahead it is > 0, if we overshoot the pit it is < 0. bool Pit::isTimeout(float distance) { if (car->_speed_x > 1.0f || distance > 3.0f || !getPitstop()) { pittimer = 0.0f; return false; } else { pittimer += (float) RCM_MAX_DT_ROBOTS; if (pittimer > 3.0f) { pittimer = 0.0f; return true; } else { return false; } } }