Decompile fn_18182 (ResourceMgr::Exists)
Batch #1614 by eAthena: 0 byte-identical, 1 confirmed by peer review. - fn_18182 ResourceMgr::Exists: logic confirmed by peer review Reviewed-by: ragnarok-clanker Adds to the build: Source/Resource/ResourcePresence.cpp
This commit is contained in:
parent
faae91cc6d
commit
916347b79a
4 changed files with 44 additions and 1 deletions
|
|
@ -1,8 +1,9 @@
|
||||||
#ifndef RAGNAROK_SOURCE_CONTENTS_EFFECTS_RAGEFFECTINITIALIZATION_H
|
#ifndef RAGNAROK_SOURCE_CONTENTS_EFFECTS_RAGEFFECTINITIALIZATION_H
|
||||||
#define RAGNAROK_SOURCE_CONTENTS_EFFECTS_RAGEFFECTINITIALIZATION_H
|
#define RAGNAROK_SOURCE_CONTENTS_EFFECTS_RAGEFFECTINITIALIZATION_H
|
||||||
|
|
||||||
|
#include "Contents/Actors/RenderObjectState.h"
|
||||||
|
|
||||||
struct RagEffectState;
|
struct RagEffectState;
|
||||||
struct RenderObjectState;
|
|
||||||
struct EffectActor;
|
struct EffectActor;
|
||||||
struct ServiceOptions;
|
struct ServiceOptions;
|
||||||
class ResourceMgr;
|
class ResourceMgr;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
|
@ -25,6 +26,7 @@ public:
|
||||||
CRes* Load(std::string name);
|
CRes* Load(std::string name);
|
||||||
void Remove(CRes* resource);
|
void Remove(CRes* resource);
|
||||||
bool Exists(const char* name);
|
bool Exists(const char* name);
|
||||||
|
bool Exists(std::string name);
|
||||||
void UnloadAll();
|
void UnloadAll();
|
||||||
void ClearUnused(const char* extension);
|
void ClearUnused(const char* extension);
|
||||||
void ClearUnused();
|
void ClearUnused();
|
||||||
|
|
|
||||||
39
Source/Resource/ResourcePresence.cpp
Normal file
39
Source/Resource/ResourcePresence.cpp
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
#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 (unsigned char* byte = reinterpret_cast<unsigned char*>(normalized); *byte; ++byte) {
|
||||||
|
if (*byte >= 'A' && *byte <= 'Z') {
|
||||||
|
*byte += 'a' - 'A';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
@ -564,6 +564,7 @@
|
||||||
"Source/Resource/ResourceAliases.cpp": 3,
|
"Source/Resource/ResourceAliases.cpp": 3,
|
||||||
"Source/Resource/ResourceFailures.cpp": 3,
|
"Source/Resource/ResourceFailures.cpp": 3,
|
||||||
"Source/Resource/ResourceMgr.cpp": 3,
|
"Source/Resource/ResourceMgr.cpp": 3,
|
||||||
|
"Source/Resource/ResourcePresence.cpp": 3,
|
||||||
"Source/Resource/ResourceTransient.cpp": 3,
|
"Source/Resource/ResourceTransient.cpp": 3,
|
||||||
"Source/Resource/RmaResource.cpp": 3,
|
"Source/Resource/RmaResource.cpp": 3,
|
||||||
"Source/Resource/SkinPalette.cpp": 3,
|
"Source/Resource/SkinPalette.cpp": 3,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue