rodecomp/Source/Archive/GPak.h
ragnarok-clanker fec919b88e Maintenance: Link-completeness fixes so the whole client links into one executable (all units in data/compile.json plus exe-only thir
Batch #13186 by ragnarok-clanker: forced by an admin (40 lower score(s), 206 changed function(s)); checked with 620 compiled unit(s), including every includer of Source/Archive/GPak.h, Source/Client/Mode/CGameMode.h, Source/Client/Mode/CLoginMode.h, Source/Client/Session.h, Source/Client/Stove/StoveMgr.h, Source/Client/Stove/StovePCSDK.h, Source/Client/Timer.h, Source/Contents/Actors/GameActor.h, Source/Contents/Actors/RenderObject.h, Source/Contents/CashEmotionMgr.h, Source/Contents/Configuration/ServiceOptions.h, Source/Contents/Skills/SkillTreeScript.h, Source/Render/DX9/D3DX9Runtime.h, Source/Resource/GifResource.h, Source/UI/AdventureGuide/UIAdventureGuide.h, Source/UI/Cooldowns/CooldownOwner.h, Source/UI/Edit/UIEditBoxEx.h, Source/UI/Lists/UIListBoxTemplate.h, Source/UI/Quest/UIRenewQuestUI.h, Source/UI/Rodex/UIRodexComposeWnd.h, Source/UI/Text/UITextViewerControl.h, Source/UI/UIBroadcastBalloon.h, Source/UI/UICaptchaRegisterWnd.h, Source/UI/UIMacroDetectorWnd.h, Source/UI/UIReputeWnd.h, Source/UI/Window/UIRegisterMgr.h, Source/UI/Window/UISecondCostumeWnd.h, Source/UI/Window/UISelCharForUServerWnd.h, Source/UI/Window/UIWindow.h, Source/UI/Window/UIWindowMgr.h, Source/Utility/EncryptedName.h.
2026-11-06 10:56:48 +00:00

88 lines
2.5 KiB
C++

#ifndef RAGNAROK_SOURCE_ARCHIVE_GPAK_H
#define RAGNAROK_SOURCE_ARCHIVE_GPAK_H
#include "Archive/PakFile.h"
#include "Archive/PakName.h"
#include <cstddef>
#include <cstdint>
#include <span>
#include <string_view>
#include <random>
#include <vector>
struct PakUniformRandom {
/* 0000 */ std::mt19937 m_engine;
/* 1388 */ std::uniform_int_distribution<int> m_distribution;
PakUniformRandom(int minimum, int maximum, unsigned int seed);
};
void FillRandomBytes(char* first, char* last, PakUniformRandom& random);
namespace myGPack {
struct PakEntry {
/* 0000 */ std::uint32_t alignedSize;
/* 0004 */ std::uint32_t compressedSize;
/* 0008 */ std::uint32_t originalSize;
/* 000C */ std::uint32_t unknown_000C;
/* 0010 */ std::uint64_t dataOffset;
/* 0018 */ std::uint8_t flags;
/* 0019 */ std::uint8_t unknown_0019[3];
/* 001C */ PakName name;
};
static_assert(sizeof(PakEntry) == 288);
static_assert(offsetof(PakEntry, dataOffset) == 16);
static_assert(offsetof(PakEntry, flags) == 24);
static_assert(offsetof(PakEntry, name) == 28);
}
struct PakAuxiliary {
PakAuxiliary();
~PakAuxiliary();
void Apply(const void* data, std::uint32_t size, const void* auxData, std::uint32_t auxSize);
bool Extract(std::string_view name, const std::uint8_t* data, std::uint32_t size, std::span<const std::uint8_t> scratch, void* output, std::uint32_t outputSize, unsigned flags);
/* 0000 */ std::uint8_t unknown_0000[244];
};
static_assert(sizeof(PakAuxiliary) == 244);
class CGPak {
public:
CGPak();
virtual ~CGPak();
bool Open(CPakFile* file);
void Reset();
bool Find(const myGPack::PakName& name, myGPack::PakEntry* entry) const;
bool Extract(const myGPack::PakEntry* entry, void* buffer);
void ReadAuxiliary(std::vector<std::uint8_t>& output, std::uint64_t* identifier = nullptr);
void ApplyAuxiliary(const void* data, std::uint32_t size, const void* auxData, std::uint32_t auxSize);
protected:
bool ReadTableV1();
bool ReadTableV2();
bool ReadTableV3();
/* 0008 */ alignas(8) CPakFile* m_file;
/* 000C */ std::uint32_t m_version;
/* 0010 */ std::uint32_t m_entryCount;
/* 0014 */ std::uint32_t unknown_0014;
/* 0018 */ std::uint64_t m_tableOffset;
/* 0020 */ std::uint32_t m_tableSize;
/* 0024 */ std::vector<myGPack::PakEntry> m_entries;
/* 0030 */ std::vector<std::uint8_t> m_scratch;
/* 003C */ CRITICAL_SECTION m_criticalSection;
/* 0054 */ PakAuxiliary m_auxiliary;
};
#if defined(_WIN32) && !defined(_WIN64)
static_assert(sizeof(CGPak) == 328);
#endif
#endif