Fix: Alt backgrounds and some models not always loading after toggling alt mode #3420
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.
There was an issue where if you ever loaded the non-alt version of a pre-rendered background, you wouldn't be able to load the non-alt version for the rest of the session.
This stems from the way that we handle caching and looking up resources. The way the resource manager works when requesting a resource is that we first check to see if we have a cached alt version, if we don't we then check to see if we have a cached non-alt version, if we do that gets returned, otherwise the normal resource load flow is performed.
The way alt textures are actually loaded is via Fast3D by direct calls to
LoadResourceProcess
which bypasses the cache lookup. However, rooms with pre-rendered backgrounds first attempt to load the resource to check if its a "background" type to see if we need to decrypt the original jpeg. This check for the background type will end up returning the cached non-alt version since alt resources are cleared from cache on scene change.As a mitigation for now, I have added a few helper methods to force "unload" the non-alt background resource so that no cache is returned on the lookup, allowing the alt version to successfully be returned.
In the long run, we may need to reconsider the caching lookup as it may be affecting other areas in the code.
I have applied the above unloading pattern to
ResourceMgr_LoadGfxByName
to address some alt models not loading after the non-alt version has loaded once. Closes #3076 and #3078.Build Artifacts