Update first pass component selection to avoid poison #70824
Closed
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 the component selection half of #70796 (but not the UI display part for component selection).
Describe the solution
Extend the restriction for first pass item selection to exclude known poisonous and hallucinogenic items in addition to the previous exclusion of containers containing items.
As a side effect the odd case where a separate filter was used (because it was used together with a supplied filter) had its first pass filter use a common operation to remove code duplication.
The code ended up no longer being inlined as the addition relied on flags that weren't in the set of files copied into the header (and the compiler complained about mismatching definitions elsewhere when it was done).
Describe alternatives you've considered
Testing
Not Tested Should Work...
I was unable to figure out how to (if possible) spawn mushrooms (or any other item that comes in random poisonous and/or hallucinogenic variants) the were affected. Manipulating flags only seems to do that, i.e. allow the removal of flags, but not actually set that it was poisonous. Adding the hidden flag would not help testing even if it would work, as the test shouldn't exclude poison you don't know about.
Ended up with a simple regression test of ordering the base camp expansion construction of two stoves where two tanks were placed one each of the two storage zone tiles, with one being empty and one containing a liquid, and verifying the two liquid containing tanks remained and the empty ones were consumed.
Additional context
As it's not tested, it would be appreciated if the logic was double checked.
I'd appreciate if someone could explain how to (and if) you can spawn poisonous and hallucinogenic shrooms, as well as ones that are but that fact is hidden to the player for testing purposes.
I realize foraging enough should eventually result in known shrooms and/or may apples of the two known categories, but that's a fair bit of work that still wouldn't cover the hidden poison/hallucinogen case.
Spawning shrooms one at a time 20 times resulted in 20 shrooms in a stack when dropped, indicating none of them would be poisonous or hallucinogenic (and the "examine" description didn't say they were). The normal foraging code seems to give poison a 1 in 10 chance of appearing, so that sample ought to have cause some poisonous or hallucinogenic case if debug spawning used the same logic.