TORCS  1.3.10
The Open Racing Car Simulator
Loading...
Searching...
No Matches
racepit.cpp
Go to the documentation of this file.
1/***************************************************************************
2
3 file : racepit.cpp
4 created : Sun Jul 12 20:00:00 CET 2026
5 copyright : (C) 2026 by Bernhard Wymann
6 email : berniw@bluewin.ch
7
8 ***************************************************************************/
9
10/***************************************************************************
11 * *
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
16 * *
17 ***************************************************************************/
18
23
24#include "racepit.h"
25
26
27void
29{
30 if (!car) {
31 return;
32 }
33
34 tdble maxFuel = car->_tank - car->_fuel;
35 if (maxFuel < 0.0f) {
36 maxFuel = 0.0f;
37 }
38 if (car->_pitFuel < 0.0f) {
39 car->_pitFuel = 0.0f;
40 } else if (car->_pitFuel > maxFuel) {
41 car->_pitFuel = maxFuel;
42 }
43
44 int maxRepair = car->_dammage;
45 if (maxRepair < 0) {
46 maxRepair = 0;
47 }
48 if (car->_pitRepair < 0) {
49 car->_pitRepair = 0;
50 } else if (car->_pitRepair > maxRepair) {
51 car->_pitRepair = maxRepair;
52 }
53}
54
55
58{
59 if (!car || !raceRules) {
60 return 0.0f;
61 }
62
63 return raceRules->pitstopBaseTime + car->_pitFuel / raceRules->refuelFuelFlow +
64 (tdble)car->_pitRepair * raceRules->damageRepairFactor + car->_penaltyTime;
65}
struct CarElt tCarElt
Car structure (tCarElt).
float tdble
Floating point type used in TORCS.
Definition tgf.h:47
struct RmRaceRules tRmRaceRules
tdble ReComputePitStopServiceTime(const tCarElt *car, const tRmRaceRules *raceRules)
Definition racepit.cpp:57
void ReNormalizePitStop(tCarElt *car)
Definition racepit.cpp:28
Pit stop command normalization and timing helpers.
tdble refuelFuelFlow
Definition raceman.h:191
tdble pitstopBaseTime
Definition raceman.h:193
tdble damageRepairFactor
Definition raceman.h:192