Skip to content

Commit

Permalink
Expand blacklisting items to all map item placing
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
anothersimulacrum committed May 6, 2020
1 parent 6d54a55 commit a8765aa
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4128,6 +4128,10 @@ item &map::add_item_or_charges( const tripoint &pos, item obj, bool overflow )
return add_item( tile, obj );
};

if( item_is_blacklisted( obj.typeId() ) ) {
return null_item_reference();
}

// Some items never exist on map as a discrete item (must be contained by another item)
if( obj.has_flag( "NO_DROP" ) ) {
return null_item_reference();
Expand Down Expand Up @@ -4186,6 +4190,10 @@ item &map::add_item_or_charges( const tripoint &pos, item obj, bool overflow )

item &map::add_item( const tripoint &p, item new_item )
{
if( item_is_blacklisted( new_item.typeId() ) ) {
return null_item_reference();
}

if( !inbounds( p ) ) {
return null_item_reference();
}
Expand Down

0 comments on commit a8765aa

Please sign in to comment.