From 3c1166c45e3be1dc44f0ea83accb0408a24b2751 Mon Sep 17 00:00:00 2001 From: Sestain <35299377+sestain@users.noreply.github.com> Date: Fri, 27 Mar 2026 21:59:35 +0200 Subject: Added support for Big-Endian DLCs (#1291) * Added support for Big-Endian DLCs * Remove unused variable * Remove the things made for other PR --- Minecraft.Client/Common/DLC/DLCManager.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'Minecraft.Client/Common/DLC/DLCManager.h') diff --git a/Minecraft.Client/Common/DLC/DLCManager.h b/Minecraft.Client/Common/DLC/DLCManager.h index d4dd2508..7191ab0b 100644 --- a/Minecraft.Client/Common/DLC/DLCManager.h +++ b/Minecraft.Client/Common/DLC/DLCManager.h @@ -94,6 +94,30 @@ public: bool readDLCDataFile(DWORD &dwFilesProcessed, const string &path, DLCPack *pack, bool fromArchive = false); DWORD retrievePackIDFromDLCDataFile(const string &path, DLCPack *pack); + static unsigned short SwapInt16(unsigned short value) { + return (value >> 8) | (value << 8); + } + + static unsigned int SwapInt32(unsigned int value) { + return ((value & 0xFF) << 24) | + ((value & 0xFF00) << 8) | + ((value & 0xFF0000) >> 8) | + ((value & 0xFF000000) >> 24); + } + + static void SwapUTF16Bytes(char16_t* buffer, size_t count) { + for (size_t i = 0; i < count; ++i) { + char16_t& c = buffer[i]; + c = (c >> 8) | (c << 8); + } + } + + static unsigned int readUInt32(unsigned char* ptr, bool endian) { + unsigned int val = *(unsigned int*)ptr; + if (endian) val = SwapInt32(val); + return val; + } + private: bool processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD dwLength, DLCPack *pack); -- cgit v1.2.3