From 1b363995a6ba0a921ca2dfc9b7ede05d49a8e5ba Mon Sep 17 00:00:00 2001 From: Miloslav Ciz Date: Wed, 25 Jun 2025 16:55:30 +0200 Subject: [PATCH] Fix a few bugs --- TODO.txt | 53 ++++++++++++++++++++++++------------------------ game.h | 7 ++++--- map.h | 10 ++++----- media/manual.txt | 7 ++++--- renderer.h | 35 ++++++++++++++++---------------- 5 files changed, 57 insertions(+), 55 deletions(-) diff --git a/TODO.txt b/TODO.txt index 01cc48a..203ec18 100644 --- a/TODO.txt +++ b/TODO.txt @@ -2,33 +2,6 @@ fuck issue trackers :D =========== GENERAL ============== -- use other libs than glibc (musl, ...) -- final tests: - - run the test frontend through all the shit (valgrind, different compilers - etc.) KINDA DID - - check every single setting individually DID 1x - - very long replay DID 1x - - absence of music file DID - - different resolutions KINDA DID 1x - - different settings (332, POTATO, ...) DID - - crazy shit with physics KINDA DID - - replay with input not occuring for more that LCR_SETTING_GHOST_STEP DID - - different platforms DID - - error handling (bad map format, bad replay format, items in data file, ...) - - valgrind, cppcheck, different compilers, optimization levels, ... - - play replay from one platform on another KINDA DID - - profiling KINDA DID - - gigantic map that fails to fit in RAM DID 1x - - replay stretching DID 1x - - play all maps a lot DOING - - correct saving of replays etc. - - empty and large data file KINDA DID - - FPS on each platform WEEELLL - - try to use the racing module by itself BRIEFLY DID, COMPILES - - spellcheck comments KINDA DID - - test a map without any CPs where the car starts at finish WORKS BUT NOT REP - - just read through the code and eyeball it DOING - =========== BUGS ================= - another TCC bug: tiny map 4 replay fails @@ -99,6 +72,32 @@ fuck issue trackers :D =========== HANDLED ============== +- use other libs than glibc (musl, ...) +- final tests: + - run the test frontend through all the shit (valgrind, different compilers + etc.) KINDA DID + - check every single setting individually DID 1x + - very long replay DID 1x + - absence of music file DID + - different resolutions KINDA DID 1x + - different settings (332, POTATO, ...) DID + - crazy shit with physics KINDA DID + - replay with input not occuring for more that LCR_SETTING_GHOST_STEP DID + - different platforms DID + - error handling (bad map format, bad replay format, items in data file, ...) + - valgrind, cppcheck, different compilers, optimization levels, ... + - play replay from one platform on another KINDA DID + - profiling KINDA DID + - gigantic map that fails to fit in RAM DID 1x + - replay stretching DID 1x + - play all maps a lot DOING + - correct saving of replays etc. + - empty and large data file KINDA DID + - FPS on each platform WEEELLL + - try to use the racing module by itself BRIEFLY DID, COMPILES + - spellcheck comments KINDA DID + - test a map without any CPs where the car starts at finish WORKS BUT NOT REP + - just read through the code and eyeball it DOING - it seems like on arduinos tiny maps can't be loaded (say "FAILED") even if in theory they should (enough block space to load): try to set the exact same settings on PC and see if the maps load or what. IT'S BCS BUILDING THE MAP diff --git a/game.h b/game.h index 4463e5c..b1db32c 100644 --- a/game.h +++ b/game.h @@ -1389,7 +1389,7 @@ void LCR_gameSaveReplay(void) for (int i = 0; i < LCR_MAP_NAME_MAX_LEN; ++i) if (LCR_currentMap.name[i]) - _LCR_gameDataCharWrite(LCR_currentMap.name[i]); + _LCR_gameDataCharWrite(LCR_currentMap.name[i]); else break; @@ -1400,7 +1400,7 @@ void LCR_gameSaveReplay(void) for (int i = (str[0] == '0' && str[1] == '0' ? 3 : 0); i < LCR_MAP_NAME_MAX_LEN; ++i) if (str[i]) - _LCR_gameDataCharWrite(str[i]); + _LCR_gameDataCharWrite(str[i]); else break; @@ -1881,7 +1881,8 @@ uint8_t LCR_gameStep(uint32_t time) LCR_audioSetEngineIntensity(paused ? 0 : (engineIntensity < 256 ? engineIntensity : 255)); - if (LCR_game.state != LCR_GAME_STATE_RUN_FINISHED) + if (LCR_game.state == LCR_GAME_STATE_RUN || + LCR_game.state == LCR_GAME_STATE_RUN_STARTING) LCR_game.runTime = LCR_racing.tick; LCR_game.nextRacingTickTime += LCR_RACING_TICK_MS_RT; diff --git a/map.h b/map.h index 615ac65..74ca0af 100644 --- a/map.h +++ b/map.h @@ -452,6 +452,11 @@ uint8_t LCR_mapLoadFromStr(char (*getNextCharFunc)(void), const char *name) { LCR_LOG0("loading map string"); + LCR_LOG2("clearing map block cache") + + for (int i = 0; i < LCR_MAP_BLOCK_CACHE_SIZE; ++i) + _LCR_mapBlockCache[i] = 0xfffffffe; + for (int i = 0; i < LCR_MAP_NAME_MAX_LEN; ++i) { LCR_currentMap.name[i] = *name; @@ -705,11 +710,6 @@ uint8_t LCR_mapLoadFromStr(char (*getNextCharFunc)(void), const char *name) c = getNextCharFunc(); } - LCR_LOG2("clearing map block cache") - - for (int i = 0; i < LCR_MAP_BLOCK_CACHE_SIZE; ++i) - _LCR_mapBlockCache[i] = 0xfffffffe; - _LCR_mapComputeHash(); LCR_LOG1("map loaded, block count/hash:") diff --git a/media/manual.txt b/media/manual.txt index ba37f16..aa71599 100644 --- a/media/manual.txt +++ b/media/manual.txt @@ -375,7 +375,7 @@ controller. Q: The graphics looks weird, stuff near camera seems to kind of warp weirdly. A: It's a feature, this is the software renderer's simplification of handling -near plane culling, it's how it was done back in the era of PS1 and similar +near plane clipping, it's how it was done back in the era of PS1 and similar consoles, it has its charm. It should be possible to turn on the "correct", non-warping way somewhere in the code (S3L_NEAR_CROSS_STRATEGY) if you really want to, but it will cost some FPS. @@ -386,14 +386,15 @@ A: This may be happening in higher resolutions, it's because of overflows in integer math. Effort was made to minimize this but it can probably still happen at times. Lowering the resolution should generally help, also increasing S3L_NEAR in renderer.h should prevent this (but it will have some consequences). -If it seems real significant, you can report this to me. +If it seems real significant, you can report this to me, but don't expect me to +add support for capitalist 1080K resolutions. Q: I found a bug and/or have some other important comment. A: Send me an email (found on top of this file). Q: I have some other question (such as "Why is this not written in a modern -language?" or "What inspired you to make the game?" etc.) +language?", "What inspired you to make the game?" or "Are you a schizo?" etc.) A: Many questions I often get asked about my life and/or programming philosophy can't now be answered in a tl;dr while doing them injustice. I have a website at diff --git a/renderer.h b/renderer.h index 92a02cf..735644e 100644 --- a/renderer.h +++ b/renderer.h @@ -1253,23 +1253,6 @@ void LCR_rendererMarkTakenCP(int x, int y, int z) } } -/** - Creates everything that's needed to start rendering the currently loaded map, - returns success (1 or 0). -*/ -uint8_t LCR_rendererLoadMap(void) -{ - LCR_LOG0("loading map"); - - if (!_LCR_buildMapModel()) - return 0; - - _LCR_makeMapChunks(); - _LCR_rendererComputeLOD(); - - return 1; -} - /** Initializes renderer, only call once. */ @@ -1773,6 +1756,24 @@ void LCR_rendererLoadMapChunks(void) camChunk[2] + ((i & 0x04) ? chunkOffsets[2] : 0)); } +/** + Creates everything that's needed to start rendering the currently loaded map, + returns success (1 or 0). +*/ +uint8_t LCR_rendererLoadMap(void) +{ + LCR_LOG0("loading map"); + + if (!_LCR_buildMapModel()) + return 0; + + _LCR_makeMapChunks(); + LCR_rendererLoadMapChunks(); + _LCR_rendererComputeLOD(); + + return 1; +} + /** Draws the LOD overlay. */