[Audit & Parity] 物品名称与词条显示未严格遵循 1.13c .tbl 字符串表(覆盖背包、储物箱、地面) #480
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?
概述 (Overview)
依据项目第一铁律(1.13c 逆向反汇编真值原则 / Ground Truth Invariant),对当前
diablo2-web中物品名称与属性词条(Affix / Property Descriptions)在**背包(含人物装备栏)、储物箱(Stash)、地面(Ground)**三大场景下的获取与格式化链路进行了全量源码与二进制数据对标检查。核心审计结论
当前无论在背包、储物箱还是地上,物品名称与属性词条均未严格通过
.tbl(string.tbl/expansionstring.tbl/patchstring.tbl)获取。虽然仓库中早已实现了完整的
.tbl二进制哈希表解码器(src/formats/tbl.ts)、多表级联查询链(src/game/item-names.ts)以及ItemStatCost.txt的descfunc/descval/descstrpos/dgrp*字段解析(src/game/properties.ts:509-558),但src/game/item-names.ts在整个src/运行时代码中被引用次数为0,且ItemStatCost.txt的描述控制字段未被src/game/item-tooltip.ts使用。一、 1.13c 原版真值(D2MOO
ItemsTbls.cpp)vs 当前实现全量对比D2Common.dll/D2Client.dll).tbl实测覆盖率diablo2-web现状与违规点(
Weapons.txt/Armor.txt/Misc.txt)DATATBLS_LoadItemsTxt(0x6FD55280) 将namestr列通过DATATBLS_GetStringIdFromReferenceString转为.tbl索引wNameStr。202/202、Weapons306/306、Misc143/151CHI: Classic 底材全覆盖
src/game/drop-pipeline.ts:581直接使用.txt的base.name;UI 端通过src/game/tooltip-i18n.ts:19-650硬编码字典ITEM_NAMES_ZH翻译,并在src/ui/item-bridge.ts:316拼接成非原版的"中文 (English)"双语格式。(
UniqueItems.txt/SetItems.txt/Sets.txt/Runes.txt)DATATBLS_LoadUniqueItemsTxt(0x6FD584E0)、DATATBLS_LoadSets_SetItemsTxt(0x6FD59140)、DATATBLS_LoadRunesTxt(0x6FD5E020) 均调用D2LANG_GetTblIndex查询index/Name(如Runeword1..Runeword170)。100%命中.tbl.txt的index字段并查tooltip-i18n.ts静态字典;符文之语直接读Runes.txt的Rune Name列而不查Name(Runeword*) 对应的.tbl词条。(
MagicPrefix.txt/MagicSuffix.txt/AutoMagic.txt/RarePrefix.txt/RareSuffix.txt)DATATBLS_LoadMagicSuffix_Prefix_AutomagicTxt(0x6FD57C20,ItemsTbls.cpp:566) 与DATATBLS_LoadRareSuffix_PrefixTxt(0x6FD58110,ItemsTbls.cpp:646) 全部调用D2LANG_GetTblIndex(szName)查.tbl。637/637、MagicSuffix741/741、RarePrefix46/46、RareSuffix155/155(100%)CHI: RarePrefix
46/46、RareSuffix155/155src/game/item-names.ts:13与src/game/affixes.ts:10存在错误的注释断言(声称词缀不查.tbl)。导致RarePrefix.txt/RareSuffix.txt中的内部键名(如GhoulRI、PlagueRI、Wraithra、Fiendra、barRI)未查.tbl(原版.tbl中GhoulRI->"Ghoul"/"食屍鬼之",barRI->"Bar"/"酒吧"),掉落亮金装备时直接把内部 Key 当作名字拼出"GhoulRI barRI"!(
LowQualityItems.txt/QualityItems.txt)DATATBLS_LoadLowQualityItemsTxt(0x6FD5BDA0,ItemsTbls.cpp:1286) 调用D2LANG_GetTblIndex;超强物品使用.tbl的Hiquality词条。100%src/game/drop-pipeline.ts:484,704,749硬编码拼接英文字符串Superior ${base.name}和${lowPrefix} ${base.name}。(
Gems.txt)DATATBLS_LoadGemsTxt(0x6FD5B2F0,ItemsTbls.cpp:1183) 用 3 字符code查.tbl,镶嵌效果通过weaponMod1..3/helmMod1..3/shieldMod1..3走ItemStatCost.txt+.tbl动态生成。68/68(100%)src/game/gems-data.ts:53-250(由scripts/generate_gems_data.ts生成)将 35 种宝石与 33 种符文的名称及武器/防具/头盔/盾牌词条全部写死为静态中英文字符串。(
ItemStatCost.txtdescfunc/descstrpos/dgrp*)DATATBLS_LoadItemStatCostTxt(0x6FD5C320,ItemsTbls.cpp:1454-1465) 将descstrpos/descstrneg/descstr2及dgrpstrpos/dgrpstrneg/dgrpstr2转为.tbl字符串 ID,客户端按descpriority排序后根据descfunc(1..28) 和descval(0..2) 组合.tbl文本。205/205(100%)CHI:
197/205src/game/properties.ts:509-558虽然解析了descFunc、descVal、descStrPos、dgrp*,但从未传给.tbl格式化器!src/game/item-tooltip.ts:430-1150与src/game/tooltip-i18n.ts:3138-3680使用上千行的switch (code)硬编码中英文模板字符串,并手工维护PROP_DESC_PRIORITY/PROP_STAT_ID。(防御、伤害、耐久、需求、凹槽)
.tbl读取ItemStats1a..ItemStats1h、Socketable、Stre8a等标准键名。100%src/ui/world-panels.ts:1039-1064与src/game/item-tooltip.ts:2010-2190硬编码"防御: "、"单手伤害: "、"耐久度: X 之 Y"、"需要力量: "、"需要等级: "、"凹槽 (X)"。二、 三大场景(背包、储物箱、地上)逐项检查结果
1. 背包与人物穿戴栏(Inventory & Equipped Paperdoll)
src/ui/inventory.ts:524-915、src/game/class-starter-profiles.ts:110-1028,1285-1725):STARTER_EQUIPPED_GEAR、STARTER_BAG_ITEMS、CLASS_EXCLUSIVE_SETS、createStarterBagForClass中的所有装备完全绕过了Item属性管线与.tbl,直接在对象字面量中手写nameZh、baseNameZh和stats: [{ text, color }]。.tbl:"+2 所有技能 (+2 To All Skills)"、"+20% 快速施法速度 (FCR)"、"+30% 快速再度攻击 (FHR)"、"+200% 增强伤害 (ED)"、"+40% 提升攻击速度 (IAS)"、"50% 更佳机会取得魔法装备 (MF)"(原版.tbl绝无(FCR)/(ED)/(MF)等括号缩写)。/合并到同一行,如"+10 力量 / +15 敏捷"、"抗寒 +40% / 抗电 +40% / 抗火 +40%"、"+25 生命 / +20 法力"、"10% 每次命中偷取生命 / 5% 偷取法力"(原版每条属性独立一行,仅当四抗全等时才触发ItemStatCost.txt的dgrp=2显示All Resistances +%d/所有抗性 +%d)。src/ui/world-panels.ts:1021-1140):WorldPanelsHud.drawItemTooltip直接读取item.nameZh、item.baseNameZh、硬编码基础标签("防御: "等)以及item.stats数组绘制,完全不经过.tbl。src/scene/act-scene.ts:3490->src/ui/item-bridge.ts:295-470):itemToUiInventoryItem(item.item, this.engine.dropTables),内部调用formatItemTooltip(item, "zh")与translateItemName(baseEn),依赖src/game/tooltip-i18n.ts的静态字典与switch(code)硬编码模板,未查询.tbl。2. 储物箱(Stash 6×8 Grid)
src/game/class-starter-profiles.ts:1034-1280):STARTER_STASH_ITEMS中的符文(Row 0–1)、完美/无瑕宝石(Row 2–3)与暗金/魔法珠宝(Row 4)全部手写nameZh(如"乔 (Jah 符文)")、baseNameZh: "符文 (#31)"(原版无此副标题)以及简写stats(如仅写武器:和防具:两行,漏掉了Gems.txt中独立的头盔/盾牌区分,且无瑕宝石只写了防具:一行,完全漏掉武器与盾牌效果!)。src/ui/world-panels.ts:624-662,1021-1140):WorldPanelsHud.drawItemTooltip,同样直接渲染手写stats和硬编码基础标签。3. 地面物品(Ground Items &
AltLabels)src/game/engine.ts:1436-1478->src/game/ground-items.ts:181-280->src/ui/ground-labels.ts:110-126):executeDropPipeline生成的Item(src/game/drop-pipeline.ts:558-865)只设置了英文name(直接取自.txt的base.name、uniqueItem.index、magicAffixes.name或未查.tbl的rareAffixes.name如"GhoulRI barRI"),完全没有设置nameZh。this.groundItems.add(drop, ...)调用resolveGroundItemMetadata(src/game/ground-items.ts:200):const nameZh = typeof s.nameZh === "string" && s.nameZh ? s.nameZh : name。由于drop.nameZh为undefined,所有怪物掉落物品在地面上的nameZh实际退化成了未经过.tbl解析的.txt原始英文名!src/game/ground-items.ts:189、src/ui/ground-labels.ts:113)硬编码为${amount} 金币,未从.tbl查询Gold词条。src/ui/ground-labels.ts:110-126):当前代码直接显示item.nameZh || item.name(怪物掉落显示原始英文全名,从背包丢到地上的初始装备则显示带英文括号的"谐角之冠 (Harlequin Crest)")。三、 整改计划与验收标准 (Remediation Checklist)
.tbl字符串表管线打通:src/game/item-names.ts与src/game/affixes.ts中关于魔法/亮金词缀不查.tbl的错误假设,确保底材namestr、暗金/套装index、符文之语Name、魔法词缀MagicPrefix/Suffix、亮金词缀RarePrefix/Suffix(含GhoulRI、barRI等)、劣质/超强前缀、Gems.txt键值全部通过.tbl解析。ItemStatCost.txtdescfunc(1..28) +dgrp的.tbl词条格式化器:ItemStatCost.txt的descpriority、descfunc、descval、descstrpos、descstrneg、descstr2及dgrp*字段配合.tbl词条模板动态格式化属性描述,移除手写(FCR)/(ED)/(MF)缩写与非法的/多属性合并行。.tbl名称与词条生成管线,消除三端显示割裂。已在 commit
b7ccc44修复并推送到main:scripts/pack-canonical-tbl.ts从 1.13c MPQ (d2data.mpq,d2exp.mpq,Patch_D2.mpq) 提取生成src/data/canonical-tbl-strings.ts(2,661 条 ENG.tbl、1,386 条 CHI.tbl及 207 条ItemStatCost.txtdescfunc/descval/dgrp规则表)。src/game/item-names.ts、src/game/tooltip-i18n.ts与src/game/item-tooltip.ts的.tbl权威解析与formatStatByIscDescFunc(1..28)词条格式化引擎。src/game/drop-pipeline.ts,src/game/ground-items.ts,src/ui/ground-labels.ts)、背包与装备栏 (src/ui/inventory.ts,src/game/class-starter-profiles.ts)、储物箱 (STARTER_STASH_ITEMS24 颗符文/宝石四部位标准.tbl描述及亮金珠宝双词根名称) 全部严格对齐 1.13c.tbl。tests/issue-480-tbl-item-parity.test.ts(10/10 通过),以及经验验证脚本 120/120 检查项全部通过。