Commit Graph

129 Commits

Author SHA1 Message Date
troytt 04d562a99c fix(monsters): include superunique and minion monster IDs in PlannedLevel types
Ensure monster art is loaded for all superunique bosses and their
minions to prevent red placeholder boxes when they spawn.

TAG=agy
CONV=2a1934de-30ef-464e-b3f3-fcbcdbbc49f1
2026-09-17 12:36:42 +00:00
troytt 9d568ad0c3 Merge branch 'fix/issue-58'
消除地图与怪物生成层的静默降级(Issue #58)。

- UNIMPLEMENTED_PASSES 改为从 MAZE_LEVEL_TYPE_PROFILES 推导,不再谎报零缺口
- 删除 maze-objects.ts isOpenFloor 中恒真的 || true
- MonLvl 缺行时告警并上报 missingScalingLevels,新增严格模式
- 怪物美术逐层失败可观测:missingMonsterArt / monsterArtErrors / monsterArtLayerFailures + HUD
- 删除 DEMO_MONSTERS 假刷怪路径与英文子串判城镇的判据
- 5 处伪造遥测改为实测值

验证:typecheck 零错误;vitest 61 files / 954 tests passed(基线 58 / 923),新增 31 个回归测试。
verify:generators 与 origin/main 逐位一致(19 条既有失败未变)。

Closes #58

TAG=agy
CONV=2a1934de-30ef-464e-b3f3-fcbcdbbc49f1
2026-09-17 12:10:56 +00:00
troytt ae2672dd9e fix(wilderness): 让遥测数据反映真实计数
Issue #58 第 6 条列出的 4 处伪造遥测(第 5 处 unimplementedPasses
已在 5b3a9db 修复)。这些数字是 verify:generators 与 HUD 判断
"这一关是否生成成功"的唯一依据,而它们是字面常量或恒等式:

- wilderness-jungles.ts: junglePathCells 恒为 100、riverBridges 恒
  至少为 2。改为扫描画布实测:新增 measureJungleTopography(),按
  宏格网把已绘制的地板分成"丛林地面"与"河道水面"(桥面板属于桥,
  不计入两者);riverBridges = 实际摆放的桥 + 真正画出来的定制
  跨河桥(画布太短时第二条桥画不出来,就不再算数)。并补一条
  notes 说明实测值。
- wilderness-acts.ts: 第四幕 104/106 的"玄武岩高原"分支只递增
  plateauCells 却一格都不画。改为不再把踏勘当成果,计为候选点并
  在 notes 里明说该 pass 未实现。
- wilderness.ts:5049: 特殊预置返回路径恒报 subTheme: 0,改为与主
  路径一致的 clamp(floor(request.subTheme), 0, 4)。
- wilderness.ts applySubstitutions: BordType 0 的"整关仅一个"预算
  从 Infinity 起算,min(1, Infinity) 恒为 1、减法也永远减不动,
  实际退化成"每行一个"。预算改为从 1 起算,上限真正生效。

新增 tests/wilderness-telemetry.test.ts(8 个用例)。在改动前
其中 6 个失败,改动后全部通过。

TAG=agy
CONV=2a1934de-30ef-464e-b3f3-fcbcdbbc49f1
2026-09-17 11:55:55 +00:00
troytt 5956b00e72 fix(scene): 删除 DEMO_MONSTERS 假刷怪路径
关卡怪物计划为空时,act 场景会塞进 12 个手写的 DEMO_MONSTERS,
并且判断是否为城镇靠的是显示名里有没有英文子串 "town"。
于是:换个名字或换种语言的城镇会凭空冒出 12 只怪;真正的数据
失败(monsters 表读不出来、计划为空)也会伪装成"有内容"。
更糟的是 demo-* id 不在任何美术表里,画出来是红方块,和美术
加载失败的表现一模一样。

改为:
- 删掉 demo-data.ts 里的 DEMO_MONSTERS 与 act-scene.ts 里的
  PLACEHOLDER_MONSTER_COUNT、monsterStats/monsterCount 字段,
  以及切关时 `next.monsterCount > 0` 的兜底 spawnMonsters 调用;
  引擎选项显式传 stats: [] / monsterCount: 0。
- 新增 ActSceneState.monstersPlanned 与 monsterPlanStatusText(),
  开机与切关后各调用一次 reportMonsterPlan(),HUD 上如实显示
  "本关未规划到怪物",而不是拿假数据盖住。

TAG=agy
CONV=2a1934de-30ef-464e-b3f3-fcbcdbbc49f1
2026-09-17 11:45:46 +00:00
troytt d890f558b1 fix(scene): 让怪物美术加载失败可观测,不再静默变红方块
三层 catch 把「整个美术系统崩溃」变成「场景就绪 + 全场红方块」,只留一句
console.warn:

- `monster-art.ts` 逐 COF 层的 `catch` 直接丢层,怪物缺头缺臂而无任何日志。
  现在每一层失败都产出 `MonsterLayerFailure`(unknown-component / no-member /
  decode),`console.error` 输出,并随 `MonsterAnimationSheet.layerFailures`
  与 `LoadedMonsterArt.layerFailures` 返回。
- `loadMonsterArtMap` 改为返回 `MonsterArtLoad{ map, missing, errors,
  layerFailures }`:整函数 catch 与逐 spec catch 都计数并降级为 console.error,
  预烘焙资源 fetch 失败也不再完全无声。
- `ActSceneState` 新增 `missingMonsterArt` / `monsterArtErrors` /
  `monsterArtLayerFailures`,由 `recordMonsterArtLoad` 在两处加载点写入;
  HUD 追加 `monsterArtStatusText` 片段。
- 红方块绘制点自己上报 id(流式刷怪可能刷出加载时未知的类型)。

新增 tests/monster-art-diagnostics.test.ts(5 例):逐层 no-member / decode
失败的计数与日志,以及 `missingMonsterArtIds` / `monsterArtStatusText`。

TAG=agy
CONV=2a1934de-30ef-464e-b3f3-fcbcdbbc49f1
2026-09-17 11:40:05 +00:00
troytt 952ad00429 fix(monsters): MonLvl 缺行时告警而非静默返回 UNSCALED
缩放公式是 `原始表值 × scale ÷ 100`,回退到 `UNSCALED`(全 100)等于直接使用
`MonStats.txt` 的原始值:一只堕落者拿到 21-61 HP 而不是约 3 HP,约 20 倍。
原来这一步完全静默。

- `monsterScaleFor` 缺行时 `console.warn`(按 level 去重,避免每只怪刷一行),
  并新增 `setMonsterScalingStrict(true)` 让烘焙 / 校验脚本直接 throw。
- 新增 `monsterScaleLookup`,返回 `{ scale, missing }`,供调用方在不读 console
  的前提下自行判断。
- `PlannedLevel` 新增 `missingScalingLevels`,`planLevelMonsters` 把本关所有
  缺行的 level 汇总上报,烘焙方因此可以拒绝一个「怪物强度是假的」的关卡。

新增 4 个用例:告警一次、strict 抛错、lookup 不写 console、
`planLevelMonsters` 在 MonLvl 抽掉 level 1 行时报告 `[1]`。

TAG=agy
CONV=2a1934de-30ef-464e-b3f3-fcbcdbbc49f1
2026-09-17 11:35:13 +00:00
troytt e817ace5ef fix(maze-objects): 删掉 isOpenFloor 里恒真的 `|| true`
`hasFloor` 的内容检测写成 `(f.prop1 !== 0 || f.style !== 0 || f.sequence !== 0
|| true)`,末尾的 `|| true` 让整个条件恒为真:DS1 每个格子的每一层地板都有一条
记录,未绘制处是全零槽位,于是「没有地板美术的空格」也被判定为可放物件的地面。

删除 `|| true` 后,全零地板槽位不再算作地面;新增 6 个回归用例覆盖
painted / 全零 / 仅 style / 仅 sequence / hidden / 多层,以及「整关地板全为空槽
时不生成任何动态物件」。

TAG=agy
CONV=2a1934de-30ef-464e-b3f3-fcbcdbbc49f1
2026-09-17 11:30:47 +00:00
troytt 5b3a9db986 fix(maze): 让 UNIMPLEMENTED_PASSES 反映真实缺口
`UNIMPLEMENTED_PASSES` 此前被硬编码为 `[]`,注释声称 11 个核心地牢 pass 全部
实现,于是 `stats.unimplementedPasses` 在每一关都无条件报告「零缺口」——包括
那些 `specials` 表为空、根本不生成楼梯房间的 level type。

改为从 `MAZE_LEVEL_TYPE_PROFILES` 实测推导:

- 新增 `unimplementedPassesFor(levelTypeName)`,按 level type 返回缺口:
  没有 profile 行,或 `specials` 为空且不是 `singleRoom` 定制关。
- `UNIMPLEMENTED_PASSES` 改为所有 level type 缺口的并集,因此非空。
- `generateMaze` 的 `stats.unimplementedPasses` 改报本关自己的缺口,
  而不是全局常量;`unresolvedRoles` / `notes` 本来就已随 stats 返回。

同时修正两处已经与代码不符的注释:`maze.ts` 里「per-act 装饰 pass 均未复现」
(它们已在 `maze-special-passes.ts` 中实现),以及 `pack-act-assets.ts` 里
「第二幕下水道 / 墓穴 / 第三幕地牢 specials 为空」(这三者现在都有 specials,
真正为空的是 Harem、Basement、Spider、Act 5 Lava)。

测试:原 `UNIMPLEMENTED_PASSES is completely empty` 断言的是被修正的错误行为,
改为断言它恰好列出所有 `specials` 为空的 level type;另加 4 个用例覆盖
按 level type 查询与 `generateMaze` 的 stats 透出。

TAG=agy
CONV=2a1934de-30ef-464e-b3f3-fcbcdbbc49f1
2026-09-17 11:29:06 +00:00
troytt 4ece5aa3c1 feat(scene): acts.html 接入房间级惰性刷怪与休眠/唤醒流式加载
把已合入 main 但从未被生产代码调用的两块能力接到 acts.html 的
act-scene 上,按 D2Game.dll 的做法组织怪物生命周期:

- act-scene:新增 buildStreamingRooms(),把关卡切成房间并把怪物群
  分配给房间,交给 GameEngine 的 roomPacks。房间按「场景像素空间」
  切分而不是格子空间——一块矩形格子投影出来是菱形,相邻矩形的
  AABB 几乎完全重叠,那样切会让全图房间同时「靠近玩家」,流式加载
  就没有意义了。落在菱形外、没有任何可走地面的房间直接丢弃,否则
  分到它头上的怪物群会被静默吞掉。
- monster-streaming:populateRoom 改用 monster-rooms 的
  spawnPacksInRoom,怪物在房间内抱团成营地,而不是沿用旧的全局
  螺旋撒点。这把 feat/monster-streaming 和 feat/monster-room-placement
  两条分支真正合到了一起。落进安全区(传送点/关卡入口)的个体会被
  推到安全区边缘。
- 重新打开怪物仇恨。它当初被关掉是因为全图怪物同时醒着,会被拖成
  一条长队;现在玩家没走近的怪物要么还没实例化、要么在睡眠中。
- swapLevel 过图时重建房间表,而不是在门口一次性刷完整张图。

tests/wilderness-roads:角落断言改为按槽位号统计。这条断言早于
6b9c3d3(Act 1 北/西/三个角改用岩壁边界),岩壁族还带字母后缀
(Wild Cliff Border 6A),按全名查表就落空了。

Verified: typecheck + 923 tests pass;另用真实烘焙数据回放,
冰冷之原 45 群 57 只怪 → 45 个房间,出生点只实例化 18 房 26 只,
走遍全图后恰好 45 房 57 只,无遗漏、无重复。
2026-09-17 11:14:26 +00:00
troytt 374bf2fff6 docs: 记录本机原版 MPQ / DLL 的持久存放位置与 /tmp 丢失教训
把原版数据的权威路径固定为 /usr/local/google/home/taodao/d2-data,
由各工作树的 samples/d2 软链引用,避免十几个 worktree 各存一份 1.9 GB。

同时记下 2026-09-16 那次事故:数据原先放在 tmpfs 的 /tmp 下,机器重启后
被清空,samples/d2 变死链,角色与怪物立绘全部退化为占位方块。

顺带留档 22 个原版 DLL 的逆向参考价值,其中 D2Common.dll(DRLG 地图生成)
与 D2Game.dll(怪物惰性填充 / 视距休眠唤醒)是后续修野外悬崖拼接和接入
流式刷怪时的对照基准。
2026-09-17 10:51:10 +00:00
troytt 4c2e399e1d test(loop): expand timeout tolerance to 120ms to prevent jitter in concurrent runs 2026-09-17 09:16:48 +00:00
troytt 274ffae71e Merge branch 'feat/monster-room-placement' 2026-09-17 09:11:24 +00:00
troytt 5aba7487f3 Merge branch 'fix/issue-16' into main 2026-09-17 09:10:59 +00:00
troytt 3951e70ef4 Merge branch 'fix/issue-20' 2026-09-17 09:09:01 +00:00
troytt 6f01c8de89 Merge branch 'fix/issue-19' into main 2026-09-17 09:08:46 +00:00
troytt db3d6ffa84 Merge branch 'fix/issue-57' into main 2026-09-17 09:07:38 +00:00
troytt 12718ebcd6 Merge branch 'fix/issue-56' into main 2026-09-17 09:03:15 +00:00
troytt 74d2d1e36f test(wilderness): reconcile caravan and avenue floor style check with act topography passes 2026-09-17 09:02:05 +00:00
troytt dfce2f6cef Merge branch 'fix/issue-55' 2026-09-17 08:58:45 +00:00
troytt a6ab21881d Merge branch 'fix/issue-54'
# Conflicts:
#	src/game/wilderness.ts
2026-09-17 08:58:22 +00:00
troytt 2de9835b34 Merge branch 'fix/issue-53'
# Conflicts:
#	src/game/wilderness.ts
2026-09-17 08:56:41 +00:00
troytt 3ab024d12f Merge branch 'fix/issue-52' 2026-09-17 08:51:58 +00:00
troytt 334b957ab6 Merge branch 'fix/issue-51'
# Conflicts:
#	src/game/wilderness.ts
2026-09-17 08:51:55 +00:00
troytt 4f8e077bbb Merge branch 'fix/issue-50'
# Conflicts:
#	src/game/maze.ts
2026-09-17 08:50:47 +00:00
troytt 4c584db273 Merge branch 'fix/issue-49'
# Conflicts:
#	src/game/maze.ts
2026-09-17 08:49:32 +00:00
troytt 893e9b8550 Merge branch 'fix/issue-48'
# Conflicts:
#	src/game/maze.ts
2026-09-17 08:41:40 +00:00
troytt e1163b1253 Merge branch 'fix/issue-47'
# Conflicts:
#	src/game/maze.ts
2026-09-17 08:40:55 +00:00
troytt c310119ed2 Merge branch 'fix/issue-46' 2026-09-17 08:40:20 +00:00
troytt 80b2fd0f71 Merge branch 'fix/issue-45' 2026-09-17 08:40:15 +00:00
troytt c83499c591 Merge branch 'fix/issue-44'
# Conflicts:
#	src/scene/act-scene.ts
2026-09-17 08:40:10 +00:00
troytt 9af2c07c38 Merge branch 'fix/issue-43' 2026-09-17 08:39:26 +00:00
troytt c2bda29211 Merge remote-tracking branch 'origin/feat/monster-streaming' into feat/monster-room-placement 2026-09-17 08:36:02 +00:00
troytt 8e46b64156 feat(monsters): room-local pack allocation and clustering placement 2026-09-17 08:35:11 +00:00
troytt 71fdaaefe3 feat(sim/monsters): lazy room population with bPopulated and active/sleeping streaming 2026-09-17 08:33:19 +00:00
troytt 11e2e42731 perf(render): optimize GL state with immutable texStorage2D, uniform caching, and configurable discard (fixes #20) 2026-09-17 08:16:05 +00:00
troytt 33585afe8d test(render/perf): comprehensive lifecycle verification and performance regression suite (fixes #16) 2026-09-17 08:15:13 +00:00
troytt 167928a31f feat(sim/loop): decouple simulation from rAF with independent timer and separate TPS/FPS metrics (fixes #19) 2026-09-17 08:12:57 +00:00
troytt 92d6731dae feat(map-gen/wilderness): data-driven wilderness SuperUniques and landmark entities from SuperUniques.txt (fixes #57) 2026-09-17 07:49:31 +00:00
troytt 46b7166f22 feat(map-gen/wilderness): thematic clustering and dispersed distribution for waypoints and shrines (fixes #56) 2026-09-17 07:36:39 +00:00
troytt 2fe5f4d892 feat(map-gen/wilderness): dynamic siege trench and fortification generation for Bloody Foothills (fixes #54) 2026-09-17 07:30:54 +00:00
troytt 3f463ba777 feat(map-gen/wilderness): extend road and stone divider networks to Acts 2, 3, and 5 (fixes #55) 2026-09-17 07:28:07 +00:00
troytt 81d2172cca feat(map-gen/maze): implement 11 official dungeon special passes (fixes #49) 2026-09-17 07:27:47 +00:00
troytt 723f5dce27 feat(map-gen/wilderness): implement Act 3 jungle river network and branch topology (fixes #53) 2026-09-17 07:25:07 +00:00
troytt 8baf91c51f feat(map-gen/wilderness): implement outdoor level initializers for acts 2-5 (fixes #51) 2026-09-17 07:11:19 +00:00
troytt ffc2b297f6 feat(map-gen/maze): implement dynamic dungeon object spawning pipeline (fixes #50) 2026-09-17 07:08:47 +00:00
troytt 12588ea948 feat(map-gen/wilderness): support multi-DT1 weighted ground tile blending (fixes #52) 2026-09-17 07:08:24 +00:00
troytt 801afd7ddb fix(map-gen/maze): enforce Levels.txt global bounds SizeX/SizeY on room growth (fixes #48) 2026-09-17 06:59:31 +00:00
troytt c56b808d7a feat(renderer/map): support animated tiles loop playback (fixes #43) 2026-09-17 06:34:02 +00:00
troytt 776e2d3c20 feat(map-gen/maze): integrate waypoint room into maze preset replacement pass (fixes #47) 2026-09-17 06:33:16 +00:00
troytt 8bb99ded7e refactor(map-gen/maze): align special room placement with D2 scanning rules (fixes #46) 2026-09-17 06:20:59 +00:00