TORCS  1.3.10
The Open Racing Car Simulator
Loading...
Searching...
No Matches
racepenalties.cpp File Reference

Race penalty application and penalty-aware race result ordering. More...

#include "racepenalties.h"
Include dependency graph for racepenalties.cpp:

Go to the source code of this file.

Functions

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.
static void applyPendingPitPenalties (tSituation *s, const tTrackPitInfo *pits)
 Apply pending drive-through and stop-and-go penalties as time.
void ReApplyRaceTimePenalties (tSituation *s, const tTrackPitInfo *pits)
 Apply race time penalties and update same-lap result order.

Detailed Description

Race penalty application and penalty-aware race result ordering.

Author
Bernhard Wymann

Definition in file racepenalties.cpp.

Function Documentation

◆ applyPendingPitPenalties()

void applyPendingPitPenalties ( tSituation * s,
const tTrackPitInfo * pits )
static

Apply pending drive-through and stop-and-go penalties as time.

The estimate assumes 300 km/h on track, the configured pit speed in the pit lane, 10 seconds for pit entry/exit, and 6 extra seconds for a stop-and-go.

Parameters
[in,out]sCurrent race situation.
[in]pitsPit lane information.

Definition at line 72 of file racepenalties.cpp.

◆ completedResultLaps()

int completedResultLaps ( const tSituation * s,
const tCarElt * car )
static

Return the result lap count used for final classification.

Race result storage caps cars at one lap beyond the configured race distance and writes completed laps as _laps - 1; penalty ordering uses the same lap group to avoid moving cars across lap boundaries.

Parameters
[in]sCurrent race situation.
[in]carCar to inspect.
Returns
Completed lap count used for result ordering.

Definition at line 39 of file racepenalties.cpp.

◆ ReApplyRaceTimePenalties()

void ReApplyRaceTimePenalties ( tSituation * s,
const tTrackPitInfo * pits )

Apply race time penalties and update same-lap result order.

Existing time penalties are kept, pending drive-through and stop-and-go penalties are converted into estimated time penalties when the race has usable on-track-side pit information, and then penalized cars are moved down only within their current completed-lap group.

Parameters
[in,out]sCurrent race situation containing the ordered car list.
[in]pitsPit lane information used to estimate pending penalty time.

Definition at line 107 of file racepenalties.cpp.

Here is the call graph for this function:

◆ swapAdjacentCars()

void swapAdjacentCars ( tCarElt ** cars,
int j )
static

Swap adjacent cars and refresh their result positions.

Parameters
[in,out]carsOrdered car pointer array.
[in]jIndex of the lower-ranked car before the swap.

Definition at line 52 of file racepenalties.cpp.