diff --git a/src/pixel_minimap.cpp b/src/pixel_minimap.cpp index c983bdc93dfd8..a469e3f4d9470 100644 --- a/src/pixel_minimap.cpp +++ b/src/pixel_minimap.cpp @@ -506,7 +506,8 @@ void pixel_minimap::render_critters( const tripoint ¢er ) mixture = lerp_clamped( 0, 100, std::max( s, 0.0f ) ); } - const level_cache &access_cache = get_map().access_cache( center.z ); + const map &m = get_map(); + const level_cache &access_cache = m.access_cache( center.z ); const point start( center.x - total_tiles_count.x / 2, center.y - total_tiles_count.y / 2 ); const point beacon_size = { @@ -518,6 +519,10 @@ void pixel_minimap::render_critters( const tripoint ¢er ) for( int y = 0; y < total_tiles_count.y; y++ ) { for( int x = 0; x < total_tiles_count.x; x++ ) { const tripoint p = start + tripoint( x, y, center.z ); + if( !m.inbounds( p ) ) { + // p might be out-of-bounds when peeking at submap boundary. Example: center=(64,59,-5), start=(4,-1) -> p=(4,-1,-5) + continue; + } const lit_level lighting = access_cache.visibility_cache[p.x][p.y]; if( lighting == lit_level::DARK || lighting == lit_level::BLANK ) {