diff --git a/src/map.cpp b/src/map.cpp index 2ed3054360beb..30c10559c0fef 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2587,6 +2587,19 @@ bool map::has_nearby_fire( const tripoint &p, int radius ) return false; } +bool map::has_nearby_table( const tripoint &p, int radius ) +{ + for( const tripoint &pt : points_in_radius( p, radius ) ) { + const optional_vpart_position vp = veh_at( p ); + if( has_flag( "FLAT_SURF", pt ) ) { + return true; + } + if( vp && ( vp->vehicle().has_part( "KITCHEN" ) || vp->vehicle().has_part( "FLAT_SURF" ) ) ) { + return true; + } + } +} + bool map::mop_spills( const tripoint &p ) { bool retval = false; diff --git a/src/map.h b/src/map.h index afe4be392d29f..dd53486b1e3b7 100644 --- a/src/map.h +++ b/src/map.h @@ -681,6 +681,11 @@ class map // "fire" item to be used for example when crafting or when // a iuse function needs fire. bool has_nearby_fire( const tripoint &p, int radius = 1 ); + /** + * Check whether a table/workbench/vehicle kitchen or other flat + * surface is nearby that could be used for crafting or eating. + */ + bool has_nearby_table( const tripoint &p, int radius = 1 ); /** * Check if creature can see some items at p. Includes: * - check for items at this location (has_items(p))