fix: use cache on LoadFileRaw (#2489)

* fix: use cache on LoadFileRaw

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

---------

Co-authored-by: briaguya <briaguya@alice>
This commit is contained in:
briaguya 2023-02-16 18:05:36 -05:00 committed by GitHub
parent 6cd7066706
commit 6b93da37d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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. // 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. // 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; static std::unordered_map<std::string, std::shared_ptr<Ship::OtrFile>> cachedRawFiles;
auto cacheFind = cachedRawFiles.find(resName);
if (cacheFind != cachedRawFiles.end()) {
return cacheFind->second->Buffer.data();
}
auto file = OTRGlobals::Instance->context->GetResourceManager()->LoadFile(resName); auto file = OTRGlobals::Instance->context->GetResourceManager()->LoadFile(resName);
cachedRawFiles[resName] = file; cachedRawFiles[resName] = file;