Fix a bug (probably)

This commit is contained in:
Miloslav Ciz 2025-03-06 19:53:29 +01:00
parent ddc4f5b6ad
commit ec084222f1
4 changed files with 14 additions and 19 deletions

18
game.h
View file

@ -279,7 +279,7 @@ struct
during a single frame, hold number of
frames for which the key has been
continuously held. */
uint32_t runTimeMS; ///< Current time of the run
uint32_t runTime; ///< Current time of the run, in ticks.
char popupStr[LCR_POPUP_STR_SIZE];
uint8_t popupCountdown;
@ -424,7 +424,7 @@ void LCR_gameResetRun(uint8_t replay, uint8_t ghost)
LCR_rendererLoadMapChunks();
LCR_game.ghost.active = ghost;
LCR_gameSetState(LCR_GAME_STATE_RUN_STARTING);
LCR_game.runTimeMS = 0;
LCR_game.runTime = 0;
}
void LCR_gameGetNthGhostSample(unsigned int n,
@ -1129,7 +1129,7 @@ void LCR_gameDraw3DView(void)
LCR_rendererComputeTextWidth(str,2) - 20,
LCR_EFFECTIVE_RESOLUTION_Y - LCR_rendererComputeTextHeight(2) - 20,0,2);
LCR_gameTimeToStr(LCR_game.runTimeMS,str);
LCR_gameTimeToStr(LCR_timeTicksToMS(LCR_game.runTime),str);
if (LCR_game.state != LCR_GAME_STATE_RUN_FINISHED)
LCR_rendererDrawText(str,20,LCR_EFFECTIVE_RESOLUTION_Y -
@ -1138,7 +1138,7 @@ void LCR_gameDraw3DView(void)
LCR_rendererDrawText(str,((LCR_EFFECTIVE_RESOLUTION_X -
LCR_rendererComputeTextWidth(str,4)) / 2),
LCR_EFFECTIVE_RESOLUTION_Y / 2,
LCR_game.runTimeMS <= LCR_currentMap.targetTime * LCR_RACING_TICK_MS ?
LCR_game.runTime <= LCR_currentMap.targetTime ?
0x0700 : 0x4208,4);
LCR_gameTimeToStr(LCR_currentMap.targetTime * LCR_RACING_TICK_MS,str);
@ -1178,11 +1178,11 @@ void LCR_gameHandleInput(void)
{
if (LCR_game.keyStates[LCR_KEY_A] == 1)
{
if (LCR_game.runTimeMS <= LCR_currentMap.targetTime * LCR_RACING_TICK_MS
if (LCR_game.runTime <= LCR_currentMap.targetTime
&& !LCR_game.ghost.active)
{
LCR_LOG1("setting new target time");
LCR_currentMap.targetTime = LCR_game.runTimeMS / LCR_RACING_TICK_MS;
LCR_currentMap.targetTime = LCR_game.runTime;
}
LCR_gameResetRun(LCR_racing.playingReplay,LCR_game.ghost.active);
@ -1456,7 +1456,7 @@ uint8_t LCR_gameStep(uint32_t time)
LCR_racingGetCarBlockCoords(carBlock);
LCR_rendererMarkTakenCP(carBlock[0],carBlock[1],carBlock[2]);
LCR_audioPlaySound(LCR_SOUND_CLICK);
LCR_gameTimeToStr(LCR_game.runTimeMS,str);
LCR_gameTimeToStr(LCR_timeTicksToMS(LCR_game.runTime),str);
LCR_gamePopupMessage(str);
}
else if (events & LCR_RACING_EVENT_FINISHED &&
@ -1464,7 +1464,7 @@ uint8_t LCR_gameStep(uint32_t time)
{
LCR_LOG1("finished");
if (LCR_game.runTimeMS <= LCR_currentMap.targetTime * LCR_RACING_TICK_MS)
if (LCR_game.runTime <= LCR_currentMap.targetTime)
LCR_gameSaveReplay();
LCR_audioPlaySound(LCR_SOUND_CLICK);
@ -1492,7 +1492,7 @@ uint8_t LCR_gameStep(uint32_t time)
(engineIntensity < 256 ? engineIntensity : 255));
if (LCR_game.state != LCR_GAME_STATE_RUN_FINISHED)
LCR_game.runTimeMS = LCR_racingGetRunTimeMS();
LCR_game.runTime = LCR_racing.tick;
LCR_game.nextRacingTickTime += LCR_RACING_TICK_MS;
}