@@ -11169,42 +11169,55 @@ static void CG_CalculateSpeed(centity_t *cent) {
11169
11169
11170
11170
static void CG_RaceTimer (void )
11171
11171
{
11172
- char timerStr [32 ] = { 0 };
11173
- int time , minutes , seconds , milliseconds ;
11174
-
11175
- if (!cg .predictedPlayerState .stats [STAT_RACEMODE ])
11176
- return ;
11177
- if (!cg .predictedPlayerState .duelTime )
11172
+ if (!cg .predictedPlayerState .stats [STAT_RACEMODE ] || !cg .predictedPlayerState .duelTime ) {
11173
+ cg .startSpeed = 0 ;
11174
+ cg .displacement = 0 ;
11175
+ cg .maxSpeed = 0 ;
11176
+ cg .displacementSamples = 0 ;
11178
11177
return ;
11178
+ }
11179
11179
11180
- time = (cg .time - cg .predictedPlayerState .duelTime );
11181
- minutes = (time / 1000 ) / 60 ;
11182
- seconds = (time / 1000 ) % 60 ;
11183
- milliseconds = (time % 1000 );
11180
+ {
11181
+ char timerStr [48 ] = { 0 };
11182
+ const int time = (cg .time - cg .predictedPlayerState .duelTime );
11183
+ const int minutes = (time / 1000 ) / 60 ;
11184
+ const int seconds = (time / 1000 ) % 60 ;
11185
+ const int milliseconds = (time % 1000 );
11184
11186
11185
- if (cg_raceTimer . integer > 1 ) {
11186
- if ( time < 1000 ) {
11187
+ if (time < cg . lastRaceTime ) {
11188
+ cg . startSpeed = 0 ;
11187
11189
cg .displacement = 0 ;
11188
11190
cg .maxSpeed = 0 ;
11189
11191
cg .displacementSamples = 0 ;
11190
11192
}
11191
- else {
11192
- if (cg .currentSpeed > cg .maxSpeed )
11193
- cg .maxSpeed = cg .currentSpeed ;
11194
- cg .displacement += cg .currentSpeed ;
11195
- cg .displacementSamples ++ ;
11193
+
11194
+ if (cg_raceTimer .integer > 1 ) {
11195
+ if (time > 0 ) {
11196
+ if (!cg .startSpeed )
11197
+ cg .startSpeed = (int )(cg .currentSpeed + 0.5f );
11198
+
11199
+ if (cg .currentSpeed > cg .maxSpeed )
11200
+ cg .maxSpeed = (int )(cg .currentSpeed + 0.5f );
11201
+ cg .displacement += cg .currentSpeed ;
11202
+ cg .displacementSamples ++ ;
11203
+ }
11196
11204
}
11197
- }
11198
11205
11199
- if (cg_raceTimer .integer < 3 )
11200
- Com_sprintf (timerStr , sizeof (timerStr ), "%i:%02i.%i\n" , minutes , seconds , milliseconds / 100 );
11201
- else
11202
- Com_sprintf (timerStr , sizeof (timerStr ), "%i:%02i.%03i\n" , minutes , seconds , milliseconds );
11206
+ cg .lastRaceTime = time ;
11203
11207
11204
- if (cg_raceTimer .integer > 1 && cg .displacementSamples )
11205
- Q_strcat (timerStr , sizeof (timerStr ), va ("Max: %i\nAvg: %i" , (int )floorf (cg .maxSpeed + 0.5f ), cg .displacement / cg .displacementSamples ));
11208
+ if (cg_raceTimer .integer < 3 )
11209
+ Com_sprintf (timerStr , sizeof (timerStr ), "%i:%02i.%i\n" , minutes , seconds , milliseconds / 100 );
11210
+ else
11211
+ Com_sprintf (timerStr , sizeof (timerStr ), "%i:%02i.%03i\n" , minutes , seconds , milliseconds );
11206
11212
11207
- CG_Text_Paint (cg_raceTimerX .integer , cg_raceTimerY .integer , cg_raceTimerSize .value , colorTable [CT_WHITE ], timerStr , 0.0f , 0 , ITEM_ALIGN_RIGHT | ITEM_TEXTSTYLE_OUTLINED , FONT_NONE );
11213
+ if (cg_raceTimer .integer > 1 && cg .displacementSamples )
11214
+ Q_strcat (timerStr , sizeof (timerStr ), va ("Max: %i\nAvg: %i" , (int )(cg .maxSpeed + 0.5f ), cg .displacement / cg .displacementSamples ));
11215
+
11216
+ if (time < 3000 )
11217
+ Q_strcat (timerStr , sizeof (timerStr ), va ("\nStart: %i" , cg .startSpeed ));
11218
+
11219
+ CG_Text_Paint (cg_raceTimerX .integer , cg_raceTimerY .integer , cg_raceTimerSize .value , colorTable [CT_WHITE ], timerStr , 0.0f , 0 , ITEM_ALIGN_RIGHT | ITEM_TEXTSTYLE_OUTLINED , FONT_NONE );
11220
+ }
11208
11221
}
11209
11222
11210
11223
#define ACCEL_SAMPLES 16
0 commit comments