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
+13 -6
View File
@@ -36,7 +36,7 @@ struct Section {
SectionInfo info;
};
// section 内的位置。不物化指针(文件是 32 位指针,本进程 64 位),
// section 内的位置。不物化指针(文件是 32 或 64 位指针),
// 全程用 (section, offset) + fixup 表按需解引用。
struct Ref {
int32_t section = -1;
@@ -53,9 +53,10 @@ enum MemberType {
MT_Int32, MT_UInt32, MT_Real16, MT_EmptyRef, MT_OnePastLast
};
// data_type_definition 在文件里的字节数(32 位指针):
// Type(4) Name(ptr4) ReferenceType(ptr4) ArrayWidth(4) Extra[3](12) Ignored(ptr4)
constexpr uint32_t kTypeDefEntrySize = 32;
// data_type_definition 在文件里的字节数(结构紧排,指针宽度随文件 magic):
// Type(4) Name(ptr) ReferenceType(ptr) ArrayWidth(4) Extra[3](12) Ignored(ptr)
// 32 位文件 = 32B,64 位文件 = 44B(与 BG3ModStudio GR2TypeNode pack(1) 一致)
constexpr uint32_t type_def_entry_size(uint32_t ptr) { return 4 + ptr + ptr + 4 + 12 + ptr; }
struct TypeMember {
std::string name;
@@ -81,13 +82,16 @@ struct File::Impl {
Ref root_obj; // grn_file_header.RootObject
Ref root_type; // grn_file_header.RootObjectTypeDefinition
bool typetree_ready = false;
// 文件指针宽度:32 位 magic = 4,64 位 magic = 8。指针槽都靠 fixup 表解引用,
// 只有成员大小 / 复合成员内部偏移随它变化。
uint32_t ptr = 4;
// 类型解析缓存:typedef 的 Ref -> 成员列表
std::unordered_map<uint64_t, std::vector<TypeMember>> type_cache;
// ── T2 / T1 ──
bool decompress_section(const GrnSection&, const uint8_t* src, detail::Section& out, LoadError*);
void build_fixups(const uint8_t* file, size_t file_len); // T1
bool build_fixups(const uint8_t* file, size_t file_len, LoadError* err); // T1
// ── T3 ──
const uint8_t* at(Ref r, size_t need = 0) const; // section 内指针 + 边界检查
@@ -106,7 +110,7 @@ struct File::Impl {
// 成员访问(obj = 对象实例的 Ref,m = 其类型的某个成员)
Ref member_slot(Ref obj, const TypeMember& m) const { return {obj.section, obj.offset + m.offset}; }
Ref read_reference(Ref obj, const TypeMember& m) const { return follow(member_slot(obj, m)); }
// ArrayOfReferences: {int32 count; ptr → [count] 个指针槽 → 各自的对象}
// ArrayOfReferences: {int32 count; ptr → [count] 个指针槽(各 ptr 字节)→ 各自的对象}
std::vector<Ref> read_array_of_refs(Ref obj, const TypeMember& m) const;
// ReferenceToArray: {int32 count; ptr → [count] 个连续对象(elem_type)}
bool read_ref_to_array(Ref obj, const TypeMember& m, Ref& base, uint32_t& count, uint32_t& stride);
@@ -121,6 +125,9 @@ struct File::Impl {
// 曲线子类型分类(T7a)。curve_obj 指向 inline 曲线对象本体,curve_type 是它的类型。
std::string classify_curve_obj(Ref curve_obj, Ref curve_type);
void read_old_curve(Ref curve_obj, Ref curve_type, Curve& out); // T7b
// curve2{variant CurveData}:各 CurveData* 压缩变体解到同一 Curve(knots + float controls)。
// keyframe_dt = 所在 animation 的 TimeStep(DaKeyframes32f 的隐含 knot 间距)。
void read_curve2(Ref curve_obj, Ref curve_type, float keyframe_dt, Curve& out);
double skeleton_self_check(int skeleton) const;
// granny_transform (68B) → 行主序 4x4(BuildCompositeTransform4x4 语义)