Debug info to trace item group spawning #74906
Open
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
Interface "Debug info to trace item group spawning"
Purpose of change
It has often come up (e.g. #65450 ) that something mysteriously appears in a location which clearly shouldn't be there, but the provenance of the item is very difficult to trace. Normally the only way to do so is to check the mapgen for the tile it spawned on and go through every possibility. Item groups can contain other item groups which can contain others which... [etc] which means that you could be searching thousands of lines of json for one entry, jumping back and forth across files.
Describe the solution
Just (temporarily) store this information on the item.
When spawning a new group, pass the ID through the incredibly confusing item group spawning functions. Continue passing it through as it recurses, adding new context when new context is had. Then make the information available when debug mode is enabled.
Note that this information is not preserved across savegames, on purpose. Doing so would cause a lot of save bloat for no real gain. In cases where this is useful, debug functions can already be used to force suspects to spawn repeatedly until another incident is seen. This function just makes backtracking it much simpler.
Describe alternatives you've considered
馃し some sort of outside-cdda interactive GUI tool which expands item groups and searches through them, and also optionally works by recursing? Outside my skillset, really
Testing
The formatting is truly awful and I have grown tired of figuring out where to put the spaces.
Clang will probably yell about not passing strings by reference, will see what I have to do about that
Additional context