fix(server): ignore disabled zero-count pack purchase rewards
This commit is contained in:
@@ -111,7 +111,12 @@ func loadStoryCatalog(db *sql.DB) (*StoryCatalog, error) {
|
|||||||
return nil, fmt.Errorf("gamedata: invalid story pack%d buy rewards", id)
|
return nil, fmt.Errorf("gamedata: invalid story pack%d buy rewards", id)
|
||||||
}
|
}
|
||||||
for i, count := range counts {
|
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()
|
rows.Close()
|
||||||
return nil, fmt.Errorf("gamedata: invalid story pack%d buy reward", id)
|
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, 8, 1)
|
||||||
raw = wire.AppendVarint(raw, 9, 100)
|
raw = wire.AppendVarint(raw, 9, 100)
|
||||||
raw = wire.AppendVarint(raw, 10, 19)
|
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 {
|
if _, err = db.Exec("INSERT INTO PackTable VALUES(?,?)", pack.id, raw); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
|||||||
Reference in New Issue
Block a user