NO_UNLOAD containers cannot be unloaded, even if liquid #61759
Merged
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
Bugfixes "Containers with NO_UNLOAD cannot unload liquids"
Purpose of change
You could do things like dump pressurized liquid ammonia on the ground. This shouldn't be possible, and that's why NO_DROP exists - but while looking up WHY it was happening, I learned that liquids can always be removed from NO_UNLOAD containers.
Describe the solution
Don't return a check saying you can unload if there's a no unload flag! The flag check needs to be in the first return otherwise it short-circuits before it gets to checking for the flag.
Describe alternatives you've considered
I considered changing the order of the logic so no unload is always checked first, but I tried this solution first and it worked during testing, so...
Testing
Compiled locally and confirmed that this change prevented liquid ammonia from being removed from its pressure tank container. I also crafted with it and (after applying the fix for #59539) confirmed that crafting interactions worked as intended. I did not test with any other liquids.
Additional context
Ammonia was just a useful test item - it needs other PRs to address its ability to migrate outside of pressurized containers.
This changes some pretty old game logic so I won't be surprised if it breaks something. This definitely needs to pass all automated tests before merging, if nothing else.
There may be a much smarter way to code this. My C++ is still novice, at best.