Fix a very nasty bug

This commit is contained in:
Miloslav Ciz 2025-06-18 03:53:35 +02:00
parent abd68ce0ae
commit dae47de5f9
4 changed files with 24 additions and 18 deletions

View file

@ -38,10 +38,6 @@ fuck issue trackers :D
=========== BUGS =================
- on arduinos for some reason straight triangles (floor, walls, ...) on map
don't fucking display, they seem to not be added at all, but maybe it's
something with the "instability" due to low memory... HOWEVER on ringo (enough
mem) it does the same thing, is some kinda shitbug
- replay loading BUG! somehow map2 replay was saves with hash 05ef0ab1 instead
of correct 3c5ba5dd once, WTF, check where hash gets modified
@ -84,6 +80,13 @@ fuck issue trackers :D
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
TEMPORARILY REQUIRES MORE BLOCKS
- on arduinos for some reason straight triangles (floor, walls, ...) on map
don't fucking display, they seem to not be added at all, but maybe it's
something with the "instability" due to low memory... HOWEVER on ringo (enough
mem) it does the same thing, is some kinda shitbug; LOOKS LIKE CULLING MOST
LIKELY; it's condition in renderer:824, most likely either a bug in
LooksConvex or CoversTri; lmao, had to change char to int in triangle winding,
char signedness is unspecified :D
- should drifting make a sound? NO NEED
- menu: key repeat?
- replay validation? maybe yes?

View file

@ -14,8 +14,8 @@
#define LCR_SETTING_MUSIC 0
#define LCR_SETTING_GHOST_MAX_SAMPLES 0
#define LCR_SETTING_MAP_MAX_BLOCKS 512
#define LCR_SETTING_MAX_MAP_VERTICES 800
#define LCR_SETTING_MAX_MAP_TRIANGLES 900
#define LCR_SETTING_MAX_MAP_VERTICES 1024
#define LCR_SETTING_MAX_MAP_TRIANGLES 1500
#define LCR_SETTING_REPLAY_MAX_SIZE 0
#define LCR_SETTING_CAR_SHADOW 0
#define LCR_SETTING_PARTICLES 0
@ -23,9 +23,10 @@
#define LCR_SETTING_LOD_DISTANCE 100
#define LCR_SETTING_CAR_ANIMATION_SUBDIVIDE 0
#define LCR_SETTING_FPS 25
#define LCR_SETTING_TEXTURE_SUBSAMPLE 8
#define LCR_SETTING_TEXTURE_SUBSAMPLE 4
#define LCR_SETTING_ENABLE_DATA_FILE 0
#define LCR_SETTING_ONLY_SMALL_MAPS 1
#define S3L_PERSPECTIVE_CORRECTION 0
#include "game.h"
@ -48,12 +49,12 @@ uint8_t LCR_keyPressed(uint8_t key)
{
#define b(button) (mp.buttons.timeHeld(button) > 0)
case LCR_KEY_UP: return arrows & 0x04; break;
case LCR_KEY_DOWN: return arrows & 0x08; break;
case LCR_KEY_RIGHT: return arrows & 0x01; break;
case LCR_KEY_LEFT: return arrows & 0x02; break;
case LCR_KEY_A: return b(BTN_A); break;
case LCR_KEY_B: return b(BTN_B); break;
case LCR_KEY_UP: return (arrows & 0x04) | b(BTN_2); break;
case LCR_KEY_DOWN: return (arrows & 0x08) | b(BTN_8) | b(BTN_5); break;
case LCR_KEY_RIGHT: return (arrows & 0x01) | b(BTN_6); break;
case LCR_KEY_LEFT: return (arrows & 0x02) | b(BTN_4); break;
case LCR_KEY_A: return b(BTN_A) | b(BTN_HASHTAG); break;
case LCR_KEY_B: return b(BTN_B) | b(BTN_ASTERISK); break;
default: return 0; break;
#undef b

View file

@ -112,7 +112,8 @@ int _LCR_strCmp(const char *s1, const char *s2)
return 1;
}
char _LCR_triangleWinding(int x0, int y0, int x1, int y1, int x2, int y2)
int _LCR_triangleWinding(int_least32_t x0, int_least32_t y0, int_least32_t x1,
int_least32_t y1, int_least32_t x2, int_least32_t y2)
{
x0 = (y1 - y0) * (x2 - x1) - (x1 - x0) * (y2 - y1);
return x0 != 0 ? (x0 > 0 ? 1 : -1) : 0;

View file

@ -297,7 +297,7 @@ int _LCR_rendererQuadLooksConvex(S3L_Unit quad[8])
r = (3 * r) / 32;
for (int i = 0; i < 8; i += 2)
if (S3L_abs(cx - quad[i]) <= r && S3L_abs(cy - quad[i + 1]) <= r)
if ((S3L_abs(cx - quad[i]) <= r) && (S3L_abs(cy - quad[i + 1]) <= r))
return 0;
return 1;
@ -688,7 +688,7 @@ int _LCR_rendererQuadCoversTri(const S3L_Unit quad[8], const S3L_Unit tri[6])
for (int k = 0; k < 3; ++k) // for each subtriangle side
{
char w =
int w =
_LCR_triangleWinding(
quad[(2 * (j + (k + 1) % 3)) % 8],
quad[(2 * (j + ((k + 1) % 3))) % 8 + 1],
@ -924,8 +924,8 @@ void _LCR_cullHiddenMapTris(void)
else
{
for (int j = 0; j < 3; ++j)
LCR_renderer.mapVerts[3 * i + j] =
LCR_renderer.mapVerts[(LCR_renderer.mapModel.vertexCount - 1) * 3 + j];
LCR_renderer.mapVerts[3 * i + j] = LCR_renderer.mapVerts[
(LCR_renderer.mapModel.vertexCount - 1) * 3 + j];
for (int j = 0; j < LCR_renderer.mapModel.triangleCount * 3; ++j)
if (LCR_renderer.mapTris[j] == LCR_renderer.mapModel.vertexCount - 1)
@ -1037,6 +1037,7 @@ uint8_t _LCR_buildMapModel(void)
blockShapeBytes,&blockShapeByteCount);
// When nearing limit, cull (can't be inside the loop sadly, trust me).
if (
LCR_renderer.mapModel.vertexCount >= LCR_SETTING_MAX_MAP_VERTICES - 16 ||
LCR_renderer.mapModel.triangleCount >= LCR_SETTING_MAX_MAP_TRIANGLES - 16)