Repository navigation
Conversation
|
Nightly build for this pull request:
This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build. |
NetsuNegi
left a comment
There was a problem hiding this comment.
Looks good, there are some code simplification suggestions to consider, non mandatory.
Co-authored-by: Netsu_Negi <71598172+NetsuNegi@users.noreply.github.com>
|
Applied, thanks! |
:) |
|
Also a heads-up on EOL: 6998e37 (this PR) committed the four Phobos/src/Misc/Hooks.BugFixes.cpp Lines 1880 to 1883 in 6998e37 I've normalized it in ef9a9e2 (just |
What kind of change is this?
Skip Changelog).Skip Changelog,Skip Docs).Skip Docs).Skip Changelog,Skip Docs,Skip Credits).Description
Fixes a vanilla crash when an
IsSonic=truewave is drawn near the top edge of the screen.Root cause
For each pixel, the sonic wave drawing code (
0x75EDF0) reads the source color from up to 3 pixels ahead in the wave direction:ColorDataentries 10-12 hold 3 times the direction step. The drawing loops therefore have to stay at least 3 pixels inside the clip rectangle.WaveClasshas two sets of drawing loops. The ones used when the ZBuffer does not wrap keep a 3 pixel margin, but the ones used when it wraps (top-down loop at0x75FD22-0x75FD76, bottom-up loop at0x760033-0x76007A) only keep 2 pixels. On row 2 (the third row from the top), a pixel whose direction points upwards reads 3 rows up, which is one row above the surface buffer and may fall into unmapped memory.The fix patches these 8 bounds in the wrapping loops from 2 to 3 pixels, so they match the non-wrapping loops. Magnetron drawing has the same 2 pixel margin, which is correct there because it clamps the color index to 9.
The existing
WaveClass_DrawSonic_CrashFixhook (0x75EE49) does not cover this case: it clamps the color index to 12 while the crash already happens with index 10.Reproduction
cnc-ddraw (the default CnCNet renderer) allocates padding around each surface (
guard_lines=200by default, seeddsurface.c), so the out-of-bounds read hits zeroed memory and nothing happens. Native DirectDraw and renderers without such padding crash. It can be reproduced with cnc-ddraw by settingguard_lines=0inddraw.ini.With Ares the crash address is reported in
Ares.dll(WaveClass_Draw_Sonic, hooked at0x75EE57), because Ares replaces that pixel read. The fix works on the loop bounds, so the pixel function is never called for those rows no matter who handles the read. None of the patched addresses are hooked by Ares or Phobos.Testing
Tested with cnc-ddraw
guard_lines=0, Ares 3.0p1, dolphin attacking while the view was moved so the waves were drawn along the screen edges:2026-10-16.20-08-43.mp4