Skip to content

Commit 2941508

Browse files
committed
Update npctalk.cpp
1 parent eb714c0 commit 2941508

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

src/npctalk.cpp

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3511,24 +3511,18 @@ talk_effect_fun_t::func f_add_trait( const JsonObject &jo, std::string_view memb
35113511

35123512
const auto &new_types = trait->types;
35133513

3514-
for( const trait_id &existing : guy->get_mutations() ) {
3515-
if( existing == trait ) {
3516-
continue;
3517-
}
3518-
const auto &existing_types = existing->types;
3519-
for( const std::string &t : existing_types ) {
3520-
bool match = false;
3521-
if constexpr( std::is_same<decltype( new_types ), const std::set<std::string> &>::value ) {
3522-
match = new_types.count( t ) > 0;
3523-
} else {
3524-
match = std::find( new_types.begin(), new_types.end(), t ) != new_types.end();
3525-
}
3526-
if( match ) {
3527-
guy->unset_mutation( existing );
3528-
break;
3529-
}
3514+
for( const std::string &t : existing_types ) {
3515+
bool match = false;
3516+
if constexpr( std::is_same_v<decltype( new_types ), const std::set<std::string> & > ) {
3517+
match = new_types.count( t ) > 0;
3518+
} else {
3519+
match = new_types.count( t ) > 0;
35303520
}
3531-
}
3521+
if( match ) {
3522+
guy->unset_mutation( existing );
3523+
break;
3524+
}
3525+
}
35323526

35333527
d.actor( is_npc )->set_mutation( trait, variant );
35343528
};

0 commit comments

Comments
 (0)