Lock normalization

This commit is contained in:
2026-05-14 08:34:50 +02:00
parent c66b7dcb2b
commit 18066ee0dd
2 changed files with 58 additions and 4 deletions
+1 -4
View File
@@ -748,10 +748,7 @@ func collectBaseDataset(dataset nativeDataset) (nativeCollectedDataset, error) {
lockData[key] = rowID
lockModified = true
}
} else if lockedID, ok := lockData[key]; ok {
row["id"] = lockedID
rowID = lockedID
} else {
} else if _, ok := lockData[key]; !ok {
lockData[key] = rowID
lockModified = true
lockAdded++
+57
View File
@@ -8336,6 +8336,63 @@ func TestBuildSkillsKeyNullRemovesIdentityWithoutNullingRow(t *testing.T) {
}
}
func TestBuildSkillsIgnoresStaleBaseSpanLockDuringInitialLoad(t *testing.T) {
root := testProjectRoot(t)
mkdirAll(t, filepath.Join(root, "topdata", "data", "skills", "modules"))
writeFile(t, filepath.Join(root, "topdata", "base_dialog.json"), "{}\n")
writeFile(t, filepath.Join(root, "topdata", "data", "skills", "base.json"), `{
"output": "skills.2da",
"columns": ["Label", "Name", "Description", "Icon", "Untrained", "KeyAbility", "ArmorCheckPenalty", "AllClassesCanUse", "Category", "MaxCR", "Constant", "HostileSkill", "HideFromLevelUp"],
"rows": [
{"id": 18, "key": "skills:taunt", "Label": "Taunt", "Name": "342", "Description": "366", "Icon": "isk_taunt", "Untrained": "1", "KeyAbility": "CHA", "ArmorCheckPenalty": "0", "AllClassesCanUse": "1", "Category": "****", "MaxCR": "1", "Constant": "SKILL_TAUNT", "HostileSkill": "1", "HideFromLevelUp": "0"},
{"id": 24, "key": "skills:intimidate", "Label": "Intimidate", "Name": "8756", "Description": "8786", "Icon": "isk_X2Inti", "Untrained": "1", "KeyAbility": "CHA", "ArmorCheckPenalty": "0", "AllClassesCanUse": "1", "Category": "****", "MaxCR": "****", "Constant": "SKILL_INTIMIDATE", "HostileSkill": "0", "HideFromLevelUp": "0"}
]
}`+"\n")
writeFile(t, filepath.Join(root, "topdata", "data", "skills", "lock.json"), `{
"skills:intimidate": 18,
"skills:taunt": 18
}`+"\n")
writeFile(t, filepath.Join(root, "topdata", "data", "skills", "modules", "ovr_taunttointimidate.json"), `{
"overrides": [
{
"id": 18,
"key": "skills:intimidate",
"Label": "Intimidate",
"Constant": "SKILL_INTIMIDATE",
"HideFromLevelUp": "0"
}
]
}`+"\n")
writeFile(t, filepath.Join(root, "topdata", "data", "skills", "modules", "rmv_removedskills.json"), `{
"overrides": [
{
"id": 24,
"key": null,
"Label": null,
"Constant": null,
"HideFromLevelUp": "1"
}
]
}`+"\n")
mkdirAll(t, filepath.Join(root, "reference"))
writeFile(t, filepath.Join(root, "reference", "build.py"), "print('ok')\n")
if _, err := buildNativeUnchecked(testProject(root), NativeBuildOptions{BuildWiki: false}, nil, nil); err != nil {
t.Fatalf("buildNativeUnchecked failed: %v", err)
}
lockRaw, err := os.ReadFile(filepath.Join(root, "topdata", "data", "skills", "lock.json"))
if err != nil {
t.Fatalf("read skills lock: %v", err)
}
lockText := string(lockRaw)
if !strings.Contains(lockText, `"skills:intimidate": 18`) {
t.Fatalf("expected intimidate to remain locked to row 18, got:\n%s", lockText)
}
if strings.Contains(lockText, `"skills:taunt"`) {
t.Fatalf("expected stale taunt alias to be pruned, got:\n%s", lockText)
}
}
func TestBuildCanonicalSkillsMatchesReference(t *testing.T) {
root := testProjectRoot(t)
mkdirAll(t, filepath.Join(root, "topdata", "data"))