Skip to content

Commit

Permalink
Merge pull request #77675 from PatrikLundell/warnings_buster
Browse files Browse the repository at this point in the history
Silenced compiler warnings
  • Loading branch information
Night-Pryanik authored Nov 11, 2024
2 parents 96c9ee4 + 9b3cbab commit 5ba11c4
Show file tree
Hide file tree
Showing 18 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/bodygraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>( 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();
Expand Down
2 changes: 1 addition & 1 deletion src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<mtype_id, int> const moncam : get_moncams() ) {
for( const std::pair<const mtype_id, int> &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() } );
Expand Down
4 changes: 2 additions & 2 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/iexamine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6164,7 +6164,7 @@ static void mill_activate( Character &you, const tripoint_bub_ms &examp )
}
}

for( std::pair<const string_id<itype>, int> mill_type_count : millable_counts ) {
for( const std::pair<const string_id<itype>, 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_;
Expand Down
8 changes: 4 additions & 4 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<material_id, int> mat : made_of() ) {
for( const std::pair<const material_id, int> &mat : made_of() ) {
const int val = ( mat.first->chip_resist() * mat.second ) / total;
res = worst ? std::min( res, val ) : std::max( res, val );
}
Expand Down Expand Up @@ -10464,7 +10464,7 @@ const material_type &item::get_random_material() const
std::vector<material_id> matlist;
const std::map<material_id, int> &mats = made_of();
matlist.reserve( mats.size() );
for( auto mat : mats ) {
for( const std::pair<const material_id, int> &mat : mats ) {
matlist.emplace_back( mat.first );
}
return *random_entry( matlist, material_id::NULL_ID() );
Expand All @@ -10475,7 +10475,7 @@ const material_type &item::get_base_material() const
const std::map<material_id, int> &mats = made_of();
const material_type *m = &material_id::NULL_ID().obj();
int portion = 0;
for( const std::pair<material_id, int> mat : mats ) {
for( const std::pair<const material_id, int> &mat : mats ) {
if( mat.second > portion ) {
portion = mat.second;
m = &mat.first.obj();
Expand Down Expand Up @@ -12070,7 +12070,7 @@ bool item::flammable( int threshold ) const

int flammability = 0;
units::volume volume_per_turn = 0_ml;
for( const std::pair<material_id, int> m : mats ) {
for( const std::pair<const material_id, int> &m : mats ) {
const mat_burn_data &bd = m.first->burn_data( 1 );
if( bd.immune ) {
// Made to protect from fire
Expand Down
2 changes: 1 addition & 1 deletion src/iuse_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1659,7 +1659,7 @@ void salvage_actor::cut_up( Character &p, item_location &cut ) const
std::map<itype_id, int> salvage;
std::map<material_id, units::mass> mat_to_weight;
std::set<material_id> mat_set;
for( std::pair<material_id, int> mat : cut.get_item()->made_of() ) {
for( const std::pair<const material_id, int> &mat : cut.get_item()->made_of() ) {
mat_set.insert( mat.first );
}

Expand Down
2 changes: 1 addition & 1 deletion src/magic_enchantment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<efftype_id, int> eff : ench_effects ) {
for( const std::pair<const efftype_id, int> &eff : ench_effects ) {
guy.add_effect( eff.first, 1_seconds, false, eff.second );
}
for( const std::pair<const time_duration, std::vector<fake_spell>> &activation :
Expand Down
2 changes: 1 addition & 1 deletion src/math_parser_diag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>( fac->food_supply.calories );
};
}

Expand Down
4 changes: 2 additions & 2 deletions src/mutation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ void Character::mutation_effect( const trait_id &mut, const bool worn_destroyed_
return true;
} );

for( std::pair<mtype_id, int> moncam : branch.moncams ) {
for( const std::pair<const mtype_id, int> &moncam : branch.moncams ) {
add_moncam( moncam );
}

Expand Down Expand Up @@ -674,7 +674,7 @@ void Character::mutation_loss_effect( const trait_id &mut )
recalculate_bodyparts();
}

for( std::pair<mtype_id, int> moncam : branch.moncams ) {
for( const std::pair<const mtype_id, int> &moncam : branch.moncams ) {
remove_moncam( moncam.first );
}

Expand Down
2 changes: 1 addition & 1 deletion src/mutation_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<species_id, int> elem : an_id ) {
for( const std::pair<const species_id, int> &elem : an_id ) {
if( !elem.first.is_valid() ) {
debugmsg( "mutation %s refers to undefined species id %s", mid.c_str(), elem.first.c_str() );
}
Expand Down
4 changes: 2 additions & 2 deletions src/newcharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_id, int> spell_pair : sorted_profs[cur_id]->spells() ) {
for( const std::pair<const spell_id, int> &spell_pair : sorted_profs[cur_id]->spells() ) {
assembled += string_format( _( "%s level %d" ), spell_pair.first->name, spell_pair.second ) + "\n";
}
}
Expand Down Expand Up @@ -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_id, int> spell_pair : sorted_hobbies[cur_id]->spells() ) {
for( const std::pair<const spell_id, int> &spell_pair : sorted_hobbies[cur_id]->spells() ) {
assembled += string_format( _( "%s level %d" ), spell_pair.first->name, spell_pair.second ) + "\n";
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_id, int> spell_pair : myclass->_starting_spells ) {
for( const std::pair<const spell_id, int> &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 ) ) {
Expand Down
8 changes: 4 additions & 4 deletions src/overmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -2421,7 +2421,7 @@ struct mutable_overmap_phase_remainder {

std::vector<om_pos_dir> suppressed_joins;

for( const std::pair<om_pos_dir, const mutable_overmap_terrain_join *> p :
for( const std::pair<om_pos_dir, const mutable_overmap_terrain_join *> &p :
rule.outward_joins( origin, dir ) ) {
const om_pos_dir &pos_d = p.first;
const mutable_overmap_terrain_join &ter_join = *p.second;
Expand Down Expand Up @@ -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 );
}
Expand Down Expand Up @@ -6620,7 +6620,7 @@ void overmap::connect_closest_points( const std::vector<point_om_omt> &points, i
// track which subgraph each point belongs to
std::vector<int> 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;
Expand Down
2 changes: 1 addition & 1 deletion src/profession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ std::map<spell_id, int> profession::spells() const

void profession::learn_spells( avatar &you ) const
{
for( const std::pair<spell_id, int> spell_pair : spells() ) {
for( const std::pair<const spell_id, int> &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 ) ) {
Expand Down
6 changes: 3 additions & 3 deletions src/turret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/overmap_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ static void finalize_item_counts( std::unordered_map<itype_id, float> &item_coun
}
}
}
for( std::pair<const itype_id, int> demographics : category.second.item_weights ) {
for( const std::pair<const itype_id, int> &demographics : category.second.item_weights ) {
item_counts[demographics.first] = 0.0;
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/vehicle_export_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/vehicle_part_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ static void test_craft_via_rig( const std::vector<item> &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<skill_id, int> req : recipe.required_skills ) {
for( const std::pair<const skill_id, int> &req : recipe.required_skills ) {
character.set_skill_level( req.first, req.second + 1 );
}
for( const recipe_proficiency &prof : recipe.proficiencies ) {
Expand Down

0 comments on commit 5ba11c4

Please sign in to comment.