Update first pass component selection to avoid poison #70826
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
None
Purpose of change
Fix #70796, i.e. select non poisonous/hallucinogenic food in preference of poisonous/hallucinogenic one where the same item exists in both variants, as well as indicate the need to use such undesirable items when there aren't enough of them by coloring the item line in magenta (same logic that's used for used water tight containers).
Note: This PR's purpose has been expanded from its first incarnation. The various edit notes have been removed and only the "final" content remains. This note is made to explain why things have changed, if anyone has looked at the PR previously.
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).
Changed the logic for component coloring to use the same kind of two pass process the component selection used, as that logic also had the side effect of determining whether components should be consumed from the personal inventory, environment inventory, or both. The changed process also made use of the same filter as the consumption used, rather than local defined ones. This added the effect handling poisonous/hallucinogenic food items.
Describe alternatives you've considered
Testing
In addition to the "formal" ones above, a lot of tests were made during the development of this PR, including ones using hallucinogenic mushrooms.
Additional context
As noted, I'm unable to test for usage of undetected poisonous shrooms, but I doubt there actually is such a thing beside the message shown when the shrooms are discovered. There's some Survival based code for whether to detect if shrooms are poisonous/hallucinogenic, but I failed to see any code to keep track of that on the item itself.
During the development and testing of this PR, #70846 was encountered. It was verified that bug existed prior to the start of the work on this PR.