fixes memory out of bounds with shaking rearview camera

This commit is contained in:
Dethrace Labs 2025-12-22 21:07:26 -08:00
parent 307bd5b532
commit 2b0dd028ae
3 changed files with 16 additions and 6 deletions

View File

@ -7303,12 +7303,14 @@ br_scalar FourPointCollB(br_scalar* f, br_matrix4* m, br_scalar* d, br_vector3*
// FUNCTION: CARM95 0x00492ff8
int TestForNan(float* f) {
tU32 i;
// i = *f;
// return isnan(*f);
// return (~i & 0x7F800000) == 0;
i = *(unsigned long*)f;
return ((i & 0x7F800000) == 0x7F800000) && ((i & 0x007FFFFF) != 0);
#ifdef DETHRACE_FIX_BUGS
return isnan(*f);
#else
memcpy(&i, f, sizeof i);
i = ~i & 0x7F800000;
return i == 0;
#endif
}
// IDA: void __cdecl CheckCameraHither()

View File

@ -2074,6 +2074,11 @@ void RenderAFrame(int pDepth_mask_on) {
}
gRearview_screen->base_x = gScreen_wobble_x + gProgram_state.current_car.mirror_left;
gRearview_screen->base_y = gScreen_wobble_y + gProgram_state.current_car.mirror_top;
#ifdef DETHRACE_FIX_BUGS
gRearview_screen->base_x = MAX(0, gRearview_screen->base_x);
gRearview_screen->base_y = MAX(0, gRearview_screen->base_y);
#endif
#endif
BrPixelmapFill(gRearview_depth_buffer, 0xFFFFFFFF);
gRendering_mirror = 1;

View File

@ -511,6 +511,8 @@ int Harness_ProcessIniFile(void) {
strcat(path, "dethrace.ini");
LOG_INFO2("Loading ini file %s", path);
if (ini_parse(path, Harness_Ini_Callback, NULL) < 0) {
LOG_DEBUG2("Failed to load config file %s", path);
return 1;
@ -550,7 +552,8 @@ int Harness_Hook_isalnum(int c) {
return 1;
}
}
} if (harness_game_info.localization == eGameLocalization_french) {
}
if (harness_game_info.localization == eGameLocalization_french) {
// French diacritic letters in Windows-1252
unsigned char letters[] = { 140, 156, 159, 192, 194, 198, 199, 200, 201, 202, 203, 206, 207, 212, 217, 219, 220, 224, 226, 230, 231, 232, 233, 234, 235, 238, 239, 244, 249, 251, 252, 255 };
for (i = 0; i < (int)sizeof(letters); i++) {