From 9e963097c0963f8261564559aa5ae008b2ac8565 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Wed, 15 Jan 2025 14:39:15 +0000 Subject: [PATCH] Fix compile error, remove unneeded string initialisation, correct translation, don't write required mutation string if we're about to overwrite it with incompatible bionics --- src/character.cpp | 4 +--- src/iexamine.cpp | 45 +++++++++++++++++++++++---------------------- src/item.cpp | 3 +-- 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/character.cpp b/src/character.cpp index 8e68df53a1532..4e3799ef03c33 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -7649,9 +7649,7 @@ void Character::drench_mut_calc() weighted_int_list Character::get_vitamin_weighted_categories() const { weighted_int_list weighted_output; - const std::map &mutation_categories = - mutation_category_trait::get_all(); - for( const auto &elem : mutation_categories ) { + for( const auto &elem : mutation_category_trait::get_all() ) { add_msg_debug( debugmode::DF_MUTATION, "get_vitamin_weighted_categories: category %s weight %d", elem.second.id.c_str(), vitamin_get( elem.second.vitamin ) ); weighted_output.add( elem.first, vitamin_get( elem.second.vitamin ) ); diff --git a/src/iexamine.cpp b/src/iexamine.cpp index 314e11725520d..c68507134a9c7 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -484,6 +484,22 @@ void iexamine::genemill( Character &you, const tripoint_bub_ms & ) std::vector threshreq = mut.threshreq; bool c_has_threshreq = threshreq.empty() ? true : false; + //Bionic Incompatibility + std::vector bionics; + for( const bionic_id &bid : you.get_bionics() ) { + if( bid->mutation_conflicts.count( trait ) != 0 ) { + bionics.push_back( bid->name.translated() ); + } + } + if( !bionics.empty() ) { + context_string = string_format( " %s %s", _( "Conflicts with installed:" ), + string_join( bionics, ", " ) ); + can_select = false; + genemenu.addentry_col( i, can_select, input_event(), mut.name(), context_string ); + i++; + continue; + } + //Threshold requirement for( const trait_id &c : threshreq ) { if( you.has_permanent_trait( c ) ) { @@ -492,29 +508,14 @@ void iexamine::genemill( Character &you, const tripoint_bub_ms & ) } } if( !c_has_threshreq ) { - std::vector thresholds; - thresholds.reserve( threshreq.size() ); - for( const trait_id &c : threshreq ) { - thresholds.push_back( c->name() ); - } - context_string = ( _( " %s" ), string_join( thresholds, ", " ) ); - context_string = - string_format( " Requires either of the following traits: %s", - context_string ); - can_select = false; - } - - //Bionic Incompatibility - std::vector bionics; - for( const bionic_id &bid : you.get_bionics() ) { - if( bid->mutation_conflicts.count( trait ) != 0 ) { - bionics.push_back( bid->name.translated() ); + context_string = string_format( " %s ", + _( "Requires any of the following traits:" ) ); + for( size_t i = 0; i < threshreq.size() - 1; i++ ) { + context_string += threshreq[i]->name(); + context_string += ", "; } - } - if( !bionics.empty() ) { - context_string = string_join( bionics, ", " ); - context_string = string_format( " Conflicts with installed: %s", - context_string ); + context_string += threshreq[threshreq.size() - 1]->name(); + context_string += ""; can_select = false; } diff --git a/src/item.cpp b/src/item.cpp index 0ed3c2094a923..df3161d1f3800 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -370,8 +370,7 @@ item::item( const itype *type, time_point turn, int qty ) : type( type ), bday( } if( type->trait_group.is_valid() ) { - const trait_group::Trait_list &tlist = trait_group::traits_from( type->trait_group ); - for( const trait_and_var &tr : tlist ) { + for( const trait_and_var &tr : trait_group::traits_from( type->trait_group ) ) { template_traits.push_back( tr.trait ); } }