Closed morallo closed 1 year ago
I was able to reproduce the crash, there is an exception here: https://github.com/Prof-Butts/xwa_ddraw_d3d11/blob/132a5dd6ee601906661a6253cb6f557a042b22ed/impl11/ddraw/PrimarySurface.cpp#L10428
Reading the comment above, it seems like a reoccurrence of the same bug, but in this case it is triggered by a video playback and it's not prevented by the current workaround.
// It looks like sometimes the craftInstance table/pointer is not valid during the first few
// frames of a new mission. I've seen some intermittent cores when playing with the GUN or
// the MIS and then switching to other craft. So adding g_iPresentCounter > 5 seems to prevent
// this problem, since we wait for a few frames at the beginning of the mission before we
// try to access the CraftInstance table.
Thinking of it, this seems to be related to tgsmush.dll calling Flip()
just to make sure ddraw captures and updates the VR 2D overlay.
However, this causes other functions to be run and in this case an access to an invalid pointer because the CraftInstance table is not ready even after 5 frames.
The right solution is probably to create a specific function that will just update the overlay and skip anything else, preventing this type of bugs in the future.
Fixed by #73
Tgsmush.dll >= 2.8, the first version where the memory was shared, are crashing with effects ddraw.dll, but not with Golden ddraw.
How to trigger: any video after B5M2-C, B4M5-C, B3M6-C, B3M4-C, B2M4-C, B1M6-C and B1M5-C makes the game crash, so the missions where you start in a Gunboat by default.