diff --git a/src/bodygraph.cpp b/src/bodygraph.cpp index 5afe1a53af2e4..a696785b0759d 100644 --- a/src/bodygraph.cpp +++ b/src/bodygraph.cpp @@ -386,7 +386,7 @@ void bodygraph_display::draw_partlist() werase( w_partlist ); int y = 0; for( int i = top_part; y < all_height - 2 && i < static_cast( partlist.size() ); i++ ) { - const auto bgt = partlist[i]; + const auto &bgt = partlist[i]; std::string txt = !std::get<1>( bgt ) ? std::get<0>( bgt )->name.translated() : std::get<1>( bgt )->name.translated(); diff --git a/src/character.cpp b/src/character.cpp index 51d68f0b5a918..81529b3e238e1 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -9799,7 +9799,7 @@ Character::moncam_cache_t Character::get_active_moncams() const { moncam_cache_t ret; for( monster const &mon : g->all_monsters() ) { - for( std::pair const moncam : get_moncams() ) { + for( const std::pair &moncam : get_moncams() ) { if( mon.type->id == moncam.first && mon.friendly != 0 && rl_dist( get_avatar().get_location(), mon.get_location() ) < moncam.second ) { ret.insert( { &mon, mon.get_location() } ); diff --git a/src/game.cpp b/src/game.cpp index 01192b1e1c59f..ac8511cd87e33 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1723,7 +1723,7 @@ units::temperature_delta get_convection_temperature( const tripoint &location ) units::from_fahrenheit_delta( fd_fire->get_intensity_level().convection_temperature_mod ) : units::from_kelvin_delta( 0 ); // Modifier from fields - for( auto fd : here.field_at( location ) ) { + for( auto &fd : here.field_at( location ) ) { // Nullify lava modifier when there is open fire if( fd.first.obj().has_fire ) { lava_mod = units::from_kelvin_delta( 0 ); @@ -1955,7 +1955,7 @@ static hint_rating rate_action_eat( const avatar &you, const item &it ) if( rate.success() ) { best_rate = hint_rating::good; return VisitResponse::ABORT; - } else if( rate.value() != INEDIBLE || rate.value() != INEDIBLE_MUTATION ) { + } else if( rate.value() != INEDIBLE && rate.value() != INEDIBLE_MUTATION ) { best_rate = hint_rating::iffy; } } diff --git a/src/iexamine.cpp b/src/iexamine.cpp index 7c4a79bf7eec2..e94fe18e7a850 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -6164,7 +6164,7 @@ static void mill_activate( Character &you, const tripoint_bub_ms &examp ) } } - for( std::pair, int> mill_type_count : millable_counts ) { + for( const std::pair, int> &mill_type_count : millable_counts ) { item source( mill_type_count.first ); const item product( source.type->milling_data->into_ ); const recipe rec = *source.type->milling_data->recipe_; diff --git a/src/item.cpp b/src/item.cpp index ed36efdf96b81..6b5eb7bd8bf9f 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -8963,7 +8963,7 @@ int item::chip_resistance( bool worst, const bodypart_id &bp ) const } const int total = type->mat_portion_total == 0 ? 1 : type->mat_portion_total; - for( const std::pair mat : made_of() ) { + for( const std::pair &mat : made_of() ) { const int val = ( mat.first->chip_resist() * mat.second ) / total; res = worst ? std::min( res, val ) : std::max( res, val ); } @@ -10464,7 +10464,7 @@ const material_type &item::get_random_material() const std::vector matlist; const std::map &mats = made_of(); matlist.reserve( mats.size() ); - for( auto mat : mats ) { + for( const std::pair &mat : mats ) { matlist.emplace_back( mat.first ); } return *random_entry( matlist, material_id::NULL_ID() ); @@ -10475,7 +10475,7 @@ const material_type &item::get_base_material() const const std::map &mats = made_of(); const material_type *m = &material_id::NULL_ID().obj(); int portion = 0; - for( const std::pair mat : mats ) { + for( const std::pair &mat : mats ) { if( mat.second > portion ) { portion = mat.second; m = &mat.first.obj(); @@ -12070,7 +12070,7 @@ bool item::flammable( int threshold ) const int flammability = 0; units::volume volume_per_turn = 0_ml; - for( const std::pair m : mats ) { + for( const std::pair &m : mats ) { const mat_burn_data &bd = m.first->burn_data( 1 ); if( bd.immune ) { // Made to protect from fire diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 5a996d5f2060b..aa300e3a11693 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -1659,7 +1659,7 @@ void salvage_actor::cut_up( Character &p, item_location &cut ) const std::map salvage; std::map mat_to_weight; std::set mat_set; - for( std::pair mat : cut.get_item()->made_of() ) { + for( const std::pair &mat : cut.get_item()->made_of() ) { mat_set.insert( mat.first ); } diff --git a/src/magic_enchantment.cpp b/src/magic_enchantment.cpp index f6e9ddb67cfdd..f7ac8a99688c7 100644 --- a/src/magic_enchantment.cpp +++ b/src/magic_enchantment.cpp @@ -1130,7 +1130,7 @@ void enchant_cache::activate_passive( Character &guy ) const if( emitter ) { get_map().emit_field( guy.pos_bub(), *emitter ); } - for( const std::pair eff : ench_effects ) { + for( const std::pair &eff : ench_effects ) { guy.add_effect( eff.first, 1_seconds, false, eff.second ); } for( const std::pair> &activation : diff --git a/src/math_parser_diag.cpp b/src/math_parser_diag.cpp index 7824b50e74272..b4af37792b643 100644 --- a/src/math_parser_diag.cpp +++ b/src/math_parser_diag.cpp @@ -272,7 +272,7 @@ diag_eval_dbl_f faction_food_supply_eval( char /* scope */, { return [fac_val = params[0]]( const_dialogue const & d ) { faction *fac = g->faction_manager_ptr->get( faction_id( fac_val.str( d ) ) ); - return fac->food_supply.calories; + return static_cast( fac->food_supply.calories ); }; } diff --git a/src/mutation.cpp b/src/mutation.cpp index 5429cbd7a6080..1b9440d239f51 100644 --- a/src/mutation.cpp +++ b/src/mutation.cpp @@ -640,7 +640,7 @@ void Character::mutation_effect( const trait_id &mut, const bool worn_destroyed_ return true; } ); - for( std::pair moncam : branch.moncams ) { + for( const std::pair &moncam : branch.moncams ) { add_moncam( moncam ); } @@ -674,7 +674,7 @@ void Character::mutation_loss_effect( const trait_id &mut ) recalculate_bodyparts(); } - for( std::pair moncam : branch.moncams ) { + for( const std::pair &moncam : branch.moncams ) { remove_moncam( moncam.first ); } diff --git a/src/mutation_data.cpp b/src/mutation_data.cpp index b634a513fb014..daf6055867aab 100644 --- a/src/mutation_data.cpp +++ b/src/mutation_data.cpp @@ -679,7 +679,7 @@ void mutation_branch::check_consistency() debugmsg( "mutation %s transform uses undefined target %s", mid.c_str(), tid.c_str() ); } } - for( const std::pair elem : an_id ) { + for( const std::pair &elem : an_id ) { if( !elem.first.is_valid() ) { debugmsg( "mutation %s refers to undefined species id %s", mid.c_str(), elem.first.c_str() ); } diff --git a/src/newcharacter.cpp b/src/newcharacter.cpp index 7a4d1b9ec8d8f..053bb937fec7c 100644 --- a/src/newcharacter.cpp +++ b/src/newcharacter.cpp @@ -2376,7 +2376,7 @@ static std::string assemble_profession_details( const avatar &u, const input_con // Profession spells if( !sorted_profs[cur_id]->spells().empty() ) { assembled += "\n" + colorize( _( "Profession spells:" ), COL_HEADER ) + "\n"; - for( const std::pair spell_pair : sorted_profs[cur_id]->spells() ) { + for( const std::pair &spell_pair : sorted_profs[cur_id]->spells() ) { assembled += string_format( _( "%s level %d" ), spell_pair.first->name, spell_pair.second ) + "\n"; } } @@ -2784,7 +2784,7 @@ static std::string assemble_hobby_details( const avatar &u, const input_context // Background spells if( !sorted_hobbies[cur_id]->spells().empty() ) { assembled += "\n" + colorize( _( "Background spells:" ), COL_HEADER ) + "\n"; - for( const std::pair spell_pair : sorted_hobbies[cur_id]->spells() ) { + for( const std::pair &spell_pair : sorted_hobbies[cur_id]->spells() ) { assembled += string_format( _( "%s level %d" ), spell_pair.first->name, spell_pair.second ) + "\n"; } } diff --git a/src/npc.cpp b/src/npc.cpp index 319ea72afdb99..b5d517cda2c9d 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -703,7 +703,7 @@ void npc::randomize( const npc_class_id &type, const npc_template_id &tem_id ) // Add martial arts learn_ma_styles_from_traits(); // Add spells for magiclysm mod - for( std::pair spell_pair : myclass->_starting_spells ) { + for( const std::pair &spell_pair : myclass->_starting_spells ) { this->magic->learn_spell( spell_pair.first, *this, true ); spell &sp = this->magic->get_spell( spell_pair.first ); while( sp.get_level() < spell_pair.second && !sp.is_max_level( *this ) ) { diff --git a/src/overmap.cpp b/src/overmap.cpp index 84e7ace4fab89..b240d54a13cc9 100644 --- a/src/overmap.cpp +++ b/src/overmap.cpp @@ -2404,7 +2404,7 @@ struct mutable_overmap_phase_remainder { ) const { int context_mandatory_joins_shortfall = 0; - for( const mutable_overmap_piece_candidate piece : rule.pieces( origin, dir ) ) { + for( const mutable_overmap_piece_candidate &piece : rule.pieces( origin, dir ) ) { if( !overmap::inbounds( piece.pos ) ) { return std::nullopt; } @@ -2421,7 +2421,7 @@ struct mutable_overmap_phase_remainder { std::vector suppressed_joins; - for( const std::pair p : + for( const std::pair &p : rule.outward_joins( origin, dir ) ) { const om_pos_dir &pos_d = p.first; const mutable_overmap_terrain_join &ter_join = *p.second; @@ -2800,7 +2800,7 @@ struct mutable_overmap_special_data : overmap_special_data { if( rule ) { const tripoint_om_omt &satisfy_origin = satisfy_result.origin; om_direction::type rot = satisfy_result.dir; - for( const mutable_overmap_piece_candidate piece : rule->pieces( satisfy_origin, rot ) ) { + for( const mutable_overmap_piece_candidate &piece : rule->pieces( satisfy_origin, rot ) ) { const mutable_overmap_terrain &ter = *piece.overmap; add_ter( ter, piece.pos, piece.rot, satisfy_result.suppressed_joins ); } @@ -6620,7 +6620,7 @@ void overmap::connect_closest_points( const std::vector &points, i // track which subgraph each point belongs to std::vector subgraphs( points.size(), -1 ); - for( edge candidate : edges ) { + for( const edge &candidate : edges ) { const size_t i = candidate.second.first; const size_t j = candidate.second.second; bool connect = false; diff --git a/src/profession.cpp b/src/profession.cpp index 4c7182dade5c8..7356e1e01349e 100644 --- a/src/profession.cpp +++ b/src/profession.cpp @@ -732,7 +732,7 @@ std::map profession::spells() const void profession::learn_spells( avatar &you ) const { - for( const std::pair spell_pair : spells() ) { + for( const std::pair &spell_pair : spells() ) { you.magic->learn_spell( spell_pair.first, you, true ); spell &sp = you.magic->get_spell( spell_pair.first ); while( sp.get_level() < spell_pair.second && !sp.is_max_level( you ) ) { diff --git a/src/turret.cpp b/src/turret.cpp index da3f36186cbad..9e83815fd3f8e 100644 --- a/src/turret.cpp +++ b/src/turret.cpp @@ -633,16 +633,16 @@ int vehicle::automatic_fire_turret( vehicle_part &pt ) if( boo_hoo ) { cpu.get_name() = string_format( pgettext( "vehicle turret", "The %s" ), pt.name() ); // check if the player can see or hear then print chooses a message accordingly - if( u_see & u_hear ) { + if( u_see && u_hear ) { add_msg( m_warning, n_gettext( "%s points in your direction and emits an IFF warning beep.", "%s points in your direction and emits %d annoyed sounding beeps.", boo_hoo ), cpu.get_name(), boo_hoo ); - } else if( !u_see & u_hear ) { + } else if( !u_see && u_hear ) { add_msg( m_warning, n_gettext( "You hear a warning beep.", "You hear %d annoyed sounding beeps.", boo_hoo ), boo_hoo ); - } else if( u_see & !u_hear ) { + } else if( u_see && !u_hear ) { add_msg( m_warning, _( "%s points in your direction." ), cpu.get_name() ); } } diff --git a/tests/overmap_test.cpp b/tests/overmap_test.cpp index 0a076bbad0712..2f7be6504a482 100644 --- a/tests/overmap_test.cpp +++ b/tests/overmap_test.cpp @@ -362,7 +362,7 @@ static void finalize_item_counts( std::unordered_map &item_coun } } } - for( std::pair demographics : category.second.item_weights ) { + for( const std::pair &demographics : category.second.item_weights ) { item_counts[demographics.first] = 0.0; } } diff --git a/tests/vehicle_export_test.cpp b/tests/vehicle_export_test.cpp index e08844a5bcbfe..c9975b0a50ce7 100644 --- a/tests/vehicle_export_test.cpp +++ b/tests/vehicle_export_test.cpp @@ -24,7 +24,7 @@ static bool operator==( const vehicle_prototype::part_def &l, const vehicle_prot static bool operator==( const vehicle_item_spawn &l, const vehicle_item_spawn &r ) { - return l.pos == r.pos && l.chance == r.chance && l.with_ammo == r.with_ammo && + return l.pos == r.pos && l.chance == r.chance && l.with_ammo == r.with_ammo && l.with_magazine == r.with_magazine && l.item_ids == r.item_ids && // NOLINTNEXTLINE(misc-redundant-expression) l.variant_ids == r.variant_ids && l.item_groups == r.item_groups; diff --git a/tests/vehicle_part_test.cpp b/tests/vehicle_part_test.cpp index 81c9d179c8593..32adbb9774f99 100644 --- a/tests/vehicle_part_test.cpp +++ b/tests/vehicle_part_test.cpp @@ -137,7 +137,7 @@ static void test_craft_via_rig( const std::vector &items, int give_battery // Shift skill levels by one to ensure successful crafting // after the change in https://github.com/CleverRaven/Cataclysm-DDA/pull/61985 character.set_skill_level( recipe.skill_used, recipe.difficulty + 1 ); - for( const std::pair req : recipe.required_skills ) { + for( const std::pair &req : recipe.required_skills ) { character.set_skill_level( req.first, req.second + 1 ); } for( const recipe_proficiency &prof : recipe.proficiencies ) {