Since many people have been wondering about this bug and why it took us so long to address it, here's a quick post-mortem, which I also
posted on Reddit when we released this as a hotfix 2 weeks ago.
- The bug was relatively rare and our testers were unable to reproduce it altogether
- When it happened to a base and we checked that same base we couldn't reproduce it there either
- I went over the tool cupboard code about 5 times and did not find anything wrong with it
The thing that finally gave us a lead was that Alistair noticed that sometimes when repairing an item in his base he could briefly see the base decay message pop up when he interacted with the tool cupboard immediately afterward. When reproducing this in the editor I could also sometimes see resources that should not be there pop up in the upkeep cost overview for a brief moment, which was no the case in the standalone build. The same weekend we received a video of a clan reproducing it by repairing an item with the repair bench in their base. (Thanks, Mellie!).
So after going over the repair bench code, I noticed that it was getting an "item amount" list from our memory pool and then returned it with the "free" method instead of the "free list" method. This caused the list in the memory pool to still contain the costs of the last item repair. The tool cupboard was also getting an "item amount" list from our memory pool, and if that happened to be the same list that had previously been used to calculate the repair costs of an item then those costs were added to the next upkeep payment. This affected all resources that were used for repairs, but it was only really noticeable for high-quality metal as repairing a weapon costs a lot of high-quality metal relative to the amounts you usually need for base upkeep.
To prevent this problem in the future we will make it so the "free" method will throw an error when it is called with a list. The code that caused the issue has not been changed in a long time, so it wasn't on our radar as the cause of the issue at all until Alistair noticed the first signs of the pattern. We're sorry it took us this long to track this down, but I hope you can understand why it wasn't an easy problem to debug.