rodecomp/Source/Resource/EmblemResource.cpp
ragnarok-clanker 97293fce11 Decompile 3 functions in Source/Resource/EmblemResource.cpp, Source/Resource/EmblemResource.h, ...
Batch #1823 by Yommy: 0 byte-identical, 3 confirmed by peer review.

- fn_07880 CEmblemRes::Create: logic confirmed by peer review
- fn_07881 CEmblemRes::Load: logic confirmed by peer review
- fn_07885 CEmblemRes::MissingFile: logic confirmed by peer review

Reviewed-by: ragnarok-clanker
2026-10-28 22:43:54 +00:00

79 lines
1.7 KiB
C++

#include "Resource/EmblemResource.h"
#include "Contents/Emblems/EmblemCache.h"
#include "Contents/GuildMgr.h"
#include "File/File.h"
#include <cstdint>
#include <cstdlib>
#include <string>
#include <zlib.h>
namespace {
// INLINED
EmblemCache& GuildEmblemCache() {
return *reinterpret_cast<EmblemCache*>(g_guildMgr);
}
}
// INLINED
CEmblemRes::CEmblemRes(BitmapResourceContext& context) : gif(context) {
}
// INLINED
CEmblemRes::~CEmblemRes() = default;
// OFFSET: 0x0074C9F0
// FUNCTION: fn_07880
CEmblemRes* CEmblemRes::Create() {
return new CEmblemRes(this->gif.Context());
}
// OFFSET: 0x0074CA90
// FUNCTION: fn_07881
bool CEmblemRes::Load(const char* name) {
if (GuildEmblemCache().IsInvalid(name) == true) {
this->gif.CreateBlank(24, 24);
return true;
}
CFile file;
if (!file.Open(name, 0, true, false)) {
return false;
}
uLongf size = static_cast<uLongf>(static_cast<std::uint32_t>(g_guildMgr->m_timeout) * 1.2);
Bytef* buffer = static_cast<Bytef*>(std::malloc(size));
if (uncompress(buffer, &size, static_cast<const Bytef*>(file.GetData()), file.GetSize()) != Z_OK
|| this->gif.Decode("_emblem.bmp", buffer, size, true) != true) {
GuildEmblemCache().MarkInvalid(name);
this->gif.CreateBlank(24, 24);
}
file.Close();
std::free(buffer);
return true;
}
// OFFSET: 0x0074CD00
// FUNCTION: fn_07882
void CEmblemRes::Unload() {
this->gif.Unload();
}
// OFFSET: 0x0074CD10
// FUNCTION: fn_07883
void CEmblemRes::Slot02() {
this->gif.Slot02();
}
// OFFSET: 0x0074CD20
// FUNCTION: fn_07884
bool CEmblemRes::IsTransient() {
return this->gif.IsTransient();
}
// OFFSET: 0x0074CD40
// FUNCTION: fn_07885
void CEmblemRes::MissingFile(CRenderSystemBase*, const char*) {
}