I haven't found the reason yet; For the record he raided 4 or 5 alchemist shops before, transfering ingredients to his wagon halfway thru, so he must have lots of ingredients in both his inventory and wagon.
But I've found a much simpler case that's already troublesome; Steps to reproduce:
Having some stack of at least two identical ingredients in the inventory,
- open potion maker interface
- add the two items into the cauldron
- close the potion maker interface
- when adding the first ingredient, the stack is split by cloning, the stackCount of the original stack being decremented and the stackCount of the clone being one. The clone is put directly into the cauldron, so it''s neither in the ingredients nor, importantly, in player's inventory;
- when adding the second and last ingredient, the stack of one item is moved from ingredients to the cauldron;
- when the interface is Popped, ClearCauldron() is called, removing ingredients from the cauldron one by one, in the same order they have been put into the cauldron, so
- the clone is removed first. Since it's not in ingredients, it's put back there;
- the original stack is removed second. Since the same ingredient type is found in ingredients (the clone), the stackCount of the clone is incremented.
It can sort-of be fixed by clearing ingredients in reverse order, but since the player is free to add and remove items between ingredients and claudron, it's not fool proof.
That seems tricky to fix reliably...