Skip to content

Commit

Permalink
Also clear items in clear_map
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
jbytheway committed Apr 13, 2020
1 parent 091e0a4 commit 9b62400
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/map_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
1 change: 1 addition & 0 deletions tests/map_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit 9b62400

Please sign in to comment.