This was first reported in the discussion under
Issue 988. I've played around with the quirks some more, so I'm collating the results in a new ticket.
CONCLUSION: When simultaneously picking up or dropping multiple stacks of unpaid items of the same type, the game's counting of the items is off by 1. This is demonstrated by the systematic shrinking of my original stack of 4 iron rations, whenever picked-up/dropped together with another iron ration stack. When the stack shrunk to 1, one last drop culminated in the dreaded "Failed to remove item" error. Fixing the item-counting mechanism should end our woes.
Here's a summary of error messages reproducible in the shop:
Code:
de.adom.jade.JadeError: Trying to drop a destroyed item: 2 iron rations (p: 68gp)
java.lang.ArithmeticException: / by zero
de.adom.jade.JadeError: Trying to add an item (0 iron rations (p: 0gp)) with an illegal item count: 0.
de.adom.jade.JadeError: Failed to remove item 'de.adom.jade.items.list.food.IronRation@10c9d6/iron ration (p: 34gp)' from the item list 'de.adom.jade.items.MutableItemList@1d40eda' because it could not be found.
Terminology in this report:
- 4IR: 1 inventory slot containing 4 iron rations
- 1IR + 1IR: 2 inventory slots, containing 1 iron ration each
- Create a new male troll barbarian -- it starts with 4IR
- Go to the Terinyo food shop, stand on an empty square
- Sell 4IR
- Pick up 4IR (unpaid)
- Go to a square with 1IR (unpaid), and pick it up
- ':d' all iron rations simultaneously: 4IR + 1IR
- Message buffer reads: "You drop an iron ration (p: 34gp). You drop 3 iron rations (p: 102gp)."
- ';' all iron rations simultaneously: 3IR + 1IR
- Message buffer reads: "You pick up an iron ration (p: 34gp). You pick up 2 iron rations (p: 68gp)."
- 'v'iew 'i'nventory: it shows 2IR + 2IR
- Save and clone game
At this point, 1 of the stacks (2IR) behaves properly, but the other (also 2IR) is bugged. Call this the "bad stack".
- Load cloned game
- Drop the bad stack (2IR)
- Error triggers:
Code:
de.adom.jade.JadeError: Trying to drop a destroyed item: 2 iron rations (p: 68gp)
at de.adom.jade.beings.Being.dropItem(SourceFile:5450)
at de.adom.jade.beings.brains.PCBrain.dropItems(SourceFile:551)
at de.adom.jade.beings.Being.doDrop(SourceFile:5429)
at de.adom.jade.ui.commands.CommandDrop.executeImpl(SourceFile:62)
at de.adom.jade.ui.commands.Command.execute(SourceFile:621)
at de.adom.jade.beings.brains.PCBrain.doActImpl(SourceFile:154)
at de.adom.jade.beings.brains.AbstractBrain.doAct(SourceFile:400)
at de.adom.jade.beings.Being.actImpl(SourceFile:830)
at de.adom.jade.kernel.actors.AbstractActor.act(SourceFile:58)
at de.adom.jade.kernel.actors.ActorReference.act(SourceFile:60)
at de.adom.jade.kernel.GameLoop.run(SourceFile:141)
- Quit, load cloned game
- Eat from the bad stack 2 times. Satiation increases both times.
- 'v'iew 'i'nventory: One of the slots shows "0 iron rations (p: 0gp)"
- Eat the 0IR. Satiation increases. Error triggers:
Code:
java.lang.ArithmeticException: / by zero
at de.adom.jade.beings.list.Shopkeeper.noticesItemConsumption(SourceFile:1304)
at de.adom.jade.items.AbstractItem.consume(SourceFile:1401)
at de.adom.jade.items.AbstractItem.consumeOneInstance(SourceFile:1374)
at de.adom.jade.items.list.AbstractFood.eat(SourceFile:144)
at de.adom.jade.ui.commands.CommandEat.executeImpl(SourceFile:68)
at de.adom.jade.ui.commands.Command.execute(SourceFile:621)
at de.adom.jade.beings.brains.PCBrain.doActImpl(SourceFile:154)
at de.adom.jade.beings.brains.AbstractBrain.doAct(SourceFile:400)
at de.adom.jade.beings.Being.actImpl(SourceFile:830)
at de.adom.jade.kernel.actors.AbstractActor.act(SourceFile:58)
at de.adom.jade.kernel.actors.ActorReference.act(SourceFile:60)
at de.adom.jade.kernel.GameLoop.run(SourceFile:141)
- Quit, load cloned game
- Eat from the bad stack 2 times. Inventory now has 0IR.
- Walk 1 square, 'v'iew inventory: 0IR is still there
- Walk 1 square, 'v'iew inventory: 0IR is gone
- Walk around several more squares. Error triggers (possibly from walking over food?):
Code:
de.adom.jade.JadeError: Trying to add an item (0 iron rations (p: 0gp)) with an illegal item count: 0.
at de.adom.jade.items.MutableItemList.addItem(SourceFile:130)
at de.adom.jade.items.MutableItemList.recombineListRequiredFor(SourceFile:610)
at de.adom.jade.beings.brains.PCBrain.doActImpl(SourceFile:135)
at de.adom.jade.beings.brains.AbstractBrain.doAct(SourceFile:400)
at de.adom.jade.beings.Being.actImpl(SourceFile:830)
at de.adom.jade.kernel.actors.AbstractActor.act(SourceFile:58)
at de.adom.jade.kernel.actors.ActorReference.act(SourceFile:60)
at de.adom.jade.kernel.GameLoop.run(SourceFile:141)
At this point, and I have 2IR in my inventory (the "good stack" from before -- eating this does not leave 0IR).
- Go to another square with 1IR.
- ';' the iron ration: 1IR
- ':d' all iron rations simultaneously: 2IR + 1IR
- Message buffer reads: "You drop an iron ration (p: 34gp). You drop an iron ration (p: 34gp)."
- ';' all iron rations simultaneously: 1IR + 1IR
- Message buffer reads: "You pick up an iron ration (p: 34gp)." Error triggers:
Code:
de.adom.jade.JadeError: Failed to remove item 'de.adom.jade.items.list.food.IronRation@10c9d6/iron ration (p: 34gp)' from the item list 'de.adom.jade.items.MutableItemList@1d40eda' because it could not be found.
at de.adom.jade.items.MutableItemList.remove(SourceFile:266)
at de.adom.jade.world.complexes.locations.maps.LocationMap.removeItemAt(SourceFile:2259)
at de.adom.jade.beings.brains.PCBrain.pickupItemsImpl(SourceFile:626)
at de.adom.jade.beings.brains.AbstractBrain.pickupItems(SourceFile:485)
at de.adom.jade.beings.Being.doPickup(SourceFile:5274)
at de.adom.jade.ui.commands.c.executeImpl(SourceFile:50)
at de.adom.jade.ui.commands.Command.execute(SourceFile:621)
at de.adom.jade.beings.brains.PCBrain.doActImpl(SourceFile:154)
at de.adom.jade.beings.brains.AbstractBrain.doAct(SourceFile:400)
at de.adom.jade.beings.Being.actImpl(SourceFile:830)
at de.adom.jade.kernel.actors.AbstractActor.act(SourceFile:58)
at de.adom.jade.kernel.actors.ActorReference.act(SourceFile:60)
at de.adom.jade.kernel.GameLoop.run(SourceFile:141)
The floor now has 2IR, and there's no iron ration in my inventory.
- ';' the iron ration stack: 2IR. Error triggers:
Code:
de.adom.jade.JadeError: Trying to pick up a destroyed item: 2 iron rations (p: 68gp)
at de.adom.jade.beings.brains.AbstractBrain.pickupItems(SourceFile:473)
at de.adom.jade.beings.Being.doPickup(SourceFile:5274)
at de.adom.jade.ui.commands.c.executeImpl(SourceFile:50)
at de.adom.jade.ui.commands.Command.execute(SourceFile:621)
at de.adom.jade.beings.brains.PCBrain.doActImpl(SourceFile:154)
at de.adom.jade.beings.brains.AbstractBrain.doAct(SourceFile:400)
at de.adom.jade.beings.Being.actImpl(SourceFile:830)
at de.adom.jade.kernel.actors.AbstractActor.act(SourceFile:58)
at de.adom.jade.kernel.actors.ActorReference.act(SourceFile:60)
at de.adom.jade.kernel.GameLoop.run(SourceFile:141)