From f90aef2edf8961656201ef0dc675adbbb5e1db35 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Fri, 6 Nov 2026 20:57:16 +0000 Subject: [PATCH] Decompile 2 functions in Source/Archive/PakFile.cpp, Source/Archive/PakCipher.cpp, ... Batch #13629 by eAthena: 2 byte-identical, 0 confirmed by peer review. - fn_04016 myGPack::CGPakRead::ReadEntry: byte-identical (already on main) - fn_18131 myGPack::CGPakRead::DerivePakKey: byte-identical Merged automatically: every function is byte-identical to the original. --- Source/Archive/GPakUpdate.h | 1 + Source/Archive/PakCipher.cpp | 4 +++- Source/Archive/PakCipher.h | 1 - Source/Archive/PakFile.cpp | 45 +++++++++++++++--------------------- 4 files changed, 23 insertions(+), 28 deletions(-) diff --git a/Source/Archive/GPakUpdate.h b/Source/Archive/GPakUpdate.h index 8dc43e612..a67591cdf 100644 --- a/Source/Archive/GPakUpdate.h +++ b/Source/Archive/GPakUpdate.h @@ -30,6 +30,7 @@ namespace myGPack { public: bool ReadEntry(PakEntry* entry, void* buffer); void CollectNames(std::set& names) const; + std::uint8_t* DerivePakKey(const char* name, std::uint8_t* key); }; struct PakFreeBlock { diff --git a/Source/Archive/PakCipher.cpp b/Source/Archive/PakCipher.cpp index 99f09bb03..b4d0a179e 100644 --- a/Source/Archive/PakCipher.cpp +++ b/Source/Archive/PakCipher.cpp @@ -1,5 +1,7 @@ #include "Archive/PakCipher.h" +#include "Archive/GPakUpdate.h" + #include #include @@ -459,7 +461,7 @@ namespace myGPack { // OFFSET: 0x00AEBC90 // FUNCTION: fn_18131 - std::uint8_t* DerivePakKey(const char* name, std::uint8_t* key) { + std::uint8_t* CGPakRead::DerivePakKey(const char* name, std::uint8_t* key) { const char* base = name; const std::size_t length = std::strlen(name); const char* const end = name + length; diff --git a/Source/Archive/PakCipher.h b/Source/Archive/PakCipher.h index 7a26ea1be..0709af5c4 100644 --- a/Source/Archive/PakCipher.h +++ b/Source/Archive/PakCipher.h @@ -21,7 +21,6 @@ namespace myGPack { }; static_assert(sizeof(PakCipher) == 128); - std::uint8_t* DerivePakKey(const char* name, std::uint8_t* key); int InitialPermutation(std::uint8_t* block); int FinalPermutation(std::uint8_t* block); int EncodeBlock(int rounds, const std::uint8_t (*roundKeys)[8], std::uint32_t inputLow, std::uint32_t inputHigh, std::uint8_t* output); diff --git a/Source/Archive/PakFile.cpp b/Source/Archive/PakFile.cpp index 13d3f8cd9..75dbbdffe 100644 --- a/Source/Archive/PakFile.cpp +++ b/Source/Archive/PakFile.cpp @@ -53,34 +53,27 @@ namespace { // INLINED int CountDigits(std::uint32_t value) { + int digits; if (value >= 1000000000) { - return 10; + digits = 9; + } else if (value >= 100000000) { + digits = 8; + } else if (value >= 10000000) { + digits = 7; + } else if (value >= 1000000) { + digits = 6; + } else if (value >= 100000) { + digits = 5; + } else if (value >= 10000) { + digits = 4; + } else if (value >= 1000) { + digits = 3; + } else if (value >= 100) { + digits = 2; + } else { + digits = value >= 10; } - if (value >= 100000000) { - return 9; - } - if (value >= 10000000) { - return 8; - } - if (value >= 1000000) { - return 7; - } - if (value >= 100000) { - return 6; - } - if (value >= 10000) { - return 5; - } - if (value >= 1000) { - return 4; - } - if (value >= 100) { - return 3; - } - if (value >= 10) { - return 2; - } - return 1; + return digits + 1; } }