Fix crash when a custom IMG model is restored while still in use - #5363
Open
Flashmyname wants to merge 1 commit into
Open
Fix crash when a custom IMG model is restored while still in use#5363Flashmyname wants to merge 1 commit into
Flashmyname wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SetStreamingInfoforce-removes the model's RwObject, and the streamer stops tracking entities that still use it.LinkModelstreams those entities out first;UnlinkModelandStreamDisablemake the same call without it, soengineRestoreDFFImage- or destroying the IMG element - frees the RW object under live entities.StreamDisabledoes callRestreamWorld(), but only after everySetStreamingInfoin the loop has already run, and not at all during session shutdown.The guard moves into a file-local helper used by all three.
Motivation
The vehicle guard came from #4544 and the weapon one from #5146; neither covered the restore paths.
CStreaming::RemoveModelat0x4089A0has no reference count - for a vehicle it callsCVehicleModelInfo::DeleteRwObject, which destroys the CVehicleStructure and the master clump regardless of who is using them.Test plan
Custom IMG holding a
banshee.dff,engineImageLinkDFFonto model 429, spawn a Banshee and get in, thenengineRestoreDFFImage(429).Before:
0xC0000005atgta_sa.exe+0x124765,EAX=0-CEntity::GetColModelreturned null and the render path dereferenced it.https://streamable.com/kc6ud6
After: the call returns true and the game keeps running.
https://streamable.com/fujmyi
Checklist