Decompile fn_18175 (ResourceMgr::Load)

Batch #1900 by Yommy: 0 byte-identical, 1 confirmed by peer review.

- fn_18175 ResourceMgr::Load: logic confirmed by peer review

Reviewed-by: ragnarok-clanker
This commit is contained in:
ragnarok-clanker 2026-10-28 23:26:18 +00:00
commit c14ddddccf

View file

@ -10,7 +10,6 @@
#include <cstring>
#include <windows.h>
#include <timeapi.h>
#include <optional>
// GLOBAL: gl_24581
unsigned g_resourceReuseDelay = 15000;
@ -143,10 +142,15 @@ bool ResourceMgr::Exists(const char* name) {
return ResourceExists(resolved.c_str(), 0);
}
// OFFSET: 0x00AEE770
// INLINED
__forceinline CRes* ResourceMgr::LoadNamed(const char* name) {
std::optional<NSyncObject> lock(std::in_place, &this->m_lock);
if (!name) {
return nullptr;
}
std::string resolved;
{
NSyncObject lock(&this->m_lock);
char normalized[260] = {};
StringFormat(normalized, sizeof(normalized), _TRUNCATE, "%s", name);
@ -160,7 +164,7 @@ __forceinline CRes* ResourceMgr::LoadNamed(const char* name) {
return nullptr;
}
std::string resolved = AddResourcePrefix(this->aliases.Resolve(normalized), this->m_prefixes[type]);
resolved = AddResourcePrefix(this->aliases.Resolve(normalized), this->m_prefixes[type]);
if (CRes* existing = this->Find(type, resolved.c_str())) {
existing->lastUse = timeGetTime();
return existing;
@ -171,17 +175,7 @@ __forceinline CRes* ResourceMgr::LoadNamed(const char* name) {
return nullptr;
}
if (resource->Load(resolved.c_str()) != 1) {
delete resource;
lock.reset();
if (resolved.find("\\map\\") == std::string::npos) {
g_resourceFailures.Report(name, resolved);
}
return nullptr;
}
if (resource->Load(resolved.c_str()) == 1) {
resource->name.Assign(resolved.c_str());
resource->type = type;
resource->lastUse = timeGetTime();
@ -192,15 +186,21 @@ __forceinline CRes* ResourceMgr::LoadNamed(const char* name) {
}
return resource;
}
delete resource;
}
if (resolved.find("\\map\\") == std::string::npos) {
g_resourceFailures.Report(name, resolved);
}
return nullptr;
}
// OFFSET: 0x00AEE770
// FUNCTION: fn_18175
CRes* ResourceMgr::Load(const char* name) {
if (!name) {
return nullptr;
}
return this->LoadNamed(name);
}