Skip to content

Commit

Permalink
Speedup move test (#36664)
Browse files Browse the repository at this point in the history
* Don't excessively clear map

* shift player and chasing monster positions instead of shifting map
  • Loading branch information
kevingranade authored and ZhilkinSerg committed Jan 4, 2020
1 parent 235601a commit c47e299
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions tests/monster_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ using move_statistics = statistics<int>;
static int moves_to_destination( const std::string &monster_type,
const tripoint &start, const tripoint &end )
{
clear_map();
clear_creatures();
REQUIRE( g->num_creatures() == 1 ); // the player
monster &test_monster = spawn_test_monster( monster_type, start );
// Get it riled up and give it a goal.
Expand Down Expand Up @@ -91,7 +91,8 @@ static int can_catch_player( const std::string &monster_type, const tripoint &di
std::list<item> temp;
while( test_player.takeoff( test_player.i_at( -2 ), &temp ) );

test_player.setpos( { 65, 65, 0 } );
const tripoint center{ 65, 65, 0 };
test_player.setpos( center );
test_player.set_moves( 0 );
// Give the player a head start.
const tripoint monster_start = { -10 * direction_of_flight + test_player.pos()
Expand All @@ -114,15 +115,9 @@ static int can_catch_player( const std::string &monster_type, const tripoint &di
test_player.pos().y < SEEY * int( MAPSIZE / 2 ) ||
test_player.pos().x >= SEEX * ( 1 + int( MAPSIZE / 2 ) ) ||
test_player.pos().y >= SEEY * ( 1 + int( MAPSIZE / 2 ) ) ) {
g->update_map( test_player );
wipe_map_terrain();
clear_npcs();
for( monster &critter : g->all_monsters() ) {
if( &critter != &test_monster ) {
g->remove_zombie( critter );
}
}
g->m.clear_traps();
tripoint offset = center - test_player.pos();
test_player.setpos( center );
test_monster.setpos( test_monster.pos() + offset );
// Verify that only the player and one monster are present.
REQUIRE( g->num_creatures() == 2 );
}
Expand Down Expand Up @@ -155,7 +150,6 @@ static int can_catch_player( const std::string &monster_type, const tripoint &di
}
}
WARN( tracker );
clear_map();
return -1000;
}

Expand Down

0 comments on commit c47e299

Please sign in to comment.