Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: erase items in area #4313

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading