This commit is contained in:
lzwdgc 2024-02-03 02:36:53 +03:00
parent 763f4aeb95
commit 308312f54a
3 changed files with 24 additions and 18 deletions

View file

@ -19,4 +19,12 @@ struct stream {
p += sizeof(T) * len;
return s;
}
template <typename T>
void operator=(const T &v) {
memcpy(p, (uint8_t*)&v, sizeof(v));
p += sizeof(v);
}
void skip(size_t len) {
p += len;
}
};

View file

@ -327,6 +327,20 @@ struct ModificatorMask
#pragma pack(push, 1)
struct pak {
static constexpr uint32_t default_block_size = 0x4000;
struct segment {
// some file offset? trash? crc? m1 has zlib crc table (png)?
uint32_t unk1;
uint32_t algorithm;
uint32_t offset;
};
struct file_description {
char name[0x50];
uint32_t offset;
uint32_t size;
};
uint32_t magic;
uint16_t unk0;
uint32_t n_files;
@ -334,20 +348,4 @@ struct pak {
uint32_t block_size;
uint32_t unk1;
};
struct file_description {
const char name[0x50];
uint32_t offset;
uint32_t size;
};
struct segment {
enum decode_algorithm : uint32_t {
none = 0x0,
// none = 0x1, // ?
};
// some file offset? trash? crc? m1 has zlib crc table (png)?
uint32_t unk1;
decode_algorithm algorithm;
uint32_t offset;
};
#pragma pack(pop)

View file

@ -44,8 +44,8 @@ void unpack_file(path fn) {
primitives::templates2::mmap_file<uint8_t> f{fn};
stream s{f};
pak p = s;
auto descs = s.span<file_description>(p.n_files);
auto segments = s.span<segment>(p.n_blocks);
auto descs = s.span<pak::file_description>(p.n_files);
auto segments = s.span<pak::segment>(p.n_blocks);
std::vector<uint8_t> decoded;
decoded.resize((segments.size() + 1) * p.block_size * 4);
auto pp = decoded.data();