diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index 2fcdc891eb4b8..485e482989b8d 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -278,7 +278,6 @@ void set_up_butchery( player_activity &act, player &u, butcher_type action ) u.add_msg_if_player( m_info, _( "None of your tools are sharp and precise enough to do that." ) ); act.set_to_null(); return; - break; case 1: u.add_msg_if_player( m_info, _( "You could use a better tool, but this will do." ) ); break; @@ -1209,7 +1208,6 @@ void activity_handlers::butcher_finish( player_activity *act, player *p ) } act->set_to_null(); return; - break; case DISSECT: p->add_msg_if_player( m_good, _( "You finish dissecting the %s." ), corpse_item.tname().c_str() ); g->m.i_rem( p->pos(), act->index ); diff --git a/src/bonuses.cpp b/src/bonuses.cpp index cbc367f616111..a6c6bdba87e34 100644 --- a/src/bonuses.cpp +++ b/src/bonuses.cpp @@ -127,11 +127,10 @@ void bonus_container::load( JsonArray &jarr, bool mult ) while( jarr.has_more() ) { JsonArray qualifiers = jarr.next_array(); - affected_stat as; damage_type dt = DT_NULL; const std::string affected_stat_string = qualifiers.next_string(); - as = affected_stat_from_string( affected_stat_string ); + affected_stat as = affected_stat_from_string( affected_stat_string ); if( as == AFFECTED_NULL ) { jarr.throw_error( "Invalid affected stat" ); } diff --git a/src/catacharset.cpp b/src/catacharset.cpp index d517446da0eec..2a3365ec0f8d6 100644 --- a/src/catacharset.cpp +++ b/src/catacharset.cpp @@ -213,13 +213,12 @@ int cursorx_to_position( const char *line, int cursorx, int *prevpos, int maxlen std::string utf8_truncate( std::string s, size_t length ) { - int last_pos; if( length == 0 || s.empty() ) { return s; } - last_pos = cursorx_to_position( s.c_str(), length, NULL, -1 ); + int last_pos = cursorx_to_position( s.c_str(), length, NULL, -1 ); return s.substr( 0, last_pos ); } diff --git a/src/clzones.cpp b/src/clzones.cpp index b663a52927041..8787431e63219 100644 --- a/src/clzones.cpp +++ b/src/clzones.cpp @@ -232,7 +232,7 @@ void plot_options::deserialize( JsonObject &jo_zone ) seed = jo_zone.get_string( "seed", "" ); }; -cata::optional zone_manager::query_name( std::string default_name ) const +cata::optional zone_manager::query_name( const std::string &default_name ) const { string_input_popup popup; popup diff --git a/src/clzones.h b/src/clzones.h index 369d9f1d4859f..2d23ca53d78d6 100644 --- a/src/clzones.h +++ b/src/clzones.h @@ -172,7 +172,7 @@ class zone_manager std::vector get_zones( const zone_type_id &type, const tripoint &where ) const; const zone_data *get_top_zone( const tripoint &where ) const; const zone_data *get_bottom_zone( const tripoint &where ) const; - cata::optional query_name( std::string default_name = "" ) const; + cata::optional query_name( const std::string &default_name = "" ) const; cata::optional query_type() const; void swap( zone_data &a, zone_data &b ); diff --git a/src/construction.cpp b/src/construction.cpp index 26c76b4fdbc23..c5b62b9037e62 100644 --- a/src/construction.cpp +++ b/src/construction.cpp @@ -37,14 +37,10 @@ static const skill_id skill_fabrication( "fabrication" ); static const skill_id skill_electronics( "electronics" ); -static const skill_id skill_unarmed( "unarmed" ); -static const skill_id skill_throw( "throw" ); static const trait_id trait_DEBUG_HS( "DEBUG_HS" ); -static const trait_id trait_NOPAIN( "NOPAIN" ); static const trait_id trait_PAINRESIST_TROGLO( "PAINRESIST_TROGLO" ); static const trait_id trait_STOCKY_TROGLO( "STOCKY_TROGLO" ); -static const trait_id trait_WEB_ROPE( "WEB_ROPE" ); const trap_str_id tr_firewood_source( "tr_firewood_source" ); diff --git a/src/crafting_gui.cpp b/src/crafting_gui.cpp index e41df8ced2f31..0fac10170b301 100644 --- a/src/crafting_gui.cpp +++ b/src/crafting_gui.cpp @@ -57,7 +57,6 @@ std::string get_cat_name( const std::string &prefixed_name ) void load_recipe_category( JsonObject &jsobj ) { - JsonArray subcats; std::string category = jsobj.get_string( "id" ); if( category.find( "CC_" ) != 0 ) { @@ -69,7 +68,7 @@ void load_recipe_category( JsonObject &jsobj ) std::string cat_name = get_cat_name( category ); craft_subcat_list[category] = std::vector(); - subcats = jsobj.get_array( "recipe_subcategories" ); + JsonArray subcats = jsobj.get_array( "recipe_subcategories" ); while( subcats.has_more() ) { std::string subcat_id = subcats.next_string(); if( subcat_id.find( "CSC_" + cat_name + "_" ) != 0 && subcat_id != "CSC_ALL" ) { diff --git a/src/creature_tracker.cpp b/src/creature_tracker.cpp index 3d5f3cfafb178..6156fb09d9cd8 100644 --- a/src/creature_tracker.cpp +++ b/src/creature_tracker.cpp @@ -129,8 +129,6 @@ bool Creature_tracker::update_pos( const monster &critter, const tripoint &new_p rebuild_cache(); return false; } - - return false; } void Creature_tracker::remove_from_location_map( const monster &critter ) diff --git a/src/dependency_tree.h b/src/dependency_tree.h index bcc1280dd3f6f..669e2c76a8b1b 100644 --- a/src/dependency_tree.h +++ b/src/dependency_tree.h @@ -77,7 +77,6 @@ class dependency_tree dependency_node *get_node( mod_id key ); std::map master_node_map; - protected: private: // Don't need to be called directly. Only reason to call these are during initialization phase. void build_node_map( std::map > key_dependency_map ); diff --git a/src/dialogue.h b/src/dialogue.h index 3758d2b3ae66d..0b6270b95d7ad 100644 --- a/src/dialogue.h +++ b/src/dialogue.h @@ -153,7 +153,7 @@ struct talk_response { /** * Sets an effect to a function object and consequence to explicitly given one. */ - void set_effect_consequence( effect_fun_t eff, dialogue_consequence con ); + void set_effect_consequence( const effect_fun_t &eff, dialogue_consequence con ); void set_effect_consequence( std::function ptr, dialogue_consequence con ); @@ -349,8 +349,6 @@ class json_talk_response */ class json_talk_topic { - public: - private: bool replace_built_in_responses = false; std::vector responses; diff --git a/src/dialogue_win.cpp b/src/dialogue_win.cpp index f8b27d28006dc..5955b75e45c34 100644 --- a/src/dialogue_win.cpp +++ b/src/dialogue_win.cpp @@ -109,8 +109,7 @@ bool dialogue_window::print_responses( int const yoffset, const std::vector folded = foldstring( responses[i].second, fold_width ); const nc_color &color = responses[i].first; for( size_t j = 0; j < folded.size(); j++, curline++ ) { @@ -138,7 +137,8 @@ void dialogue_window::refresh_response_display() can_scroll_up = false; } -void dialogue_window::display_responses( int const hilight_lines, std::vector responses, +void dialogue_window::display_responses( int const hilight_lines, + const std::vector &responses, const long &ch ) { if( text_only ) { diff --git a/src/dialogue_win.h b/src/dialogue_win.h index 02f161d4b2a4b..c7bb1def1a2e2 100644 --- a/src/dialogue_win.h +++ b/src/dialogue_win.h @@ -18,7 +18,8 @@ class dialogue_window bool text_only = false; void clear_window_texts(); - void display_responses( int hilight_lines, std::vector responses, const long &ch ); + void display_responses( int hilight_lines, const std::vector &responses, + const long &ch ); void refresh_response_display(); /** * Folds and adds the folded text to @ref history. Returns the number of added lines. diff --git a/src/faction_camp.cpp b/src/faction_camp.cpp index 931718aba4b76..93d77f2a5f629 100644 --- a/src/faction_camp.cpp +++ b/src/faction_camp.cpp @@ -2302,7 +2302,7 @@ std::map talk_function::camp_recipe_deck( const std::s return cooking_recipes; } -int talk_function::camp_recipe_batch_max( const recipe making, const inventory &total_inv ) +int talk_function::camp_recipe_batch_max( const recipe &making, const inventory &total_inv ) { int max_batch = 0; int max_checks = 9; diff --git a/src/faction_camp.h b/src/faction_camp.h index 028ed948d26ea..7ea034cdada41 100644 --- a/src/faction_camp.h +++ b/src/faction_camp.h @@ -222,7 +222,7 @@ std::string name_mission_tabs( npc &p, const std::string &id, const std::string /// Creats a map of all the recipes that are available to a building at om_cur, "ALL" for all possible std::map camp_recipe_deck( const std::string &om_cur ); /// Determines what the absolute max (out of 9999) that can be crafted using inventory and food supplies -int camp_recipe_batch_max( const recipe making, const inventory &total_inv ); +int camp_recipe_batch_max( const recipe &making, const inventory &total_inv ); /* * check if a companion survives a random encounter diff --git a/src/game.cpp b/src/game.cpp index 0394cff0da32d..a18b9ad14c2e8 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -4447,11 +4447,10 @@ int game::mon_info( const catacurses::window &w ) // Print the symbols of all monsters in all directions. for( int i = 0; i < 8; i++ ) { - int symroom; point pr( xcoords[i] + widths[i] + 1, ycoords[i] + startrow ); // The list of symbols needs a space on each end. - symroom = ( width / 3 ) - widths[i] - 2; + int symroom = ( width / 3 ) - widths[i] - 2; const int typeshere_npc = unique_types[i].size(); const int typeshere_mon = unique_mons[i].size(); const int typeshere = typeshere_mon + typeshere_npc; @@ -5154,7 +5153,6 @@ void game::emp_blast( const tripoint &p ) // TODO: Implement z part int x = p.x; int y = p.y; - int rn; const bool sight = g->u.sees( p ); if( m.has_flag( "CONSOLE", x, y ) ) { if( sight ) { @@ -5165,7 +5163,7 @@ void game::emp_blast( const tripoint &p ) } // TODO: More terrain effects. if( m.ter( x, y ) == t_card_science || m.ter( x, y ) == t_card_military ) { - rn = rng( 1, 100 ); + int rn = rng( 1, 100 ); if( rn > 92 || rn < 40 ) { if( sight ) { add_msg( _( "The card reader is rendered non-functional." ) ); @@ -5632,7 +5630,7 @@ void game::exam_vehicle( vehicle &veh, int cx, int cy ) } } -bool game::forced_door_closing( const tripoint &p, const ter_id door_type, int bash_dmg ) +bool game::forced_door_closing( const tripoint &p, const ter_id &door_type, int bash_dmg ) { // TODO: Z const int &x = p.x; @@ -6545,9 +6543,8 @@ void game::print_fields_info( const tripoint &lp, const catacurses::window &w_lo if( fld.first == fd_fire && ( m.has_flag( TFLAG_FIRE_CONTAINER, lp ) || m.ter( lp ) == t_pit_shallow || m.ter( lp ) == t_pit ) ) { const int max_width = getmaxx( w_look ) - column - 2; - int lines; - lines = fold_and_print( w_look, ++line, column, max_width, cur.color(), - get_fire_fuel_string( lp ) ) - 1; + int lines = fold_and_print( w_look, ++line, column, max_width, cur.color(), + get_fire_fuel_string( lp ) ) - 1; line += lines; } else { mvwprintz( w_look, ++line, column, cur.color(), cur.name() ); @@ -8817,8 +8814,8 @@ void game::plthrow( int pos ) m.draw( w_terrain, u.pos() ); // target_ui() sets x and y, or returns empty vector if we canceled (by pressing Esc) - std::vector trajectory; - trajectory = target_handler().target_ui( u, TARGET_MODE_THROW, &thrown, range ); + std::vector trajectory = target_handler().target_ui( u, TARGET_MODE_THROW, &thrown, + range ); if( trajectory.empty() ) { return; } @@ -10894,9 +10891,8 @@ void game::place_player( const tripoint &dest_loc ) } int and_the_rest = 0; for( size_t i = 0; i < names.size(); ++i ) { - std::string fmt; //~ number of items: " " - fmt = ngettext( "%1$d %2$s", "%1$d %2$s", counts[i] ); + std::string fmt = ngettext( "%1$d %2$s", "%1$d %2$s", counts[i] ); names[i] = string_format( fmt, counts[i], names[i].c_str() ); // Skip the first two. if( i > 1 ) { @@ -12589,8 +12585,7 @@ void game::process_artifact( item &it, player &p ) { const bool worn = p.is_worn( it ); const bool wielded = ( &it == &p.weapon ); - std::vector effects; - effects = it.type->artifact->effects_carried; + std::vector effects = it.type->artifact->effects_carried; if( worn ) { auto &ew = it.type->artifact->effects_worn; effects.insert( effects.end(), ew.begin(), ew.end() ); diff --git a/src/game.h b/src/game.h index 4c0344f9629c6..fe6c8f994be28 100644 --- a/src/game.h +++ b/src/game.h @@ -850,7 +850,7 @@ class game // will do so, if bash_dmg is greater than 0, items won't stop the door // from closing at all. // If the door gets closed the items on the door tile get moved away or destroyed. - bool forced_door_closing( const tripoint &p, const ter_id door_type, int bash_dmg ); + bool forced_door_closing( const tripoint &p, const ter_id &door_type, int bash_dmg ); //pixel minimap management int pixel_minimap_option; diff --git a/src/gamemode.h b/src/gamemode.h index f957342854c57..30b80a5997639 100644 --- a/src/gamemode.h +++ b/src/gamemode.h @@ -138,14 +138,12 @@ struct defense_game : public special_game { private: void init_to_style( defense_style new_style ); - void load_style( std::string style_name ); void setup(); void refresh_setup( const catacurses::window &w, int selection ); void init_mtypes(); void init_constructions(); void init_map(); - std::vector carvan_items( caravan_category cat ); void spawn_wave(); void caravan(); diff --git a/src/iexamine.cpp b/src/iexamine.cpp index ebf3b33f4851b..9682915cde332 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -68,7 +68,6 @@ const efftype_id effect_sleep( "sleep" ); static const trait_id trait_AMORPHOUS( "AMORPHOUS" ); static const trait_id trait_ARACHNID_ARMS_OK( "ARACHNID_ARMS_OK" ); static const trait_id trait_BADKNEES( "BADKNEES" ); -static const trait_id trait_BEAK_HUM( "BEAK_HUM" ); static const trait_id trait_ILLITERATE( "ILLITERATE" ); static const trait_id trait_INSECT_ARMS_OK( "INSECT_ARMS_OK" ); static const trait_id trait_M_DEFENDER( "M_DEFENDER" ); @@ -77,7 +76,6 @@ static const trait_id trait_M_FERTILE( "M_FERTILE" ); static const trait_id trait_M_SPORES( "M_SPORES" ); static const trait_id trait_NOPAIN( "NOPAIN" ); static const trait_id trait_PARKOUR( "PARKOUR" ); -static const trait_id trait_PROBOSCIS( "PROBOSCIS" ); static const trait_id trait_THRESH_MARLOSS( "THRESH_MARLOSS" ); static const trait_id trait_THRESH_MYCUS( "THRESH_MYCUS" ); static const trait_id trait_BURROW( "BURROW" ); @@ -4127,10 +4125,8 @@ void iexamine::smoker_options( player &p, const tripoint &examp ) case 1: //activate if ( active ) { add_msg( _("It is already lit and smoking.") ); - break; } else { smoker_activate( p, examp ); - break; } break; case 2: // load food diff --git a/src/input.cpp b/src/input.cpp index e4c0e055d0f08..2e60fa132f849 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1343,7 +1343,7 @@ std::vector input_context::filter_strings_by_phrase( return filtered_strings; } -void input_context::set_edittext( std::string s ) +void input_context::set_edittext( const std::string &s ) { edittext = s; } diff --git a/src/input.h b/src/input.h index a8fe7f7219d8e..b6b9d1fcdc77e 100644 --- a/src/input.h +++ b/src/input.h @@ -264,8 +264,6 @@ class input_manager */ void wait_for_any_key(); - bool translate_to_window_position(); - /** * Sets global input polling timeout as appropriate for the current interface system. * Use `input_context::(re)set_timeout()` when possible so timeout will be properly @@ -646,7 +644,7 @@ class input_context /** * Get/Set edittext to display IME unspecified string. */ - void set_edittext( std::string s ); + void set_edittext( const std::string &s ); std::string get_edittext(); void set_iso( bool mode = true ); diff --git a/src/inventory_ui.cpp b/src/inventory_ui.cpp index 4a01a43685d88..3cb45b18b77de 100644 --- a/src/inventory_ui.cpp +++ b/src/inventory_ui.cpp @@ -1263,7 +1263,7 @@ inventory_selector::stat display_stat( const std::string &caption, int cur_value inventory_selector::stats inventory_selector::get_weight_and_volume_stats( units::mass weight_carried, units::mass weight_capacity, - units::volume volume_carried, units::volume volume_capacity ) + const units::volume &volume_carried, const units::volume &volume_capacity ) { return { { diff --git a/src/inventory_ui.h b/src/inventory_ui.h index c15d5e428d656..3f1a82193b8c5 100644 --- a/src/inventory_ui.h +++ b/src/inventory_ui.h @@ -492,7 +492,7 @@ class inventory_selector static stats get_weight_and_volume_stats( units::mass weight_carried, units::mass weight_capacity, - units::volume volume_carried, units::volume volume_capacity ); + const units::volume &volume_carried, const units::volume &volume_capacity ); /** Get stats to display in top right. * @@ -551,7 +551,6 @@ class inventory_selector } } void toggle_navigation_mode(); - void reassign_custom_invlets(); /** Entry has been added */ virtual void on_entry_add( const inventory_entry & ) {} diff --git a/src/item.cpp b/src/item.cpp index ee8ef65c6ddfe..d8793fc3a803e 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -626,7 +626,7 @@ bool item::merge_charges( const item &rhs ) return true; } -void item::put_in( item payload ) +void item::put_in( const item &payload ) { contents.push_back( payload ); } diff --git a/src/item.h b/src/item.h index bd918ea1e8861..7475912245606 100644 --- a/src/item.h +++ b/src/item.h @@ -624,7 +624,7 @@ class item : public visitable /** * Puts the given item into this one, no checks are performed. */ - void put_in( item payload ); + void put_in( const item &payload ); /** Stores a newly constructed item at the end of this item's contents */ template diff --git a/src/item_factory.h b/src/item_factory.h index 07c793faec2a4..5418f638c63ef 100644 --- a/src/item_factory.h +++ b/src/item_factory.h @@ -331,7 +331,6 @@ class Item_factory void add_entry( Item_group &sg, JsonObject &obj ); void load_basic_info( JsonObject &jo, itype &def, const std::string &src ); - void tags_from_json( JsonObject &jo, std::string member, std::set &tags ); void set_qualities_from_json( JsonObject &jo, const std::string &member, itype &def ); void set_properties_from_json( JsonObject &jo, const std::string &member, itype &def ); diff --git a/src/iuse.cpp b/src/iuse.cpp index 226265420f9b5..500632cf5ed09 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -1440,15 +1440,12 @@ int petfood( player &p, const item &it, Petfood animal_food_type ) case CATFOOD: return feedpet( p, mon, MF_CATFOOD, _( "The %s seems to like you! Or maybe it just tolerates your presence better. It's hard to tell with felines." ) ); - break; case CATTLEFODDER: return feedpet( p, mon, MF_CATTLEFODDER, _( "The %s seems to like you! It lets you pat its head and seems friendly." ) ); - break; case BIRDFOOD: return feedpet( p, mon, MF_BIRDFOOD, _( "The %s seems to like you! It runs around your legs and seems friendly." ) ); - break; } } else { @@ -3548,8 +3545,6 @@ int iuse::shocktonfa_off( player *p, item *it, bool t, const tripoint &pos ) case 0: { return iuse::tazer2( p, it, t, pos ); } - break; - case 1: { if( !it->ammo_sufficient() ) { p->add_msg_if_player( m_info, _( "The batteries are dead." ) ); @@ -3581,8 +3576,6 @@ int iuse::shocktonfa_on( player *p, item *it, bool t, const tripoint &pos ) case 0: { return iuse::tazer2( p, it, t, pos ); } - break; - case 1: { p->add_msg_if_player( _( "You turn off the light." ) ); it->convert( "shocktonfa_off" ).active = false; @@ -4327,7 +4320,6 @@ int iuse::torch_lit( player *p, item *it, bool t, const tripoint &pos ) } return 0; } - break; case 1: { tripoint temp = pos; if( firestarter_actor::prep_firestarter_use( *p, temp ) ) { @@ -4371,7 +4363,6 @@ int iuse::battletorch_lit( player *p, item *it, bool t, const tripoint &pos ) } return 0; } - break; case 1: { tripoint temp = pos; if( firestarter_actor::prep_firestarter_use( *p, temp ) ) { @@ -7706,14 +7697,12 @@ int iuse::washclothes( player *p, item *it, bool, const tripoint & ) inv_s.add_character_items( *p ); inv_s.set_title( _( "Multiclean" ) ); inv_s.set_hint( _( "To clean x items, type a number before selecting." ) ); - std::list> to_clean; if( inv_s.empty() ) { popup( std::string( _( "You have nothing to clean." ) ), PF_GET_KEY ); return 0; } - - to_clean = inv_s.execute(); - if( to_clean.size() == 0 ) { + std::list> to_clean = inv_s.execute(); + if( to_clean.empty() ) { return 0; } int required_water = 0; diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index ae3ef02b28ce0..520bc66ab9d37 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -1537,7 +1537,7 @@ bool cauterize_actor::cauterize_effect( player &p, item &it, bool force ) return true; } - return 0; + return false; } long cauterize_actor::use( player &p, item &it, bool t, const tripoint & ) const @@ -3200,9 +3200,6 @@ hp_part pick_part_to_heal( return healed_part; } } - - // Won't happen? - return num_hp_parts; } hp_part heal_actor::use_healing_item( player &healer, player &patient, item &it, bool force ) const diff --git a/src/iuse_software.cpp b/src/iuse_software.cpp index a997c24205d05..5b7e234b86a4f 100644 --- a/src/iuse_software.cpp +++ b/src/iuse_software.cpp @@ -35,8 +35,6 @@ bool play_videogame( const std::string &function_name, } return foundkitten; - - return true; } else if( function_name == "snake_game" ) { snake_game sg; int iScore = sg.start_game(); diff --git a/src/map.cpp b/src/map.cpp index 57fabfb74fd0d..1bb13b30745ca 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -360,7 +360,6 @@ bool map::vehproceed() VehicleList vehs = get_vehicles(); vehicle *cur_veh = nullptr; float max_of_turn = 0; - tripoint pt; // First horizontal movement for( auto &vehs_v : vehs ) { if( vehs_v.v->of_turn > max_of_turn ) { @@ -1078,7 +1077,7 @@ bool map::displace_water( const tripoint &p ) // 2D overloads for furniture // To be removed once not needed -void map::set( const int x, const int y, const ter_id new_terrain, const furn_id new_furniture ) +void map::set( const int x, const int y, const ter_id &new_terrain, const furn_id &new_furniture ) { furn_set( x, y, new_furniture ); ter_set( x, y, new_terrain ); @@ -1107,7 +1106,7 @@ furn_id map::furn( const int x, const int y ) const return current_submap->get_furn( lx, ly ); } -void map::furn_set( const int x, const int y, const furn_id new_furniture ) +void map::furn_set( const int x, const int y, const furn_id &new_furniture ) { furn_set( tripoint( x, y, abs_sub.z ), new_furniture ); } @@ -1118,7 +1117,7 @@ std::string map::furnname( const int x, const int y ) } // End of 2D overloads for furniture -void map::set( const tripoint &p, const ter_id new_terrain, const furn_id new_furniture ) +void map::set( const tripoint &p, const ter_id &new_terrain, const furn_id &new_furniture ) { furn_set( p, new_furniture ); ter_set( p, new_terrain ); @@ -1160,7 +1159,7 @@ furn_id map::furn( const tripoint &p ) const return current_submap->get_furn( lx, ly ); } -void map::furn_set( const tripoint &p, const furn_id new_furniture ) +void map::furn_set( const tripoint &p, const furn_id &new_furniture ) { if( !inbounds( p ) ) { return; @@ -1254,7 +1253,7 @@ ter_id map::ter( const int x, const int y ) const return current_submap->get_ter( lx, ly ); } -bool map::ter_set( const int x, const int y, const ter_id new_terrain ) +bool map::ter_set( const int x, const int y, const ter_id &new_terrain ) { return ter_set( tripoint( x, y, abs_sub.z ), new_terrain ); } @@ -1361,7 +1360,7 @@ bool map::is_harvestable( const tripoint &pos ) const /* * set terrain via string; this works for -any- terrain id */ -bool map::ter_set( const tripoint &p, const ter_id new_terrain ) +bool map::ter_set( const tripoint &p, const ter_id &new_terrain ) { if( !inbounds( p ) ) { return false; @@ -2356,13 +2355,13 @@ void map::make_rubble( const tripoint &p ) make_rubble( p, f_rubble, false, t_dirt, false ); } -void map::make_rubble( const tripoint &p, const furn_id rubble_type, const bool items ) +void map::make_rubble( const tripoint &p, const furn_id &rubble_type, const bool items ) { make_rubble( p, rubble_type, items, t_dirt, false ); } -void map::make_rubble( const tripoint &p, furn_id rubble_type, bool items, ter_id floor_type, - bool overwrite ) +void map::make_rubble( const tripoint &p, const furn_id &rubble_type, const bool items, + const ter_id &floor_type, bool overwrite ) { if( overwrite ) { ter_set( p, floor_type ); @@ -3652,7 +3651,7 @@ bool map::open_door( const tripoint &p, const bool inside, const bool check_only return false; } -void map::translate( const ter_id from, const ter_id to ) +void map::translate( const ter_id &from, const ter_id &to ) { if( from == to ) { debugmsg( "map::translate %s => %s", @@ -3674,7 +3673,7 @@ void map::translate( const ter_id from, const ter_id to ) } //This function performs the translate function within a given radius of the player. -void map::translate_radius( const ter_id from, const ter_id to, float radi, const tripoint &p, +void map::translate_radius( const ter_id &from, const ter_id &to, float radi, const tripoint &p, const bool same_submap ) { if( from == to ) { @@ -5467,8 +5466,6 @@ lit_level map::apparent_light_at( const tripoint &p, const visibility_variables } else { return LL_BLANK; } - // Is this ever supposed to happen? - return LL_DARK; } visibility_type map::get_visibility( const lit_level ll, const visibility_variables &cache ) const diff --git a/src/map.h b/src/map.h index 4b42a6252d387..c55acf4e41343 100644 --- a/src/map.h +++ b/src/map.h @@ -533,7 +533,7 @@ class map void move_vehicle( vehicle &veh, const tripoint &dp, const tileray &facing ); // Furniture: 2D overloads - void set( const int x, const int y, const ter_id new_terrain, const furn_id new_furniture ); + void set( const int x, const int y, const ter_id &new_terrain, const furn_id &new_furniture ); std::string name( const int x, const int y ); bool has_furn( const int x, const int y ) const; @@ -541,11 +541,11 @@ class map // Furniture at coordinates (x, y); {x|y}=(0, SEE{X|Y}*3] furn_id furn( const int x, const int y ) const; - void furn_set( const int x, const int y, const furn_id new_furniture ); + void furn_set( const int x, const int y, const furn_id &new_furniture ); std::string furnname( const int x, const int y ); // Furniture: 3D - void set( const tripoint &p, const ter_id new_terrain, const furn_id new_furniture ); + void set( const tripoint &p, const ter_id &new_terrain, const furn_id &new_furniture ); std::string name( const tripoint &p ); std::string disp_name( const tripoint &p ); @@ -558,7 +558,7 @@ class map furn_id furn( const tripoint &p ) const; - void furn_set( const tripoint &p, const furn_id new_furniture ); + void furn_set( const tripoint &p, const furn_id &new_furniture ); std::string furnname( const tripoint &p ); bool can_move_furniture( const tripoint &pos, player *p = nullptr ); @@ -566,7 +566,7 @@ class map // Terrain integer id at coordinates (x, y); {x|y}=(0, SEE{X|Y}*3] ter_id ter( const int x, const int y ) const; - bool ter_set( const int x, const int y, const ter_id new_terrain ); + bool ter_set( const int x, const int y, const ter_id &new_terrain ); std::string tername( const int x, const int y ) const; // Name of terrain at (x, y) // Terrain: 3D @@ -581,7 +581,7 @@ class map const std::set &get_harvest_names( const tripoint &p ) const; ter_id get_ter_transforms_into( const tripoint &p ) const; - bool ter_set( const tripoint &p, const ter_id new_terrain ); + bool ter_set( const tripoint &p, const ter_id &new_terrain ); std::string tername( const tripoint &p ) const; @@ -694,10 +694,10 @@ class map /** Generates rubble at the given location, if overwrite is true it just writes on top of what currently exists * floor_type is only used if there is a non-bashable wall at the location or with overwrite = true */ - void make_rubble( const tripoint &p, furn_id rubble_type, bool items, - ter_id floor_type, bool overwrite = false ); + void make_rubble( const tripoint &p, const furn_id &rubble_type, const bool items, + const ter_id &floor_type, bool overwrite = false ); void make_rubble( const tripoint &p ); - void make_rubble( const tripoint &p, furn_id rubble_type, bool items ); + void make_rubble( const tripoint &p, const furn_id &rubble_type, const bool items ); bool is_divable( const int x, const int y ) const; bool is_outside( const int x, const int y ) const; @@ -743,9 +743,10 @@ class map void add_corpse( const tripoint &p ); // Terrain changing functions - void translate( const ter_id from, const ter_id to ); // Change all instances of $from->$to + // Change all instances of $from->$to + void translate( const ter_id &from, const ter_id &to ); // Change all instances $from->$to within this radius, optionally limited to locations in the same submap. - void translate_radius( const ter_id from, const ter_id to, const float radi, const tripoint &p, + void translate_radius( const ter_id &from, const ter_id &to, const float radi, const tripoint &p, const bool same_submap = false ); bool close_door( const tripoint &p, const bool inside, const bool check_only ); bool open_door( const tripoint &p, const bool inside, const bool check_only = false ); @@ -1342,11 +1343,11 @@ class map void shift_traps( const tripoint &shift ); void copy_grid( const tripoint &to, const tripoint &from ); - void draw_map( const oter_id terrain_type, const oter_id t_north, const oter_id t_east, - const oter_id t_south, const oter_id t_west, const oter_id t_neast, - const oter_id t_seast, const oter_id t_swest, const oter_id t_nwest, - const oter_id t_above, const oter_id t_below, const time_point &when, const float density, - const int zlevel, const regional_settings *rsettings ); + void draw_map( const oter_id &terrain_type, const oter_id &t_north, const oter_id &t_east, + const oter_id &t_south, const oter_id &t_west, const oter_id &t_neast, + const oter_id &t_seast, const oter_id &t_swest, const oter_id &t_nwest, + const oter_id &t_above, const oter_id &t_below, const time_point &when, + const float density, const int zlevel, const regional_settings *rsettings ); void build_transparency_cache( int zlev ); public: @@ -1454,7 +1455,6 @@ class map bool low_light, bool bright_light, bool inorder ) const; long determine_wall_corner( const tripoint &p ) const; - void cache_seen( const int fx, const int fy, const int tx, const int ty, const int max_range ); // apply a circular light pattern immediately, however it's best to use... void apply_light_source( const tripoint &p, float luminance ); // ...this, which will apply the light after at the end of generate_lightmap, and prevent redundant diff --git a/src/mapgen.cpp b/src/mapgen.cpp index e62d12015f928..0432bba9ccf57 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -106,7 +106,7 @@ const mtype_id mon_zombie_soldier( "mon_zombie_soldier" ); const mtype_id mon_zombie_spitter( "mon_zombie_spitter" ); const mtype_id mon_zombie_tough( "mon_zombie_tough" ); -bool connects_to( oter_id there, int dir_from_here ); +bool connects_to( const oter_id &there, int dir_from_here ); void science_room( map *m, int x1, int y1, int x2, int y2, int z, int rotate ); void set_science_room( map *m, int x1, int y1, bool faces_right, const time_point &when ); void silo_rooms( map *m ); @@ -2212,16 +2212,14 @@ void mapgen_function_lua::generate( map *m, const oter_id &terrain_type, const m // track down what is and isn't supposed to be carried around between bits of code. // I suggest that we break the function down into smaller parts -void map::draw_map( const oter_id terrain_type, const oter_id t_north, const oter_id t_east, - const oter_id t_south, const oter_id t_west, const oter_id t_neast, - const oter_id t_seast, const oter_id t_swest, const oter_id t_nwest, - const oter_id t_above, const oter_id t_below, const time_point &when, const float density, - const int zlevel, const regional_settings *rsettings ) +void map::draw_map( const oter_id &terrain_type, const oter_id &t_north, const oter_id &t_east, + const oter_id &t_south, const oter_id &t_west, const oter_id &t_neast, + const oter_id &t_seast, const oter_id &t_swest, const oter_id &t_nwest, + const oter_id &t_above, const oter_id &t_below, const time_point &when, + const float density, const int zlevel, const regional_settings *rsettings ) { static const mongroup_id GROUP_ZOMBIE( "GROUP_ZOMBIE" ); static const mongroup_id GROUP_LAB( "GROUP_LAB" ); - static const mongroup_id GROUP_PUBLICWORKERS( "GROUP_PUBLICWORKERS" ); - static const mongroup_id GROUP_DOMESTIC( "GROUP_DOMESTIC" ); // Big old switch statement with a case for each overmap terrain type. // Many of these can be copied from another type, then rotated; for instance, // "house_east" is identical to "house_north", just rotated 90 degrees to @@ -7336,7 +7334,7 @@ void map::rotate( int turns ) } // Hideous function, I admit... -bool connects_to( oter_id there, int dir ) +bool connects_to( const oter_id &there, int dir ) { switch( dir ) { case 2: diff --git a/src/mapgen.h b/src/mapgen.h index c52c6c6e635b9..433beb878f668 100644 --- a/src/mapgen.h +++ b/src/mapgen.h @@ -391,7 +391,7 @@ enum room_type { void house_room( map *m, room_type type, int x1, int y1, int x2, int y2, mapgendata &dat ); // helpful functions -bool connects_to( oter_id there, int dir ); +bool connects_to( const oter_id &there, int dir ); void mapgen_rotate( map *m, oter_id terrain_type, bool north_is_down = false ); // wrappers for map:: functions void line( map *m, const ter_id type, int x1, int y1, int x2, int y2 ); diff --git a/src/mapgen_functions.cpp b/src/mapgen_functions.cpp index 6c268a868008a..7c4df1eaeb384 100644 --- a/src/mapgen_functions.cpp +++ b/src/mapgen_functions.cpp @@ -216,33 +216,24 @@ int &mapgendata::dir( int dir_in ) switch( dir_in ) { case 0: return n_fac; - break; case 1: return e_fac; - break; case 2: return s_fac; - break; case 3: return w_fac; - break; case 4: return ne_fac; - break; case 5: return se_fac; - break; case 6: return sw_fac; - break; case 7: return nw_fac; - break; default: debugmsg( "Invalid direction for mapgendata::set_dir. dir_in = %d", dir_in ); //return something just so the compiler doesn't freak out. Not really correct, though. return n_fac; - break; } } diff --git a/src/martialarts.cpp b/src/martialarts.cpp index 1c5a91c6cb60c..27b28d3d07f0f 100644 --- a/src/martialarts.cpp +++ b/src/martialarts.cpp @@ -886,7 +886,7 @@ bool player::can_melee() const } ); } -bool player::has_mabuff( mabuff_id id ) const +bool player::has_mabuff( const mabuff_id &id ) const { return search_ma_buff_effect( *effects, [&id]( const ma_buff & b, const effect & ) { return b.id == id; diff --git a/src/material.cpp b/src/material.cpp index a1aadbe33ae8b..a74d057fa8531 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -145,22 +145,16 @@ int material_type::dam_resist( damage_type damtype ) const switch( damtype ) { case DT_BASH: return _bash_resist; - break; case DT_CUT: return _cut_resist; - break; case DT_ACID: return _acid_resist; - break; case DT_ELECTRIC: return _elec_resist; - break; case DT_HEAT: return _fire_resist; - break; default: return 0; - break; } } diff --git a/src/melee.cpp b/src/melee.cpp index 002d6721bb621..edb16b95e409e 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -40,7 +40,6 @@ static const skill_id skill_cutting( "cutting" ); static const skill_id skill_unarmed( "unarmed" ); static const skill_id skill_bashing( "bashing" ); static const skill_id skill_melee( "melee" ); -static const skill_id skill_dodge( "dodge" ); const efftype_id effect_badpoison( "badpoison" ); const efftype_id effect_beartrap( "beartrap" ); @@ -370,7 +369,7 @@ void player::melee_attack( Creature &t, bool allow_special, const matec_id &forc if( hit_spread < 0 ) { int stumble_pen = stumble( *this, cur_weapon ); - sfx::generate_melee_sound( pos(), t.pos(), 0, 0 ); + sfx::generate_melee_sound( pos(), t.pos(), false, false ); if( is_player() ) { // Only display messages if this is the player if( one_in( 2 ) ) { @@ -460,7 +459,7 @@ void player::melee_attack( Creature &t, bool allow_special, const matec_id &forc material = "steel"; } } - sfx::generate_melee_sound( pos(), t.pos(), 1, t.is_monster(), material ); + sfx::generate_melee_sound( pos(), t.pos(), true, t.is_monster(), material ); int dam = dealt_dam.total_damage(); // Practice melee and relevant weapon skill (if any) except when using CQB bionic diff --git a/src/mission.cpp b/src/mission.cpp index 782a1576ff7ef..fbbf0f5036601 100644 --- a/src/mission.cpp +++ b/src/mission.cpp @@ -270,13 +270,11 @@ bool mission::is_complete( const int _npc_id ) const const tripoint cur_pos = g->u.global_omt_location(); return ( rl_dist( cur_pos, target ) <= 1 ); } - break; case MGOAL_GO_TO_TYPE: { const auto cur_ter = overmap_buffer.ter( g->u.global_omt_location() ); return is_ot_type( type->target_id.str(), cur_ter ); } - break; case MGOAL_FIND_ITEM: { inventory tmp_inv = u.crafting_inventory(); @@ -338,7 +336,6 @@ bool mission::is_complete( const int _npc_id ) const default: return false; } - return false; } bool mission::has_deadline() const diff --git a/src/mission_companion.cpp b/src/mission_companion.cpp index 0b629f307abe0..5857b52ab07e2 100644 --- a/src/mission_companion.cpp +++ b/src/mission_companion.cpp @@ -1749,7 +1749,7 @@ std::vector talk_function::companion_sort( std::vector available, } struct companion_sort_skill { - companion_sort_skill( std::string skill_tested ) { + companion_sort_skill( const std::string &skill_tested ) { this->skill_tested = skill_tested; } diff --git a/src/mod_manager_ui.cpp b/src/mod_manager_ui.cpp index 98e7b9ddea38c..0f9ba678adc62 100644 --- a/src/mod_manager_ui.cpp +++ b/src/mod_manager_ui.cpp @@ -253,21 +253,16 @@ bool mod_ui::can_shift_down( long selection, const std::vector &active_l std::vector dependents = mm_tree.get_dependents_of_X_as_strings( active_list[selection] ); - int newsel; - int oldsel; - mod_id selstring; - mod_id modstring; - // figure out if we can move down! if( selection == ( int )active_list.size() - 1 ) { // can't move down, don't bother trying return false; } - newsel = selection; - oldsel = selection + 1; + int newsel = selection; + int oldsel = selection + 1; - modstring = active_list[newsel]; - selstring = active_list[oldsel]; + mod_id modstring = active_list[newsel]; + mod_id selstring = active_list[oldsel]; if( modstring->core || std::find( dependents.begin(), dependents.end(), selstring ) != dependents.end() ) { diff --git a/src/monattack.cpp b/src/monattack.cpp index 898a361942ad0..e2327c25c7eb8 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -127,9 +127,7 @@ static const trait_id trait_THRESH_MYCUS( "THRESH_MYCUS" ); // shared utility functions int within_visual_range( monster *z, int max_range ) { - int dist; - - dist = rl_dist( z->pos(), g->u.pos() ); + int dist = rl_dist( z->pos(), g->u.pos() ); if( dist > max_range || !z->sees( g->u ) ) { return -1; // Out of range } diff --git a/src/monfaction.cpp b/src/monfaction.cpp index 2e0d65787071f..00cb6261643eb 100644 --- a/src/monfaction.cpp +++ b/src/monfaction.cpp @@ -222,10 +222,9 @@ void add_to_attitude_map( const std::set< std::string > &keys, mfaction_att_map void monfactions::load_monster_faction( JsonObject &jo ) { // Factions inherit values from their parent factions - this is set during finalization - std::set< std::string > by_mood, neutral, friendly; - by_mood = jo.get_tags( "by_mood" ); - neutral = jo.get_tags( "neutral" ); - friendly = jo.get_tags( "friendly" ); + std::set< std::string > by_mood = jo.get_tags( "by_mood" ); + std::set< std::string > neutral = jo.get_tags( "neutral" ); + std::set< std::string > friendly = jo.get_tags( "friendly" ); // Need to make sure adding new factions won't invalidate our current faction's reference // That +1 is for base faction faction_list.reserve( faction_list.size() + by_mood.size() + neutral.size() + friendly.size() + 1 ); diff --git a/src/monster.cpp b/src/monster.cpp index 8cd9fcdc3e2a0..2a34ac3aa4a44 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -2197,7 +2197,7 @@ void monster::make_ally( const monster &z ) faction = z.faction; } -void monster::add_item( item it ) +void monster::add_item( const item &it ) { inv.push_back( it ); } diff --git a/src/monster.h b/src/monster.h index 82f46e5540232..4008403385745 100644 --- a/src/monster.h +++ b/src/monster.h @@ -369,7 +369,8 @@ class monster : public Creature void make_friendly(); /** Makes this monster an ally of the given monster. */ void make_ally( const monster &z ); - void add_item( item it ); // Add an item to inventory + // Add an item to inventory + void add_item( const item &it ); /** * Makes monster react to heard sound diff --git a/src/morale.cpp b/src/morale.cpp index 1e9ffc5dc808c..29e7c01f738fb 100644 --- a/src/morale.cpp +++ b/src/morale.cpp @@ -24,9 +24,8 @@ static const efftype_id effect_took_prozac_bad( "took_prozac_bad" ); namespace { -static const std::string item_name_placeholder = "%s"; // Used to address an item name -bool is_permanent_morale( const morale_type id ) +bool is_permanent_morale( const morale_type &id ) { static const std::set permanent_morale = {{ MORALE_PERM_OPTIMIST, diff --git a/src/morale.h b/src/morale.h index c5ab1a7e5095e..e4db4c16f5968 100644 --- a/src/morale.h +++ b/src/morale.h @@ -71,7 +71,7 @@ class player_morale { public: morale_point( - morale_type type = MORALE_NULL, + const morale_type &type = MORALE_NULL, const itype *item_type = nullptr, int bonus = 0, int max_bonus = 0, diff --git a/src/newcharacter.cpp b/src/newcharacter.cpp index 59df02ed6c8c8..1a9633ce93414 100644 --- a/src/newcharacter.cpp +++ b/src/newcharacter.cpp @@ -702,7 +702,7 @@ void draw_points( const catacurses::window &w, points_left &points, int netPoint } template -void draw_sorting_indicator( const catacurses::window &w_sorting, input_context ctxt, +void draw_sorting_indicator( const catacurses::window &w_sorting, const input_context &ctxt, Compare sorter ) { auto const sort_order = sorter.sort_by_points ? _( "points" ) : _( "name" ); diff --git a/src/npc.cpp b/src/npc.cpp index 32e58276ab3f6..5e36c6ab0d452 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -301,7 +301,6 @@ void npc::randomize( const npc_class_id &type ) debugmsg( "Invalid NPC class %s", type.c_str() ); myclass = npc_class_id::NULL_ID(); } else if( type.is_null() && !one_in( 5 ) ) { - npc_class_id typetmp; myclass = npc_class::random_common(); } else { myclass = type; diff --git a/src/npcmove.cpp b/src/npcmove.cpp index 0bfe487ea5b08..f1af944f8e321 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -1305,16 +1305,12 @@ double npc::confidence_mult() const switch( rules.aim ) { case AIM_WHEN_CONVENIENT: return emergency() ? 1.5f : 1.0f; - break; case AIM_SPRAY: return 2.0f; - break; case AIM_PRECISE: return emergency() ? 1.0f : 0.75f; - break; case AIM_STRICTLY_PRECISE: return 0.5f; - break; } return 1.0f; diff --git a/src/npctalk.cpp b/src/npctalk.cpp index 75531edd8c13d..031c14fc9b056 100644 --- a/src/npctalk.cpp +++ b/src/npctalk.cpp @@ -1871,7 +1871,7 @@ void talk_response::effect_fun_t::set_change_faction_rep( int rep_change ) }; } -void talk_response::effect_t::set_effect_consequence( effect_fun_t fun, dialogue_consequence con ) +void talk_response::effect_t::set_effect_consequence( const effect_fun_t &fun, dialogue_consequence con ) { effects.push_back( fun ); guaranteed_consequence = std::max( guaranteed_consequence, con ); diff --git a/src/npctrade.h b/src/npctrade.h index d98e3c0bbab5e..a511779cdcd0a 100644 --- a/src/npctrade.h +++ b/src/npctrade.h @@ -1,3 +1,7 @@ +#pragma once +#ifndef NPCTRADE_H +#define NPCTRADE_H + #include "npc.h" #include "itype.h" #include "game.h" @@ -27,3 +31,5 @@ inventory inventory_exchange( inventory &inv, std::vector init_selling( npc &p ); std::vector init_buying( npc &p, player &u ); bool trade( npc &p, int cost, const std::string &deal ); + +#endif diff --git a/src/path_info.cpp b/src/path_info.cpp index 3694994c92cff..cdb0bf672f125 100644 --- a/src/path_info.cpp +++ b/src/path_info.cpp @@ -56,9 +56,7 @@ void PATH_INFO::init_user_dir( const char *ud ) void PATH_INFO::update_pathname( const std::string &name, const std::string &path ) { - std::map::iterator iter; - - iter = FILENAMES.find( name ); + std::map::iterator iter = FILENAMES.find( name ); if( iter != FILENAMES.end() ) { FILENAMES[name] = path; } else { diff --git a/src/player.cpp b/src/player.cpp index 446c71dd13c75..a41dc46d562de 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -210,7 +210,6 @@ static const bionic_id bio_membrane( "bio_membrane" ); static const bionic_id bio_memory( "bio_memory" ); static const bionic_id bio_metabolics( "bio_metabolics" ); static const bionic_id bio_noise( "bio_noise" ); -static const bionic_id bio_ods( "bio_ods" ); static const bionic_id bio_plut_filter( "bio_plut_filter" ); static const bionic_id bio_power_weakness( "bio_power_weakness" ); static const bionic_id bio_purifier( "bio_purifier" ); @@ -256,7 +255,6 @@ static const trait_id trait_CEPH_EYES( "CEPH_EYES" ); static const trait_id trait_CF_HAIR( "CF_HAIR" ); static const trait_id trait_CHAOTIC( "CHAOTIC" ); static const trait_id trait_CHEMIMBALANCE( "CHEMIMBALANCE" ); -static const trait_id trait_CHITIN( "CHITIN" ); static const trait_id trait_CHITIN2( "CHITIN2" ); static const trait_id trait_CHITIN3( "CHITIN3" ); static const trait_id trait_CHITIN_FUR( "CHITIN_FUR" ); @@ -5995,8 +5993,7 @@ void player::suffer() slow_rad += ((tank_plut * 0.1) + (reactor_plut * 0.01)); //begin power generation if (reactor_plut > 0) { - int power_gen; - power_gen = 0; + int power_gen = 0; if (has_bionic( bio_advreactor ) ) { if ((reactor_plut * 0.05) > 2000){ power_gen = 2000; @@ -11216,7 +11213,7 @@ bool player::uncanny_dodge() tripoint player::adjacent_tile() const { std::vector ret; - int dangerous_fields; + int dangerous_fields = 0; for( const tripoint &p : g->m.points_in_radius( pos(), 1 ) ) { if( p == pos() ) { // Don't consider player position diff --git a/src/player.h b/src/player.h index 1126bc4bef14f..5d5a08570f550 100644 --- a/src/player.h +++ b/src/player.h @@ -444,7 +444,7 @@ class player : public Character void ma_ongethit_effects(); /** Returns true if the player has any martial arts buffs attached */ - bool has_mabuff( mabuff_id buff_id ) const; + bool has_mabuff( const mabuff_id &buff_id ) const; /** Returns true if the player has access to the entered martial art */ bool has_martialart( const matype_id &ma_id ) const; /** Adds the entered martial art to the player's list */ diff --git a/src/ranged.cpp b/src/ranged.cpp index edf858520eca0..a31164a86ecd9 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -43,7 +43,6 @@ const skill_id skill_launcher( "launcher" ); const efftype_id effect_on_roof( "on_roof" ); const efftype_id effect_hit_by_player( "hit_by_player" ); -static const trait_id trait_TRIGGERHAPPY( "TRIGGERHAPPY" ); static const trait_id trait_HOLLOW_BONES( "HOLLOW_BONES" ); static const trait_id trait_LIGHT_BONES( "LIGHT_BONES" ); static const trait_id trait_PYROMANIA( "PYROMANIA" ); diff --git a/src/recipe_groups.cpp b/src/recipe_groups.cpp index 9670d52c8aa78..74cad673416e2 100644 --- a/src/recipe_groups.cpp +++ b/src/recipe_groups.cpp @@ -36,8 +36,7 @@ generic_factory recipe_groups_data( "recipe group type", "nam void recipe_group_data::load( JsonObject &jo, const std::string & ) { building_type = jo.get_string( "building_type" ); - JsonArray jsarr; - jsarr = jo.get_array( "recipes" ); + JsonArray jsarr = jo.get_array( "recipes" ); while( jsarr.has_more() ) { JsonObject ordering = jsarr.next_object(); std::string name_id = ordering.get_string( "id" ); diff --git a/src/recipe_groups.h b/src/recipe_groups.h index f23b6dd54cf20..4ba5206b01f5e 100644 --- a/src/recipe_groups.h +++ b/src/recipe_groups.h @@ -1,8 +1,9 @@ -#include "map.h" #pragma once #ifndef RECIPE_GROUPS_H #define RECIPE_GROUPS_H +#include "map.h" + #include class JsonObject; diff --git a/src/scent_map.cpp b/src/scent_map.cpp index e9a6c768ed421..9c1045d0e0e93 100644 --- a/src/scent_map.cpp +++ b/src/scent_map.cpp @@ -193,9 +193,8 @@ void scent_map::update( const tripoint ¢er, map &m ) } else { this_diffusivity = diffusivity / 5; //less air movement for REDUCE_SCENT square } - int temp_scent; // take the old scent and subtract what diffuses out - temp_scent = scent_here * ( 10 * 1000 - squares_used * this_diffusivity ); + int temp_scent = scent_here * ( 10 * 1000 - squares_used * this_diffusivity ); // neighboring walls and reduce_scent squares absorb some scent temp_scent -= scent_here * this_diffusivity * ( 90 - squares_used ) / 5; // we've already summed neighboring scent values in the y direction in the previous diff --git a/src/sdltiles.cpp b/src/sdltiles.cpp index 29eca10b97707..beca8674ef2a9 100644 --- a/src/sdltiles.cpp +++ b/src/sdltiles.cpp @@ -159,7 +159,7 @@ class Font { * Draw character t at (x,y) on the screen, * using (curses) color. */ - virtual void OutputChar(std::string ch, int x, int y, unsigned char color) = 0; + virtual void OutputChar(const std::string &ch, int x, int y, unsigned char color) = 0; virtual void draw_ascii_lines(unsigned char line_id, int drawx, int drawy, int FG) const; bool draw_window( const catacurses::window &win ); bool draw_window( const catacurses::window &win, int offsetx, int offsety ); @@ -183,7 +183,7 @@ class CachedTTFFont : public Font { CachedTTFFont( int w, int h, std::string typeface, int fontsize, bool fontblending ); ~CachedTTFFont() override = default; - virtual void OutputChar(std::string ch, int x, int y, unsigned char color) override; + virtual void OutputChar(const std::string &ch, int x, int y, unsigned char color) override; protected: SDL_Texture_Ptr create_glyph( const std::string &ch, int color ); @@ -219,7 +219,7 @@ class BitmapFont : public Font { BitmapFont( int w, int h, const std::string &path ); ~BitmapFont() override = default; - virtual void OutputChar(std::string ch, int x, int y, unsigned char color) override; + virtual void OutputChar(const std::string &ch, int x, int y, unsigned char color) override; void OutputChar(long t, int x, int y, unsigned char color); virtual void draw_ascii_lines(unsigned char line_id, int drawx, int drawy, int FG) const override; protected: @@ -690,7 +690,7 @@ SDL_Texture_Ptr CachedTTFFont::create_glyph( const std::string &ch, const int co return SDL_Texture_Ptr( SDL_CreateTextureFromSurface( renderer.get(), sglyph.get() ) ); } -void CachedTTFFont::OutputChar(std::string ch, int const x, int const y, unsigned char const color) +void CachedTTFFont::OutputChar(const std::string &ch, int const x, int const y, unsigned char const color) { key_t key {std::move(ch), static_cast(color & 0xf)}; @@ -722,7 +722,7 @@ void CachedTTFFont::OutputChar(std::string ch, int const x, int const y, unsigne #endif } -void BitmapFont::OutputChar(std::string ch, int x, int y, unsigned char color) +void BitmapFont::OutputChar(const std::string &ch, int x, int y, unsigned char color) { int len = ch.length(); const char *s = ch.c_str(); @@ -1408,7 +1408,7 @@ int HandleDPad() * -1 when a ALT+number sequence has been started, * or something that a call to ncurses getch would return. */ -long sdl_keysym_to_curses( SDL_Keysym keysym ) +long sdl_keysym_to_curses( const SDL_Keysym &keysym ) { if( get_option( "DIAG_MOVE_WITH_MODIFIERS" ) ) { @@ -3180,7 +3180,7 @@ input_event input_manager::get_input_event() { else if (inputdelay > 0) { unsigned long starttime=SDL_GetTicks(); - unsigned long endtime; + unsigned long endtime = 0; bool timedout = false; do { @@ -3702,10 +3702,10 @@ Mix_Chunk *do_pitch_shift( Mix_Chunk *s, float pitch ) result->abuf = ( Uint8 * )malloc( result->alen * sizeof( Uint8 ) ); result->volume = s->volume; for( i = 0; i < s_out; i++ ) { - Sint16 lt; - Sint16 rt; - Sint16 lt_out; - Sint16 rt_out; + Sint16 lt = 0; + Sint16 rt = 0; + Sint16 lt_out = 0; + Sint16 rt_out = 0; Sint64 lt_avg = 0; Sint64 rt_avg = 0; Uint32 begin = ( Uint32 )( ( float )i / pitch_real ); diff --git a/src/sounds.h b/src/sounds.h index 923b42744e65c..50e80fc3ea1ce 100644 --- a/src/sounds.h +++ b/src/sounds.h @@ -69,7 +69,7 @@ void play_ambient_variant_sound( const std::string &id, const std::string &varia int duration ); void generate_gun_sound( const player &source, const item &firing ); void generate_melee_sound( const tripoint &source, const tripoint &target, bool hit, - bool targ_mon = 0, const std::string &material = "flesh" ); + bool targ_mon = false, const std::string &material = "flesh" ); void do_hearing_loss( int turns = -1 ); void remove_hearing_loss(); void do_projectile_hit( const Creature &target ); diff --git a/src/string_formatter.h b/src/string_formatter.h index 4ad0fef38239b..15bf0608d5c75 100644 --- a/src/string_formatter.h +++ b/src/string_formatter.h @@ -20,7 +20,7 @@ class string_formatter; [[noreturn]] void throw_error( const string_formatter &, const std::string & ); // wrapper to access string_formatter::temp_buffer before the definition of string_formatter -const char *string_formatter_set_temp_buffer( const string_formatter &, std::string ); +const char *string_formatter_set_temp_buffer( const string_formatter &, const std::string & ); // Handle currently active exception from string_formatter and return it as string std::string handle_string_format_error(); @@ -210,7 +210,7 @@ class string_formatter /// for printing non-strings through "%s". It *only* works because this prints each format /// specifier separately, so the content of @ref temp_buffer is only used once. friend const char *string_formatter_set_temp_buffer( const string_formatter &sf, - std::string text ) { + const std::string &text ) { sf.temp_buffer = text; return sf.temp_buffer.c_str(); } @@ -287,7 +287,6 @@ class string_formatter std::forward( args )... ) ); default: throw_error( "Unsupported format conversion: " + std::string( 1, c ) ); - break; } } diff --git a/src/string_input_popup.cpp b/src/string_input_popup.cpp index bcf0c0f7c257b..e075c848a07b5 100644 --- a/src/string_input_popup.cpp +++ b/src/string_input_popup.cpp @@ -442,7 +442,7 @@ void string_input_popup::edit( int &value ) } } -string_input_popup &string_input_popup::text( std::string value ) +string_input_popup &string_input_popup::text( const std::string &value ) { _text = value; auto u8size = utf8_wrapper( _text ).size(); diff --git a/src/string_input_popup.h b/src/string_input_popup.h index a1906b7ab6557..d2a237a8f34ec 100644 --- a/src/string_input_popup.h +++ b/src/string_input_popup.h @@ -92,7 +92,7 @@ class string_input_popup * It's optional default is an empty string. */ /**@{*/ - string_input_popup &text( std::string value ); + string_input_popup &text( const std::string &value ); const std::string &text() const { return _text; } diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 75ed4d866c276..780edbf2063ec 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1395,7 +1395,7 @@ bool vehicle::merge_rackable_vehicle( vehicle *carry_veh, const std::vector vehicle_part &carried_part = parts.back(); carried_part.mount = carry_map.carry_mount; carried_part.carry_names.push( unique_id ); - carried_part.enabled = 0; + carried_part.enabled = false; carried_part.set_flag( vehicle_part::carried_flag ); parts[ carry_map.rack_part ].set_flag( vehicle_part::carrying_flag ); } diff --git a/src/wcwidth.h b/src/wcwidth.h index f384e3feca3c7..6b84416703b77 100644 --- a/src/wcwidth.h +++ b/src/wcwidth.h @@ -73,7 +73,7 @@ struct interval { static uint32_t bisearch( uint32_t ucs, const struct interval *table, uint32_t max ) { uint32_t min = 0; - uint32_t mid; + uint32_t mid = 0; if( ucs < table[0].first || ucs > table[max].last ) { return 0; diff --git a/src/worldfactory.cpp b/src/worldfactory.cpp index 028934082f7ad..d4206318139e2 100644 --- a/src/worldfactory.cpp +++ b/src/worldfactory.cpp @@ -154,7 +154,7 @@ WORLDPTR worldfactory::make_new_world( bool show_prompt, const std::string &worl iOffsetX ); int curtab = 0; - int lasttab; // give placement memory to menus, sorta. + int lasttab = 0; // give placement memory to menus, sorta. const size_t numtabs = tabs.size(); while( static_cast( curtab ) < numtabs ) { lasttab = curtab; diff --git a/src/worldfactory.h b/src/worldfactory.h index 698102be73652..d4adefe8c89fb 100644 --- a/src/worldfactory.h +++ b/src/worldfactory.h @@ -128,7 +128,6 @@ class worldfactory static void draw_worldgen_tabs( const catacurses::window &win, size_t current ); void show_active_world_mods( const std::vector &world_mods ); - protected: private: std::map all_worlds; diff --git a/tests/map_memory.cpp b/tests/map_memory.cpp index 77856802c3798..6bac5239051ff 100644 --- a/tests/map_memory.cpp +++ b/tests/map_memory.cpp @@ -12,7 +12,7 @@ TEST_CASE( "map_memory_defaults", "[map_memory]" ) map_memory memory; CHECK( memory.get_symbol( p1 ) == 0 ); memorized_terrain_tile default_tile = memory.get_tile( p1 ); - CHECK( default_tile.tile == "" ); + CHECK( default_tile.tile.empty() ); CHECK( default_tile.subtile == 0 ); CHECK( default_tile.rotation == 0 ); } diff --git a/tests/ranged_balance.cpp b/tests/ranged_balance.cpp index 37d2ccb2f966e..63e4d33060808 100644 --- a/tests/ranged_balance.cpp +++ b/tests/ranged_balance.cpp @@ -82,8 +82,8 @@ static void equip_shooter( npc &shooter, const std::vector &apparel std::array accuracy_levels = {{ accuracy_grazing, accuracy_standard, accuracy_goodhit, accuracy_critical, accuracy_headshot }}; -static std::array firing_test( dispersion_sources dispersion, int range, - std::array thresholds ) +static std::array firing_test( const dispersion_sources &dispersion, + int range, const std::array &thresholds ) { std::array firing_stats; bool threshold_within_confidence_interval = false; diff --git a/tests/vehicle_split_test.cpp b/tests/vehicle_split_test.cpp index ddc80e8d9c0fd..7711d8a1199d3 100644 --- a/tests/vehicle_split_test.cpp +++ b/tests/vehicle_split_test.cpp @@ -12,8 +12,7 @@ TEST_CASE( "vehicle_split_section" ) tripoint test_origin( 15, 15, 0 ); g->u.setpos( test_origin ); tripoint vehicle_origin = tripoint( 10, 10, 0 ); - VehicleList vehs; - vehs = g->m.get_vehicles(); + VehicleList vehs = g->m.get_vehicles(); vehicle *veh_ptr; for( auto &vehs_v : vehs ) { veh_ptr = vehs_v.v;