fix(server): ignore disabled zero-count pack purchase rewards

This commit is contained in:
2026-10-04 14:59:58 +08:00
parent 013c4dcf1c
commit e1ec47bfae
2 changed files with 11 additions and 1 deletions
+6 -1
View File
@@ -111,7 +111,12 @@ func loadStoryCatalog(db *sql.DB) (*StoryCatalog, error) {
return nil, fmt.Errorf("gamedata: invalid story pack%d buy rewards", id)
}
for i, count := range counts {
if count == 0 || types[i] == 0 {
// PackTable may retain a disabled reward slot with a real type/ID
// and zero count. It contributes no granted reward.
if count == 0 {
continue
}
if types[i] == 0 || count > math.MaxInt32 || types[i] > math.MaxInt32 || ids[i] > math.MaxInt32 {
rows.Close()
return nil, fmt.Errorf("gamedata: invalid story pack%d buy reward", id)
}
@@ -26,6 +26,11 @@ func TestStoryCatalogEnumeratesSeparateChainsAndContentTicketRules(t *testing.T)
raw = wire.AppendVarint(raw, 8, 1)
raw = wire.AppendVarint(raw, 9, 100)
raw = wire.AppendVarint(raw, 10, 19)
// An official-shaped disabled costume slot must be equivalent
// to omitting that slot; type and ID remain populated.
raw = wire.AppendVarint(raw, 8, 0)
raw = wire.AppendVarint(raw, 9, 200)
raw = wire.AppendVarint(raw, 10, 11)
}
if _, err = db.Exec("INSERT INTO PackTable VALUES(?,?)", pack.id, raw); err != nil {
t.Fatal(err)