Andrettin / Wyrmsun

Strategy game based on history, mythology and fiction
http://andrettin.github.io/
GNU General Public License v2.0
301 stars 47 forks source link

Negative amount of cheese/carrots available #74

Closed KroArtem closed 8 years ago

KroArtem commented 8 years ago

When I was already killed (no moving units, only buildings) I tried to produce cheese and carrots and it is possible to get negative values.

2016-02-20 03-09-13

Andrettin commented 8 years ago

Thanks for the report :)

The game checks whether there is enough stock when the command is given to buy the item, while it subtracts from the stock after the action of the building producing the item is finished. So this probably happened because of clicking the button very fast. And once the values went into the negative, the check didn't work properly anymore (it prevented from buying the item if the stock were equal to zero, so a negative stock would allow purchasing).

I've made it so the production of the item aborts if for some reason the building lacks the stock when actually producing it, and I've also improved the other check to prevent the item buying command to work if the stock is equal to or below zero.

https://github.com/Andrettin/Wyrmgus/commit/35d8fb0f39255b483f6e4ce7f62a0f49a88f4a5c