Files
AVA2/shared/gr2/src/gr2_decompress.cpp
T
shenleiandClaude Opus 5.5 9077aa389a AVA2 client Windows parity passes (gr2 BitKnit2/64-bit, GamePhase handlers, python modules)
- gr2: BitKnit2 decompression, 64-bit LE files, compressed curves
- net: remaining GamePhase handlers, generated GC packet table
- python: event/chat/chr/minimap/guild/quest/messenger/shop-search and
  other native modules ported against the AVA2 Windows client
- render: D3D8 fixed-function lighting in Gr2ModelRenderer, terrain
  without baked shade; cape/NPC equipment attachment
- tests + audits updated; docs/PORT-PLAN.md and WINDOWS-PARITY.md

Batch 4 (render pipeline: background.*, app.RenderGame/UpdateGame,
camera bindings, main.cpp fake-content removal) is still in progress.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 10:43:01 +09:00

69 lines
2.6 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// M0 T2 —— section 解压分派。见 docs/reference/steps/M0-gr2-reader.md
#include "internal.h"
#include "oodle1.h"
#include "bitknit2.h"
#include <cstring>
namespace gr2 {
// src 指向文件里该 section 的压缩字节(长度 s.data_size)。
// 本函数会做一份可写的、尾部留 32B 零的副本(Oodle1 解码器会写它、读过界)。
bool File::Impl::decompress_section(const detail::GrnSection& s, const uint8_t* src,
detail::Section& out, LoadError* err) {
out.info = {s.compression, s.data_size, s.expanded_data_size, s.pointer_fixup_count, 0};
if (s.expanded_data_size == 0) { // 空 section
out.data.clear();
return true;
}
switch (s.compression) {
case 0: { // NoCompression
out.data.assign(src, src + s.data_size);
out.data.resize(s.expanded_data_size);
return true;
}
case 1: // Oodle0 —— 同一族解码器的变体,暂未实现(T2 后续;样本里极少)
out.info.decompress_status = 1;
if (err) *err = {"section", "Oodle0 not implemented (M0 T2)"};
return false;
case 2: { // Oodle1
// 4 字节对齐的可写副本 + 32B 零尾
std::vector<uint8_t> buf;
buf.reserve(s.data_size + 32);
buf.assign(src, src + s.data_size);
buf.resize(s.data_size + 32, 0);
out.data.assign(s.expanded_data_size, 0);
int rc = gr2_oodle1_decompress(/*byte_reversed=*/0,
s.data_size, buf.data(),
s.first16bit, s.first8bit, s.expanded_data_size,
out.data.data());
out.info.decompress_status = rc;
if (rc != 0) {
if (err) *err = {"section", "Oodle1 decompress failed"};
return false;
}
return true;
}
case 3: // BitKnit(v1)—— Granny 2.11 之前的旧格式,AVA2 语料未出现
out.info.decompress_status = 3;
if (err) *err = {"section", "BitKnit (v1) not implemented"};
return false;
case 4: { // BitKnit2(Granny 2.11+;AVA2 pc/item 约 90% 的 gr2)
out.data.assign(s.expanded_data_size, 0);
if (!bitknit2_decompress(src, s.data_size, out.data.data(), out.data.size())) {
out.info.decompress_status = 4;
if (err) *err = {"section", "BitKnit2 decompress failed"};
return false;
}
return true;
}
default:
out.info.decompress_status = -1;
if (err) *err = {"section", "unknown compression format"};
return false;
}
}
} // namespace gr2