Skip to content

Commit

Permalink
Added check for items overflow: there is a path to destination.
Browse files Browse the repository at this point in the history
  • Loading branch information
ipcyborg committed Sep 27, 2019
1 parent 28028a5 commit 38f3bc2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4327,12 +4327,19 @@ item &map::add_item_or_charges( const tripoint &pos, item obj, bool overflow )

} else if( overflow ) {
// ...otherwise try to overflow to adjacent tiles (if permitted)
auto tiles = closest_tripoints_first( 2, pos );
const int max_dist = 2;
auto tiles = closest_tripoints_first( max_dist, pos );
tiles.erase( tiles.begin() ); // we already tried this position
for( const auto &e : tiles ) {
const int max_path_length = 4 * max_dist;
const pathfinding_settings setting( 0, max_dist, max_path_length, 0, false, true, false, false );
for( const tripoint &e : tiles ) {
if( !inbounds( e ) ) {
continue;
}
//must be a path to the target tile
if( g->m.route( pos, e, setting ).empty() ) {
continue;
}
if( obj.made_of( LIQUID ) || !obj.has_flag( "DROP_ACTION_ONLY_IF_LIQUID" ) ) {
if( obj.on_drop( e, *this ) ) {
return null_item_reference();
Expand Down

0 comments on commit 38f3bc2

Please sign in to comment.