Skip to content

Commit

Permalink
Fix gear rendering for Suppressor (#256)
Browse files Browse the repository at this point in the history
Fix misaligned gear mask and a buffer overflow for cars which use more
than 8 gears, and thus pixelmaps other than HGEARS.PIX.

Signed-off-by: Artur Rojek <contact@artur-rojek.eu>
  • Loading branch information
zear committed Dec 3, 2022
1 parent 3f440a5 commit bb41b81
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/DETHRACE/common/displays.c
Original file line number Diff line number Diff line change
Expand Up @@ -1160,15 +1160,26 @@ void DoInstruments(tU32 pThe_time) {
} else {
gear = gCar_to_view->gear;
}
#if defined(DETHRACE_FIX_BUGS)
/*
* The OG derives gear mask height of 28 by `gears_image->height / 8`, but
* this is only valid for HGEARS.PIX, which contains 8 gear images. Hardcoding
* this number fixes gear rendering for cars using HGEARS4.PIX, which consists
* of 11 gear images.
*/
#define GEAR_HEIGHT 28
#else
#define GEAR_HEIGHT ((int)gProgram_state.current_car.gears_image->height / 8)
#endif
DRPixelmapRectangleMaskedCopy(
gBack_screen,
the_wobble_x + gProgram_state.current_car.gear_x[gProgram_state.cockpit_on],
the_wobble_y + gProgram_state.current_car.gear_y[gProgram_state.cockpit_on],
gProgram_state.current_car.gears_image,
0,
(gear + 1) * ((int)gProgram_state.current_car.gears_image->height >> 3),
(gear + 1) * GEAR_HEIGHT,
gProgram_state.current_car.gears_image->width,
(int)gProgram_state.current_car.gears_image->height >> 3);
GEAR_HEIGHT);
}
speedo_image = gProgram_state.current_car.speedo_image[gProgram_state.cockpit_on];
if (gProgram_state.current_car.speedo_radius_2[gProgram_state.cockpit_on] >= 0) {
Expand Down

0 comments on commit bb41b81

Please sign in to comment.