Skip to content
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

Merged
merged 4 commits into from
Feb 16, 2023

Conversation

briaguya-ai
Copy link
Contributor

@briaguya-ai briaguya-ai commented Feb 16, 2023

this makes it so explosions don't use the dpad texture

fixes #2484

Build Artifacts

briaguya added 4 commits February 16, 2023 12:17
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);
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

@Kenix3 Kenix3 left a 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.

@briaguya-ai briaguya-ai merged commit 6b93da3 into HarbourMasters:develop Feb 16, 2023
@briaguya-ai briaguya-ai deleted the fix-dpad-bombs branch March 1, 2023 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bomb/Bombchu explosions shaped like D-Pads, Bomb shadow shaped like D-Pad
3 participants