diff --git a/.clang-tidy b/.clang-tidy index f5ccc3fef40fb..de79d44bc055c 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -21,7 +21,6 @@ readability-*,\ -bugprone-misplaced-widening-cast,\ -bugprone-narrowing-conversions,\ -bugprone-unused-return-value,\ --bugprone-use-after-move,\ -cert-err34-c,\ -cert-flp30-c,\ -cert-msc30-c,\ diff --git a/src/ranged.cpp b/src/ranged.cpp index 8148813709bbe..af2bb9a223dbc 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -683,10 +683,15 @@ dealt_projectile_attack player::throw_item( const tripoint &target, const item & proj_effects.insert( "TANGLE" ); } + Creature *critter = g->critter_at( target, true ); + const dispersion_sources dispersion = throwing_dispersion( thrown, critter, + blind_throw_from_pos.has_value() ); + const itype *thrown_type = thrown.type; + // Put the item into the projectile proj.set_drop( std::move( thrown ) ); - if( thrown.has_flag( "CUSTOM_EXPLOSION" ) ) { - proj.set_custom_explosion( thrown.type->explosion ); + if( thrown_type->item_tags.count( "CUSTOM_EXPLOSION" ) ) { + proj.set_custom_explosion( thrown_type->explosion ); } // Throw from the player's position, unless we're blind throwing, in which case @@ -703,9 +708,6 @@ dealt_projectile_attack player::throw_item( const tripoint &target, const item & // This should generally have values below ~20*sqrt(skill_lvl) const float final_xp_mult = range_factor * damage_factor; - Creature *critter = g->critter_at( target, true ); - const dispersion_sources dispersion = throwing_dispersion( thrown, critter, - blind_throw_from_pos.has_value() ); auto dealt_attack = projectile_attack( proj, throw_from, target, dispersion, this ); const double missed_by = dealt_attack.missed_by; diff --git a/tests/colony_test.cpp b/tests/colony_test.cpp index 403270bde9ec5..e2ae8f0f6ad5a 100644 --- a/tests/colony_test.cpp +++ b/tests/colony_test.cpp @@ -217,6 +217,7 @@ TEST_CASE( "colony basics", "[colony]" ) // Move test CHECK( test_colony_2.size() == 400 ); + // NOLINTNEXTLINE(bugprone-use-after-move) test_colony.insert( &ten ); // Insert to post-moved-colony test diff --git a/tests/list_test.cpp b/tests/list_test.cpp index 08b1098245b23..3dad8946b1850 100644 --- a/tests/list_test.cpp +++ b/tests/list_test.cpp @@ -234,6 +234,7 @@ TEST_CASE( "list basics", "[list]" ) SECTION( "swap() and max_size()" ) { cata::list test_list_2; + // NOLINTNEXTLINE(bugprone-use-after-move) test_list_2 = test_list; CHECK( test_list_2.size() == 400 ); @@ -951,6 +952,7 @@ TEST_CASE( "list emplace, move, copy, and reverse iterate", "[list]" ) } CHECK( passed ); + // NOLINTNEXTLINE(bugprone-use-after-move) CHECK( test_list.empty() ); } @@ -974,6 +976,7 @@ TEST_CASE( "list emplace, move, copy, and reverse iterate", "[list]" ) } CHECK( passed ); + // NOLINTNEXTLINE(bugprone-use-after-move) CHECK( test_list_2.empty() ); } diff --git a/tests/string_formatter_test.cpp b/tests/string_formatter_test.cpp index b6216878a6454..a28438cf4f033 100644 --- a/tests/string_formatter_test.cpp +++ b/tests/string_formatter_test.cpp @@ -178,6 +178,7 @@ TEST_CASE( "string_formatter" ) const std::string expected = "b" + long_string + "b"; // moving into string_format should *not* consume the string. test_for_expected( expected, "b%sb", std::move( long_string ) ); + // NOLINTNEXTLINE(bugprone-use-after-move) CHECK( long_string.size() == 100000 ); }