-
Notifications
You must be signed in to change notification settings - Fork 465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: use cache on LoadFileRaw #2489
fix: use cache on LoadFileRaw #2489
Conversation
this makes it so explosions don't use the dpad texture
@@ -888,6 +888,12 @@ extern "C" char* ResourceMgr_LoadFileRaw(const char* resName) { | |||
// TODO: This should not exist. Anywhere we are loading textures with this function should be Resources instead. | |||
// We are not currently packing our otr archive with certain textures as resources with otr headers. | |||
static std::unordered_map<std::string, std::shared_ptr<Ship::OtrFile>> cachedRawFiles; | |||
|
|||
auto cacheFind = cachedRawFiles.find(resName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does using a cache fix this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't know yet, @Kenix3 is going to do some investigation later. I found that the texture would pop in and out and glitch out if it was never added to the cache by just commenting out what we had before
// static std::unordered_map<std::string, std::shared_ptr<Ship::OtrFile>> cachedRawFiles;
auto file = OTRGlobals::Instance->context->GetResourceManager()->LoadFile(resName);
// cachedRawFiles[resName] = file;
if (file == nullptr) {
return nullptr;
}
return file->Buffer.data();
I still don't know why putting it in the cache and never using it from there leads to the texture popping up in unexpected places, but if nothing else this PR updates the logic in this method to be what it should have been in the first place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ultimately this fixes a logic error in the function which loads raw files from the OTR archive. This fix is desired whether or not it addresses the recently reported dpad texture issues.
this makes it so explosions don't use the dpad texture
fixes #2484
Build Artifacts