From 5b1084872ade64889e23d159c8c8e52a5ab63ac3 Mon Sep 17 00:00:00 2001 From: Zlorthishen <79779913+Zlorthishen@users.noreply.github.com> Date: Sat, 27 Jan 2024 12:41:58 -0600 Subject: [PATCH] fix(dialogue conditions): `at_om_location` handling directional OMTs Co-authored-by: Mark Langsdorf --- src/condition.cpp | 5 ++--- tests/npc_talk_test.cpp | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/condition.cpp b/src/condition.cpp index 092912f20d7d..4ad18b387002 100644 --- a/src/condition.cpp +++ b/src/condition.cpp @@ -392,20 +392,19 @@ void conditional_t::set_at_om_location( const JsonObject &jo, const std::stri } const tripoint_abs_omt omt_pos = actor->global_omt_location(); const oter_id &omt_ref = overmap_buffer.ter( omt_pos ); + const std::string &omt_str = omt_ref.id().c_str(); if( location == "FACTION_CAMP_ANY" ) { std::optional bcp = overmap_buffer.find_camp( omt_pos.xy() ); if( bcp ) { return true; } - // legacy check - const std::string &omt_str = omt_ref.id().c_str(); return omt_str.find( "faction_base_camp" ) != std::string::npos; } else if( location == "FACTION_CAMP_START" ) { return !recipe_group::get_recipes_by_id( "all_faction_base_types", omt_ref.id().c_str() ).empty(); } else { - return omt_ref == oter_id( oter_no_dir( oter_id( location ) ) ); + return oter_no_dir( omt_ref ) == location; } }; } diff --git a/tests/npc_talk_test.cpp b/tests/npc_talk_test.cpp index f0ef5860d133..0f629ce8e3eb 100644 --- a/tests/npc_talk_test.cpp +++ b/tests/npc_talk_test.cpp @@ -306,6 +306,10 @@ TEST_CASE( "npc_talk_location", "[npc_talk]" ) gen_response_lines( d, 2 ); CHECK( d.responses[0].text == "This is a basic test response." ); CHECK( d.responses[1].text == "This is a faction camp any test response." ); + change_om_type( "evac_center_7_west" ); + gen_response_lines( d, 2 ); + CHECK( d.responses[0].text == "This is a basic test response." ); + CHECK( d.responses[1].text == "This is a om_location_field direction variant response." ); } TEST_CASE( "npc_talk_role", "[npc_talk]" )