Skip to content

Commit

Permalink
feat: erase items in area (#4313)
Browse files Browse the repository at this point in the history
  • Loading branch information
scarf005 authored Mar 8, 2024
1 parent 5fdfd73 commit 2f32b55
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/debug_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -297,6 +298,7 @@ static int map_uilist()
const std::vector<uilist_entry> 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" ) ) },
Expand Down Expand Up @@ -1530,6 +1532,23 @@ void debug()
}
}
break;
case DEBUG_ERASE_ITEMS_AREA: {
const std::optional<tripoint_range<tripoint>> points_opt = select_area();
if( !points_opt.has_value() ) {
break;
}

const tripoint_range<tripoint> 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<tripoint_range<tripoint>> points_opt = select_area();
if( !points_opt.has_value() ) {
Expand Down

0 comments on commit 2f32b55

Please sign in to comment.