From 42f669f4e39967bfd6a3a3ac4e413dfeca3c362c Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Mon, 29 Apr 2019 08:52:03 +0100 Subject: [PATCH 1/2] 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. --- tests/map_helpers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/map_helpers.cpp b/tests/map_helpers.cpp index cea8c4f715412..0c1efe9983417 100644 --- a/tests/map_helpers.cpp +++ b/tests/map_helpers.cpp @@ -35,7 +35,6 @@ void clear_creatures() { // Remove any interfering monsters. g->clear_zombies(); - g->unload_npcs(); } void clear_npcs() @@ -72,6 +71,7 @@ void clear_map() } wipe_map_terrain(); g->m.clear_traps(); + clear_npcs(); clear_creatures(); } From 9c4decef5a3d96c58938512b8f43883f33bcf57e Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Mon, 29 Apr 2019 21:33:25 +0100 Subject: [PATCH 2/2] 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 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/map_helpers.cpp b/tests/map_helpers.cpp index 0c1efe9983417..0f63be073e81d 100644 --- a/tests/map_helpers.cpp +++ b/tests/map_helpers.cpp @@ -39,6 +39,10 @@ void clear_creatures() 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() );