From 9b62400244384c6e2ccdb752e65a6a27a4f77896 Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Mon, 13 Apr 2020 09:02:13 -0400 Subject: [PATCH] Also clear items in clear_map Failing to do so could break the crafting tests because extra items might be available for crafting nearby, thus causing the crafting code to need to ask the player which one to use (which triggers UI code which aborts in test mode, since there's no UI). --- tests/map_helpers.cpp | 13 +++++++++++++ tests/map_helpers.h | 1 + 2 files changed, 14 insertions(+) diff --git a/tests/map_helpers.cpp b/tests/map_helpers.cpp index de32c7b69f571..70c5741ab0952 100644 --- a/tests/map_helpers.cpp +++ b/tests/map_helpers.cpp @@ -76,6 +76,16 @@ void clear_fields( const int zlevel ) } } +void clear_items( const int zlevel ) +{ + const int mapsize = g->m.getmapsize() * SEEX; + for( int x = 0; x < mapsize; ++x ) { + for( int y = 0; y < mapsize; ++y ) { + g->m.i_clear( { x, y, zlevel } ); + } + } +} + void clear_map() { // Clearing all z-levels is rather slow, so just clear the ones I know the @@ -87,6 +97,9 @@ void clear_map() clear_npcs(); clear_creatures(); g->m.clear_traps(); + for( int z = -2; z <= 0; ++z ) { + clear_items( z ); + } } void clear_map_and_put_player_underground() diff --git a/tests/map_helpers.h b/tests/map_helpers.h index e0b37ac3a016d..c5a94a1812d00 100644 --- a/tests/map_helpers.h +++ b/tests/map_helpers.h @@ -13,6 +13,7 @@ void wipe_map_terrain(); void clear_creatures(); void clear_npcs(); void clear_fields( int zlevel ); +void clear_items( int zlevel ); void clear_map(); void clear_map_and_put_player_underground(); monster &spawn_test_monster( const std::string &monster_type, const tripoint &start );