Expand blacklisting to all map item placement functions #40237
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: Infrastructure "Expand blacklisting to more item spawning"
Purpose of change
I was playing around with blacklisting all items, and, once I fixed the single crash (I'm impressed there was only one), I noticed that blacklisted items were still spawning in the world. Prevent these items from appearing.
Changes to
item_factory.cpp
:The game would crash on loading while trying to inline an empty list of requirements.
Changes to
map.cpp
:Things such as turrets firing weapons and taking down furniture could place items on that map that were blacklisted.
Describe the solution
item_factory.cpp
: Check that that list is not empty before attempting to do anything with it.map.cpp
: In the functions that did not already, make sure an item is not blacklisted before placing it.Testing
Using this mod blacklisting all items in the game: no_items.zip
Ran around in the world, had turrets shoot things, took down furniture, killed monsters - no items were spawned.
Ran the tests, and all test passed.
Additional context
There is some minor possibility for additional crashing here, by adding a new way this function can return a null item reference. There were already ways this function could return a null item reference, so anything where this would cause a crash could already be problematic.