From 91dedd4c46d4a2cd7267178fddb3958965b25848 Mon Sep 17 00:00:00 2001 From: scarf Date: Fri, 8 Mar 2024 15:40:23 +0900 Subject: [PATCH] feat: erase items in area --- src/debug_menu.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/debug_menu.cpp b/src/debug_menu.cpp index a61ae56d20f6..f0044fcd8da9 100644 --- a/src/debug_menu.cpp +++ b/src/debug_menu.cpp @@ -129,6 +129,7 @@ enum debug_menu_index { DEBUG_SPAWN_MON, DEBUG_GAME_STATE, DEBUG_REPRODUCE_AREA, + DEBUG_ERASE_ITEMS_AREA, DEBUG_KILL_AREA, DEBUG_KILL_NPCS, DEBUG_MUTATE, @@ -297,6 +298,7 @@ static int map_uilist() const std::vector uilist_initializer = { { uilist_entry( DEBUG_REVEAL_MAP, true, 'r', _( "Reveal map" ) ) }, { uilist_entry( DEBUG_REPRODUCE_AREA, true, 'R', _( "Reproduce in Area" ) ) }, + { uilist_entry( DEBUG_ERASE_ITEMS_AREA, true, 'e', _( "Erase items in Area" ) ) }, { uilist_entry( DEBUG_KILL_AREA, true, 'a', _( "Kill in Area" ) ) }, { uilist_entry( DEBUG_KILL_NPCS, true, 'k', _( "Kill NPCs" ) ) }, { uilist_entry( DEBUG_MAP_EDITOR, true, 'M', _( "Map editor" ) ) }, @@ -1530,6 +1532,23 @@ void debug() } } break; + case DEBUG_ERASE_ITEMS_AREA: { + const std::optional> points_opt = select_area(); + if( !points_opt.has_value() ) { + break; + } + + const tripoint_range points = points_opt.value(); + + const int count = std::accumulate( points.begin(), points.end(), 0, + [&m]( int sum, const tripoint & p ) { + const int size = m.i_at( p ).size(); + m.i_clear( p ); + return sum + size; + } ); + add_msg( m_good, string_format( _( "Erased %d items." ), count ) ); + } + break; case DEBUG_KILL_AREA: { const std::optional> points_opt = select_area(); if( !points_opt.has_value() ) {