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>
This commit is contained in:
shenlei
2026-10-08 10:43:01 +09:00
co-authored by Claude Opus 5.5
parent 9f748eb05a
commit 9077aa389a
145 changed files with 22692 additions and 6584 deletions
+45 -3
View File
@@ -14,9 +14,12 @@ void wr32(std::vector<uint8_t> &bytes, size_t off, uint32_t value) {
bytes[off + 3] = uint8_t(value >> 24);
}
std::vector<uint8_t> granny_header(size_t size, uint32_t section_count) {
constexpr uint32_t kMagic32LE[] = { 0xCAB067B8, 0x0FB16DF8, 0x7E8C7284, 0x1E00195E };
constexpr uint32_t kMagic64LE[] = { 0x5E499BE5, 0x141F636F, 0xA9EB131E, 0xC4EDBE90 };
constexpr uint32_t kMagic32BE[] = { 0xB595110E, 0x4BB5A56A, 0x502828EB, 0x04B37825 };
std::vector<uint8_t> granny_header(size_t size, uint32_t section_count, const uint32_t *magic = kMagic32LE) {
std::vector<uint8_t> bytes(size, 0);
const uint32_t magic[] = { 0xCAB067B8, 0x0FB16DF8, 0x7E8C7284, 0x1E00195E };
for (int i = 0; i < 4; ++i) {
wr32(bytes, size_t(i) * 4, magic[i]);
}
@@ -47,14 +50,53 @@ int main() {
bool ok = true;
ok &= expect_failure(std::vector<uint8_t>(80, 0), "header");
ok &= expect_failure(granny_header(80, 0), "fileinfo");
// 64-bit little-endian Granny (AVA2 plechi_* assets) passes the header stage;
// big-endian is still rejected there.
ok &= expect_failure(granny_header(80, 0, kMagic64LE), "fileinfo");
ok &= expect_failure(granny_header(80, 0, kMagic32BE), "header");
auto unsupported = granny_header(160, 1);
constexpr size_t section = 72;
wr32(unsupported, section + 0, 4); // unsupported BitKnit
wr32(unsupported, section + 0, 3); // BitKnit v1 is not implemented
wr32(unsupported, section + 4, uint32_t(unsupported.size()));
wr32(unsupported, section + 12, 1); // non-empty expanded section
ok &= expect_failure(unsupported, "section");
// BitKnit2 (Format 4) with an empty stream: no 0x75B1 magic -> clean section failure.
auto bitknit_empty = unsupported;
wr32(bitknit_empty, section + 0, 4);
ok &= expect_failure(bitknit_empty, "section");
// BitKnit2 stored quantum: magic 0x75B1, u16 0 marker, 8 raw bytes. The section
// decodes, so loading proceeds to the (empty) type tree instead of failing in "section".
auto bitknit_stored = granny_header(160, 1);
const uint8_t stream[] = { 0xB1, 0x75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
for (size_t i = 0; i < sizeof(stream); ++i) bitknit_stored[120 + i] = stream[i];
wr32(bitknit_stored, section + 0, 4);
wr32(bitknit_stored, section + 4, 120);
wr32(bitknit_stored, section + 8, uint32_t(sizeof(stream)));
wr32(bitknit_stored, section + 12, 8);
{
gr2::LoadError err;
auto file = gr2::File::load(bitknit_stored.data(), bitknit_stored.size(), &err);
if (!file && err.stage == "section") {
std::fprintf(stderr, "BitKnit2 stored quantum rejected: %s\n", err.message.c_str());
ok = false;
}
}
// Truncated stored quantum (claims 8 bytes, carries 4) must fail cleanly.
auto bitknit_short = bitknit_stored;
wr32(bitknit_short, section + 8, 8);
ok &= expect_failure(bitknit_short, "section");
// BitKnit2 fixup table: u32 compressed size pointing past EOF -> clean "fixup" failure.
auto bitknit_fixup = bitknit_stored;
wr32(bitknit_fixup, section + 28, 150); // PointerFixupArrayOffset
wr32(bitknit_fixup, section + 32, 1); // PointerFixupArrayCount
wr32(bitknit_fixup, 150, 1000);
ok &= expect_failure(bitknit_fixup, "fixup");
auto bad_offset = granny_header(160, 1);
wr32(bad_offset, section + 4, UINT32_MAX);
ok &= expect_failure(bad_offset, "section");