Fix case where loadout_addItems loses magazines #3154
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.
What type of PR is this.
What have you changed and why?
loadout_addItems assumed that units have a backpack, and could dump large item batches into the void under certain conditions, for example if a batch fitted within uniform+vest but not in either individually. Could happen with marksman rifles, as 5x20rnd 7.62 mags is often too much for a vest, and marksmen don't use backpacks.
This PR fixes the problem by using the vest as the fallback container in the case where backpack max load is zero. This may mean that the vest is sometimes overfilled, but that's working as intended. It does the same with backpacks.
Please specify which Issue this PR Resolves.
closes #3153
Please verify the following and ensure all checks are completed.
Is further testing or are further changes required?
Probably needs a run with various templates to see if anything weirder than expected turns up.