Skip to content

Commit

Permalink
Use clear_npcs in clear_map (#30051)
Browse files Browse the repository at this point in the history
* Use clear_npcs in clear_map

clear_map had a similar flaw to the one fixed in #30031 affecting
npc_can_target_player.  Fix it in the same way.

This wasn't obviously affecting any tests, but it makes sense to fix it
pre-emptively.

* Before killing npcs, ensure correct ones loaded

Some tests
(default_overmap_generation_has_non_mandatory_specials_at_origin)
overwrite overmaps, which leads to orphaned NPCs.  Unloading and
reloading the NPCs ensures that all the active NPCs are known to the
overmap.
  • Loading branch information
jbytheway authored and kevingranade committed Apr 30, 2019
1 parent 7c4147f commit 79448f9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tests/map_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ void clear_creatures()
{
// Remove any interfering monsters.
g->clear_zombies();
g->unload_npcs();
}

void clear_npcs()
{
// Unload and reaload to ensure that all active NPCs are in the
// overmap_buffer.
g->unload_npcs();
g->load_npcs();
for( npc &n : g->all_npcs() ) {
n.die( nullptr );
overmap_buffer.remove_npc( n.getID() );
Expand Down Expand Up @@ -72,6 +75,7 @@ void clear_map()
}
wipe_map_terrain();
g->m.clear_traps();
clear_npcs();
clear_creatures();
}

Expand Down

0 comments on commit 79448f9

Please sign in to comment.