Fix shadowing bug in rules engine.

This commit is contained in:
Kistaro Windrider 2023-04-02 19:36:28 -07:00
parent d13e04e2f4
commit 2c2e68ff93
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -141,7 +141,7 @@ func (r *RuleCollection[C]) performInsert(k *keyedRule[C]) {
r.rules[k.id] = k r.rules[k.id] = k
s := r.byStep[k.Step()] s := r.byStep[k.Step()]
if s == nil { if len(s) == 0 {
r.steps = nil r.steps = nil
} }
s = append(s, k.id) s = append(s, k.id)
@ -326,7 +326,7 @@ func (r *RuleCollection[C]) Run(p *Player[C]) error {
steps := r.steps steps := r.steps
if steps == nil { if steps == nil {
// Step set changed, recalculate. // Step set changed, recalculate.
steps := make([]int, 0, len(r.byStep)) steps = make([]int, 0, len(r.byStep))
for step := range r.byStep { for step := range r.byStep {
steps = append(steps, step) steps = append(steps, step)
} }