From 79448f96b9ec5f0070809e99702f1a74dfaea1a4 Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Tue, 30 Apr 2019 04:11:24 +0100 Subject: [PATCH] Use clear_npcs in clear_map (#30051) * 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. --- tests/map_helpers.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/map_helpers.cpp b/tests/map_helpers.cpp index cea8c4f715412..0f63be073e81d 100644 --- a/tests/map_helpers.cpp +++ b/tests/map_helpers.cpp @@ -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() ); @@ -72,6 +75,7 @@ void clear_map() } wipe_map_terrain(); g->m.clear_traps(); + clear_npcs(); clear_creatures(); }