From 2172fcedd1c1b2c0b8fec87bdb19af5c28b18cd4 Mon Sep 17 00:00:00 2001 From: Miloslav Ciz Date: Thu, 23 Jan 2025 11:45:19 +0100 Subject: [PATCH] Reload chunks on reset --- TODO.txt | 2 +- game.h | 11 +++++++++-- renderer.h | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/TODO.txt b/TODO.txt index e537e5f..868b94e 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,6 +1,5 @@ =========== GENERAL ============== -- force chunk reload upon map restart so that there's no blinking at start - make a small txt game menual - test if the replay stretching works - replay validation @@ -32,6 +31,7 @@ =========== HANDLED ============== - allow stopping car rotation in air like in Trackmania +- force chunk reload upon map restart so that there's no blinking at start - ghost visible distance -- maybe even car should have this (watching rep with free camera)? maybe generalize setCar/GhostVisibility to setCarGhostVisibilityDistance where 0 means make invisible? diff --git a/game.h b/game.h index 71c3bcb..c3fd6c0 100644 --- a/game.h +++ b/game.h @@ -345,6 +345,7 @@ void LCR_gameResetRun(uint8_t replay, uint8_t ghost) LCR_racingGetCarTransform(carTransform,carTransform + 3,0); LCR_rendererSetCarTransform(carTransform,carTransform + 3); LCR_rendererCameraReset(); + LCR_rendererLoadMapChunks(); LCR_game.ghost.active = ghost; LCR_gameSetState(LCR_GAME_STATE_RUN_STARTING); LCR_game.runTimeMS = 0; @@ -429,13 +430,19 @@ void LCR_gameGhostGetTransform(uint32_t frame, position[2] += LCR_GAME_UNIT / 16; } +/** + Prepares ghost, computes position/rotation samples. When calling this, the + correct replay and map have to be already loaded. +*/ void _LCR_gamePrepareGhost(void) { LCR_GameUnit carTransform[6]; LCR_LOG1("preparing ghost"); LCR_gameResetRun(1,0); - + + LCR_replayInitPlaying(); + uint8_t *currentSample = LCR_game.ghost.samples; LCR_game.ghost.stretch = 0; @@ -444,7 +451,7 @@ void _LCR_gamePrepareGhost(void) (LCR_SETTING_GHOST_STEP << LCR_game.ghost.stretch) * LCR_SETTING_GHOST_MAX_SAMPLES) { - LCR_LOG2("stretching replay step"); + LCR_LOG1("stretching replay step"); LCR_game.ghost.stretch++; } diff --git a/renderer.h b/renderer.h index 79b9cb8..6213959 100644 --- a/renderer.h +++ b/renderer.h @@ -1531,7 +1531,7 @@ S3L_Unit _LCR_rendererSmoothRot(S3L_Unit angleOld, S3L_Unit angleNew, Loads the map models with 8 chunks that are nearest to a certain point towards which the camera is looking. */ -void _LCR_rendererLoadMapChunks(void) +void LCR_rendererLoadMapChunks(void) { LCR_LOG2("loading map chunks"); @@ -1925,7 +1925,7 @@ void LCR_rendererDraw3D(void) #endif if (LCR_renderer.frame % LCR_SETTING_MAP_CHUNK_RELOAD_INTERVAL == 0) - _LCR_rendererLoadMapChunks(); + LCR_rendererLoadMapChunks(); LCR_rendererDrawSky(LCR_currentMap.environment, LCR_renderer.scene.camera.transform.rotation.y,