When `SmokeLine` is called through `DrawTheGlow`, the calculated shade
table offset might result in a negative value. Subject to usual
arithmetic conversions, it is then treated as a large unsigned array
index. On 32-bit systems (e.g. OG builds for DOS, Windows 95), the
pointer arithmetic overflows and produces a negative index access,
simply grabbing game data a few bytes before the start of the table. On
64-bit platforms this instead results in page fault.
1. Keep table offset in a signed integer, making the negative values
explicit. This provides OG behavior for 64-bit builds.
2. Optionally, cap all negative values at 0, preventing underflows.
Signed-off-by: Artur Rojek <contact@artur-rojek.eu>
If the sound has been muted (!gS3_enabled) during game data loading, it
is then possible to unmute it during gameplay and request a sound effect
which doesn't have a sample loaded (most prominent for pratcam sfx).
While logic in `S3StartSound` accommodates for such a case by loading
the missing sample, it first calls `S3CalculateRandomizedFields`, which
triggers a NULL pointer dereference on platforms with memory protection.
This bug is most likely an overlook from the DOS era.
Fix this by checking for NULL pointer before use.
Signed-off-by: Artur Rojek <contact@artur-rojek.eu>
* support for index_blend materials
* blended materials should not write to zbuffer
* remove reliance on glsl layout qualifiers
* tidy StripBlendedFaces
Strip map height is a 16 bit value. Cast to `br_uint_16 *`, so that the
upper 8 bits don't get lost.
This fixes cockpit image rendering for -hires mode, where said images
have heights exceeding 255px.
When searching for a particular headup slot, don't return on the first
empty hole, but rather try to find if the matching slot is in use.
This resolves a bug where two headups of the same type could end up
displayed on top of each other.
Signed-off-by: Artur Rojek <contact@artur-rojek.eu>
* Prevent clicking on racer scroll buttons when hidden (#262)
Fix a bug where racers could be scrolled in other view modes, messing up
the screen.
Signed-off-by: Artur Rojek <contact@artur-rojek.eu>
Co-authored-by: Dethrace Engineering Department <78985374+dethrace-labs@users.noreply.github.com>
Resolve a bug in DRPixelmapRectangleShearedCopy, where source pixelmap
gets clipped along the shear, rather than vertically, at right-most edge
of the destination pixelmap.
While at it, also eliminate duplicate code - this part introduces no
logic changes.
Signed-off-by: Artur Rojek <contact@artur-rojek.eu>
Flush framebuffer/depthbuffer after rendering the 3d scene. This allows
screen effects such as smoke, sparks or electro-bastard ray to display
correctly.
Signed-off-by: Artur Rojek <contact@artur-rojek.eu>
Store the previous time credit in `gLast_time_credit_amount` instead of
`gLast_time_credit_headup`. The latter is supposed to hold the headup
slot number and gets overwritten with time unrelated values.
Signed-off-by: Artur Rojek <contact@artur-rojek.eu>
The Linux implementation of `OS_fopen` fails to close directories after
use, leaking the underlying file descriptors. Eventually, the limit of
allowed file descriptors per process is reached, causing subsequent
`opendir` failures, and leading to random game crashes.
Fix this issue by calling `closedir` once the directory can be disposed.
Signed-off-by: Artur Rojek <contact@artur-rojek.eu>
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>
* Use Brender macro's in MungeClipPlane
* gNet_mode is an enum
* Create macro defining the area where pedestrians are considered active
* When respawning pedestrians, only animate the pedestrians that are in view
* Make the gl renderer aware of BR_MATF_TWO_SIDED and BR_MATF_ALWAYS_VISIBLE
Prevent the gl renderer from culling back-faced textures if the material
is two-sided or always visible.
Due to the wrong order of vertices in the model, oil spill object is
subject to back face culling, preventing it from being rendered. Set
the oil spill material as two-sided, allowing it to be displayed.
Signed-off-by: Artur Rojek <contact@artur-rojek.eu>
* Add enum for splatpack xmas: they have a different demo screen (splatpack demo has smk, xmas demo has a flic)
* Simplify sign
* Fix DecodeLine2 + decode_datatxt.py
* Compare against pointers
* Use float cos and sin functions
* Implement StopGroovidelic
* Implement TestAutoSpecialVolume
* Use floats in SmokeCircle related functions
* gOffset is initialized to 0
* Don't stub DrawTheGlow: every crash is an opportunity to find a bug
* Decrease indentation of LineBoxColl (no functional change)
* Use BrVector3XXX macro's in GetBoundsEdge (no functional change)
* Fix address sanitzier warning when using APC
* Use BrVector3XXX macro in GetPlaneNormal (no functional change)
* Get rid of global is_full_screen variable
* Add command line argument to start DethRace in full screen mode
* cmake: move DETHRACE_FIX_BUGS cmake option to top cmake script
* Add DETHRACE_FIX_BUGS macro when DETHRACE_FIX_BUGS cmake variable is defined
* harness: prescale mouse pointer so it works seamlessly with hires
* Fix IWANTTOFIDDLE
* Add comments for the fixes
* Revert "Don't stub DrawTheGlow: every crash is an opportunity to find a bug"
This reverts commit 3345649201.
Fix OG bug, where APC car would have its vertices and faces removed,
preventing it from being rendered in the wreck gallery.
Signed-off-by: Artur Rojek <contact@artur-rojek.eu>
Don't reset skidmark normal to the horizontal plane, but rather use the
one received from the wheel.
This fixes incorrect rendering of skidmarks on sloped surfaces.
Signed-off-by: Artur Rojek <contact@artur-rojek.eu>
* Remove magic numbers from CalculateFrameRate
* Move conditionals in MungeCarGraphics a bit
* Move code around in LoadCar + less magic numbers
* Tweak conditionals of ReallocExtraPathSections
* Use BrVector3Copy in PointVisibleFromHere
* tCar_spec->gear is an int
* Re-use variable in SearchForSection
* Use floats in CalcGetNearPlayerRoute
* Use floats in ControlBoundFunkGroovePlus
* Align pointers to multiple of pointer size in ShiftBoundGrooveFunks
* Change conditionals in AddProximities + assign the_face at start of iteration
* Move conditionals around in AddGroovidelics
* Move code around in GrooveThisDelic
* Assign the_groove each loop iteration in GrooveThoseDelics
* Compare against NULL in MungeWindscreen
* No need to check for pCount <= 0 in GetALineAndInterpretCommand
* racestrt.c: fix out-of-bounds write in DrawGrid
Catched by undefined behavior sanitizer
* opponent.c: use cops array to access 'finished_for_this_race' property
* displays.c: Fix left shift of negative value in DoHeadups
Found by using he undefined behavior sanitizer
* Switch variable names in DoDamageScreen