From 87d08f0151e643951769e323995f1c5ed89ee200 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Fri, 18 Sep 2026 01:50:17 -0400 Subject: fix: harden economy recovery, shutdown concurrency, world validation, and inventory-loss paths --- internal/casino/machine.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'internal/casino/machine.go') diff --git a/internal/casino/machine.go b/internal/casino/machine.go index 0f137ec..844c5e9 100644 --- a/internal/casino/machine.go +++ b/internal/casino/machine.go @@ -228,8 +228,12 @@ func (m *Machine) finishSpin() []Event { events := []Event{} result := m.spin.Payout + m.payoutRemainder // Checked conversion: a runaway profile or overflow must clamp at the - // economy cap instead of wrapping through a machine-sized int. - if result > MaxCredits || result != result || result < 0 { + // economy cap instead of wrapping through a machine-sized int. A NaN or + // negative result is a corrupt computation, not a jackpot: clamp it to + // zero (fail closed) rather than up to the economy ceiling (fail open). + if math.IsNaN(result) || result < 0 { + result = 0 + } else if result > MaxCredits { result = MaxCredits } credits := int(math.Floor(result)) -- cgit v1.2.3