From 131cbbe586463a7232f332650af5f0b2c13dc7e9 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Fri, 10 Jul 2026 20:37:29 -0400 Subject: feat(admin): remove unused fields from drop tables --- internal/validate/checks.go | 72 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) (limited to 'internal/validate/checks.go') diff --git a/internal/validate/checks.go b/internal/validate/checks.go index f89e52d..bbcb820 100644 --- a/internal/validate/checks.go +++ b/internal/validate/checks.go @@ -2,6 +2,8 @@ package validate import ( "fmt" + "os" + "path/filepath" "sort" "strings" @@ -732,7 +734,24 @@ func validateDropTables(s Source) []Issue { }) continue } - for _, d := range dt.Drops { + + // Detect files that use "entries:" instead of "drops:" as the top-level list key. + // DropTableDef only reads "drops:", so "entries:" produces an empty list. + if len(dt.Drops) == 0 { + raw, rawErr := os.ReadFile(filepath.Join(s.DataDir, "drops", id+".yaml")) + if rawErr == nil { + content := string(raw) + if strings.Contains(content, "\nentries:") || strings.HasPrefix(content, "entries:") { + issues = append(issues, Issue{ + Level: "ERROR", + Type: "integrity", + Message: fmt.Sprintf("Drop table %q: uses key 'entries:' instead of 'drops:' — entries are not loaded; rename to 'drops:'", id), + }) + } + } + } + + for i, d := range dt.Drops { if d.ItemID != "" && !itemIDs[d.ItemID] { issues = append(issues, Issue{ Level: "ERROR", @@ -749,6 +768,57 @@ func validateDropTables(s Source) []Issue { id, d.Table), }) } + + if d.ItemID != "" && d.Table != "" { + issues = append(issues, Issue{ + Level: "WARN", + Type: "integrity", + Message: fmt.Sprintf("Drop table %q entry %d: both item_id and table set (only one is used per entry)", id, i+1), + }) + } + if d.ItemID == "" && d.Table == "" { + issues = append(issues, Issue{ + Level: "WARN", + Type: "integrity", + Message: fmt.Sprintf("Drop table %q entry %d: neither item_id nor table set (roll produces nothing)", id, i+1), + }) + } + + if d.Depletes { + issues = append(issues, Issue{ + Level: "WARN", + Type: "integrity", + Message: fmt.Sprintf("Drop table %q entry %d: 'depletes' is ignored on shared drop table entries; set it on the gather entry that references this table instead", id, i+1), + }) + } + if d.Level > 0 { + issues = append(issues, Issue{ + Level: "WARN", + Type: "integrity", + Message: fmt.Sprintf("Drop table %q entry %d: 'level' is ignored on shared drop table entries; set it on the gather entry that references this table", id, i+1), + }) + } + if d.XP > 0 { + issues = append(issues, Issue{ + Level: "WARN", + Type: "integrity", + Message: fmt.Sprintf("Drop table %q entry %d: 'xp' is ignored on shared drop table entries; set it on the gather entry that references this table", id, i+1), + }) + } + if d.Tool != "" { + issues = append(issues, Issue{ + Level: "WARN", + Type: "integrity", + Message: fmt.Sprintf("Drop table %q entry %d: 'tool' is ignored on shared drop table entries; set it on the gather entry that references this table", id, i+1), + }) + } + if d.SuccessMessage != "" { + issues = append(issues, Issue{ + Level: "WARN", + Type: "integrity", + Message: fmt.Sprintf("Drop table %q entry %d: 'success_message' is ignored on shared drop table entries; set it on the gather entry that references this table", id, i+1), + }) + } } } -- cgit v1.2.3