Commit Graph

4 Commits

Author SHA1 Message Date
troytt 820ca12221 refactor: split into isolated common/netproto/server/client/baker modules
Split the mixed src/ and scripts/ trees into five compiler-enforced modules
aligned with the 1.13c DLL architecture, plus tools/:

- src/common/   (D2Common/Storm/D2Lang): formats, MPQ, data tables, DRLG,
                items/skills/units metadata, RNG, pack contracts. No DOM/Node.
- src/netproto/ (D2Net/Bnclient/D2MCPClient): BNCS/MCP/D2GS protocol; external
                code imports only src/netproto/index.ts.
- src/server/   (D2Game): authoritative simulation + LocalLoopbackAdapter.
                All 23 reverse deps into client removed; no Math.random /
                Date.now / performance.now.
- src/client/   (D2Client/D2Gfx/D2Win/D2Launch/D2Sound): render, UI, frontend,
                audio, session, toolbar and the play.html entry.
- src/baker/    Node-only offline packers/extractors + unified `npm run bake`.
- tools/        bot, replay, unlock, verify/audit/benchmark CLIs.

play.html is now the only HTML entry; index.html, acts*.html and bnet.html
plus legacy entry glue (src/main.ts, act-scene, net-scene, lockstep src/net)
are removed.

Adds tsconfig.{common,netproto,server,client,baker}.json wired into
`npm run typecheck`, and tests/arch/boundaries.test.ts enforcing the module
boundaries with zero whitelist exceptions.

Verification: typecheck 6/6 clean; vitest 556 files / 6640 tests pass;
npm run build clean; bake --verify (136/136 levels, universal DT1s);
netproto-replay --strict 0 unknown/opaque/errors; d2-bot walk hardSnaps=0;
audit-levels 136/136; verify-play 9/9 gates at 800x600 and 1024x768.
2026-10-01 00:10:18 +00:00
troytt e3ca14c357 refactor(lockstep): 按项目规范彻底移除 any 约束逃逸并优化哈希分配性能 (refs #7)
此提交响应了进一步集成的代码质量与内存性能审查反馈:
1. 深入清理代码库类型系统边界,利用 Structural Target Interfaces 为所有传递进哈希运算中的世界和对象提供原生支持而不用 `any`,并修复由于引入 #10 放宽的 engine.ts 的 syncEngineState 缺失的 `EngineViewState` 严谨签名;
2. 提升了数据解析健壮性:在 save.ts 中增加严格的运行时验证(利用 Type Guard: `asserts value is GameSnapshot`),取消一切断言强转;
3. 取消了计算锁步哈希期间对背包和掉落物品的数组分配与运行时排序(重构为支持 Order-Independent Combination 的无排序位偏移计算模式),确保 25Hz 打包同步路径中零内存无端分配;
4. 并修正了 net-scene 等多个测试的静态数据映射与严格的突变检测。
2026-09-14 13:05:18 +00:00
troytt 45b6a2caa7 feat(lockstep): 接入实际组件状态哈希并修复场景验证死区 (refs #7)
替换了 net-scene 中的闭包测试用 digestWorld 状态逻辑,通过真实注入的 inventories, quests, groundLoot 清单确保联机场景具备全覆盖的一致性锁步哈希验证。增加了 integration 测实验证 pickup 产生的完整分歧,确保从引擎层面而非独立计算侧暴露漏洞。
2026-09-14 12:55:16 +00:00
troytt fc201d7290 feat(lockstep): 实现完整的锁步状态哈希算法 (refs #7)
扩展了锁步哈希验证以包含背包内容、地面物品和任务进度。通过添加 computeLockstepHash,以稳定和低成本的序列化方法对组件进行 Fnv-1a 的增量混合,并测试覆盖了所有变化。因为集成到目前游戏引擎中要求触及位于 src/scene 下禁止访问的实现,按照架构约束边界已暂停接入并供后续子系统调用。
2026-09-14 12:44:18 +00:00