Handle basecamp component selection cancellation #36740
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
SUMMARY: Bugfixes "Prevent exploit allowing cheaper basecamp actions"
Purpose of change
Various basecamp actions require components and tools to be consumed.
When there are choices to be made amongst these, the player is presented with the choice between the various options in the usual way.
However, if the player cancels, the action proceeded regardless. This allowed the player to circumvent the consumption of the requirements.
Describe the solution
Fix this by separating the selection of the components from the consumption. Now the order of events is:
We needed to perform the split because we need to select both the requirements and the NPC before performing alterations to either.
Implemented by introducing a new class
basecamp_action_components
to store this selection state.Describe alternatives you've considered
Thought about using the existing functions with a failure return value, but that would have required pulling the NPC off the mission after they had already been assigned, which is tricky at best.
Testing
Verified in-game that cancelled selections mean that the whole process is aborted, whereas previously the NPC was assigned and the components were partially consumed.
Additional context
Found this while working on #36657. This is a blocker for that.