41 return MIN(car->_laps, s->_totLaps + 1) - 1;
55 cars[j] = cars[j - 1];
57 cars[j]->_pos = j + 1;
58 cars[j - 1]->_pos = j;
78 const tdble drivethrough = 10.0f;
79 const tdble stopandgo = 6.0f + drivethrough;
80 const tdble v0 = 84.0f;
82 const tdble dv = v0 - v1;
85 if (dv > 1.0f && v1 > 1.0f) {
89 for (
int i = 0; i < s->_ncars; i++) {
94 car->_penaltyTime += dt + drivethrough;
96 car->_penaltyTime += dt + stopandgo;
109 if (!s || !s->
cars) {
115 for (
int i = 1; i < s->_ncars; i++) {
122 if (previous->_penaltyTime <= 0.0f) {
128 if (previousLaps != currentLaps) {
133 if (previousLaps < 1 ||
141 const double previousTime = previous->_curTime + previous->_penaltyTime;
142 const double currentTime = current->_curTime + current->_penaltyTime;
144 if (previousTime <= currentTime) {
#define RM_PENALTY_DRIVETHROUGH
struct CarElt tCarElt
Car structure (tCarElt).
struct CarPenalty tCarPenalty
One penalty.
#define RM_PENALTY_STOPANDGO
float tdble
Floating point type used in TORCS.
#define GF_TAILQ_NEXT(elm, field)
Next element of a TAILQ.
#define GF_TAILQ_FIRST(head)
First element of a TAILQ.
struct Situation tSituation
cars situation used to inform the GUI and the drivers
static void applyPendingPitPenalties(tSituation *s, const tTrackPitInfo *pits)
Apply pending drive-through and stop-and-go penalties as time.
static int completedResultLaps(const tSituation *s, const tCarElt *car)
Return the result lap count used for final classification.
static void swapAdjacentCars(tCarElt **cars, int j)
Swap adjacent cars and refresh their result positions.
void ReApplyRaceTimePenalties(tSituation *s, const tTrackPitInfo *pits)
Apply race time penalties and update same-lap result order.
Race penalty application and penalty-aware race result ordering.
tCarElt ** cars
list of cars
tdble len
Lenght of each pit stop.
tdble speedLimit
Speed limit between pitStart and pitEnd.
int nMaxPits
number max of pits
#define TR_PIT_ON_TRACK_SIDE
The pits are on the track side.