From 327967cc1e982ecb3f2d182853338db44cbb2dd7 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Thu, 5 Nov 2026 15:15:26 +0000 Subject: [PATCH] Decompile fn_07870 (CGifRes::DecodeGif) Batch #12438 by Yommy: 0 byte-identical, 1 confirmed by peer review. - fn_07870 CGifRes::DecodeGif: logic confirmed by peer review Peer-reviewed-by: KWDev, SapitoSucio, dori, cremane Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/Resource/GifLzw.cpp | 2 +- Source/Resource/GifResource.cpp | 7 +++---- Source/Resource/GifResource.h | 1 + 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/Resource/GifLzw.cpp b/Source/Resource/GifLzw.cpp index 1702a9b6..5bd4f409 100644 --- a/Source/Resource/GifLzw.cpp +++ b/Source/Resource/GifLzw.cpp @@ -1,4 +1,4 @@ -#include "Resource/GifLzw.h" +#include "Resource/GifResource.h" #include diff --git a/Source/Resource/GifResource.cpp b/Source/Resource/GifResource.cpp index dd3ff2c6..09e03942 100644 --- a/Source/Resource/GifResource.cpp +++ b/Source/Resource/GifResource.cpp @@ -1,7 +1,6 @@ #include "Resource/GifResource.h" #include "File/File.h" -#include "Resource/GifLzw.h" #include #include @@ -47,8 +46,8 @@ namespace { // INLINED bool IsGifSignature(const void* data) { - const auto* bytes = static_cast(data); - return bytes[0] == 'G' && bytes[1] == 'I' && bytes[2] == 'F'; + constexpr char signature[] = {'G', 'I', 'F'}; + return std::memcmp(data, signature, sizeof(signature)) == 0; } } @@ -295,7 +294,7 @@ bool CGifRes::DecodeGif(const void* data, int bytes, bool iconOnly) { ++cursor; unsigned char* indices = new unsigned char[descriptor.width * descriptor.height]; - if (DecodeGifLzw(minimumCodeSize, compressed, compressedBytes, indices) > 0) { + if (this->DecodeGifLzw(minimumCodeSize, compressed, compressedBytes, indices) > 0) { const unsigned int pixelCount = screenHeight * screenWidth; std::uint32_t* pixels = new std::uint32_t[pixelCount]; diff --git a/Source/Resource/GifResource.h b/Source/Resource/GifResource.h index 1630de71..abf3d027 100644 --- a/Source/Resource/GifResource.h +++ b/Source/Resource/GifResource.h @@ -23,6 +23,7 @@ public: void CreateBlank(int width, int height); bool DecodeGif(const void* data, int bytes, bool iconOnly); + int DecodeGifLzw(int minimumCodeSize, const unsigned char* input, int inputBytes, unsigned char* output); /* 0124 */ std::vector frames; /* 0130 */ std::uint16_t loopCount;