[P0][T17] 冻结物品数据结构:一次预留 .d2s 位对齐编码所需的全部字段 #88
Labels
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: troytt/diablo2-web#88
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
问题
M10 一旦开始改
src/game/items.ts的Item/ItemBase结构,M13(.d2s存档互通)就被锁死了。.d2s的物品段是位对齐的变长编码,字段一旦定错,round-trip 比对就过不去,届时要把整个物品模型翻一遍。母 issue 已经明确提醒了这一点。本 issue 的任务是在写任何加载 / 序列化代码之前,把字段清单一次定死。
金标准数据
关键事实:
.d2s的物品记录与网络0x9C包用的是同一个序列化函数 ——D2Common!6FD77180,逐字段调WriteBits(D2Common!6FD592C4)。所以从这一个函数就能读出完整字段表。整体:
"JM"+ 物品数(u16),随后每件物品一条位对齐变长记录,LSB-first 位序、跨字节连续、整条记录不按字节对齐(下一件紧接着写)。头部(所有物品)
"JM"ItemData+0x30,钳[0,1023]Unit+0x10,钳[0,7](0 stored / 1 equipped / 2 belt / 3 ground / 4 cursor / 5 dropping / 6 socketed)ItemData+0x44ItemData+0x45 + 1(inventory / cube / stash)"gld ")[0,7]若外层传入「简单物品」标志(宝石 / 药水 / 符文等),写完这里再写一个 32 位值就返回 —— 对应
.d2s的 simple / compact item。扩展部分(非 simple item)
Unit+0x28(dwInitSeed)—— 词缀数值靠它复原[1,99]再钳[0,127]+0x23非 0 才可能为 1ItemData+0x49ItemData+0x36,AutoMagic.txt索引,钳[0,2047]6FD787AC)0xFFF= 无)ItemStatCost的Save Add(10)Save Bits(含Save Param Bits),以0x1FF结束0x1FF);runeword 另起一段实现要求
数据结构至少要覆盖:
陷阱
验收标准
docs/),每个字段标注位宽、来源偏移、是否可选、依赖哪个 flagItem/ItemBaseinterface 按清单改完,含rawFlags与未识别位的保留字段npm run typecheck0 errornpx vitest run全绿npx tsx scripts/verify-items.ts新增断言通过溯源
D2Common!6FD77180/D2Common!6FD592C4(objdump -d,D2Common 基址0x6FD50000、D2Game0x6FC10000)已完成并通过 D2Common!6FD77180 反汇编确证的 .d2s 位对齐规范冻结(docs/item-d2s-spec.md + src/game/items.ts),合并入 main (commit
24fbc3b)。