discount loaded ammo from smoking rack even when not allowing removal #76500
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
None
Purpose of change
Address one issue related to #59189, i.e. charcoal kiln reloading reloads max capacity even when partially filled.
Not sure if it does address the whole issue.
Describe the solution
Move the code for detecting existing contents out of the remove allowed only section so the existing contents is actually discounted when refilling the furniture.
The operation changed has a parameter specifying whether contents can be removed in the operation or not, and it cannot be removed in this call chain. There is another call chain where removal is permitted, though. There's no need for removal within the loading in this call chain, as there's a separate removal choice in the menu invoking the operation.
Describe alternatives you've considered
The code is weird in that it allows for multiple types of "ammo", but only carries a single pointer out of the loop. The check further down complaining about mixing ammo seems to indicate you're only supposed to have a single type of ammo at a time in furniture (e.g. either coal or charcoal, but not a bit of both). Thus, the moved code doesn't add up different kinds of ammo (it didn't for the remove permitted case either). The option would be to somehow permit a mixture of ammo, but that seems to be an expansion of functionality out of scope and with the potential of bringing in new worm cans.
Testing
Additional context
I have made no attempt to check whether the error message about overloaded racks goes away when you no longer can overload racks (and have emptied and optionally reloaded ones already overloaded, of course), but expect that to be the case.