rodecomp/Source/Resource/ResourcePresence.cpp
ragnarok-clanker 07a53404f2 Decompile fn_18182 (ResourceMgr::Exists)
Batch #16041 by Yommy: 0 byte-identical, 1 confirmed by peer review.

- fn_18182 ResourceMgr::Exists: logic confirmed by peer review

Peer-reviewed-by: alisonrag, youko
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
2026-11-10 14:34:38 +00:00

37 lines
937 B
C++

#include "File/ResourcePath.h"
#include "Resource/ResourceMgr.h"
#include "Utility/Text/GroupedInteger.h"
#include <string>
#include <windows.h>
#include <timeapi.h>
// OFFSET: 0x00AEF940
// FUNCTION: fn_18182
bool ResourceMgr::Exists(std::string name) {
const char* text = name.c_str();
if (!text) {
return false;
}
char normalized[260] = {};
strncpy_s(normalized, sizeof(normalized), text, _TRUNCATE);
for (char* c = normalized; *c; ++c) {
*c = g_lowercaseTable[static_cast<unsigned char>(*c)];
}
const char* dot = ReverseFindChar(normalized, '.');
const int type = this->FindType(dot ? dot + 1 : nullptr);
if (type < 0) {
return false;
}
const std::string resolved = AddResourcePrefix(normalized, this->m_prefixes[type]);
if (CRes* existing = this->Find(type, resolved.c_str())) {
existing->lastUse = timeGetTime();
return true;
}
return ResourceExists(resolved.c_str(), 0);
}