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/game/cmd_trigger_enchant.go | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'internal/game/cmd_trigger_enchant.go') diff --git a/internal/game/cmd_trigger_enchant.go b/internal/game/cmd_trigger_enchant.go index 62a3c48..02c9755 100644 --- a/internal/game/cmd_trigger_enchant.go +++ b/internal/game/cmd_trigger_enchant.go @@ -72,23 +72,22 @@ func (g *Game) triggerChipBolts(sess *net.Session, p *player.Player, mod *ModDef return } + outputDef, _ := g.ItemStore.Load(chip.Output) + // Verify the output can be placed BEFORE consuming the bolts: never + // consume inputs into an inventory with nowhere to put the result. + if !craftOutputFits(p, chip.Output, outputDef) { + sess.WriteLine("Your inventory is too full!") + return + } + if p.Action != nil { g.cancelAction(p) } p.RemoveItem(chip.Input, chip.Qty) - placed := false - for i := 0; i < 28; i++ { - slot := p.InvSlot(i) - if slot != nil && slot.ItemID == chip.Output { - slot.Quantity += chip.Qty - placed = true - break - } - } - if !placed { - freeSlot := p.FirstFreeSlot() - p.SetInvSlot(freeSlot, &player.InventorySlot{ItemID: chip.Output, Quantity: chip.Qty}) + if !placeCraftOutput(p, chip.Output, outputDef, chip.Qty) { + sess.WriteLine("Your inventory is too full!") + return } g.triggerModReward(sess, p, mod, 1.0) -- cgit v1.2.3