Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand blacklisting to all map item placement functions #40237

Merged
merged 2 commits into from
May 6, 2020

Conversation

anothersimulacrum
Copy link
Member

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.

When doing stupid things, such as blacklisting all items in the game,
the game would crash on loading trying to inline an empty list of
requirements. Check that that list is not empty before attempting to
do anything with it.
Things such as turrets firing weapons and taking down furniture could
place items on that map that were blacklisted. Make sure an item is not
blacklisted before placing it.

There is some minor possibility for 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.
@Night-Pryanik
Copy link
Contributor

This only affects spawning items, right?

@kevingranade kevingranade merged commit 03af8b2 into CleverRaven:master May 6, 2020
@anothersimulacrum
Copy link
Member Author

What do you mean? This effects all item placement. If you have say, casings blacklisted, and fire a gun, those casings will not be placed because they are blacklisted, where they would have been previously.

@anothersimulacrum anothersimulacrum deleted the exp-bl-1 branch May 6, 2020 14:30
@Night-Pryanik
Copy link
Contributor

Just wanted to know if it would fix showing blacklisted items in item info menu, like in #22294.

@anothersimulacrum
Copy link
Member Author

Oh, yeah, it doesn't fix that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants