Item stacking mechanism wreaks havoc in shops
issueid=1047 05-15-2012 03:10 PM
Junior Member
Number of reported issues by aquavires: 17
Item stacking mechanism wreaks havoc in shops

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

  1. Create a new male troll barbarian -- it starts with 4IR
  2. Go to the Terinyo food shop, stand on an empty square
  3. Sell 4IR
  4. Pick up 4IR (unpaid)
  5. Go to a square with 1IR (unpaid), and pick it up
  6. ':d' all iron rations simultaneously: 4IR + 1IR
  7. Message buffer reads: "You drop an iron ration (p: 34gp). You drop 3 iron rations (p: 102gp)."
  8. ';' all iron rations simultaneously: 3IR + 1IR
  9. Message buffer reads: "You pick up an iron ration (p: 34gp). You pick up 2 iron rations (p: 68gp)."
  10. 'v'iew 'i'nventory: it shows 2IR + 2IR
  11. 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".
  1. Load cloned game
  2. Drop the bad stack (2IR)
  3. 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)
  1. Quit, load cloned game
  2. Eat from the bad stack 2 times. Satiation increases both times.
  3. 'v'iew 'i'nventory: One of the slots shows "0 iron rations (p: 0gp)"
  4. 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)
  1. Quit, load cloned game
  2. Eat from the bad stack 2 times. Inventory now has 0IR.
  3. Walk 1 square, 'v'iew inventory: 0IR is still there
  4. Walk 1 square, 'v'iew inventory: 0IR is gone
  5. 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).
  1. Go to another square with 1IR.
  2. ';' the iron ration: 1IR
  3. ':d' all iron rations simultaneously: 2IR + 1IR
  4. Message buffer reads: "You drop an iron ration (p: 34gp). You drop an iron ration (p: 34gp)."
  5. ';' all iron rations simultaneously: 1IR + 1IR
  6. 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.
  1. ';' 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)
Issue Details
Issue Number 1047
Project ADOM II (formerly known as JADE)
Category Gameplay
Status Fixed
Priority 1 - Highest
Affected Version ADOM II 0.2.6
Fixed Version ADOM II 0.2.7
Users able to reproduce bug 0
Users unable to reproduce bug 0
Assigned Users (none)
Tags (none)




05-15-2012 08:45 PM
The Creator
Execellent detailed analysis - thanks!
Fixed for ADOM II 0.2.7. Please send your real name to creator(at)ancientdomainsofmystery.com for it to be included in the credits. (If you were already asked to do so you can ignore this message. Please include a reference to the bug or RFE you are credited for.)

+ Reply