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: None
Purpose of change
Fixes #39043
We've had a very intermittent error for who knows how long when matchbooks are spawned.
It turns out this happens when an item_group has a non-zero with_ammo field and a child item modifier of it is a tool with default charges and a null ammo type.
Describe the solution
The issue turns out to be a mismatch between null strings produced by item::default_ammo() and expected by item::ammo_set().
Describe alternatives you've considered
A more complete fix to this would be to make itype_id or possibly just the ammo string a formal type instead of using std::string, but that's a pretty huge change I don't have the stomach to tackle right now.
A slightly more complete fix that I might consider soon is auditing the uses of "null" vs "NULL" in the item code and data to eliminate errors of this kind, but we need to be careful because remaining mismatches can cause further errors.
Testing
The recently added mx_minefield test was triggering this fairly frequently by simply generating a map extra that contained an affected item group. I was able to isolate the cause and add a unit test for it.