From 0d48dd82a8a96c17bfaa53df4f9b6a9ddbba69e9 Mon Sep 17 00:00:00 2001 From: scarf <greenscarf005@gmail.com> Date: Sun, 8 Oct 2023 19:18:05 +0900 Subject: [PATCH] perf: use `emplace_back` --- src/active_item_cache.cpp | 6 +- src/activity_actor_definitions.h | 2 +- src/activity_handlers.cpp | 2 +- src/activity_item_handling.cpp | 66 +-- src/advanced_inv.cpp | 2 +- src/armor_layers.cpp | 26 +- src/artifact.cpp | 14 +- src/auto_note.cpp | 4 +- src/avatar.cpp | 4 +- src/avatar_action.cpp | 4 +- src/avatar_functions.cpp | 6 +- src/bionics.cpp | 20 +- src/bionics_ui.cpp | 6 +- src/character_display.cpp | 32 +- src/clzones.cpp | 16 +- src/consistency_report.h | 2 +- src/construction.cpp | 4 +- src/crafting.cpp | 2 +- src/crafting_gui.cpp | 10 +- src/creature.cpp | 6 +- src/debug_menu.cpp | 5 +- src/dialogue_win.cpp | 4 +- src/editmap.cpp | 4 +- src/effect.cpp | 50 +- src/event_field_transformations.cpp | 4 +- src/explosion.cpp | 12 +- src/faction_camp.cpp | 18 +- src/field_type.cpp | 4 +- src/game.cpp | 12 +- src/handle_action.cpp | 2 +- src/handle_liquid.cpp | 2 +- src/iexamine.cpp | 22 +- src/inventory_ui.cpp | 6 +- src/item.cpp | 884 ++++++++++++++-------------- src/item_factory.cpp | 12 +- src/iuse.cpp | 28 +- src/iuse_actor.cpp | 18 +- src/iuse_software_lightson.cpp | 6 +- src/iuse_software_minesweeper.cpp | 6 +- src/iuse_software_snake.cpp | 54 +- src/iuse_software_sokoban.cpp | 18 +- src/language.cpp | 2 +- src/lightmap.cpp | 2 +- src/line.cpp | 12 +- src/map_field.cpp | 22 +- src/map_item_stack.cpp | 2 +- src/mapgen.cpp | 52 +- src/melee.cpp | 8 +- src/mission.cpp | 8 +- src/monattack.cpp | 2 +- src/mondeath.cpp | 10 +- src/monexamine.cpp | 6 +- src/mongroup.cpp | 8 +- src/monmove.cpp | 6 +- src/mutation_data.cpp | 4 +- src/newcharacter.cpp | 8 +- src/npc.cpp | 4 +- src/npcmove.cpp | 6 +- src/npctalk.cpp | 4 +- src/options.cpp | 2 +- src/output.cpp | 2 +- src/overmap.cpp | 30 +- src/overmap_location.cpp | 2 +- src/overmapbuffer.cpp | 16 +- src/panels.cpp | 208 +++---- src/pathfinding.cpp | 2 +- src/pixel_minimap.cpp | 2 +- src/player_activity.cpp | 6 +- src/profession.cpp | 2 +- src/ranged.cpp | 2 +- src/recipe.cpp | 18 +- src/safemode_ui.cpp | 21 +- src/sounds.cpp | 10 +- src/string_utils.cpp | 2 +- src/trap.cpp | 2 +- src/veh_type.cpp | 8 +- src/vehicle.cpp | 2 +- src/vehicle_use.cpp | 50 +- src/weather.cpp | 2 +- src/worldfactory.cpp | 10 +- 80 files changed, 985 insertions(+), 985 deletions(-) diff --git a/src/active_item_cache.cpp b/src/active_item_cache.cpp index d7ef2865926e..a1eab77c6812 100644 --- a/src/active_item_cache.cpp +++ b/src/active_item_cache.cpp @@ -46,12 +46,12 @@ void active_item_cache::add( item &it ) return; } if( it.can_revive() ) { - special_items[ special_item_type::corpse ].push_back( it ); + special_items[ special_item_type::corpse ].emplace_back( it ); } if( it.get_use( "explosion" ) ) { - special_items[ special_item_type::explosive ].push_back( it ); + special_items[ special_item_type::explosive ].emplace_back( it ); } - target_list.push_back( it ); + target_list.emplace_back( it ); } bool active_item_cache::empty() const diff --git a/src/activity_actor_definitions.h b/src/activity_actor_definitions.h index 912c05a8a593..89fcc7a6a5eb 100644 --- a/src/activity_actor_definitions.h +++ b/src/activity_actor_definitions.h @@ -329,7 +329,7 @@ class move_items_activity_actor : public activity_actor relative_destination( relative_destination ) { for( item *&it : items ) { - target_items.push_back( it ); + target_items.emplace_back( it ); } } diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index 7092187bcd64..20524954e2ef 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -4469,7 +4469,7 @@ void activity_handlers::fertilize_plot_do_turn( player_activity *act, player *p auto check_fertilizer = [&]( bool ask_user = true ) -> void { if( act->str_values.empty() ) { - act->str_values.push_back( "" ); + act->str_values.emplace_back( "" ); } fertilizer = itype_id( act->str_values[0] ); diff --git a/src/activity_item_handling.cpp b/src/activity_item_handling.cpp index 9f2894e8ee4b..d257830a4376 100644 --- a/src/activity_item_handling.cpp +++ b/src/activity_item_handling.cpp @@ -796,13 +796,13 @@ void wash_activity_actor::finish( player_activity &act, Character &who ) } std::vector<item_comp> comps; - comps.push_back( item_comp( itype_water, required.water ) ); - comps.push_back( item_comp( itype_water_clean, required.water ) ); + comps.emplace_back( itype_water, required.water ); + comps.emplace_back( itype_water_clean, required.water ); who.as_player()->consume_items( comps, 1, is_liquid_crafting_component ); std::vector<item_comp> comps1; - comps1.push_back( item_comp( itype_soap, required.cleanser ) ); - comps1.push_back( item_comp( itype_detergent, required.cleanser ) ); + comps1.emplace_back( itype_soap, required.cleanser ); + comps1.emplace_back( itype_detergent, required.cleanser ); who.as_player()->consume_items( comps1 ); who.add_msg_if_player( m_good, _( "You washed your items." ) ); @@ -976,7 +976,7 @@ static bool vehicle_activity( player &p, const tripoint &src_loc, int vpindex, c // values[7] p.activity->values.push_back( here.getabs( src_loc ).z ); // this would only be used for refilling tasks - p.activity->targets.emplace_back( safe_reference<item>() ); + p.activity->targets.emplace_back( ); p.activity->placement = here.getabs( src_loc ); p.activity_vehicle_part_index = -1; return true; @@ -1736,7 +1736,7 @@ static std::vector<std::tuple<tripoint, itype_id, int>> requirements_map( player continue; } } - requirement_map.push_back( std::make_tuple( point_elem, map_elem.first, map_elem.second ) ); + requirement_map.emplace_back( point_elem, map_elem.first, map_elem.second ); } } // Ok we now have a list of all the items that match the requirements, their points, and a quantity for each one. @@ -1760,8 +1760,8 @@ static std::vector<std::tuple<tripoint, itype_id, int>> requirements_map( player } if( item_quantity >= quantity_required ) { // it's just this spot that can fulfil the requirement on its own - final_map.push_back( std::make_tuple( pos_here, item_here, std::min<int>( quantity_here, - quantity_required ) ) ); + final_map.emplace_back( pos_here, item_here, std::min<int>( quantity_here, + quantity_required ) ); if( quantity_here >= quantity_required ) { line_found = true; break; @@ -1787,10 +1787,10 @@ static std::vector<std::tuple<tripoint, itype_id, int>> requirements_map( player int quantity_here2 = std::get<2>( *it ); if( comp_elem.type == item_here2 ) { if( quantity_here2 >= remainder ) { - final_map.push_back( std::make_tuple( pos_here2, item_here2, remainder ) ); + final_map.emplace_back( pos_here2, item_here2, remainder ); line_found = true; } else { - final_map.push_back( std::make_tuple( pos_here2, item_here2, remainder ) ); + final_map.emplace_back( pos_here2, item_here2, remainder ); remainder -= quantity_here2; } } @@ -1818,8 +1818,8 @@ static std::vector<std::tuple<tripoint, itype_id, int>> requirements_map( player } if( item_quantity >= quantity_required ) { // it's just this spot that can fulfil the requirement on its own - final_map.push_back( std::make_tuple( pos_here, item_here, std::min<int>( quantity_here, - quantity_required ) ) ); + final_map.emplace_back( pos_here, item_here, std::min<int>( quantity_here, + quantity_required ) ); if( quantity_here >= quantity_required ) { line_found = true; break; @@ -1845,10 +1845,10 @@ static std::vector<std::tuple<tripoint, itype_id, int>> requirements_map( player int quantity_here2 = std::get<2>( *it ); if( comp_elem.type == item_here2 ) { if( quantity_here2 >= remainder ) { - final_map.push_back( std::make_tuple( pos_here2, item_here2, remainder ) ); + final_map.emplace_back( pos_here2, item_here2, remainder ); line_found = true; } else { - final_map.push_back( std::make_tuple( pos_here2, item_here2, remainder ) ); + final_map.emplace_back( pos_here2, item_here2, remainder ); remainder -= quantity_here2; } } @@ -1872,7 +1872,7 @@ static std::vector<std::tuple<tripoint, itype_id, int>> requirements_map( player item &test_item = *item::spawn_temporary( item_here, calendar::start_of_cataclysm ); if( test_item.has_quality( tool_qual, qual_level ) ) { // it's just this spot that can fulfil the requirement on its own - final_map.push_back( std::make_tuple( pos_here, item_here, 1 ) ); + final_map.emplace_back( pos_here, item_here, 1 ); line_found = true; break; } @@ -1920,7 +1920,7 @@ static bool construction_activity( player &p, const zone_data * /*zone*/, const for( const std::vector<tool_comp> &it : built_chosen.requirements->get_tools() ) { p.consume_tools( it ); } - p.backlog.push_front( std::make_unique<player_activity>( activity_to_restore ) ); + p.backlog.emplace_front( std::make_unique<player_activity>( activity_to_restore ) ); p.assign_activity( ACT_BUILD ); p.activity->placement = here.getabs( src_loc ); return true; @@ -2249,7 +2249,7 @@ void activity_on_turn_move_loot( player_activity &act, player &p ) continue; } it->set_owner( p ); - items.push_back( std::make_pair( it, true ) ); + items.emplace_back( it, true ); } } else { src_veh = nullptr; @@ -2260,7 +2260,7 @@ void activity_on_turn_move_loot( player_activity &act, player &p ) continue; } it->set_owner( p ); - items.push_back( std::make_pair( it, false ) ); + items.emplace_back( it, false ); } //Skip items that have already been processed @@ -2387,7 +2387,7 @@ static bool mine_activity( player &p, const tripoint &src_loc ) moves /= 2; } p.assign_activity( powered ? ACT_JACKHAMMER : ACT_PICKAXE, moves ); - p.activity->targets.push_back( chosen_item ); + p.activity->targets.emplace_back( chosen_item ); p.activity->placement = here.getabs( src_loc ); return true; @@ -2407,12 +2407,12 @@ static bool chop_tree_activity( player &p, const tripoint &src_loc ) const ter_id ter = here.ter( src_loc ); if( here.has_flag( flag_TREE, src_loc ) ) { p.assign_activity( ACT_CHOP_TREE, moves, -1, p.get_item_position( best_qual ) ); - p.activity->targets.push_back( best_qual ); + p.activity->targets.emplace_back( best_qual ); p.activity->placement = here.getabs( src_loc ); return true; } else if( ter == t_trunk || ter == t_stump ) { p.assign_activity( ACT_CHOP_LOGS, moves, -1, p.get_item_position( best_qual ) ); - p.activity->targets.push_back( best_qual ); + p.activity->targets.emplace_back( best_qual ); p.activity->placement = here.getabs( src_loc ); return true; } @@ -2751,7 +2751,7 @@ static requirement_check_result generic_multi_activity_check_requirement( player return SKIP_LOCATION; } else { if( !check_only ) { - p.backlog.push_front( std::make_unique<player_activity>( act_id ) ); + p.backlog.emplace_front( std::make_unique<player_activity>( act_id ) ); p.assign_activity( ACT_FETCH_REQUIRED ); player_activity &act_prev = *p.backlog.front(); act_prev.str_values.push_back( what_we_need.str() ); @@ -2810,7 +2810,7 @@ static bool generic_multi_activity_do( player &p, const activity_id &act_id, } else if( reason == do_activity_reason::NEEDS_TILLING && here.has_flag( flag_PLOWABLE, src_loc ) && p.has_quality( qual_DIG, 1 ) && !here.has_furn( src_loc ) ) { p.assign_activity( ACT_CHURN, 18000, -1 ); - p.backlog.push_front( std::make_unique<player_activity>( act_id ) ); + p.backlog.emplace_front( std::make_unique<player_activity>( act_id ) ); p.activity->placement = src; return false; } else if( reason == do_activity_reason::NEEDS_PLANTING && @@ -2829,24 +2829,24 @@ static bool generic_multi_activity_do( player &p, const activity_id &act_id, continue; } iexamine::plant_seed( p, src_loc, itype_id( seed ) ); - p.backlog.push_front( std::make_unique<player_activity>( act_id ) ); + p.backlog.emplace_front( std::make_unique<player_activity>( act_id ) ); return false; } } else if( reason == do_activity_reason::NEEDS_CHOPPING && p.has_quality( qual_AXE, 1 ) ) { if( chop_plank_activity( p, src_loc ) ) { - p.backlog.push_front( std::make_unique<player_activity>( act_id ) ); + p.backlog.emplace_front( std::make_unique<player_activity>( act_id ) ); return false; } } else if( reason == do_activity_reason::NEEDS_BUTCHERING || reason == do_activity_reason::NEEDS_BIG_BUTCHERING ) { if( butcher_corpse_activity( p, src_loc, reason ) ) { - p.backlog.push_front( std::make_unique<player_activity>( act_id ) ); + p.backlog.emplace_front( std::make_unique<player_activity>( act_id ) ); return false; } } else if( reason == do_activity_reason::CAN_DO_CONSTRUCTION || reason == do_activity_reason::CAN_DO_PREREQ ) { if( here.partial_con_at( src_loc ) ) { - p.backlog.push_front( std::make_unique<player_activity>( act_id ) ); + p.backlog.emplace_front( std::make_unique<player_activity>( act_id ) ); p.assign_activity( std::make_unique<player_activity>( ACT_BUILD ) ); p.activity->placement = src; return false; @@ -2869,34 +2869,34 @@ static bool generic_multi_activity_do( player &p, const activity_id &act_id, } } else if( reason == do_activity_reason::NEEDS_TREE_CHOPPING && p.has_quality( qual_AXE, 1 ) ) { if( chop_tree_activity( p, src_loc ) ) { - p.backlog.push_front( std::make_unique<player_activity>( act_id ) ); + p.backlog.emplace_front( std::make_unique<player_activity>( act_id ) ); return false; } } else if( reason == do_activity_reason::NEEDS_FISHING && p.has_quality( qual_FISHING, 1 ) ) { - p.backlog.push_front( std::make_unique<player_activity>( act_id ) ); + p.backlog.emplace_front( std::make_unique<player_activity>( act_id ) ); // we don't want to keep repeating the fishing activity, just piggybacking on this functions structure to find requirements. p.activity = std::make_unique<player_activity>(); item *best_rod = p.best_quality_item( qual_FISHING ); p.assign_activity( std::make_unique<player_activity>( ACT_FISH, to_moves<int>( 5_hours ), 0, 0, best_rod->tname() ) ); - p.activity->targets.push_back( best_rod ); + p.activity->targets.emplace_back( best_rod ); p.activity->coord_set = g->get_fishable_locations( ACTIVITY_SEARCH_DISTANCE, src_loc ); return false; } else if( reason == do_activity_reason::NEEDS_MINING ) { // if have enough batteries to continue etc. - p.backlog.push_front( std::make_unique<player_activity>( act_id ) ); + p.backlog.emplace_front( std::make_unique<player_activity>( act_id ) ); if( mine_activity( p, src_loc ) ) { return false; } } else if( reason == do_activity_reason::NEEDS_VEH_DECONST ) { if( vehicle_activity( p, src_loc, p.activity_vehicle_part_index, 'o' ) ) { - p.backlog.push_front( std::make_unique<player_activity>( act_id ) ); + p.backlog.emplace_front( std::make_unique<player_activity>( act_id ) ); return false; } p.activity_vehicle_part_index = -1; } else if( reason == do_activity_reason::NEEDS_VEH_REPAIR ) { if( vehicle_activity( p, src_loc, p.activity_vehicle_part_index, 'r' ) ) { - p.backlog.push_front( std::make_unique<player_activity>( act_id ) ); + p.backlog.emplace_front( std::make_unique<player_activity>( act_id ) ); return false; } p.activity_vehicle_part_index = -1; diff --git a/src/advanced_inv.cpp b/src/advanced_inv.cpp index f6230d9f9871..512b665fd5ef 100644 --- a/src/advanced_inv.cpp +++ b/src/advanced_inv.cpp @@ -607,7 +607,7 @@ void advanced_inventory::recalc_pane( side p ) categories.insert( it.cat ); } for( auto &cat : categories ) { - pane.items.push_back( advanced_inv_listitem( cat ) ); + pane.items.emplace_back( cat ); } } // Finally sort all items (category headers will now be moved to their proper position) diff --git a/src/armor_layers.cpp b/src/armor_layers.cpp index 532a925210b1..cedfedb4a84b 100644 --- a/src/armor_layers.cpp +++ b/src/armor_layers.cpp @@ -328,43 +328,43 @@ std::vector<std::string> clothing_flags_description( const item &worn_item ) std::vector<std::string> description_stack; if( worn_item.has_flag( flag_FIT ) ) { - description_stack.push_back( _( "It fits you well." ) ); + description_stack.emplace_back( _( "It fits you well." ) ); } else if( worn_item.has_flag( flag_VARSIZE ) ) { - description_stack.push_back( _( "It could be refitted." ) ); + description_stack.emplace_back( _( "It could be refitted." ) ); } if( worn_item.has_flag( flag_HOOD ) ) { - description_stack.push_back( _( "It has a hood." ) ); + description_stack.emplace_back( _( "It has a hood." ) ); } if( worn_item.has_flag( flag_POCKETS ) ) { - description_stack.push_back( _( "It has pockets." ) ); + description_stack.emplace_back( _( "It has pockets." ) ); } if( worn_item.has_flag( flag_WATERPROOF ) ) { - description_stack.push_back( _( "It is waterproof." ) ); + description_stack.emplace_back( _( "It is waterproof." ) ); } if( worn_item.has_flag( flag_WATER_FRIENDLY ) ) { - description_stack.push_back( _( "It is water friendly." ) ); + description_stack.emplace_back( _( "It is water friendly." ) ); } if( worn_item.has_flag( flag_FANCY ) ) { - description_stack.push_back( _( "It looks fancy." ) ); + description_stack.emplace_back( _( "It looks fancy." ) ); } if( worn_item.has_flag( flag_SUPER_FANCY ) ) { - description_stack.push_back( _( "It looks really fancy." ) ); + description_stack.emplace_back( _( "It looks really fancy." ) ); } if( worn_item.has_flag( flag_FLOTATION ) ) { - description_stack.push_back( _( "You will not drown today." ) ); + description_stack.emplace_back( _( "You will not drown today." ) ); } if( worn_item.has_flag( flag_OVERSIZE ) ) { - description_stack.push_back( _( "It is very bulky." ) ); + description_stack.emplace_back( _( "It is very bulky." ) ); } if( worn_item.has_flag( flag_SWIM_GOGGLES ) ) { - description_stack.push_back( _( "It helps you to see clearly underwater." ) ); + description_stack.emplace_back( _( "It helps you to see clearly underwater." ) ); } if( worn_item.has_flag( flag_SEMITANGIBLE ) ) { - description_stack.push_back( _( "It can occupy the same space as other things." ) ); + description_stack.emplace_back( _( "It can occupy the same space as other things." ) ); } if( worn_item.has_flag( flag_COMPACT ) ) { - description_stack.push_back( _( "It won't encumber you when worn with other things." ) ); + description_stack.emplace_back( _( "It won't encumber you when worn with other things." ) ); } return description_stack; diff --git a/src/artifact.cpp b/src/artifact.cpp index c3e00c3f915c..222f38eab9b0 100644 --- a/src/artifact.cpp +++ b/src/artifact.cpp @@ -934,7 +934,7 @@ itype_id new_natural_artifact( artifact_natural_property prop ) def.sym = ":"; def.color = c_yellow; - def.materials.push_back( material_id( "stone" ) ); + def.materials.emplace_back( "stone" ); def.volume = rng( shape_data.volume_min, shape_data.volume_max ); def.weight = rng( shape_data.weight_min, shape_data.weight_max ); def.melee[DT_BASH] = 0; @@ -1121,16 +1121,16 @@ void it_artifact_tool::deserialize( const JsonObject &jo ) // quite some time. Loading and saving once will write things out as a JSON // array. if( jo.has_string( "m1" ) ) { - materials.push_back( material_id( jo.get_string( "m1" ) ) ); + materials.emplace_back( jo.get_string( "m1" ) ); } if( jo.has_string( "m2" ) ) { - materials.push_back( material_id( jo.get_string( "m2" ) ) ); + materials.emplace_back( jo.get_string( "m2" ) ); } // Assumption, perhaps dangerous, that we won't wind up with m1 and m2 and // a materials array in our serialized objects at the same time. if( jo.has_array( "materials" ) ) { for( const std::string id : jo.get_array( "materials" ) ) { - materials.push_back( material_id( id ) ); + materials.emplace_back( id ); } } volume = jo.get_int( "volume" ) * units::legacy_volume_factor; @@ -1230,16 +1230,16 @@ void it_artifact_armor::deserialize( const JsonObject &jo ) // quite some time. Loading and saving once will write things out as a JSON // array. if( jo.has_string( "m1" ) ) { - materials.push_back( material_id( jo.get_string( "m1" ) ) ); + materials.emplace_back( jo.get_string( "m1" ) ); } if( jo.has_string( "m2" ) ) { - materials.push_back( material_id( jo.get_string( "m2" ) ) ); + materials.emplace_back( jo.get_string( "m2" ) ); } // Assumption, perhaps dangerous, that we won't wind up with m1 and m2 and // a materials array in our serialized objects at the same time. if( jo.has_array( "materials" ) ) { for( const std::string id : jo.get_array( "materials" ) ) { - materials.push_back( material_id( id ) ); + materials.emplace_back( id ); } } volume = jo.get_int( "volume" ) * units::legacy_volume_factor; diff --git a/src/auto_note.cpp b/src/auto_note.cpp index 0c9f9546c7bb..991ee0d3b6ac 100644 --- a/src/auto_note.cpp +++ b/src/auto_note.cpp @@ -157,8 +157,8 @@ auto_note_manager_gui::auto_note_manager_gui() bool isAutoNoteEnabled = settings.has_auto_note_enabled( extra.id ); - mapExtraCache.emplace( std::make_pair( extra.id, std::make_pair( extra, - isAutoNoteEnabled ) ) ); + mapExtraCache.emplace( extra.id, std::make_pair( extra, + isAutoNoteEnabled ) ); if( settings.was_discovered( extra.id ) ) { displayCache.push_back( extra.id ); diff --git a/src/avatar.cpp b/src/avatar.cpp index a66bda84cd4e..1cca7f7ae0ed 100644 --- a/src/avatar.cpp +++ b/src/avatar.cpp @@ -771,11 +771,11 @@ void avatar::do_read( item *loc ) player *n = g->find_npc( character_id( activity->values[i] ) ); if( n != nullptr ) { const std::string &s = activity->get_str_value( i, "1" ); - learners.push_back( { n, strtod( s.c_str(), nullptr ) } ); + learners.emplace_back( n, strtod( s.c_str(), nullptr ) ); } // Otherwise they must have died/teleported or something } - learners.push_back( { this, 1.0 } ); + learners.emplace_back( this, 1.0 ); //whether to continue reading or not bool continuous = false; // NPCs who learned a little about the skill diff --git a/src/avatar_action.cpp b/src/avatar_action.cpp index 5ef21bc7894d..7f7ea4f01de7 100644 --- a/src/avatar_action.cpp +++ b/src/avatar_action.cpp @@ -1239,7 +1239,7 @@ void avatar_action::reload( item &loc, bool prompt, bool empty ) } else { u.activity->targets.emplace_back( opt.target ); } - u.activity->targets.push_back( opt.ammo ); + u.activity->targets.emplace_back( opt.ammo ); } } @@ -1331,7 +1331,7 @@ void avatar_action::reload_weapon( bool try_everything ) u.assign_activity( std::make_unique<player_activity>( activity_id( "ACT_RELOAD" ), opt.moves(), opt.qty() ) ); u.activity->targets.emplace_back( turret.base() ); - u.activity->targets.push_back( opt.ammo ); + u.activity->targets.emplace_back( opt.ammo ); } return; } diff --git a/src/avatar_functions.cpp b/src/avatar_functions.cpp index 74307c5ed2e9..0784ff993ef5 100644 --- a/src/avatar_functions.cpp +++ b/src/avatar_functions.cpp @@ -324,7 +324,7 @@ void mend_item( avatar &you, item &obj, bool interactive ) you.assign_activity( activity_id( "ACT_MEND_ITEM" ), to_moves<int>( method.time ) ); you.activity->name = opt.fault.str(); you.activity->str_values.emplace_back( method.id ); - you.activity->targets.push_back( &obj ); + you.activity->targets.emplace_back( &obj ); } } @@ -449,8 +449,8 @@ void gunmod_add( avatar &you, item &gun, item &mod ) const int moves = !you.has_trait( trait_DEBUG_HS ) ? mod.type->gunmod->install_time : 0; you.assign_activity( activity_id( "ACT_GUNMOD_ADD" ), moves, -1, 0, tool ); - you.activity->targets.push_back( &gun ); - you.activity->targets.push_back( &mod ); + you.activity->targets.emplace_back( &gun ); + you.activity->targets.emplace_back( &mod ); you.activity->values.push_back( 0 ); // dummy value you.activity->values.push_back( roll ); // chance of success (%) you.activity->values.push_back( risk ); // chance of damage (%) diff --git a/src/bionics.cpp b/src/bionics.cpp index 80bebe7bfc30..4b9b38e73ba7 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -479,7 +479,7 @@ std::vector<std::pair<bionic_id, item *>> find_reloadable_cbms( npc &who ) if( bio.ammo_count > 0 ) { cbm_fake.ammo_set( bio.ammo_loaded, bio.ammo_count ); } - cbm_list.emplace_back( std::make_pair( bio.id, &cbm_fake ) ); + cbm_list.emplace_back( bio.id, &cbm_fake ); } return cbm_list; } @@ -881,7 +881,7 @@ bool Character::activate_bionic( bionic &bio, bool eff_only ) detached_ptr<item> obj; stack.erase( it, &obj ); - affected.emplace_back( std::make_pair( std::move( obj ), p ) ); + affected.emplace_back( std::move( obj ), p ); break; } } @@ -2085,13 +2085,13 @@ bool Character::uninstall_bionic( const bionic_id &b_id, player &installer, bool activity->values.push_back( success ); activity->values.push_back( units::to_kilojoule( b_id->capacity ) ); activity->values.push_back( pl_skill ); - activity->str_values.push_back( "uninstall" ); + activity->str_values.emplace_back( "uninstall" ); activity->str_values.push_back( b_id.str() ); - activity->str_values.push_back( "" ); // installer_name is unused for uninstall + activity->str_values.emplace_back( "" ); // installer_name is unused for uninstall if( autodoc ) { - activity->str_values.push_back( "true" ); + activity->str_values.emplace_back( "true" ); } else { - activity->str_values.push_back( "false" ); + activity->str_values.emplace_back( "false" ); } for( const std::pair<const bodypart_str_id, int> &elem : b_id->occupied_bodyparts ) { add_effect( effect_under_op, difficulty * 20_minutes, elem.first->token, difficulty ); @@ -2352,18 +2352,18 @@ bool Character::install_bionics( const itype &type, player &installer, bool auto activity->values.push_back( success ); activity->values.push_back( units::to_joule( bioid->capacity ) ); activity->values.push_back( pl_skill ); - activity->str_values.push_back( "install" ); + activity->str_values.emplace_back( "install" ); activity->str_values.push_back( bioid.str() ); if( installer.has_trait( trait_PROF_MED ) || installer.has_trait( trait_PROF_AUTODOC ) ) { activity->str_values.push_back( installer.disp_name( true ) ); } else { - activity->str_values.push_back( "NOT_MED" ); + activity->str_values.emplace_back( "NOT_MED" ); } if( autodoc ) { - activity->str_values.push_back( "true" ); + activity->str_values.emplace_back( "true" ); } else { - activity->str_values.push_back( "false" ); + activity->str_values.emplace_back( "false" ); } for( const std::pair<const bodypart_str_id, int> &elem : bioid->occupied_bodyparts ) { add_effect( effect_under_op, difficulty * 20_minutes, elem.first->token, difficulty ); diff --git a/src/bionics_ui.cpp b/src/bionics_ui.cpp index 1df0de1e38f3..83a457bf55f5 100644 --- a/src/bionics_ui.cpp +++ b/src/bionics_ui.cpp @@ -312,14 +312,14 @@ static std::string build_bionic_poweronly_string( const bionic &bio ) bio_data.charge_time ) ); } if( bio_data.has_flag( STATIC( flag_id( "BIONIC_TOGGLED" ) ) ) ) { - properties.push_back( bio.powered ? _( "ON" ) : _( "OFF" ) ); + properties.emplace_back( bio.powered ? _( "ON" ) : _( "OFF" ) ); } if( bio.incapacitated_time > 0_turns ) { - properties.push_back( _( "(incapacitated)" ) ); + properties.emplace_back( _( "(incapacitated)" ) ); } if( !bio.has_flag( flag_SAFE_FUEL_OFF ) && ( !bio.info().fuel_opts.empty() || bio.info().is_remote_fueled ) ) { - properties.push_back( _( "(fuel saving ON)" ) ); + properties.emplace_back( _( "(fuel saving ON)" ) ); } if( bio.is_auto_start_on() && ( !bio.info().fuel_opts.empty() || bio.info().is_remote_fueled ) ) { const std::string label = string_format( _( "(auto start < %d %%)" ), diff --git a/src/character_display.cpp b/src/character_display.cpp index c8756f86accf..a801e4131410 100644 --- a/src/character_display.cpp +++ b/src/character_display.cpp @@ -1079,7 +1079,7 @@ void character_display::disp_info( Character &ch ) if( _effect_it.second.is_removed() || tmp.empty() ) { continue; } - effect_name_and_text.push_back( { tmp, _effect_it.second.disp_desc() } ); + effect_name_and_text.emplace_back( tmp, _effect_it.second.disp_desc() ); } } if( ch.get_perceived_pain() > 0 ) { @@ -1095,7 +1095,7 @@ void character_display::disp_info( Character &ch ) add_if( ppen.intelligence, _( "Intelligence -%d" ) ); add_if( ppen.perception, _( "Perception -%d" ) ); add_if( ppen.speed, _( "Speed -%d %%" ) ); - effect_name_and_text.push_back( { _( "Pain" ), pain_text } ); + effect_name_and_text.emplace_back( _( "Pain" ), pain_text ); } const float bmi = ch.bmi(); @@ -1124,7 +1124,7 @@ void character_display::disp_info( Character &ch ) str_penalty * 50.0f ); } - effect_name_and_text.push_back( { starvation_name, starvation_text } ); + effect_name_and_text.emplace_back( starvation_name, starvation_text ); } if( ( ch.has_trait( trait_id( "TROGLO" ) ) && g->is_in_sunlight( ch.pos() ) && @@ -1132,25 +1132,25 @@ void character_display::disp_info( Character &ch ) ( ch.has_trait( trait_id( "TROGLO2" ) ) && g->is_in_sunlight( ch.pos() ) && get_weather().weather_id->sun_intensity < sun_intensity_type::high ) ) { - effect_name_and_text.push_back( { _( "In Sunlight" ), - _( "The sunlight irritates you.\n" - "Strength - 1; Dexterity - 1; Intelligence - 1; Perception - 1" ) - } ); + effect_name_and_text.emplace_back( _( "In Sunlight" ), + _( "The sunlight irritates you.\n" + "Strength - 1; Dexterity - 1; Intelligence - 1; Perception - 1" ) + ); } else if( ch.has_trait( trait_id( "TROGLO2" ) ) && g->is_in_sunlight( ch.pos() ) ) { - effect_name_and_text.push_back( { _( "In Sunlight" ), - _( "The sunlight irritates you badly.\n" - "Strength - 2; Dexterity - 2; Intelligence - 2; Perception - 2" ) - } ); + effect_name_and_text.emplace_back( _( "In Sunlight" ), + _( "The sunlight irritates you badly.\n" + "Strength - 2; Dexterity - 2; Intelligence - 2; Perception - 2" ) + ); } else if( ch.has_trait( trait_id( "TROGLO3" ) ) && g->is_in_sunlight( ch.pos() ) ) { - effect_name_and_text.push_back( { _( "In Sunlight" ), - _( "The sunlight irritates you terribly.\n" - "Strength - 4; Dexterity - 4; Intelligence - 4; Perception - 4" ) - } ); + effect_name_and_text.emplace_back( _( "In Sunlight" ), + _( "The sunlight irritates you terribly.\n" + "Strength - 4; Dexterity - 4; Intelligence - 4; Perception - 4" ) + ); } for( auto &elem : ch.addictions ) { if( elem.sated < 0_turns && elem.intensity >= MIN_ADDICTION_LEVEL ) { - effect_name_and_text.push_back( { addiction_name( elem ), addiction_text( elem ) } ); + effect_name_and_text.emplace_back( addiction_name( elem ), addiction_text( elem ) ); } } diff --git a/src/clzones.cpp b/src/clzones.cpp index 7e1b64ef1ea0..b7f224844a12 100644 --- a/src/clzones.cpp +++ b/src/clzones.cpp @@ -301,7 +301,7 @@ plot_options::query_seed_result plot_options::query_seed() } } std::vector<seed_tuple> seed_entries = iexamine::get_seed_entries( seed_inv ); - seed_entries.emplace( seed_entries.begin(), seed_tuple( itype_id( "null" ), _( "No seed" ), 0 ) ); + seed_entries.emplace( seed_entries.begin(), itype_id( "null" ), _( "No seed" ), 0 ); int seed_index = iexamine::query_seed( seed_entries ); @@ -358,8 +358,8 @@ std::string loot_options::get_zone_name_suggestion() const std::vector<std::pair<std::string, std::string>> loot_options::get_descriptions() const { std::vector<std::pair<std::string, std::string>> options; - options.emplace_back( std::make_pair( _( "Loot: Custom: " ), - !mark.empty() ? mark : _( "No filter" ) ) ); + options.emplace_back( _( "Loot: Custom: " ), + !mark.empty() ? mark : _( "No filter" ) ); return options; } @@ -421,8 +421,8 @@ std::vector<std::pair<std::string, std::string>> blueprint_options::get_descript { std::vector<std::pair<std::string, std::string>> options = std::vector<std::pair<std::string, std::string>>(); - options.emplace_back( std::make_pair( _( "Construct: " ), - group ? group->name() : _( "No Construction" ) ) ); + options.emplace_back( _( "Construct: " ), + group ? group->name() : _( "No Construction" ) ); return options; } @@ -431,8 +431,8 @@ std::vector<std::pair<std::string, std::string>> plot_options::get_descriptions( { auto options = std::vector<std::pair<std::string, std::string>>(); options.emplace_back( - std::make_pair( _( "Plant seed: " ), - !seed.is_empty() ? item::nname( itype_id( seed ) ) : _( "No seed" ) ) ); + _( "Plant seed: " ), + !seed.is_empty() ? item::nname( itype_id( seed ) ) : _( "No seed" ) ); return options; } @@ -1240,7 +1240,7 @@ void zone_manager::zone_edited( zone_data &zone ) } } //Add it to the list of changed zones - changed_vzones.push_back( std::make_pair( zone_data( zone ), &zone ) ); + changed_vzones.emplace_back( zone_data( zone ), &zone ); } } diff --git a/src/consistency_report.h b/src/consistency_report.h index 3310a55d35d6..3425cd8f8782 100644 --- a/src/consistency_report.h +++ b/src/consistency_report.h @@ -21,7 +21,7 @@ class consistency_report ~consistency_report() = default; void warn( const char *msg ) { - warns.push_back( msg ); + warns.emplace_back( msg ); } void warn( const std::string &msg ) { diff --git a/src/construction.cpp b/src/construction.cpp index b0843eada8f4..1f907e80f6d9 100644 --- a/src/construction.cpp +++ b/src/construction.cpp @@ -593,7 +593,7 @@ std::optional<construction_id> construction_menu( const bool blueprint ) } current_buffer_location += construct_buffers[i].size(); if( i < construct_buffers.size() - 1 ) { - full_construct_buffer.push_back( std::string() ); + full_construct_buffer.emplace_back( ); current_buffer_location++; } } @@ -1773,7 +1773,7 @@ void construction::finalize() if( !vp.has_flag( flag_INITIAL_PART ) ) { continue; } - frame_items.push_back( item_comp( vp.item, 1 ) ); + frame_items.emplace_back( vp.item, 1 ); } if( frame_items.empty() ) { diff --git a/src/crafting.cpp b/src/crafting.cpp index a8f63b7d12a6..6981ffb09082 100644 --- a/src/crafting.cpp +++ b/src/crafting.cpp @@ -754,7 +754,7 @@ item *player::start_craft( craft_command &command, const tripoint & ) set_item_inventory( *this, std::move( craft ) ); assign_activity( ACT_CRAFT ); - activity->targets.push_back( craft_in_world ); + activity->targets.emplace_back( craft_in_world ); activity->coords.push_back( bench.position ); activity->values.push_back( command.is_long() ); // Ugly diff --git a/src/crafting_gui.cpp b/src/crafting_gui.cpp index f65908d19393..ad38959267e3 100644 --- a/src/crafting_gui.cpp +++ b/src/crafting_gui.cpp @@ -435,7 +435,7 @@ const recipe *select_crafting_recipe( int &batch_size ) component_print_buffer.insert( component_print_buffer.end(), comps.begin(), comps.end() ); if( !u.knows_recipe( current[line] ) ) { - component_print_buffer.push_back( _( "Recipe not memorized yet" ) ); + component_print_buffer.emplace_back( _( "Recipe not memorized yet" ) ); auto books_with_recipe = show_unavailable ? crafting::get_books_for_recipe( current[line] ) : crafting::get_books_for_recipe( u, crafting_inv, current[line] ); @@ -629,8 +629,8 @@ const recipe *select_crafting_recipe( int &batch_size ) current.clear(); for( int i = 1; i <= 50; i++ ) { current.push_back( chosen ); - available.push_back( availability( chosen, i, - !show_unavailable || available_recipes.contains( *chosen ) ) ); + available.emplace_back( chosen, i, + !show_unavailable || available_recipes.contains( *chosen ) ); } } else { std::vector<const recipe *> picking; @@ -977,7 +977,7 @@ std::string peek_related_recipe( const recipe *current, const recipe_subset &ava const requirement_data &req = current->simple_requirements(); for( const std::vector<item_comp> &comp_list : req.get_components() ) { for( const item_comp &a : comp_list ) { - related_components.push_back( { a.type, item::nname( a.type, 1 ) } ); + related_components.emplace_back( a.type, item::nname( a.type, 1 ) ); } } std::sort( related_components.begin(), related_components.end(), compare_second ); @@ -993,7 +993,7 @@ std::string peek_related_recipe( const recipe *current, const recipe_subset &ava const std::set<const recipe *> &known_recipes = u.get_learned_recipes().of_component( tid ); for( const auto *b : known_recipes ) { if( available.contains( *b ) ) { - related_results.push_back( { b->result(), b->result_name() } ); + related_results.emplace_back( b->result(), b->result_name() ); } } std::stable_sort( related_results.begin(), related_results.end(), compare_second ); diff --git a/src/creature.cpp b/src/creature.cpp index ab1cd569dc8b..e70935cbbf39 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -1738,7 +1738,7 @@ std::vector<bodypart_id> Creature::get_all_body_parts( bool only_main ) const if( only_main && elem.first->main_part != elem.first ) { continue; } - all_bps.push_back( elem.first ); + all_bps.emplace_back( elem.first ); } return all_bps; @@ -2116,13 +2116,13 @@ void Creature::describe_infrared( std::vector<std::string> &buf ) const size_str = "invalid"; break; } - buf.push_back( _( "You see a figure radiating heat." ) ); + buf.emplace_back( _( "You see a figure radiating heat." ) ); buf.push_back( string_format( _( "It is %s in size." ), size_str ) ); } void Creature::describe_specials( std::vector<std::string> &buf ) const { - buf.push_back( _( "You sense a creature here." ) ); + buf.emplace_back( _( "You sense a creature here." ) ); } effects_map Creature::get_all_effects() const diff --git a/src/debug_menu.cpp b/src/debug_menu.cpp index ee1d04acdf85..8e75e59b15f6 100644 --- a/src/debug_menu.cpp +++ b/src/debug_menu.cpp @@ -338,7 +338,7 @@ static int debug_menu_uilist( bool display_all_entries = true ) menu.insert( menu.begin() + 1, debug_menu.begin(), debug_menu.end() ); if( cata::has_lua() ) { - menu.push_back( uilist_entry( 7, true, 'l', _( "Lua console" ) ) ); + menu.emplace_back( 7, true, 'l', _( "Lua console" ) ); } } @@ -1441,7 +1441,8 @@ void debug() std::vector<std::pair<m_flag, int>> sorted; sorted.reserve( m_flag::MF_MAX ); for( int f = 0; f < m_flag::MF_MAX; f++ ) { - sorted.push_back( {static_cast<m_flag>( f ), MonsterGenerator::generator().m_flag_usage_stats[f]} ); + sorted.emplace_back( static_cast<m_flag>( f ), + MonsterGenerator::generator().m_flag_usage_stats[f] ); } std::sort( sorted.begin(), sorted.end(), []( std::pair<m_flag, int> a, std::pair<m_flag, int> b ) { return a.second != b.second ? a.second > b.second : a.first < b.first; diff --git a/src/dialogue_win.cpp b/src/dialogue_win.cpp index 44a5a036bc0d..c0dfd5e7b2d0 100644 --- a/src/dialogue_win.cpp +++ b/src/dialogue_win.cpp @@ -146,9 +146,9 @@ static void print_keybindings( const catacurses::window &w ) void dialogue_window::cache_msg( const std::string &msg, size_t idx ) { const std::vector<std::string> folded = foldstring( msg, getmaxx( d_win ) / 2 ); - draw_cache.push_back( {"", idx} ); + draw_cache.emplace_back( "", idx ); for( const std::string &fs : folded ) { - draw_cache.push_back( {fs, idx} ); + draw_cache.emplace_back( fs, idx ); } } diff --git a/src/editmap.cpp b/src/editmap.cpp index ee5721a1cff0..e61ef44b5459 100644 --- a/src/editmap.cpp +++ b/src/editmap.cpp @@ -2047,7 +2047,7 @@ void editmap::mapgen_retarget() for( int y = target.y - SEEY + 1; y < target.y + SEEY + 1; y++ ) { if( x == target.x - SEEX + 1 || x == target.x + SEEX || y == target.y - SEEY + 1 || y == target.y + SEEY ) { - target_list.push_back( tripoint( x, y, target.z ) ); + target_list.emplace_back( x, y, target.z ); } } } @@ -2113,7 +2113,7 @@ void editmap::edit_mapgen() for( int y = target.y - SEEY + 1; y < target.y + SEEY + 1; y++ ) { if( x == target.x - SEEX + 1 || x == target.x + SEEX || y == target.y - SEEY + 1 || y == target.y + SEEY ) { - target_list.push_back( tripoint( x, y, target.z ) ); + target_list.emplace_back( x, y, target.z ); } } } diff --git a/src/effect.cpp b/src/effect.cpp index 36557c4ed7a3..b3901271139d 100644 --- a/src/effect.cpp +++ b/src/effect.cpp @@ -513,7 +513,7 @@ bool effect_type::load_miss_msgs( const JsonObject &jo, const std::string &membe { if( jo.has_array( member ) ) { for( JsonArray inner : jo.get_array( member ) ) { - miss_msgs.push_back( std::make_pair( inner.get_string( 0 ), inner.get_int( 1 ) ) ); + miss_msgs.emplace_back( inner.get_string( 0 ), inner.get_int( 1 ) ); } return true; } @@ -537,7 +537,7 @@ bool effect_type::load_decay_msgs( const JsonObject &jo, const std::string &memb } else { rate = m_neutral; } - decay_msgs.push_back( std::make_pair( msg, rate ) ); + decay_msgs.emplace_back( msg, rate ); } return true; } @@ -657,32 +657,32 @@ std::string effect::disp_desc( bool reduced ) const // place to add them. int val = 0; val = get_avg_mod( "PAIN", reduced ); - values.push_back( desc_freq( get_percentage( "PAIN", val, reduced ), val, _( "pain" ), - _( "pain" ) ) ); + values.emplace_back( get_percentage( "PAIN", val, reduced ), val, _( "pain" ), + _( "pain" ) ); val = get_avg_mod( "HURT", reduced ); - values.push_back( desc_freq( get_percentage( "HURT", val, reduced ), val, _( "damage" ), - _( "damage" ) ) ); + values.emplace_back( get_percentage( "HURT", val, reduced ), val, _( "damage" ), + _( "damage" ) ); val = get_avg_mod( "STAMINA", reduced ); - values.push_back( desc_freq( get_percentage( "STAMINA", val, reduced ), val, - _( "stamina recovery" ), _( "fatigue" ) ) ); + values.emplace_back( get_percentage( "STAMINA", val, reduced ), val, + _( "stamina recovery" ), _( "fatigue" ) ); val = get_avg_mod( "THIRST", reduced ); - values.push_back( desc_freq( get_percentage( "THIRST", val, reduced ), val, _( "thirst" ), - _( "quench" ) ) ); + values.emplace_back( get_percentage( "THIRST", val, reduced ), val, _( "thirst" ), + _( "quench" ) ); val = get_avg_mod( "HUNGER", reduced ); - values.push_back( desc_freq( get_percentage( "HUNGER", val, reduced ), val, _( "hunger" ), - _( "sate" ) ) ); + values.emplace_back( get_percentage( "HUNGER", val, reduced ), val, _( "hunger" ), + _( "sate" ) ); val = get_avg_mod( "FATIGUE", reduced ); - values.push_back( desc_freq( get_percentage( "FATIGUE", val, reduced ), val, _( "sleepiness" ), - _( "rest" ) ) ); + values.emplace_back( get_percentage( "FATIGUE", val, reduced ), val, _( "sleepiness" ), + _( "rest" ) ); val = get_avg_mod( "COUGH", reduced ); - values.push_back( desc_freq( get_percentage( "COUGH", val, reduced ), val, _( "coughing" ), - _( "coughing" ) ) ); + values.emplace_back( get_percentage( "COUGH", val, reduced ), val, _( "coughing" ), + _( "coughing" ) ); val = get_avg_mod( "VOMIT", reduced ); - values.push_back( desc_freq( get_percentage( "VOMIT", val, reduced ), val, _( "vomiting" ), - _( "vomiting" ) ) ); + values.emplace_back( get_percentage( "VOMIT", val, reduced ), val, _( "vomiting" ), + _( "vomiting" ) ); val = get_avg_mod( "SLEEP", reduced ); - values.push_back( desc_freq( get_percentage( "SLEEP", val, reduced ), val, _( "blackouts" ), - _( "blackouts" ) ) ); + values.emplace_back( get_percentage( "SLEEP", val, reduced ), val, _( "blackouts" ), + _( "blackouts" ) ); for( auto &i : values ) { if( i.val > 0 ) { @@ -1286,7 +1286,7 @@ void load_effect_type( const JsonObject &jo ) new_etype.desc.push_back( line ); } } else { - new_etype.desc.push_back( "" ); + new_etype.desc.emplace_back( "" ); } if( jo.has_member( "reduced_desc" ) ) { for( const std::string line : jo.get_array( "reduced_desc" ) ) { @@ -1322,16 +1322,16 @@ void load_effect_type( const JsonObject &jo ) new_etype.blood_analysis_description = jo.get_string( "blood_analysis_description", "" ); for( auto &&f : jo.get_string_array( "resist_traits" ) ) { // *NOPAD* - new_etype.resist_traits.push_back( trait_id( f ) ); + new_etype.resist_traits.emplace_back( f ); } for( auto &&f : jo.get_string_array( "resist_effects" ) ) { // *NOPAD* - new_etype.resist_effects.push_back( efftype_id( f ) ); + new_etype.resist_effects.emplace_back( f ); } for( auto &&f : jo.get_string_array( "removes_effects" ) ) { // *NOPAD* - new_etype.removes_effects.push_back( efftype_id( f ) ); + new_etype.removes_effects.emplace_back( f ); } for( auto &&f : jo.get_string_array( "blocks_effects" ) ) { // *NOPAD* - new_etype.blocks_effects.push_back( efftype_id( f ) ); + new_etype.blocks_effects.emplace_back( f ); } if( jo.has_string( "max_duration" ) ) { diff --git a/src/event_field_transformations.cpp b/src/event_field_transformations.cpp index c5eda21d4b00..1336b83e0403 100644 --- a/src/event_field_transformations.cpp +++ b/src/event_field_transformations.cpp @@ -14,7 +14,7 @@ static std::vector<cata_variant> flags_of_terrain( const cata_variant &v ) std::vector<cata_variant> result; result.reserve( flags.size() ); for( const std::string &s : flags ) { - result.push_back( cata_variant( s ) ); + result.emplace_back( s ); } return result; } @@ -41,7 +41,7 @@ static std::vector<cata_variant> species_of_monster( const cata_variant &v ) std::vector<cata_variant> result; result.reserve( species.size() ); for( const species_id &s : species ) { - result.push_back( cata_variant( s ) ); + result.emplace_back( s ); } return result; } diff --git a/src/explosion.cpp b/src/explosion.cpp index 9a491182d4b1..ab707dd6c59c 100644 --- a/src/explosion.cpp +++ b/src/explosion.cpp @@ -403,7 +403,7 @@ class ExplosionProcess inline bool is_occluded( const tripoint from, const tripoint to ); inline void add_event( const float delay, const ExplosionEvent &event ) { assert( delay >= 0 ); - event_queue.push( { cur_relative_time + delay + std::numeric_limits<float>::epsilon(), event } ); + event_queue.emplace( cur_relative_time + delay + std::numeric_limits<float>::epsilon(), event ); } inline bool is_animated() { return !test_mode && get_option<int>( "ANIMATION_DELAY" ) > 0; @@ -453,12 +453,12 @@ void ExplosionProcess::fill_maps() // We static_cast<int> in order to keep parity with legacy blasts using rl_dist for distance // which, as stated above, converts trig_dist into int implicitly if( blast_radius > 0 && static_cast<int>( z_aware_distance ) <= blast_radius ) { - blast_map.push_back( { z_aware_distance, target } ); + blast_map.emplace_back( z_aware_distance, target ); } if( shrapnel && static_cast<int>( distance ) <= shrapnel_range && target.z == center.z && !is_occluded( center, target ) ) { - shrapnel_map.push_back( { distance, target } ); + shrapnel_map.emplace_back( distance, target ); } } @@ -1184,7 +1184,7 @@ static std::map<const Creature *, int> legacy_shrapnel( const tripoint &src, const float z_distance = abs( target.z - blast_center.z ); const float z_aware_distance = distance + ( Z_LEVEL_DIST - 1 ) * z_distance; if( z_aware_distance <= raw_blast_radius ) { - blast_map.emplace_back( std::make_pair( z_aware_distance, target ) ); + blast_map.emplace_back( z_aware_distance, target ); } } @@ -1271,7 +1271,7 @@ static std::map<const Creature *, int> legacy_blast( const tripoint &p, const fl open; std::set<tripoint> closed; std::map<tripoint, float> dist_map; - open.push( std::make_pair( 0.0f, p ) ); + open.emplace( 0.0f, p ); dist_map[p] = 0.0f; // Find all points to blast while( !open.empty() ) { @@ -1326,7 +1326,7 @@ static std::map<const Creature *, int> legacy_blast( const tripoint &p, const fl } if( dist_map.count( dest ) == 0 || dist_map[dest] > next_dist ) { - open.push( std::make_pair( next_dist, dest ) ); + open.emplace( next_dist, dest ); dist_map[dest] = next_dist; } } diff --git a/src/faction_camp.cpp b/src/faction_camp.cpp index 1416efded588..46f5e12fe3f7 100644 --- a/src/faction_camp.cpp +++ b/src/faction_camp.cpp @@ -2830,10 +2830,10 @@ void basecamp::recruit_return( const std::string &task, int score ) description += _( "Select an option:" ); std::vector<std::string> rec_options; - rec_options.push_back( _( "Increase Food" ) ); - rec_options.push_back( _( "Decrease Food" ) ); - rec_options.push_back( _( "Make Offer" ) ); - rec_options.push_back( _( "Not Interested" ) ); + rec_options.emplace_back( _( "Increase Food" ) ); + rec_options.emplace_back( _( "Decrease Food" ) ); + rec_options.emplace_back( _( "Make Offer" ) ); + rec_options.emplace_back( _( "Not Interested" ) ); rec_m = uilist( description, rec_options ); if( rec_m < 0 || rec_m == 3 || static_cast<size_t>( rec_m ) >= rec_options.size() ) { @@ -3385,19 +3385,19 @@ void om_range_mark( const tripoint_abs_omt &origin, int range, bool add_notes, std::vector<tripoint_abs_omt> note_pts; //North Limit for( int x = origin.x() - range; x < origin.x() + range + 1; x++ ) { - note_pts.push_back( tripoint_abs_omt( x, origin.y() - range, origin.z() ) ); + note_pts.emplace_back( x, origin.y() - range, origin.z() ); } //South for( int x = origin.x() - range; x < origin.x() + range + 1; x++ ) { - note_pts.push_back( tripoint_abs_omt( x, origin.y() + range, origin.z() ) ); + note_pts.emplace_back( x, origin.y() + range, origin.z() ); } //West for( int y = origin.y() - range; y < origin.y() + range + 1; y++ ) { - note_pts.push_back( tripoint_abs_omt( origin.x() - range, y, origin.z() ) ); + note_pts.emplace_back( origin.x() - range, y, origin.z() ); } //East for( int y = origin.y() - range; y < origin.y() + range + 1; y++ ) { - note_pts.push_back( tripoint_abs_omt( origin.x() + range, y, origin.z() ) ); + note_pts.emplace_back( origin.x() + range, y, origin.z() ); } for( auto pt : note_pts ) { @@ -3625,7 +3625,7 @@ std::vector<std::pair<std::string, tripoint_abs_omt>> talk_function::om_building std::string om_rnear_id = omt_rnear.id().c_str(); if( !purge || ( om_rnear_id.find( "faction_base_" ) != std::string::npos && om_rnear_id.find( "faction_base_camp" ) == std::string::npos ) ) { - om_camp_region.push_back( std::make_pair( om_rnear_id, omt_near_pos ) ); + om_camp_region.emplace_back( om_rnear_id, omt_near_pos ); } } return om_camp_region; diff --git a/src/field_type.cpp b/src/field_type.cpp index 672f01a0fe0b..90e1baabde0e 100644 --- a/src/field_type.cpp +++ b/src/field_type.cpp @@ -236,8 +236,8 @@ void field_type::load( const JsonObject &jo, const std::string & ) immunity_data_traits.emplace_back( id ); } for( JsonArray jao : jid.get_array( "body_part_env_resistance" ) ) { - immunity_data_body_part_env_resistance.emplace_back( std::make_pair( get_body_part_token( - jao.get_string( 0 ) ), jao.get_int( 1 ) ) ); + immunity_data_body_part_env_resistance.emplace_back( get_body_part_token( + jao.get_string( 0 ) ), jao.get_int( 1 ) ); } optional( jo, was_loaded, "immune_mtypes", immune_mtypes ); optional( jo, was_loaded, "underwater_age_speedup", underwater_age_speedup, 0_turns ); diff --git a/src/game.cpp b/src/game.cpp index fb7216aa09b7..c902ecc19675 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -770,11 +770,11 @@ vehicle *game::place_vehicle_nearby( if( search_types.empty() ) { vehicle veh( id ); if( veh.can_float() ) { - search_types.push_back( "river" ); - search_types.push_back( "lake" ); + search_types.emplace_back( "river" ); + search_types.emplace_back( "lake" ); } else { - search_types.push_back( "field" ); - search_types.push_back( "road" ); + search_types.emplace_back( "field" ); + search_types.emplace_back( "road" ); } } for( const std::string &search_type : search_types ) { @@ -9322,7 +9322,7 @@ point game::place_player( const tripoint &dest_loc ) u.assign_activity( activity_id( "ACT_PULP" ), calendar::INDEFINITELY_LONG, 0 ); u.activity->placement = m.getabs( pos ); u.activity->auto_resume = true; - u.activity->str_values.push_back( "auto_pulp_no_acid" ); + u.activity->str_values.emplace_back( "auto_pulp_no_acid" ); return; } } @@ -12036,7 +12036,7 @@ game::Creature_range::Creature_range( game &game_ref ) : u( &game_ref.u, []( pla const auto &monsters = game_ref.critter_tracker->get_monsters_list(); items.insert( items.end(), monsters.begin(), monsters.end() ); items.insert( items.end(), game_ref.active_npc.begin(), game_ref.active_npc.end() ); - items.push_back( u ); + items.emplace_back( u ); } game::npc_range::npc_range( game &game_ref ) diff --git a/src/handle_action.cpp b/src/handle_action.cpp index 008348161455..01e454c435ac 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -235,7 +235,7 @@ static void generate_weather_anim_frame( const weather_type_id &wtype, weather_p if( m.is_outside( mapp ) && m.get_visibility( lighting, cache ) == VIS_CLEAR && !g->critter_at( mapp, true ) ) { // Suppress if a critter is there - wPrint.vdrops.emplace_back( std::make_pair( iRand.x, iRand.y ) ); + wPrint.vdrops.emplace_back( iRand.x, iRand.y ); } } } diff --git a/src/handle_liquid.cpp b/src/handle_liquid.cpp index 01f669101901..306f3cc09991 100644 --- a/src/handle_liquid.cpp +++ b/src/handle_liquid.cpp @@ -63,7 +63,7 @@ static void serialize_liquid_target( player_activity &act, const vehicle &veh ) static void serialize_liquid_target( player_activity &act, item &container ) { act.values.push_back( LTT_CONTAINER ); - act.targets.push_back( &container ); + act.targets.emplace_back( &container ); } static void serialize_liquid_target( player_activity &act, const tripoint &pos ) diff --git a/src/iexamine.cpp b/src/iexamine.cpp index da7c88690b29..a1e00ee32d59 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -622,7 +622,7 @@ class atm_menu // the next turn. Putting this here makes sure there will be something to be // done next turn. u.assign_activity( ACT_ATM, 0, transfer_all_money ); - u.activity->targets.push_back( dst ); + u.activity->targets.emplace_back( dst ); break; } @@ -1221,7 +1221,7 @@ void iexamine::pit( player &p, const tripoint &examp ) return; } std::vector<item_comp> planks; - planks.push_back( item_comp( itype_2x4, 1 ) ); + planks.emplace_back( itype_2x4, 1 ); map &here = get_map(); if( query_yn( _( "Place a plank over the pit?" ) ) ) { @@ -3464,7 +3464,7 @@ void iexamine::tree_maple( player &p, const tripoint &examp ) } std::vector<item_comp> comps; - comps.push_back( item_comp( itype_tree_spile, 1 ) ); + comps.emplace_back( itype_tree_spile, 1 ); p.consume_items( comps, 1, is_crafting_component ); p.mod_moves( -to_moves<int>( 20_seconds ) ); @@ -4121,7 +4121,7 @@ void iexamine::sign( player &p, const tripoint &examp ) } ); tools.reserve( filter.size() ); for( const item *writing_item : filter ) { - tools.push_back( tool_comp( writing_item->typeId(), 1 ) ); + tools.emplace_back( writing_item->typeId(), 1 ); } if( !tools.empty() ) { @@ -4860,9 +4860,9 @@ void iexamine::autodoc( player &p, const tripoint &examp ) } case 2: { std::vector<std::string> choice_names; - choice_names.push_back( _( "Personality_Override" ) ); + choice_names.emplace_back( _( "Personality_Override" ) ); for( size_t i = 0; i < 6; i++ ) { - choice_names.push_back( _( "C0RR#PTED?D#TA" ) ); + choice_names.emplace_back( _( "C0RR#PTED?D#TA" ) ); } int choice_index = uilist( _( "Choose bionic to uninstall" ), choice_names ); if( choice_index == 0 ) { @@ -4955,7 +4955,7 @@ void iexamine::autodoc( player &p, const tripoint &examp ) } ); for( const item *anesthesia_item : a_filter ) { if( anesthesia_item->ammo_remaining() >= 1 ) { - anesth_kit.push_back( tool_comp( anesthesia_item->typeId(), 1 ) ); + anesth_kit.emplace_back( anesthesia_item->typeId(), 1 ); } } } @@ -5574,7 +5574,7 @@ static void smoker_load_food( player &p, const tripoint &examp, entries.push_back( smokable_item ); } names.push_back( item::nname( smokable_item->typeId(), 1 ) ); - comps.push_back( item_comp( smokable_item->typeId(), count ) ); + comps.emplace_back( smokable_item->typeId(), count ); } } @@ -5623,7 +5623,7 @@ static void smoker_load_food( player &p, const tripoint &examp, // reload comps with chosen items and quantity comps.clear(); - comps.push_back( item_comp( what->typeId(), amount ) ); + comps.emplace_back( what->typeId(), amount ); // select from where to get the items from and place them inv.form_from_map( g->u.pos(), PICKUP_RANGE, &g->u ); @@ -5683,7 +5683,7 @@ static void mill_load_food( player &p, const tripoint &examp, entries.push_back( millable_item ); } names.push_back( item::nname( millable_item->typeId(), 1 ) ); - comps.push_back( item_comp( millable_item->typeId(), count ) ); + comps.emplace_back( millable_item->typeId(), count ); } } @@ -5732,7 +5732,7 @@ static void mill_load_food( player &p, const tripoint &examp, // reload comps with chosen items and quantity comps.clear(); - comps.push_back( item_comp( what->typeId(), amount ) ); + comps.emplace_back( what->typeId(), amount ); // select from where to get the items from and place them inv.form_from_map( g->u.pos(), PICKUP_RANGE, &g->u ); diff --git a/src/inventory_ui.cpp b/src/inventory_ui.cpp index 8426e62b1e44..7bbd39e53975 100644 --- a/src/inventory_ui.cpp +++ b/src/inventory_ui.cpp @@ -2115,10 +2115,10 @@ void inventory_iuse_selector::set_chosen_count( inventory_entry &entry, size_t c entry.get_available_count() ); to_use[it].clear(); if( entry.locations.size() == 1 ) { - to_use[it].push_back( iuse_location{ *entry.locations[0], static_cast<int>( entry.chosen_count ) } ); + to_use[it].emplace_back( *entry.locations[0], static_cast<int>( entry.chosen_count ) ); } else { for( size_t i = 0; i < entry.chosen_count; i++ ) { - to_use[it].push_back( iuse_location{ *entry.locations[i], 1 } ); + to_use[it].emplace_back( *entry.locations[i], 1 ); } } } @@ -2188,7 +2188,7 @@ drop_locations inventory_drop_selector::execute() for( auto &col : get_all_columns() ) { for( const auto &entry : col->get_entries( always_yes ) ) { if( entry->any_item() == drop_pair.first ) { - selected_entries.push_back( std::pair<inventory_entry *, int>( entry, drop_pair.second ) ); + selected_entries.emplace_back( entry, drop_pair.second ); } } } diff --git a/src/item.cpp b/src/item.cpp index a24b79e1ee54..6e57be8ea10d 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -1381,7 +1381,7 @@ void item::validate_ownership() const static void insert_separation_line( std::vector<iteminfo> &info ) { if( info.empty() || info.back().sName != "--" ) { - info.push_back( iteminfo( "DESCRIPTION", "--" ) ); + info.emplace_back( "DESCRIPTION", "--" ); } } @@ -1559,7 +1559,7 @@ void item::basic_info( std::vector<iteminfo> &info, const iteminfo_query *parts, []( const material_type * material ) { return string_format( "<stat>%s</stat>", material->name() ); }, enumeration_conjunction::none ); - info.push_back( iteminfo( "BASE", string_format( _( "Material: %s" ), material_list ) ) ); + info.emplace_back( "BASE", string_format( _( "Material: %s" ), material_list ) ); } } if( parts->test( iteminfo_parts::BASE_VOLUME ) ) { @@ -1570,31 +1570,31 @@ void item::basic_info( std::vector<iteminfo> &info, const iteminfo_query *parts, if( converted_volume_scale != 0 ) { f |= iteminfo::is_three_decimal; } - info.push_back( iteminfo( "BASE", _( "Volume: " ), - string_format( "<num> %s", volume_units_abbr() ), - f, converted_volume ) ); + info.emplace_back( "BASE", _( "Volume: " ), + string_format( "<num> %s", volume_units_abbr() ), + f, converted_volume ); } if( parts->test( iteminfo_parts::BASE_WEIGHT ) ) { - info.push_back( iteminfo( "BASE", space + _( "Weight: " ), - string_format( "<num> %s", weight_units() ), - iteminfo::lower_is_better | iteminfo::is_decimal, - convert_weight( weight() ) * batch ) ); + info.emplace_back( "BASE", space + _( "Weight: " ), + string_format( "<num> %s", weight_units() ), + iteminfo::lower_is_better | iteminfo::is_decimal, + convert_weight( weight() ) * batch ); } if( !owner.is_null() ) { - info.push_back( iteminfo( "BASE", string_format( _( "Owner: %s" ), - _( get_owner_name() ) ) ) ); + info.emplace_back( "BASE", string_format( _( "Owner: %s" ), + _( get_owner_name() ) ) ); } if( parts->test( iteminfo_parts::BASE_CATEGORY ) ) { - info.push_back( iteminfo( "BASE", _( "Category: " ), - "<header>" + get_category().name() + "</header>" ) ); + info.emplace_back( "BASE", _( "Category: " ), + "<header>" + get_category().name() + "</header>" ); } if( !type->weapon_category.empty() && parts->test( iteminfo_parts::WEAPON_CATEGORY ) ) { const std::string weapon_categories = enumerate_as_string( type->weapon_category.begin(), type->weapon_category.end(), [&]( const weapon_category_id & elem ) { return elem->name().translated(); }, enumeration_conjunction::none ); - info.push_back( iteminfo( "BASE", _( "Weapon Category: " ), - "<header>" + weapon_categories + "</header>" ) ); + info.emplace_back( "BASE", _( "Weapon Category: " ), + "<header>" + weapon_categories + "</header>" ); } if( parts->test( iteminfo_parts::DESCRIPTION ) ) { @@ -1604,24 +1604,24 @@ void item::basic_info( std::vector<iteminfo> &info, const iteminfo_query *parts, const std::optional<translation> snippet = SNIPPET.get_snippet_by_id( snip_id ); if( snippet.has_value() ) { // Just use the dynamic description - info.push_back( iteminfo( "DESCRIPTION", snippet.value().translated() ) ); + info.emplace_back( "DESCRIPTION", snippet.value().translated() ); } else if( idescription != item_vars.end() ) { - info.push_back( iteminfo( "DESCRIPTION", idescription->second ) ); + info.emplace_back( "DESCRIPTION", idescription->second ); } else { if( has_flag( flag_MAGIC_FOCUS ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "This item is a <info>magical focus</info>. " - "You can cast spells with it in your hand." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "This item is a <info>magical focus</info>. " + "You can cast spells with it in your hand." ) ); } if( is_craft() ) { const std::string desc = _( "This is an in progress %s. " "It is %d percent complete." ); const int percent_progress = item_counter / 100000; - info.push_back( iteminfo( "DESCRIPTION", string_format( desc, - craft_data_->making->result_name(), - percent_progress ) ) ); + info.emplace_back( "DESCRIPTION", string_format( desc, + craft_data_->making->result_name(), + percent_progress ) ); } else { - info.push_back( iteminfo( "DESCRIPTION", type->description.translated() ) ); + info.emplace_back( "DESCRIPTION", type->description.translated() ); } } insert_separation_line( info ); @@ -1669,52 +1669,52 @@ void item::basic_info( std::vector<iteminfo> &info, const iteminfo_query *parts, } if( has_var( "contained_name" ) && parts->test( iteminfo_parts::BASE_CONTENTS ) ) { - info.push_back( iteminfo( "BASE", string_format( _( "Contains: %s" ), - get_var( "contained_name" ) ) ) ); + info.emplace_back( "BASE", string_format( _( "Contains: %s" ), + get_var( "contained_name" ) ) ); } if( count_by_charges() && !is_food() && !is_medication() && parts->test( iteminfo_parts::BASE_AMOUNT ) ) { - info.push_back( iteminfo( "BASE", _( "Amount: " ), "<num>", iteminfo::no_flags, - charges * batch ) ); + info.emplace_back( "BASE", _( "Amount: " ), "<num>", iteminfo::no_flags, + charges * batch ); } if( debug && parts->test( iteminfo_parts::BASE_DEBUG ) ) { if( g != nullptr ) { - info.push_back( iteminfo( "BASE", string_format( "itype_id: %s", - typeId().c_str() ) ) ); - info.push_back( iteminfo( "BASE", _( "age (hours): " ), "", iteminfo::lower_is_better, - to_hours<int>( age() ) ) ); - info.push_back( iteminfo( "BASE", _( "charges: " ), "", iteminfo::lower_is_better, - charges ) ); - info.push_back( iteminfo( "BASE", _( "damage: " ), "", iteminfo::lower_is_better, - damage_ ) ); - info.push_back( iteminfo( "BASE", _( "active: " ), "", iteminfo::lower_is_better, - active ) ); - info.push_back( iteminfo( "BASE", _( "burn: " ), "", iteminfo::lower_is_better, - burnt ) ); + info.emplace_back( "BASE", string_format( "itype_id: %s", + typeId().c_str() ) ); + info.emplace_back( "BASE", _( "age (hours): " ), "", iteminfo::lower_is_better, + to_hours<int>( age() ) ); + info.emplace_back( "BASE", _( "charges: " ), "", iteminfo::lower_is_better, + charges ); + info.emplace_back( "BASE", _( "damage: " ), "", iteminfo::lower_is_better, + damage_ ); + info.emplace_back( "BASE", _( "active: " ), "", iteminfo::lower_is_better, + active ); + info.emplace_back( "BASE", _( "burn: " ), "", iteminfo::lower_is_better, + burnt ); const std::string tags_listed = enumerate_as_string( item_tags, []( const flag_id & f ) { return f.str(); }, enumeration_conjunction::none ); - info.push_back( iteminfo( "BASE", string_format( _( "tags: %s" ), tags_listed ) ) ); + info.emplace_back( "BASE", string_format( _( "tags: %s" ), tags_listed ) ); for( auto const &imap : item_vars ) { - info.push_back( iteminfo( "BASE", - string_format( _( "item var: %s, %s" ), imap.first, - imap.second ) ) ); + info.emplace_back( "BASE", + string_format( _( "item var: %s, %s" ), imap.first, + imap.second ) ); } const item *food = get_food(); if( food && food->goes_bad() ) { - info.push_back( iteminfo( "BASE", _( "age (turns): " ), - "", iteminfo::lower_is_better, - to_turns<int>( food->age() ) ) ); - info.push_back( iteminfo( "BASE", _( "rot (turns): " ), - "", iteminfo::lower_is_better, - to_turns<int>( food->rot ) ) ); - info.push_back( iteminfo( "BASE", space + _( "max rot (turns): " ), - "", iteminfo::lower_is_better, - to_turns<int>( food->get_shelf_life() ) ) ); - info.push_back( iteminfo( "BASE", _( "last rot: " ), - "", iteminfo::lower_is_better, - to_turn<int>( food->last_rot_check ) ) ); + info.emplace_back( "BASE", _( "age (turns): " ), + "", iteminfo::lower_is_better, + to_turns<int>( food->age() ) ); + info.emplace_back( "BASE", _( "rot (turns): " ), + "", iteminfo::lower_is_better, + to_turns<int>( food->rot ) ); + info.emplace_back( "BASE", space + _( "max rot (turns): " ), + "", iteminfo::lower_is_better, + to_turns<int>( food->get_shelf_life() ) ); + info.emplace_back( "BASE", _( "last rot: " ), + "", iteminfo::lower_is_better, + to_turn<int>( food->last_rot_check ) ); } } } @@ -1725,23 +1725,23 @@ void item::med_info( const item *med_item, std::vector<iteminfo> &info, const it { const cata::value_ptr<islot_comestible> &med_com = med_item->get_comestible(); if( med_com->quench != 0 && parts->test( iteminfo_parts::MED_QUENCH ) ) { - info.push_back( iteminfo( "MED", _( "Quench: " ), med_com->quench ) ); + info.emplace_back( "MED", _( "Quench: " ), med_com->quench ); } if( med_item->get_comestible_fun() != 0 && parts->test( iteminfo_parts::MED_JOY ) ) { - info.push_back( iteminfo( "MED", _( "Enjoyability: " ), - get_avatar().fun_for( *med_item ).first ) ); + info.emplace_back( "MED", _( "Enjoyability: " ), + get_avatar().fun_for( *med_item ).first ); } if( med_com->stim != 0 && parts->test( iteminfo_parts::MED_STIMULATION ) ) { std::string name = string_format( "%s <stat>%s</stat>", _( "Stimulation:" ), med_com->stim > 0 ? _( "Upper" ) : _( "Downer" ) ); - info.push_back( iteminfo( "MED", name ) ); + info.emplace_back( "MED", name ); } if( parts->test( iteminfo_parts::MED_PORTIONS ) ) { - info.push_back( iteminfo( "MED", _( "Portions: " ), - std::abs( static_cast<int>( med_item->charges ) * batch ) ) ); + info.emplace_back( "MED", _( "Portions: " ), + std::abs( static_cast<int>( med_item->charges ) * batch ) ); } if( med_com->addict && parts->test( iteminfo_parts::DESCRIPTION_MED_ADDICTING ) ) { @@ -1780,32 +1780,32 @@ void item::food_info( const item *food_item, std::vector<iteminfo> &info, const std::string space = " "; if( max_nutr.kcal != 0 || food_item->get_comestible()->quench != 0 ) { if( parts->test( iteminfo_parts::FOOD_NUTRITION ) ) { - info.push_back( iteminfo( "FOOD", _( "<bold>Calories (kcal)</bold>: " ), - "", iteminfo::no_newline, min_nutr.kcal ) ); + info.emplace_back( "FOOD", _( "<bold>Calories (kcal)</bold>: " ), + "", iteminfo::no_newline, min_nutr.kcal ); if( max_nutr.kcal != min_nutr.kcal ) { - info.push_back( iteminfo( "FOOD", _( "-" ), - "", iteminfo::no_newline, max_nutr.kcal ) ); + info.emplace_back( "FOOD", _( "-" ), + "", iteminfo::no_newline, max_nutr.kcal ); } } if( parts->test( iteminfo_parts::FOOD_QUENCH ) ) { - info.push_back( iteminfo( "FOOD", space + _( "Quench: " ), - food_item->get_comestible()->quench ) ); + info.emplace_back( "FOOD", space + _( "Quench: " ), + food_item->get_comestible()->quench ); } } const std::pair<int, int> fun_for_food_item = you.fun_for( *food_item ); if( fun_for_food_item.first != 0 && parts->test( iteminfo_parts::FOOD_JOY ) ) { - info.push_back( iteminfo( "FOOD", _( "Enjoyability: " ), fun_for_food_item.first ) ); + info.emplace_back( "FOOD", _( "Enjoyability: " ), fun_for_food_item.first ); } if( parts->test( iteminfo_parts::FOOD_PORTIONS ) ) { - info.push_back( iteminfo( "FOOD", _( "Portions: " ), - std::abs( static_cast<int>( food_item->charges ) * batch ) ) ); + info.emplace_back( "FOOD", _( "Portions: " ), + std::abs( static_cast<int>( food_item->charges ) * batch ) ); } if( food_item->corpse != nullptr && parts->test( iteminfo_parts::FOOD_SMELL ) && ( debug || ( g != nullptr && ( you.has_trait( trait_CARNIVORE ) || you.has_artifact_with( AEP_SUPER_CLAIRVOYANCE ) ) ) ) ) { - info.push_back( iteminfo( "FOOD", _( "Smells like: " ) + food_item->corpse->nname() ) ); + info.emplace_back( "FOOD", _( "Smells like: " ) + food_item->corpse->nname() ); } auto format_vitamin = [&]( const std::pair<vitamin_id, int> &v, bool display_vitamins ) { @@ -1942,19 +1942,19 @@ void item::food_info( const item *food_item, std::vector<iteminfo> &info, } if( food_item->rotten() ) { if( you.has_bionic( bio_digestion ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "This food has started to <neutral>rot</neutral>, " - "but <info>your bionic digestion can tolerate " - "it</info>." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "This food has started to <neutral>rot</neutral>, " + "but <info>your bionic digestion can tolerate " + "it</info>." ) ); } else if( you.has_trait( trait_SAPROVORE ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "This food has started to <neutral>rot</neutral>, " - "but <info>you can tolerate it</info>." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "This food has started to <neutral>rot</neutral>, " + "but <info>you can tolerate it</info>." ) ); } else { - info.push_back( iteminfo( "DESCRIPTION", - _( "This food has started to <bad>rot</bad>. " - "<info>Eating</info> it would be a <bad>very bad " - "idea</bad>." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "This food has started to <bad>rot</bad>. " + "<info>Eating</info> it would be a <bad>very bad " + "idea</bad>." ) ); } } } @@ -2142,8 +2142,8 @@ void item::gun_info( const item *mod, std::vector<iteminfo> &info, const iteminf if( parts->test( iteminfo_parts::GUN_DAMAGE ) ) { insert_separation_line( info ); - info.push_back( iteminfo( "GUN", _( "<bold>Ranged damage</bold>: " ), "", iteminfo::no_newline, - gun_du.amount ) ); + info.emplace_back( "GUN", _( "<bold>Ranged damage</bold>: " ), "", iteminfo::no_newline, + gun_du.amount ); } if( mod->ammo_required() ) { @@ -2151,16 +2151,16 @@ void item::gun_info( const item *mod, std::vector<iteminfo> &info, const iteminf if( parts->test( iteminfo_parts::GUN_DAMAGE_LOADEDAMMO ) ) { assert( curammo ); // Appease clang-tidy damage_instance ammo_dam = curammo->ammo->damage; - info.push_back( iteminfo( "GUN", "ammo_damage", "", - iteminfo::no_newline | iteminfo::no_name | - iteminfo::show_plus, ammo_du.amount ) ); + info.emplace_back( "GUN", "ammo_damage", "", + iteminfo::no_newline | iteminfo::no_name | + iteminfo::show_plus, ammo_du.amount ); } if( parts->test( iteminfo_parts::GUN_DAMAGE_TOTAL ) ) { // Intentionally not using total_damage() as it applies multipliers - info.push_back( iteminfo( "GUN", "sum_of_damage", _( " = <num>" ), - iteminfo::no_newline | iteminfo::no_name, - gun_du.amount + ammo_du.amount ) ); + info.emplace_back( "GUN", "sum_of_damage", _( " = <num>" ), + iteminfo::no_newline | iteminfo::no_name, + gun_du.amount + ammo_du.amount ); } } info.back().bNewLine = true; @@ -2173,88 +2173,88 @@ void item::gun_info( const item *mod, std::vector<iteminfo> &info, const iteminf // TODO: This doesn't cover multiple damage types if( parts->test( iteminfo_parts::GUN_ARMORPIERCE ) ) { - info.push_back( iteminfo( "GUN", _( "Armor-pierce: " ), "", - iteminfo::no_newline, get_ranged_pierce( gun ) ) ); + info.emplace_back( "GUN", _( "Armor-pierce: " ), "", + iteminfo::no_newline, get_ranged_pierce( gun ) ); } if( mod->ammo_required() ) { assert( curammo ); // Appease clang-tidy int ammo_pierce = get_ranged_pierce( *curammo->ammo ); // ammo_armor_pierce and sum_of_armor_pierce don't need to translate. if( parts->test( iteminfo_parts::GUN_ARMORPIERCE_LOADEDAMMO ) ) { - info.push_back( iteminfo( "GUN", "ammo_armor_pierce", "", - iteminfo::no_newline | iteminfo::no_name | - iteminfo::show_plus, ammo_pierce ) ); + info.emplace_back( "GUN", "ammo_armor_pierce", "", + iteminfo::no_newline | iteminfo::no_name | + iteminfo::show_plus, ammo_pierce ); } if( parts->test( iteminfo_parts::GUN_ARMORPIERCE_TOTAL ) ) { - info.push_back( iteminfo( "GUN", "sum_of_armor_pierce", _( " = <num>" ), - iteminfo::no_name, - get_ranged_pierce( gun ) + ammo_pierce ) ); + info.emplace_back( "GUN", "sum_of_armor_pierce", _( " = <num>" ), + iteminfo::no_name, + get_ranged_pierce( gun ) + ammo_pierce ); } } info.back().bNewLine = true; if( parts->test( iteminfo_parts::GUN_DAMAGEMULT ) ) { - info.push_back( iteminfo( "GUN", _( "Damage multiplier: " ), "", - iteminfo::no_newline | iteminfo::is_decimal, - gun_du.damage_multiplier ) ); + info.emplace_back( "GUN", _( "Damage multiplier: " ), "", + iteminfo::no_newline | iteminfo::is_decimal, + gun_du.damage_multiplier ); } if( mod->ammo_required() ) { if( parts->test( iteminfo_parts::GUN_DAMAGEMULT_AMMO ) ) { - info.push_back( iteminfo( "GUN", "ammo_mult", "*", - iteminfo::no_newline | iteminfo::no_name | iteminfo::is_decimal, - ammo_du.damage_multiplier ) ); + info.emplace_back( "GUN", "ammo_mult", "*", + iteminfo::no_newline | iteminfo::no_name | iteminfo::is_decimal, + ammo_du.damage_multiplier ); } if( parts->test( iteminfo_parts::GUN_DAMAGEMULT_TOTAL ) ) { - info.push_back( iteminfo( "GUN", "sum_of_damage", _( " = <num>" ), - iteminfo::no_newline | iteminfo::no_name | iteminfo::is_decimal, - gun_du.damage_multiplier * ammo_du.damage_multiplier ) ); + info.emplace_back( "GUN", "sum_of_damage", _( " = <num>" ), + iteminfo::no_newline | iteminfo::no_name | iteminfo::is_decimal, + gun_du.damage_multiplier * ammo_du.damage_multiplier ); } } info.back().bNewLine = true; if( parts->test( iteminfo_parts::GUN_ARMORMULT ) ) { - info.push_back( iteminfo( "GUN", _( "Armor multiplier: " ), "", - iteminfo::no_newline | iteminfo::lower_is_better | iteminfo::is_decimal, - gun_du.res_mult ) ); + info.emplace_back( "GUN", _( "Armor multiplier: " ), "", + iteminfo::no_newline | iteminfo::lower_is_better | iteminfo::is_decimal, + gun_du.res_mult ); } if( mod->ammo_required() ) { if( parts->test( iteminfo_parts::GUN_ARMORMULT_LOADEDAMMO ) ) { - info.push_back( iteminfo( "GUN", "ammo_armor_mult", _( "*<num>" ), - iteminfo::no_newline | iteminfo::no_name | - iteminfo::lower_is_better | iteminfo::is_decimal, - ammo_du.res_mult ) ); + info.emplace_back( "GUN", "ammo_armor_mult", _( "*<num>" ), + iteminfo::no_newline | iteminfo::no_name | + iteminfo::lower_is_better | iteminfo::is_decimal, + ammo_du.res_mult ); } if( parts->test( iteminfo_parts::GUN_ARMORMULT_TOTAL ) ) { - info.push_back( iteminfo( "GUN", "final_armor_mult", _( " = <num>" ), - iteminfo::no_name | iteminfo::lower_is_better | iteminfo::is_decimal, - gun_du.res_mult * ammo_du.res_mult ) ); + info.emplace_back( "GUN", "final_armor_mult", _( " = <num>" ), + iteminfo::no_name | iteminfo::lower_is_better | iteminfo::is_decimal, + gun_du.res_mult * ammo_du.res_mult ); } } info.back().bNewLine = true; if( parts->test( iteminfo_parts::GUN_DISPERSION ) ) { - info.push_back( iteminfo( "GUN", _( "Dispersion: " ), "", - iteminfo::no_newline | iteminfo::lower_is_better, - mod->gun_dispersion( false, false ) ) ); + info.emplace_back( "GUN", _( "Dispersion: " ), "", + iteminfo::no_newline | iteminfo::lower_is_better, + mod->gun_dispersion( false, false ) ); } if( mod->ammo_required() ) { int ammo_dispersion = curammo->ammo->dispersion; // ammo_dispersion and sum_of_dispersion don't need to translate. if( parts->test( iteminfo_parts::GUN_DISPERSION_LOADEDAMMO ) ) { - info.push_back( iteminfo( "GUN", "ammo_dispersion", "", - iteminfo::no_newline | iteminfo::lower_is_better | - iteminfo::no_name | iteminfo::show_plus, - ammo_dispersion ) ); + info.emplace_back( "GUN", "ammo_dispersion", "", + iteminfo::no_newline | iteminfo::lower_is_better | + iteminfo::no_name | iteminfo::show_plus, + ammo_dispersion ); } if( parts->test( iteminfo_parts::GUN_DISPERSION_TOTAL ) ) { - info.push_back( iteminfo( "GUN", "sum_of_dispersion", _( " = <num>" ), - iteminfo::lower_is_better | iteminfo::no_name | iteminfo::no_newline, - loaded_mod->gun_dispersion( true, false ) ) ); - info.push_back( iteminfo( "GUN", "eff_dispersion", _( " (effective: <num>)" ), - iteminfo::lower_is_better | iteminfo::no_name, - static_cast<int>( ranged::get_weapon_dispersion( you, *this ).max() ) ) ); + info.emplace_back( "GUN", "sum_of_dispersion", _( " = <num>" ), + iteminfo::lower_is_better | iteminfo::no_name | iteminfo::no_newline, + loaded_mod->gun_dispersion( true, false ) ); + info.emplace_back( "GUN", "eff_dispersion", _( " (effective: <num>)" ), + iteminfo::lower_is_better | iteminfo::no_name, + static_cast<int>( ranged::get_weapon_dispersion( you, *this ).max() ) ); } } info.back().bNewLine = true; @@ -2265,17 +2265,17 @@ void item::gun_info( const item *mod, std::vector<iteminfo> &info, const iteminf int adj_disp = eff_disp - act_disp; if( parts->test( iteminfo_parts::GUN_DISPERSION_SIGHT ) ) { - info.push_back( iteminfo( "GUN", _( "Sight dispersion: " ), "", - iteminfo::no_newline | iteminfo::lower_is_better, - act_disp ) ); + info.emplace_back( "GUN", _( "Sight dispersion: " ), "", + iteminfo::no_newline | iteminfo::lower_is_better, + act_disp ); if( adj_disp ) { - info.push_back( iteminfo( "GUN", "sight_adj_disp", "", - iteminfo::no_newline | iteminfo::lower_is_better | - iteminfo::no_name | iteminfo::show_plus, adj_disp ) ); - info.push_back( iteminfo( "GUN", "sight_eff_disp", _( " = <num>" ), - iteminfo::lower_is_better | iteminfo::no_name, - eff_disp ) ); + info.emplace_back( "GUN", "sight_adj_disp", "", + iteminfo::no_newline | iteminfo::lower_is_better | + iteminfo::no_name | iteminfo::show_plus, adj_disp ); + info.emplace_back( "GUN", "sight_eff_disp", _( " = <num>" ), + iteminfo::lower_is_better | iteminfo::no_name, + eff_disp ); } } @@ -2333,8 +2333,8 @@ void item::gun_info( const item *mod, std::vector<iteminfo> &info, const iteminf } if( parts->test( iteminfo_parts::GUN_USEDSKILL ) ) { - info.push_back( iteminfo( "GUN", _( "Skill used: " ), - "<info>" + skill.name() + "</info>" ) ); + info.emplace_back( "GUN", _( "Skill used: " ), + "<info>" + skill.name() + "</info>" ); } if( mod->magazine_integral() || mod->magazine_current() ) { @@ -2448,7 +2448,7 @@ void item::gun_info( const item *mod, std::vector<iteminfo> &info, const iteminf iternum++; } mod_str += "."; - info.push_back( iteminfo( "DESCRIPTION", mod_str ) ); + info.emplace_back( "DESCRIPTION", mod_str ); } if( mod->casings_count() && parts->test( iteminfo_parts::DESCRIPTION_GUN_CASINGS ) ) { @@ -2468,37 +2468,37 @@ void item::gunmod_info( std::vector<iteminfo> &info, const iteminfo_query *parts const islot_gunmod &mod = *type->gunmod; if( is_gun() && parts->test( iteminfo_parts::DESCRIPTION_GUNMOD ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "This mod <info>must be attached to a gun</info>, " - "it can not be fired separately." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "This mod <info>must be attached to a gun</info>, " + "it can not be fired separately." ) ); } if( has_flag( flag_REACH_ATTACK ) && parts->test( iteminfo_parts::DESCRIPTION_GUNMOD_REACH ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "When attached to a gun, <good>allows</good> making " - "<info>reach melee attacks</info> with it." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "When attached to a gun, <good>allows</good> making " + "<info>reach melee attacks</info> with it." ) ); } if( mod.dispersion != 0 && parts->test( iteminfo_parts::GUNMOD_DISPERSION ) ) { - info.push_back( iteminfo( "GUNMOD", _( "Dispersion modifier: " ), "", - iteminfo::lower_is_better | iteminfo::show_plus, - mod.dispersion ) ); + info.emplace_back( "GUNMOD", _( "Dispersion modifier: " ), "", + iteminfo::lower_is_better | iteminfo::show_plus, + mod.dispersion ); } if( mod.sight_dispersion != -1 && parts->test( iteminfo_parts::GUNMOD_DISPERSION_SIGHT ) ) { - info.push_back( iteminfo( "GUNMOD", _( "Sight dispersion: " ), "", - iteminfo::lower_is_better, mod.sight_dispersion ) ); + info.emplace_back( "GUNMOD", _( "Sight dispersion: " ), "", + iteminfo::lower_is_better, mod.sight_dispersion ); } if( mod.aim_speed >= 0 && parts->test( iteminfo_parts::GUNMOD_AIMSPEED ) ) { - info.push_back( iteminfo( "GUNMOD", _( "Aim speed: " ), "", - iteminfo::lower_is_better, mod.aim_speed ) ); + info.emplace_back( "GUNMOD", _( "Aim speed: " ), "", + iteminfo::lower_is_better, mod.aim_speed ); } int total_damage = static_cast<int>( mod.damage.total_damage() ); if( total_damage != 0 && parts->test( iteminfo_parts::GUNMOD_DAMAGE ) ) { - info.push_back( iteminfo( "GUNMOD", _( "Damage: " ), "", iteminfo::show_plus, - total_damage ) ); + info.emplace_back( "GUNMOD", _( "Damage: " ), "", iteminfo::show_plus, + total_damage ); } int pierce = get_ranged_pierce( mod ); if( get_ranged_pierce( mod ) != 0 && parts->test( iteminfo_parts::GUNMOD_ARMORPIERCE ) ) { - info.push_back( iteminfo( "GUNMOD", _( "Armor-pierce: " ), "", iteminfo::show_plus, - pierce ) ); + info.emplace_back( "GUNMOD", _( "Armor-pierce: " ), "", iteminfo::show_plus, + pierce ); } if( mod.handling != 0 && parts->test( iteminfo_parts::GUNMOD_HANDLING ) ) { info.emplace_back( "GUNMOD", _( "Handling modifier: " ), "", @@ -2506,8 +2506,8 @@ void item::gunmod_info( std::vector<iteminfo> &info, const iteminfo_query *parts } if( !type->mod->ammo_modifier.empty() && parts->test( iteminfo_parts::GUNMOD_AMMO ) ) { for( const ammotype &at : type->mod->ammo_modifier ) { - info.push_back( iteminfo( "GUNMOD", string_format( _( "Ammo: <stat>%s</stat>" ), - at->name() ) ) ); + info.emplace_back( "GUNMOD", string_format( _( "Ammo: <stat>%s</stat>" ), + at->name() ) ); } } if( mod.reload_modifier != 0 && parts->test( iteminfo_parts::GUNMOD_RELOAD ) ) { @@ -2515,8 +2515,8 @@ void item::gunmod_info( std::vector<iteminfo> &info, const iteminfo_query *parts iteminfo::lower_is_better, mod.reload_modifier ); } if( mod.min_str_required_mod > 0 && parts->test( iteminfo_parts::GUNMOD_STRENGTH ) ) { - info.push_back( iteminfo( "GUNMOD", _( "Minimum strength required modifier: " ), - mod.min_str_required_mod ) ); + info.emplace_back( "GUNMOD", _( "Minimum strength required modifier: " ), + mod.min_str_required_mod ); } if( !mod.add_mod.empty() && parts->test( iteminfo_parts::GUNMOD_ADD_MOD ) ) { insert_separation_line( info ); @@ -2534,7 +2534,7 @@ void item::gunmod_info( std::vector<iteminfo> &info, const iteminfo_query *parts iternum++; } mod_loc_str += "."; - info.push_back( iteminfo( "GUNMOD", mod_loc_str ) ); + info.emplace_back( "GUNMOD", mod_loc_str ); } insert_separation_line( info ); @@ -2562,12 +2562,12 @@ void item::gunmod_info( std::vector<iteminfo> &info, const iteminfo_query *parts used_on_str += enumerate_as_string( combination, enumeration_conjunction::or_ ); } - info.push_back( iteminfo( "GUNMOD", used_on_str ) ); + info.emplace_back( "GUNMOD", used_on_str ); } if( parts->test( iteminfo_parts::GUNMOD_LOCATION ) ) { - info.push_back( iteminfo( "GUNMOD", string_format( _( "Location: %s" ), - mod.location.name() ) ) ); + info.emplace_back( "GUNMOD", string_format( _( "Location: %s" ), + mod.location.name() ) ); } if( !mod.blacklist_mod.empty() && parts->test( iteminfo_parts::GUNMOD_BLACKLIST_MOD ) ) { @@ -2582,7 +2582,7 @@ void item::gunmod_info( std::vector<iteminfo> &info, const iteminfo_query *parts iternum++; } mod_black_str += "."; - info.push_back( iteminfo( "GUNMOD", mod_black_str ) ); + info.emplace_back( "GUNMOD", mod_black_str ); } } @@ -2597,34 +2597,34 @@ void item::armor_protection_info( std::vector<iteminfo> &info, const iteminfo_qu const std::string space = " "; if( parts->test( iteminfo_parts::ARMOR_PROTECTION ) ) { - info.push_back( iteminfo( "ARMOR", _( "<bold>Protection</bold>: Bash: " ), "", - iteminfo::no_newline, bash_resist() ) ); - info.push_back( iteminfo( "ARMOR", space + _( "Cut: " ), "", iteminfo::no_newline, cut_resist() ) ); - info.push_back( iteminfo( "ARMOR", space + _( "Ballistic: " ), bullet_resist() ) ); - info.push_back( iteminfo( "ARMOR", space + _( "Acid: " ), "", - iteminfo::no_newline, acid_resist() ) ); - info.push_back( iteminfo( "ARMOR", space + _( "Fire: " ), "", - iteminfo::no_newline, fire_resist() ) ); - info.push_back( iteminfo( "ARMOR", space + _( "Environmental: " ), - get_base_env_resist( *this ) ) ); + info.emplace_back( "ARMOR", _( "<bold>Protection</bold>: Bash: " ), "", + iteminfo::no_newline, bash_resist() ); + info.emplace_back( "ARMOR", space + _( "Cut: " ), "", iteminfo::no_newline, cut_resist() ); + info.emplace_back( "ARMOR", space + _( "Ballistic: " ), bullet_resist() ); + info.emplace_back( "ARMOR", space + _( "Acid: " ), "", + iteminfo::no_newline, acid_resist() ); + info.emplace_back( "ARMOR", space + _( "Fire: " ), "", + iteminfo::no_newline, fire_resist() ); + info.emplace_back( "ARMOR", space + _( "Environmental: " ), + get_base_env_resist( *this ) ); if( type->can_use( "GASMASK" ) || type->can_use( "DIVE_TANK" ) ) { - info.push_back( iteminfo( "ARMOR", - _( "<bold>Protection when active</bold>: " ) ) ); - info.push_back( iteminfo( "ARMOR", space + _( "Acid: " ), "", - iteminfo::no_newline, - acid_resist( false, get_base_env_resist_w_filter() ) ) ); - info.push_back( iteminfo( "ARMOR", space + _( "Fire: " ), "", - iteminfo::no_newline, - fire_resist( false, get_base_env_resist_w_filter() ) ) ); - info.push_back( iteminfo( "ARMOR", space + _( "Environmental: " ), - get_env_resist( get_base_env_resist_w_filter() ) ) ); + info.emplace_back( "ARMOR", + _( "<bold>Protection when active</bold>: " ) ); + info.emplace_back( "ARMOR", space + _( "Acid: " ), "", + iteminfo::no_newline, + acid_resist( false, get_base_env_resist_w_filter() ) ); + info.emplace_back( "ARMOR", space + _( "Fire: " ), "", + iteminfo::no_newline, + fire_resist( false, get_base_env_resist_w_filter() ) ); + info.emplace_back( "ARMOR", space + _( "Environmental: " ), + get_env_resist( get_base_env_resist_w_filter() ) ); } if( damage() > 0 ) { - info.push_back( iteminfo( "ARMOR", - _( "Protection values are <bad>reduced by damage</bad> and " - "you may be able to <info>improve them by repairing this " - "item</info>." ) ) ); + info.emplace_back( "ARMOR", + _( "Protection values are <bad>reduced by damage</bad> and " + "you may be able to <info>improve them by repairing this " + "item</info>." ) ); } } } @@ -2701,7 +2701,7 @@ void item::armor_info( std::vector<iteminfo> &info, const iteminfo_query *parts, coverage += _( "<info>Nothing</info>." ); } - info.push_back( iteminfo( "ARMOR", coverage ) ); + info.emplace_back( "ARMOR", coverage ); } if( parts->test( iteminfo_parts::ARMOR_LAYER ) && covers_anything ) { @@ -2722,15 +2722,15 @@ void item::armor_info( std::vector<iteminfo> &info, const iteminfo_query *parts, layering += _( "<stat>Normal</stat>. " ); } - info.push_back( iteminfo( "ARMOR", layering ) ); + info.emplace_back( "ARMOR", layering ); } if( parts->test( iteminfo_parts::ARMOR_COVERAGE ) && covers_anything ) { - info.push_back( iteminfo( "ARMOR", _( "Average Coverage: " ), "<num>%", - iteminfo::no_newline, get_avg_coverage() ) ); + info.emplace_back( "ARMOR", _( "Average Coverage: " ), "<num>%", + iteminfo::no_newline, get_avg_coverage() ); } if( parts->test( iteminfo_parts::ARMOR_WARMTH ) && covers_anything ) { - info.push_back( iteminfo( "ARMOR", space + _( "Warmth: " ), get_warmth() ) ); + info.emplace_back( "ARMOR", space + _( "Warmth: " ), get_warmth() ); } insert_separation_line( info ); @@ -2809,8 +2809,8 @@ void item::armor_info( std::vector<iteminfo> &info, const iteminfo_query *parts, } } } - info.push_back( iteminfo( "ARMOR", _( "<bold>Encumbrance</bold>:" ), format, - iteminfo::lower_is_better ) ); + info.emplace_back( "ARMOR", _( "<bold>Encumbrance</bold>:" ), format, + iteminfo::lower_is_better ); for( auto &piece : to_display_data ) { if( t->sided ) { const bodypart_str_id &covering_id = piece.first; @@ -2823,18 +2823,18 @@ void item::armor_info( std::vector<iteminfo> &info, const iteminfo_query *parts, []( const armor_portion_data & data ) { return data.encumber != data.max_encumber; } ); - info.push_back( iteminfo( "ARMOR", - string_format( _( "%s:" ), piece.second.to_display.translated() ) + space, "", - iteminfo::no_newline | iteminfo::lower_is_better, - piece.second.portion.encumber ) ); + info.emplace_back( "ARMOR", + string_format( _( "%s:" ), piece.second.to_display.translated() ) + space, "", + iteminfo::no_newline | iteminfo::lower_is_better, + piece.second.portion.encumber ); if( !type->rigid || any_encumb_increase ) { - info.push_back( iteminfo( "ARMOR", space + _( "When Full:" ) + space, "", - iteminfo::no_newline | iteminfo::lower_is_better, - piece.second.portion.max_encumber ) ); + info.emplace_back( "ARMOR", space + _( "When Full:" ) + space, "", + iteminfo::no_newline | iteminfo::lower_is_better, + piece.second.portion.max_encumber ); } - info.push_back( iteminfo( "ARMOR", space + _( "Coverage:" ) + space, "", - iteminfo::lower_is_better, - piece.second.portion.coverage ) ); + info.emplace_back( "ARMOR", space + _( "Coverage:" ) + space, "", + iteminfo::lower_is_better, + piece.second.portion.coverage ); } } } @@ -2846,9 +2846,9 @@ void item::armor_info( std::vector<iteminfo> &info, const iteminfo_query *parts, &converted_storage_scale ), 2 ); if( parts->test( iteminfo_parts::ARMOR_STORAGE ) && converted_storage > 0 ) { const iteminfo::flags f = converted_storage_scale == 0 ? iteminfo::no_flags : iteminfo::is_decimal; - info.push_back( iteminfo( "ARMOR", space + _( "Storage: " ), - string_format( "<num> %s", volume_units_abbr() ), - f, converted_storage ) ); + info.emplace_back( "ARMOR", space + _( "Storage: " ), + string_format( "<num> %s", volume_units_abbr() ), + f, converted_storage ); } // Whatever the last entry was, we want a newline at this point @@ -2867,9 +2867,9 @@ void item::armor_info( std::vector<iteminfo> &info, const iteminfo_query *parts, } else { modifier = "<num><color_light_green>x</color>"; } - info.push_back( iteminfo( "ARMOR", - _( "<bold>Weight capacity modifier</bold>: " ), modifier, - iteminfo::no_newline | iteminfo::is_decimal, weight_modif ) ); + info.emplace_back( "ARMOR", + _( "<bold>Weight capacity modifier</bold>: " ), modifier, + iteminfo::no_newline | iteminfo::is_decimal, weight_modif ); } if( weight_bonus != 0_gram ) { std::string bonus; @@ -2878,9 +2878,9 @@ void item::armor_info( std::vector<iteminfo> &info, const iteminfo_query *parts, } else { bonus = string_format( "<num> <color_light_green> %s</color>", weight_units() ); } - info.push_back( iteminfo( "ARMOR", _( "<bold>Weight capacity bonus</bold>: " ), bonus, - iteminfo::no_newline | iteminfo::is_decimal, - convert_weight( weight_bonus ) ) ); + info.emplace_back( "ARMOR", _( "<bold>Weight capacity bonus</bold>: " ), bonus, + iteminfo::no_newline | iteminfo::is_decimal, + convert_weight( weight_bonus ) ); } } @@ -2898,9 +2898,9 @@ void item::animal_armor_info( std::vector<iteminfo> &info, const iteminfo_query &converted_storage_scale ), 2 ); if( parts->test( iteminfo_parts::ARMOR_STORAGE ) && converted_storage > 0 ) { const iteminfo::flags f = converted_storage_scale == 0 ? iteminfo::no_flags : iteminfo::is_decimal; - info.push_back( iteminfo( "ARMOR", space + _( "Storage: " ), - string_format( "<num> %s", volume_units_abbr() ), - f, converted_storage ) ); + info.emplace_back( "ARMOR", space + _( "Storage: " ), + string_format( "<num> %s", volume_units_abbr() ), + f, converted_storage ); } // Whatever the last entry was, we want a newline at this point @@ -2921,9 +2921,9 @@ void item::armor_fit_info( std::vector<iteminfo> &info, const iteminfo_query *pa if( has_flag( flag_HELMET_COMPAT ) && parts->test( iteminfo_parts::DESCRIPTION_FLAGS_HELMETCOMPAT ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "* This item can be <info>worn with a " - "helmet</info>." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* This item can be <info>worn with a " + "helmet</info>." ) ); } if( parts->test( iteminfo_parts::DESCRIPTION_FLAGS_FITS ) ) { @@ -3007,7 +3007,7 @@ void item::armor_fit_info( std::vector<iteminfo> &info, const iteminfo_query *pa } if( !resize_str.empty() ) { std::string info_str = string_format( _( "* This clothing %s." ), resize_str ); - info.push_back( iteminfo( "DESCRIPTION", info_str ) ); + info.emplace_back( "DESCRIPTION", info_str ); } } else { switch( sizing_level ) { @@ -3030,7 +3030,7 @@ void item::armor_fit_info( std::vector<iteminfo> &info, const iteminfo_query *pa } std::string info_str = string_format( _( "* This clothing <info>can be " "refitted</info>%s." ), resize_str ); - info.push_back( iteminfo( "DESCRIPTION", info_str ) ); + info.emplace_back( "DESCRIPTION", info_str ); } } else { info.emplace_back( "DESCRIPTION", _( "* This clothing <bad>can not be refitted, " @@ -3039,29 +3039,29 @@ void item::armor_fit_info( std::vector<iteminfo> &info, const iteminfo_query *pa } if( is_sided() && parts->test( iteminfo_parts::DESCRIPTION_FLAGS_SIDED ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "* This item can be worn on <info>either side</info> of " - "the body." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* This item can be worn on <info>either side</info> of " + "the body." ) ); } if( ( is_power_armor() ) && parts->test( iteminfo_parts::DESCRIPTION_FLAGS_POWERARMOR ) ) { if( parts->test( iteminfo_parts::DESCRIPTION_FLAGS_POWERARMOR_RADIATIONHINT ) ) { if( covers( bodypart_id( "head" ) ) && has_flag( flag_POWERARMOR_EXTERNAL ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "* When worn with a power armor suit, it will " - "<good>fully protect</good> you from " - "<info>radiation</info>." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* When worn with a power armor suit, it will " + "<good>fully protect</good> you from " + "<info>radiation</info>." ) ); } else if( has_flag( flag_POWERARMOR_EXO ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "* When worn with a power armor helmet, it will " - "<good>fully protect</good> you from " "<info>radiation</info>." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* When worn with a power armor helmet, it will " + "<good>fully protect</good> you from " "<info>radiation</info>." ) ); } } } if( typeId() == itype_rad_badge && parts->test( iteminfo_parts::DESCRIPTION_IRRADIATION ) ) { - info.push_back( iteminfo( "DESCRIPTION", - string_format( _( "* The film strip on the badge is %s." ), - rad_badge_color( irradiation ) ) ) ); + info.emplace_back( "DESCRIPTION", + string_format( _( "* The film strip on the badge is %s." ), + rad_badge_color( irradiation ) ) ); } } @@ -3078,33 +3078,33 @@ void item::book_info( std::vector<iteminfo> &info, const iteminfo_query *parts, const islot_book &book = *type->book; // Some things about a book you CAN tell by it's cover. if( !book.skill && !type->can_use( "MA_MANUAL" ) && parts->test( iteminfo_parts::BOOK_SUMMARY ) ) { - info.push_back( iteminfo( "BOOK", _( "Just for fun." ) ) ); + info.emplace_back( "BOOK", _( "Just for fun." ) ); } if( type->can_use( "MA_MANUAL" ) && parts->test( iteminfo_parts::BOOK_SUMMARY ) ) { - info.push_back( iteminfo( "BOOK", - _( "Some sort of <info>martial arts training " - "manual</info>." ) ) ); + info.emplace_back( "BOOK", + _( "Some sort of <info>martial arts training " + "manual</info>." ) ); const matype_id style_to_learn = martial_art_learned_from( *type ); - info.push_back( iteminfo( "BOOK", - string_format( _( "You can learn <info>%s</info> style " - "from it." ), style_to_learn->name ) ) ); - info.push_back( iteminfo( "BOOK", - string_format( _( "This fighting style is <info>%s</info> " - "to learn." ), - martialart_difficulty( style_to_learn ) ) ) ); - info.push_back( iteminfo( "BOOK", - string_format( _( "It'd be easier to master if you'd have " - "skill expertise in <info>%s</info>." ), - style_to_learn->primary_skill->name() ) ) ); + info.emplace_back( "BOOK", + string_format( _( "You can learn <info>%s</info> style " + "from it." ), style_to_learn->name ) ); + info.emplace_back( "BOOK", + string_format( _( "This fighting style is <info>%s</info> " + "to learn." ), + martialart_difficulty( style_to_learn ) ) ); + info.emplace_back( "BOOK", + string_format( _( "It'd be easier to master if you'd have " + "skill expertise in <info>%s</info>." ), + style_to_learn->primary_skill->name() ) ); } if( book.req == 0 && parts->test( iteminfo_parts::BOOK_REQUIREMENTS_BEGINNER ) ) { - info.push_back( iteminfo( "BOOK", _( "It can be <info>understood by " - "beginners</info>." ) ) ); + info.emplace_back( "BOOK", _( "It can be <info>understood by " + "beginners</info>." ) ); } avatar &you = get_avatar(); if( !you.has_identified( typeId() ) && parts->test( iteminfo_parts::BOOK_UNREAD ) ) { - info.push_back( iteminfo( "BOOK", - _( "You have <info>never read</info> this book." ) ) ); + info.emplace_back( "BOOK", + _( "You have <info>never read</info> this book." ) ); } if( book.skill ) { const SkillLevel &skill = you.get_skill_level_object( book.skill ); @@ -3112,31 +3112,31 @@ void item::book_info( std::vector<iteminfo> &info, const iteminfo_query *parts, const std::string skill_name = book.skill->name(); std::string fmt = string_format( _( "Can bring your <info>%s skill to</info> " "<num>." ), skill_name ); - info.push_back( iteminfo( "BOOK", "", fmt, iteminfo::no_flags, book.level ) ); + info.emplace_back( "BOOK", "", fmt, iteminfo::no_flags, book.level ); fmt = string_format( _( "Your current <stat>%s skill</stat> is <num>." ), skill_name ); - info.push_back( iteminfo( "BOOK", "", fmt, iteminfo::no_flags, skill.level() ) ); + info.emplace_back( "BOOK", "", fmt, iteminfo::no_flags, skill.level() ); } if( book.req != 0 && parts->test( iteminfo_parts::BOOK_SKILLRANGE_MIN ) ) { const std::string fmt = string_format( _( "<info>Requires %s level</info> <num> to " "understand." ), book.skill.obj().name() ); - info.push_back( iteminfo( "BOOK", "", fmt, - iteminfo::lower_is_better, book.req ) ); + info.emplace_back( "BOOK", "", fmt, + iteminfo::lower_is_better, book.req ); } } if( book.intel != 0 && parts->test( iteminfo_parts::BOOK_REQUIREMENTS_INT ) ) { - info.push_back( iteminfo( "BOOK", "", - _( "Requires <info>intelligence of</info> <num> to easily " - "read." ), iteminfo::lower_is_better, book.intel ) ); + info.emplace_back( "BOOK", "", + _( "Requires <info>intelligence of</info> <num> to easily " + "read." ), iteminfo::lower_is_better, book.intel ); } if( character_funcs::get_book_fun_for( character, *this ) != 0 && parts->test( iteminfo_parts::BOOK_MORALECHANGE ) ) { - info.push_back( iteminfo( "BOOK", "", - _( "Reading this book affects your morale by <num>" ), - iteminfo::show_plus, character_funcs::get_book_fun_for( character, *this ) ) ); + info.emplace_back( "BOOK", "", + _( "Reading this book affects your morale by <num>" ), + iteminfo::show_plus, character_funcs::get_book_fun_for( character, *this ) ); } if( parts->test( iteminfo_parts::BOOK_TIMEPERCHAPTER ) ) { std::string fmt = vgettext( @@ -3151,8 +3151,8 @@ void item::book_info( std::vector<iteminfo> &info, const iteminfo_query *parts, "<info>A training session</info> with this book takes " "<num> <info>minutes</info>.", book.time ); } - info.push_back( iteminfo( "BOOK", "", fmt, - iteminfo::lower_is_better, book.time ) ); + info.emplace_back( "BOOK", "", fmt, + iteminfo::lower_is_better, book.time ); } if( book.chapters > 0 && parts->test( iteminfo_parts::BOOK_NUMUNREADCHAPTERS ) ) { @@ -3160,7 +3160,7 @@ void item::book_info( std::vector<iteminfo> &info, const iteminfo_query *parts, std::string fmt = vgettext( "This book has <num> <info>unread chapter</info>.", "This book has <num> <info>unread chapters</info>.", unread ); - info.push_back( iteminfo( "BOOK", "", fmt, iteminfo::no_flags, unread ) ); + info.emplace_back( "BOOK", "", fmt, iteminfo::no_flags, unread ); } std::vector<std::string> recipe_list; @@ -3191,14 +3191,14 @@ void item::book_info( std::vector<iteminfo> &info, const iteminfo_query *parts, recipe_list.size(), enumerate_as_string( recipe_list ) ); insert_separation_line( info ); - info.push_back( iteminfo( "DESCRIPTION", recipe_line ) ); + info.emplace_back( "DESCRIPTION", recipe_line ); } if( recipe_list.size() != book.recipes.size() && parts->test( iteminfo_parts::DESCRIPTION_BOOK_ADDITIONAL_RECIPES ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "It might help you figuring out some <good>more " - "recipes</good>." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "It might help you figuring out some <good>more " + "recipes</good>." ) ); } } @@ -3227,7 +3227,7 @@ void item::container_info( std::vector<iteminfo> &info, const iteminfo_query *pa container_str += string_format( _( "can store <info>%s %s</info>." ), format_volume( c.contains ), volume_units_long() ); - info.push_back( iteminfo( "CONTAINER", container_str ) ); + info.emplace_back( "CONTAINER", container_str ); } void item::battery_info( std::vector<iteminfo> &info, const iteminfo_query * /*parts*/, @@ -3304,20 +3304,20 @@ void item::component_info( std::vector<iteminfo> &info, const iteminfo_query *pa return; } if( is_craft() ) { - info.push_back( iteminfo( "DESCRIPTION", string_format( _( "Using: %s" ), - _( components_to_string() ) ) ) ); + info.emplace_back( "DESCRIPTION", string_format( _( "Using: %s" ), + _( components_to_string() ) ) ); // Ugly hack warning! Corpses have CBMs as their components } else if( !is_corpse() ) { - info.push_back( iteminfo( "DESCRIPTION", string_format( _( "Made from: %s" ), - _( components_to_string() ) ) ) ); + info.emplace_back( "DESCRIPTION", string_format( _( "Made from: %s" ), + _( components_to_string() ) ) ); } else if( get_var( "bionics_scanned_by", -1 ) == get_avatar().getID().get_value() ) { // TODO: Extract into a more proper place (function in namespace) std::string bionics_string = enumerate_as_string( components.begin(), components.end(), []( const item * const & entry ) -> std::string { return entry->is_bionic() ? entry->display_name() : ""; }, enumeration_conjunction::none ); - info.push_back( iteminfo( "DESCRIPTION", string_format( _( "Contains: %s" ), - bionics_string ) ) ); + info.emplace_back( "DESCRIPTION", string_format( _( "Contains: %s" ), + bionics_string ) ); } } @@ -3392,7 +3392,7 @@ void item::disassembly_info( std::vector<iteminfo> &info, const iteminfo_query * } insert_separation_line( info ); - info.push_back( iteminfo( "DESCRIPTION", descr ) ); + info.emplace_back( "DESCRIPTION", descr ); } } @@ -3453,9 +3453,9 @@ void item::bionic_info( std::vector<iteminfo> &info, const iteminfo_query *parts // TODO: Unhide when enforcing limits if( get_option < bool >( "CBM_SLOTS_ENABLED" ) && parts->test( iteminfo_parts::DESCRIPTION_CBM_SLOTS ) ) { - info.push_back( iteminfo( "DESCRIPTION", list_occupied_bps( type->bionic->id, - _( "This bionic is installed in the following body " - "part(s):" ) ) ) ); + info.emplace_back( "DESCRIPTION", list_occupied_bps( type->bionic->id, + _( "This bionic is installed in the following body " + "part(s):" ) ) ); } insert_separation_line( info ); @@ -3464,78 +3464,78 @@ void item::bionic_info( std::vector<iteminfo> &info, const iteminfo_query *parts if( !fuels.empty() ) { const int &fuel_numb = fuels.size(); - info.push_back( iteminfo( "DESCRIPTION", - vgettext( "* This bionic can produce power from the following fuel: ", - "* This bionic can produce power from the following fuels: ", - fuel_numb ) + enumerate_as_string( fuels.begin(), - fuels.end(), []( const itype_id & id ) -> std::string { return "<info>" + id->nname( 1 ) + "</info>"; } ) ) ); + info.emplace_back( "DESCRIPTION", + vgettext( "* This bionic can produce power from the following fuel: ", + "* This bionic can produce power from the following fuels: ", + fuel_numb ) + enumerate_as_string( fuels.begin(), + fuels.end(), []( const itype_id & id ) -> std::string { return "<info>" + id->nname( 1 ) + "</info>"; } ) ); } insert_separation_line( info ); if( bid->capacity > 0_J ) { - info.push_back( iteminfo( "CBM", _( "<bold>Power Capacity</bold>:" ), _( " <num> J" ), - iteminfo::no_newline, - units::to_joule( bid->capacity ) ) ); + info.emplace_back( "CBM", _( "<bold>Power Capacity</bold>:" ), _( " <num> J" ), + iteminfo::no_newline, + units::to_joule( bid->capacity ) ); } insert_separation_line( info ); if( !bid->encumbrance.empty() ) { - info.push_back( iteminfo( "DESCRIPTION", _( "<bold>Encumbrance</bold>: " ), - iteminfo::no_newline ) ); + info.emplace_back( "DESCRIPTION", _( "<bold>Encumbrance</bold>: " ), + iteminfo::no_newline ); for( const std::pair< const bodypart_str_id, int > element : sorted_lex( bid->encumbrance ) ) { - info.push_back( iteminfo( "CBM", body_part_name_as_heading( element.first->token, 1 ), - " <num> ", iteminfo::no_newline, element.second ) ); + info.emplace_back( "CBM", body_part_name_as_heading( element.first->token, 1 ), + " <num> ", iteminfo::no_newline, element.second ); } } if( !bid->env_protec.empty() ) { - info.push_back( iteminfo( "DESCRIPTION", - bid->activated ? _( "<bold>Environmental Protection (activated)</bold>: " ) : - _( "<bold>Environmental Protection</bold>: " ), - iteminfo::no_newline ) ); + info.emplace_back( "DESCRIPTION", + bid->activated ? _( "<bold>Environmental Protection (activated)</bold>: " ) : + _( "<bold>Environmental Protection</bold>: " ), + iteminfo::no_newline ); for( const std::pair< const bodypart_str_id, int > element : sorted_lex( bid->env_protec ) ) { - info.push_back( iteminfo( "CBM", body_part_name_as_heading( element.first->token, 1 ), - " <num> ", iteminfo::no_newline, element.second ) ); + info.emplace_back( "CBM", body_part_name_as_heading( element.first->token, 1 ), + " <num> ", iteminfo::no_newline, element.second ); } } if( !bid->bash_protec.empty() ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "<bold>Bash Protection</bold>: " ), - iteminfo::no_newline ) ); + info.emplace_back( "DESCRIPTION", + _( "<bold>Bash Protection</bold>: " ), + iteminfo::no_newline ); for( const std::pair< const bodypart_str_id, int > element : sorted_lex( bid->bash_protec ) ) { - info.push_back( iteminfo( "CBM", body_part_name_as_heading( element.first->token, 1 ), - " <num> ", iteminfo::no_newline, element.second ) ); + info.emplace_back( "CBM", body_part_name_as_heading( element.first->token, 1 ), + " <num> ", iteminfo::no_newline, element.second ); } } if( !bid->cut_protec.empty() ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "<bold>Cut Protection</bold>: " ), - iteminfo::no_newline ) ); + info.emplace_back( "DESCRIPTION", + _( "<bold>Cut Protection</bold>: " ), + iteminfo::no_newline ); for( const std::pair< const bodypart_str_id, int > element : sorted_lex( bid->cut_protec ) ) { - info.push_back( iteminfo( "CBM", body_part_name_as_heading( element.first->token, 1 ), - " <num> ", iteminfo::no_newline, element.second ) ); + info.emplace_back( "CBM", body_part_name_as_heading( element.first->token, 1 ), + " <num> ", iteminfo::no_newline, element.second ); } } if( !bid->bullet_protec.empty() ) { - info.push_back( iteminfo( "DESCRIPTION", _( "<bold>Ballistic Protection</bold>: " ), - iteminfo::no_newline ) ); + info.emplace_back( "DESCRIPTION", _( "<bold>Ballistic Protection</bold>: " ), + iteminfo::no_newline ); for( const auto &element : bid->bullet_protec ) { - info.push_back( iteminfo( "CBM", body_part_name_as_heading( element.first->token, 1 ), - " <num> ", iteminfo::no_newline, element.second ) ); + info.emplace_back( "CBM", body_part_name_as_heading( element.first->token, 1 ), + " <num> ", iteminfo::no_newline, element.second ); } } if( !bid->stat_bonus.empty() ) { - info.push_back( iteminfo( "DESCRIPTION", _( "<bold>Stat Bonus</bold>: " ), - iteminfo::no_newline ) ); + info.emplace_back( "DESCRIPTION", _( "<bold>Stat Bonus</bold>: " ), + iteminfo::no_newline ); for( const auto &element : bid->stat_bonus ) { - info.push_back( iteminfo( "CBM", get_stat_name( element.first ), " <num> ", - iteminfo::no_newline, element.second ) ); + info.emplace_back( "CBM", get_stat_name( element.first ), " <num> ", + iteminfo::no_newline, element.second ); } } @@ -3548,10 +3548,10 @@ void item::bionic_info( std::vector<iteminfo> &info, const iteminfo_query *parts } else { modifier = "<num><color_light_green>x</color>"; } - info.push_back( iteminfo( "CBM", - _( "<bold>Weight capacity modifier</bold>: " ), modifier, - iteminfo::no_newline | iteminfo::is_decimal, - weight_modif ) ); + info.emplace_back( "CBM", + _( "<bold>Weight capacity modifier</bold>: " ), modifier, + iteminfo::no_newline | iteminfo::is_decimal, + weight_modif ); } if( weight_bonus != 0_gram ) { std::string bonus; @@ -3560,9 +3560,9 @@ void item::bionic_info( std::vector<iteminfo> &info, const iteminfo_query *parts } else { bonus = string_format( "<num> <color_light_green>%s</color>", weight_units() ); } - info.push_back( iteminfo( "CBM", _( "<bold>Weight capacity bonus</bold>: " ), bonus, - iteminfo::no_newline | iteminfo::is_decimal, - convert_weight( weight_bonus ) ) ); + info.emplace_back( "CBM", _( "<bold>Weight capacity bonus</bold>: " ), bonus, + iteminfo::no_newline | iteminfo::is_decimal, + convert_weight( weight_bonus ) ); } } @@ -3578,30 +3578,30 @@ void item::combat_info( std::vector<iteminfo> &info, const iteminfo_query *parts insert_separation_line( info ); std::string sep; if( dmg_bash || dmg_cut || dmg_stab ) { - info.push_back( iteminfo( "BASE", _( "<bold>Melee damage</bold>: " ), "", iteminfo::no_newline ) ); + info.emplace_back( "BASE", _( "<bold>Melee damage</bold>: " ), "", iteminfo::no_newline ); } if( dmg_bash ) { - info.push_back( iteminfo( "BASE", _( "Bash: " ), "", iteminfo::no_newline, dmg_bash ) ); + info.emplace_back( "BASE", _( "Bash: " ), "", iteminfo::no_newline, dmg_bash ); sep = space; } if( dmg_cut ) { - info.push_back( iteminfo( "BASE", sep + _( "Cut: " ), "", iteminfo::no_newline, dmg_cut ) ); + info.emplace_back( "BASE", sep + _( "Cut: " ), "", iteminfo::no_newline, dmg_cut ); sep = space; } if( dmg_stab ) { - info.push_back( iteminfo( "BASE", sep + _( "Pierce: " ), "", iteminfo::no_newline, dmg_stab ) ); + info.emplace_back( "BASE", sep + _( "Pierce: " ), "", iteminfo::no_newline, dmg_stab ); } } if( dmg_bash || dmg_cut || dmg_stab ) { if( parts->test( iteminfo_parts::BASE_TOHIT ) ) { - info.push_back( iteminfo( "BASE", space + _( "To-hit bonus: " ), "", - iteminfo::show_plus, type->m_to_hit ) ); + info.emplace_back( "BASE", space + _( "To-hit bonus: " ), "", + iteminfo::show_plus, type->m_to_hit ); } if( parts->test( iteminfo_parts::BASE_MOVES ) ) { - info.push_back( iteminfo( "BASE", _( "Moves per attack: " ), "", - iteminfo::lower_is_better, attack_cost() ) ); + info.emplace_back( "BASE", _( "Moves per attack: " ), "", + iteminfo::lower_is_better, attack_cost() ); info.emplace_back( "BASE", _( "Typical damage per second:" ), "" ); const std::map<std::string, double> &dps_data = dps( true, false ); std::string sep; @@ -3622,11 +3622,11 @@ void item::combat_info( std::vector<iteminfo> &info, const iteminfo_query *parts if( !all_techniques.empty() ) { const std::vector<matec_id> all_tec_sorted = sorted_lex( all_techniques ); insert_separation_line( info ); - info.push_back( iteminfo( "DESCRIPTION", _( "<bold>Techniques when wielded</bold>: " ) + + info.emplace_back( "DESCRIPTION", _( "<bold>Techniques when wielded</bold>: " ) + enumerate_as_string( all_tec_sorted.begin(), all_tec_sorted.end(), []( const matec_id & tid ) { return string_format( "<stat>%s</stat>: <info>%s</info>", _( tid.obj().name ), _( tid.obj().description ) ); - } ) ) ); + } ) ); } } @@ -3636,9 +3636,9 @@ void item::combat_info( std::vector<iteminfo> &info, const iteminfo_query *parts const std::string valid_styles = you.martial_arts_data->enumerate_known_styles( typeId() ); if( !valid_styles.empty() ) { insert_separation_line( info ); - info.push_back( iteminfo( "DESCRIPTION", - _( "You know how to use this with these martial arts " - "styles: " ) + valid_styles ) ); + info.emplace_back( "DESCRIPTION", + _( "You know how to use this with these martial arts " + "styles: " ) + valid_styles ); } } @@ -3646,13 +3646,13 @@ void item::combat_info( std::vector<iteminfo> &info, const iteminfo_query *parts parts->test( iteminfo_parts::DESCRIPTION_GUNMOD_ADDREACHATTACK ) ) { insert_separation_line( info ); if( has_flag( flag_REACH3 ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "* This item can be used to make <stat>long reach " - "attacks</stat>." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* This item can be used to make <stat>long reach " + "attacks</stat>." ) ); } else { - info.push_back( iteminfo( "DESCRIPTION", - _( "* This item can be used to make <stat>reach " - "attacks</stat>." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* This item can be used to make <stat>reach " + "attacks</stat>." ) ); } } @@ -3664,48 +3664,48 @@ void item::combat_info( std::vector<iteminfo> &info, const iteminfo_query *parts int attack_cost = you.attack_cost( *this ); insert_separation_line( info ); if( parts->test( iteminfo_parts::DESCRIPTION_MELEEDMG ) ) { - info.push_back( iteminfo( "DESCRIPTION", _( "<bold>Average melee damage</bold>:" ) ) ); + info.emplace_back( "DESCRIPTION", _( "<bold>Average melee damage</bold>:" ) ); } // Chance of critical hit if( parts->test( iteminfo_parts::DESCRIPTION_MELEEDMG_CRIT ) ) { - info.push_back( iteminfo( "DESCRIPTION", - string_format( _( "Critical hit chance <neutral>%d%% - %d%%</neutral>" ), + info.emplace_back( "DESCRIPTION", + string_format( _( "Critical hit chance <neutral>%d%% - %d%%</neutral>" ), static_cast<int>( you.crit_chance( 0, 100, *this ) * 100 ), static_cast<int>( you.crit_chance( 100, 0, *this ) * - 100 ) ) ) ); + 100 ) ) ); } // Bash damage if( parts->test( iteminfo_parts::DESCRIPTION_MELEEDMG_BASH ) ) { // NOTE: Using "BASE" instead of "DESCRIPTION", so numerical formatting will work // (output.cpp:format_item_info does not interpolate <num> for DESCRIPTION info) - info.push_back( iteminfo( "BASE", _( "Bashing: " ), "<num>", iteminfo::no_newline, - non_crit.type_damage( DT_BASH ) ) ); - info.push_back( iteminfo( "BASE", space + _( "Critical bash: " ), "<num>", iteminfo::no_flags, - crit.type_damage( DT_BASH ) ) ); + info.emplace_back( "BASE", _( "Bashing: " ), "<num>", iteminfo::no_newline, + non_crit.type_damage( DT_BASH ) ); + info.emplace_back( "BASE", space + _( "Critical bash: " ), "<num>", iteminfo::no_flags, + crit.type_damage( DT_BASH ) ); } // Cut damage if( ( non_crit.type_damage( DT_CUT ) > 0.0f || crit.type_damage( DT_CUT ) > 0.0f ) && parts->test( iteminfo_parts::DESCRIPTION_MELEEDMG_CUT ) ) { - info.push_back( iteminfo( "BASE", _( "Cutting: " ), "<num>", iteminfo::no_newline, - non_crit.type_damage( DT_CUT ) ) ); - info.push_back( iteminfo( "BASE", space + _( "Critical cut: " ), "<num>", iteminfo::no_flags, - crit.type_damage( DT_CUT ) ) ); + info.emplace_back( "BASE", _( "Cutting: " ), "<num>", iteminfo::no_newline, + non_crit.type_damage( DT_CUT ) ); + info.emplace_back( "BASE", space + _( "Critical cut: " ), "<num>", iteminfo::no_flags, + crit.type_damage( DT_CUT ) ); } // Pierce/stab damage if( ( non_crit.type_damage( DT_STAB ) > 0.0f || crit.type_damage( DT_STAB ) > 0.0f ) && parts->test( iteminfo_parts::DESCRIPTION_MELEEDMG_PIERCE ) ) { - info.push_back( iteminfo( "BASE", _( "Piercing: " ), "<num>", iteminfo::no_newline, - non_crit.type_damage( DT_STAB ) ) ); - info.push_back( iteminfo( "BASE", space + _( "Critical pierce: " ), "<num>", iteminfo::no_flags, - crit.type_damage( DT_STAB ) ) ); + info.emplace_back( "BASE", _( "Piercing: " ), "<num>", iteminfo::no_newline, + non_crit.type_damage( DT_STAB ) ); + info.emplace_back( "BASE", space + _( "Critical pierce: " ), "<num>", iteminfo::no_flags, + crit.type_damage( DT_STAB ) ); } // Moves if( parts->test( iteminfo_parts::DESCRIPTION_MELEEDMG_MOVES ) ) { - info.push_back( iteminfo( "BASE", _( "Moves per attack: " ), "<num>", - iteminfo::lower_is_better, attack_cost ) ); + info.emplace_back( "BASE", _( "Moves per attack: " ), "<num>", + iteminfo::lower_is_better, attack_cost ); } insert_separation_line( info ); } @@ -3830,23 +3830,23 @@ void item::final_info( std::vector<iteminfo> &info, const iteminfo_query &parts_ if( parts->test( iteminfo_parts::DESCRIPTION_CONDUCTIVITY ) ) { if( !conductive() ) { - info.push_back( iteminfo( "BASE", _( "* This item <good>does not " - "conduct</good> electricity." ) ) ); + info.emplace_back( "BASE", _( "* This item <good>does not " + "conduct</good> electricity." ) ); } else if( has_flag( flag_CONDUCTIVE ) ) { - info.push_back( iteminfo( "BASE", - _( "* This item effectively <bad>conducts</bad> " - "electricity, as it has no guard." ) ) ); + info.emplace_back( "BASE", + _( "* This item effectively <bad>conducts</bad> " + "electricity, as it has no guard." ) ); } else { - info.push_back( iteminfo( "BASE", _( "* This item <bad>conducts</bad> electricity." ) ) ); + info.emplace_back( "BASE", _( "* This item <bad>conducts</bad> electricity." ) ); } } avatar &you = get_avatar(); if( is_armor() && you.has_trait( trait_WOOLALLERGY ) && ( made_of( material_id( "wool" ) ) || has_own_flag( flag_wooled ) ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "* This clothing will give you an <bad>allergic " - "reaction</bad>." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* This clothing will give you an <bad>allergic " + "reaction</bad>." ) ); } if( parts->test( iteminfo_parts::DESCRIPTION_FLAGS ) ) { @@ -3869,28 +3869,28 @@ void item::final_info( std::vector<iteminfo> &info, const iteminfo_query &parts_ if( is_tool() ) { if( is_power_armor() && parts->test( iteminfo_parts::DESCRIPTION_BIONIC_ARMOR_INTERFACE ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "* This tool can draw power from a <info>Bionic Armor Interface</info>" ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* This tool can draw power from a <info>Bionic Armor Interface</info>" ) ); } if( has_flag( flag_USE_UPS ) && parts->test( iteminfo_parts::DESCRIPTION_RECHARGE_UPSMODDED ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "* This tool uses a <info>universal power supply</info> " - "and is <neutral>not compatible</neutral> with " - "<info>standard batteries</info>." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* This tool uses a <info>universal power supply</info> " + "and is <neutral>not compatible</neutral> with " + "<info>standard batteries</info>." ) ); } else if( has_flag( flag_RECHARGE ) && has_flag( flag_NO_RELOAD ) && parts->test( iteminfo_parts::DESCRIPTION_RECHARGE_NORELOAD ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "* This tool has a <info>rechargeable power cell</info> " - "and is <neutral>not compatible</neutral> with " - "<info>standard batteries</info>." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* This tool has a <info>rechargeable power cell</info> " + "and is <neutral>not compatible</neutral> with " + "<info>standard batteries</info>." ) ); } else if( has_flag( flag_RECHARGE ) && parts->test( iteminfo_parts::DESCRIPTION_RECHARGE_UPSCAPABLE ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "* This tool has a <info>rechargeable power cell</info> " - "and can be recharged in any <neutral>UPS-compatible " - "recharging station</neutral>. You could charge it with " - "<info>standard batteries</info>, but unloading it is " - "impossible." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* This tool has a <info>rechargeable power cell</info> " + "and can be recharged in any <neutral>UPS-compatible " + "recharging station</neutral>. You could charge it with " + "<info>standard batteries</info>, but unloading it is " + "impossible." ) ); } else if( has_flag( flag_USES_BIONIC_POWER ) ) { info.emplace_back( "DESCRIPTION", _( "* This tool <info>runs on bionic power</info>." ) ); @@ -3935,37 +3935,37 @@ void item::final_info( std::vector<iteminfo> &info, const iteminfo_query &parts_ if( is_gun() && has_flag( flag_FIRE_TWOHAND ) && parts->test( iteminfo_parts::DESCRIPTION_TWOHANDED ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "* This weapon needs <info>two free hands</info> " - "to fire." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* This weapon needs <info>two free hands</info> " + "to fire." ) ); } if( is_gunmod() && has_flag( flag_DISABLE_SIGHTS ) && parts->test( iteminfo_parts::DESCRIPTION_GUNMOD_DISABLESSIGHTS ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "* This mod <bad>obscures sights</bad> of the " - "base weapon." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* This mod <bad>obscures sights</bad> of the " + "base weapon." ) ); } if( is_gunmod() && has_flag( flag_CONSUMABLE ) && parts->test( iteminfo_parts::DESCRIPTION_GUNMOD_CONSUMABLE ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "* This mod might <bad>suffer wear</bad> when firing " - "the base weapon." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* This mod might <bad>suffer wear</bad> when firing " + "the base weapon." ) ); } if( has_flag( flag_LEAK_DAM ) && has_flag( flag_RADIOACTIVE ) && damage() > 0 && parts->test( iteminfo_parts::DESCRIPTION_RADIOACTIVITY_DAMAGED ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "* The casing of this item has <neutral>cracked</neutral>, " - "revealing an <info>ominous green glow</info>." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* The casing of this item has <neutral>cracked</neutral>, " + "revealing an <info>ominous green glow</info>." ) ); } if( has_flag( flag_LEAK_ALWAYS ) && has_flag( flag_RADIOACTIVE ) && parts->test( iteminfo_parts::DESCRIPTION_RADIOACTIVITY_ALWAYS ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "* This object is <neutral>surrounded</neutral> by a " - "<info>sickly green glow</info>." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* This object is <neutral>surrounded</neutral> by a " + "<info>sickly green glow</info>." ) ); } if( is_brewable() || ( !contents.empty() && contents.front().is_brewable() ) ) { @@ -3975,25 +3975,25 @@ void item::final_info( std::vector<iteminfo> &info, const iteminfo_query &parts_ int btime_i = to_days<int>( btime ); if( btime <= 2_days ) { btime_i = to_hours<int>( btime ); - info.push_back( iteminfo( "DESCRIPTION", - string_format( vgettext( "* Once set in a vat, this " + info.emplace_back( "DESCRIPTION", + string_format( vgettext( "* Once set in a vat, this " "will ferment in around %d hour.", "* Once set in a vat, this will ferment in " - "around %d hours.", btime_i ), btime_i ) ) ); + "around %d hours.", btime_i ), btime_i ) ); } else { - info.push_back( iteminfo( "DESCRIPTION", - string_format( vgettext( "* Once set in a vat, this " + info.emplace_back( "DESCRIPTION", + string_format( vgettext( "* Once set in a vat, this " "will ferment in around %d day.", "* Once set in a vat, this will ferment in " - "around %d days.", btime_i ), btime_i ) ) ); + "around %d days.", btime_i ), btime_i ) ); } } if( parts->test( iteminfo_parts::DESCRIPTION_BREWABLE_PRODUCTS ) ) { for( const itype_id &res : brewed.brewing_results() ) { - info.push_back( iteminfo( "DESCRIPTION", - string_format( _( "* Fermenting this will produce " - "<neutral>%s</neutral>." ), - nname( res, brewed.charges ) ) ) ); + info.emplace_back( "DESCRIPTION", + string_format( _( "* Fermenting this will produce " + "<neutral>%s</neutral>." ), + nname( res, brewed.charges ) ) ); } } } @@ -4034,13 +4034,13 @@ void item::final_info( std::vector<iteminfo> &info, const iteminfo_query &parts_ } const int time_to_do = tt->time_to_do( *this ); if( time_to_do <= 0 ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "It's done and <info>can be activated</info>." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "It's done and <info>can be activated</info>." ) ); } else { const std::string time = to_string_clipped( time_duration::from_turns( time_to_do ) ); - info.push_back( iteminfo( "DESCRIPTION", - string_format( _( "It will be done in %s." ), - time.c_str() ) ) ); + info.emplace_back( "DESCRIPTION", + string_format( _( "It will be done in %s." ), + time.c_str() ) ); } } } @@ -4065,7 +4065,7 @@ void item::final_info( std::vector<iteminfo> &info, const iteminfo_query &parts_ //~ %1$s: inscription text ntext = string_format( pgettext( "carving", "Note: %1$s" ), item_note->second ); } - info.push_back( iteminfo( "DESCRIPTION", ntext ) ); + info.emplace_back( "DESCRIPTION", ntext ); } if( this->get_var( "die_num_sides", 0 ) != 0 ) { @@ -4081,14 +4081,14 @@ void item::final_info( std::vector<iteminfo> &info, const iteminfo_query &parts_ const int price_postapoc = price( true ) * batch; if( parts->test( iteminfo_parts::BASE_PRICE ) ) { insert_separation_line( info ); - info.push_back( iteminfo( "BASE", _( "Price: " ), _( "$<num>" ), - iteminfo::is_decimal | iteminfo::lower_is_better | iteminfo::no_newline, - static_cast<double>( price_preapoc ) / 100 ) ); + info.emplace_back( "BASE", _( "Price: " ), _( "$<num>" ), + iteminfo::is_decimal | iteminfo::lower_is_better | iteminfo::no_newline, + static_cast<double>( price_preapoc ) / 100 ); } if( price_preapoc != price_postapoc && parts->test( iteminfo_parts::BASE_BARTER ) ) { - info.push_back( iteminfo( "BASE", space + _( "Barter value: " ), _( "$<num>" ), - iteminfo::is_decimal | iteminfo::lower_is_better, - static_cast<double>( price_postapoc ) / 100 ) ); + info.emplace_back( "BASE", space + _( "Barter value: " ), _( "$<num>" ), + iteminfo::is_decimal | iteminfo::lower_is_better, + static_cast<double>( price_postapoc ) / 100 ); } // Recipes using this item as an ingredient @@ -4102,17 +4102,17 @@ void item::final_info( std::vector<iteminfo> &info, const iteminfo_query &parts_ if( item_recipes.empty() ) { insert_separation_line( info ); - info.push_back( iteminfo( "DESCRIPTION", - _( "You know of nothing you could craft with it." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "You know of nothing you could craft with it." ) ); } else { if( item_recipes.size() > 24 ) { insert_separation_line( info ); - info.push_back( iteminfo( "DESCRIPTION", - _( "You know dozens of things you could craft with it." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "You know dozens of things you could craft with it." ) ); } else if( item_recipes.size() > 12 ) { insert_separation_line( info ); - info.push_back( iteminfo( "DESCRIPTION", - _( "You could use it to craft various other things." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "You could use it to craft various other things." ) ); } else { // Extract item names from recipes and sort them std::vector<std::pair<std::string, bool>> result_names; @@ -4135,9 +4135,9 @@ void item::final_info( std::vector<iteminfo> &info, const iteminfo_query &parts_ } } ); insert_separation_line( info ); - info.push_back( iteminfo( "DESCRIPTION", - string_format( _( "You could use it to craft: %s" ), - recipes ) ) ); + info.emplace_back( "DESCRIPTION", + string_format( _( "You could use it to craft: %s" ), + recipes ) ); } } } @@ -4145,7 +4145,7 @@ void item::final_info( std::vector<iteminfo> &info, const iteminfo_query &parts_ const ascii_art_id art = type->picture_id; if( art.is_valid() ) { for( const std::string &line : art->picture ) { - info.push_back( iteminfo( "DESCRIPTION", line ) ); + info.emplace_back( "DESCRIPTION", line ); } } } @@ -7392,7 +7392,7 @@ std::vector<std::pair<const recipe *, int>> item::get_available_recipes( const p if( is_book() ) { for( const islot_book::recipe_with_description_t &elem : type->book->recipes ) { if( u.get_skill_level( elem.recipe->skill_used ) >= elem.skill_level ) { - recipe_entries.push_back( std::make_pair( elem.recipe, elem.skill_level ) ); + recipe_entries.emplace_back( elem.recipe, elem.skill_level ); } } } else if( has_var( "EIPC_RECIPES" ) ) { @@ -7409,7 +7409,7 @@ std::vector<std::pair<const recipe *, int>> item::get_available_recipes( const p next_string_index - first_string_index ); const recipe *r = &recipe_id( new_recipe ).obj(); if( u.get_skill_level( r->skill_used ) >= r->difficulty ) { - recipe_entries.push_back( std::make_pair( r, r->difficulty ) ); + recipe_entries.emplace_back( r, r->difficulty ); } first_string_index = next_string_index + 1; } @@ -10394,7 +10394,7 @@ std::vector<item_comp> item::get_uncraft_components() const if( iter != ret.end() ) { iter->count += component->count(); } else { - ret.push_back( item_comp( component->typeId(), component->count() ) ); + ret.emplace_back( component->typeId(), component->count() ); } } } diff --git a/src/item_factory.cpp b/src/item_factory.cpp index 551515ed90c3..e868f3a9f404 100644 --- a/src/item_factory.cpp +++ b/src/item_factory.cpp @@ -732,7 +732,7 @@ void Item_factory::finalize_item_blacklist() if( maybe_ammo != m_templates.end() && maybe_ammo->second.ammo ) { auto replacement = m_templates.find( migrate.second.replace ); if( replacement->second.ammo ) { - migrated_ammo.emplace( std::make_pair( migrate.first, replacement->second.ammo->type ) ); + migrated_ammo.emplace( migrate.first, replacement->second.ammo->type ); } else { debugmsg( "Replacement item %s for migrated ammo %s is not ammo.", migrate.second.replace.str(), migrate.first.str() ); @@ -744,7 +744,7 @@ void Item_factory::finalize_item_blacklist() if( maybe_mag != m_templates.end() && maybe_mag->second.magazine ) { auto replacement = m_templates.find( migrate.second.replace ); if( replacement->second.magazine ) { - migrated_magazines.emplace( std::make_pair( migrate.first, migrate.second.replace ) ); + migrated_magazines.emplace( migrate.first, migrate.second.replace ); } else { debugmsg( "Replacement item %s for migrated magazine %s is not a magazine.", migrate.second.replace.str(), migrate.first.str() ); @@ -2513,7 +2513,7 @@ void hflesh_to_flesh( itype &item_template ) // Only add "flesh" material if not already present if( old_size != mats.size() && std::find( mats.begin(), mats.end(), material_id( "flesh" ) ) == mats.end() ) { - mats.push_back( material_id( "flesh" ) ); + mats.emplace_back( "flesh" ); } } @@ -3026,10 +3026,10 @@ bool Item_factory::load_sub_ref( std::unique_ptr<Item_spawn_data> &ptr, const Js return false; } if( obj.has_string( iname ) ) { - entries.push_back( std::make_pair( obj.get_string( iname ), false ) ); + entries.emplace_back( obj.get_string( iname ), false ); } if( obj.has_string( gname ) ) { - entries.push_back( std::make_pair( obj.get_string( gname ), true ) ); + entries.emplace_back( obj.get_string( gname ), true ); } if( entries.size() > 1 && name != "contents" ) { @@ -3364,7 +3364,7 @@ std::vector<item_group_id> Item_factory::get_all_group_names() { std::vector<item_group_id> rval; for( GroupMap::value_type &group_pair : m_template_groups ) { - rval.push_back( item_group_id( group_pair.first ) ); + rval.emplace_back( group_pair.first ); } return rval; } diff --git a/src/iuse.cpp b/src/iuse.cpp index 6adaae880d3e..c3dfe3eac282 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -1800,7 +1800,7 @@ int iuse::fishing_rod( player *p, item *it, bool, const tripoint & ) } p->add_msg_if_player( _( "You cast your line and wait to hook something…" ) ); p->assign_activity( ACT_FISH, to_moves<int>( 5_hours ), 0, 0, it->tname() ); - p->activity->targets.push_back( it ); + p->activity->targets.emplace_back( it ); p->activity->coord_set = g->get_fishable_locations( 60, *found ); return 0; } @@ -2074,7 +2074,7 @@ int iuse::pack_cbm( player *p, item *it, bool, const tripoint & ) } std::vector<item_comp> comps; - comps.push_back( item_comp( it->typeId(), 1 ) ); + comps.emplace_back( it->typeId(), 1 ); p->consume_items( comps, 1, is_crafting_component ); return 0; @@ -3237,7 +3237,7 @@ int iuse::jackhammer( player *p, item *it, bool, const tripoint &pos ) moves = moves * ( 10 - helpers.size() ) / 10; p->assign_activity( ACT_JACKHAMMER, moves ); - p->activity->targets.push_back( it ); + p->activity->targets.emplace_back( it ); p->activity->placement = g->m.getabs( pnt ); p->add_msg_if_player( _( "You start drilling into the %1$s with your %2$s." ), g->m.tername( pnt ), it->tname() ); @@ -3292,7 +3292,7 @@ int iuse::pickaxe( player *p, item *it, bool, const tripoint &pos ) moves = moves * ( 10 - helpers.size() ) / 10; p->assign_activity( ACT_PICKAXE, moves, -1 ); - p->activity->targets.push_back( it ); + p->activity->targets.emplace_back( it ); p->activity->placement = g->m.getabs( pnt ); p->add_msg_if_player( _( "You strike the %1$s with your %2$s." ), g->m.tername( pnt ), it->tname() ); @@ -4422,7 +4422,7 @@ int iuse::portable_game( player *p, item *it, bool t, const tripoint & ) p->add_msg_if_player( _( "You play on your %s for a while." ), it->tname() ); p->assign_activity( ACT_GAME, moves, -1, 0, "gaming" ); - p->activity->targets.push_back( it ); + p->activity->targets.emplace_back( it ); std::string end_message; end_message.clear(); int game_score = 0; @@ -4463,7 +4463,7 @@ int iuse::hand_crank( player *p, item *it, bool, const tripoint & ) p->add_msg_if_player( _( "You start cranking the %s to charge its %s." ), it->tname(), it->magazine_current()->tname() ); p->assign_activity( ACT_HAND_CRANK, moves, -1, 0, "hand-cranking" ); - p->activity->targets.push_back( it ); + p->activity->targets.emplace_back( it ); } else { p->add_msg_if_player( _( "You could use the %s to charge its %s, but it's already charged." ), it->tname(), magazine->tname() ); @@ -4510,7 +4510,7 @@ int iuse::vibe( player *p, item *it, bool, const tripoint & ) it->tname() ); } p->assign_activity( ACT_VIBE, moves, -1, 0, "de-stressing" ); - p->activity->targets.push_back( it ); + p->activity->targets.emplace_back( it ); } return it->type->charges_to_use(); } @@ -4681,7 +4681,7 @@ int iuse::mind_splicer( player *p, item *it, bool, const tripoint & ) std::unique_ptr<player_activity> act = std::make_unique<player_activity>( ACT_MIND_SPLICER, to_moves<int>( time ) ); - act->targets.push_back( &data_card ); + act->targets.emplace_back( &data_card ); p->assign_activity( std::move( act ) ); return it->type->charges_to_use(); } @@ -4790,7 +4790,7 @@ int iuse::chop_tree( player *p, item *it, bool t, const tripoint & ) moves = moves * ( 10 - helpers.size() ) / 10; p->assign_activity( ACT_CHOP_TREE, moves, -1, p->get_item_position( it ) ); - p->activity->targets.push_back( it ); + p->activity->targets.emplace_back( it ); p->activity->placement = g->m.getabs( pnt ); return it->type->charges_to_use(); @@ -4837,7 +4837,7 @@ int iuse::chop_logs( player *p, item *it, bool t, const tripoint & ) p->assign_activity( ACT_CHOP_LOGS, moves, -1, p->get_item_position( it ) ); p->activity->placement = g->m.getabs( pnt ); - p->activity->targets.push_back( it ); + p->activity->targets.emplace_back( it ); return it->type->charges_to_use(); } @@ -4935,7 +4935,7 @@ int iuse::oxytorch( player *p, item *it, bool, const tripoint & ) // placing ter here makes resuming tasks work better p->assign_activity( ACT_OXYTORCH, moves, static_cast<int>( ter ) ); - p->activity->targets.push_back( it ); + p->activity->targets.emplace_back( it ); p->activity->placement = pnt; p->activity->values.push_back( charges ); @@ -6586,7 +6586,7 @@ int iuse::einktabletpc( player *p, item *it, bool t, const tripoint &pos ) if( s.empty() ) { continue; } - monster_photos.push_back( mtype_id( s ) ); + monster_photos.emplace_back( s ); std::string menu_str; const monster dummy( monster_photos.back() ); menu_str = dummy.name(); @@ -7694,7 +7694,7 @@ int iuse::camera( player *p, item *it, bool, const tripoint & ) continue; } - monster_photos.push_back( mtype_id( s ) ); + monster_photos.emplace_back( s ); std::string menu_str; @@ -9605,7 +9605,7 @@ int iuse::craft( player *p, item *it, bool, const tripoint &pos ) return 0; } } - p->activity->targets.push_back( where ); + p->activity->targets.emplace_back( where ); p->activity->coords.push_back( best_bench.position ); p->activity->values.push_back( 0 ); // Not a long craft // Ugly diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 058d09315aa9..4535cfc50047 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -1013,7 +1013,7 @@ void place_monster_iuse::load( const JsonObject &obj ) if( obj.has_array( "skills" ) ) { JsonArray skills_ja = obj.get_array( "skills" ); for( JsonValue s : skills_ja ) { - skills.emplace( skill_id( s.get_string() ) ); + skills.emplace( s.get_string() ); } } } @@ -1199,7 +1199,7 @@ int pick_lock_actor::use( player &p, item &it, bool, const tripoint &t ) const ( p.dex_cur + 5 ) * 2300 ); p.assign_activity( activity_id( "ACT_LOCKPICK" ), duration, -1, p.get_item_position( &it ) ); - p.activity->targets.push_back( &it ); + p.activity->targets.emplace_back( &it ); p.activity->placement = pnt; return it.type->charges_to_use(); @@ -1331,7 +1331,7 @@ void reveal_map_actor::load( const JsonObject &obj ) ter_match_type = jo.get_enum_value<ot_match_type>( "om_terrain_match_type", ot_match_type::contains ); } - omt_types.push_back( std::make_pair( ter, ter_match_type ) ); + omt_types.emplace_back( ter, ter_match_type ); } } @@ -1521,7 +1521,7 @@ int firestarter_actor::use( player &p, item &it, bool t, const tripoint &spos ) moves_modifier + moves_cost_fast / 100.0 + 2; p.assign_activity( ACT_START_FIRE, moves, potential_skill_gain, 0, it.tname() ); - p.activity->targets.push_back( &it ); + p.activity->targets.emplace_back( &it ); p.activity->values.push_back( g->natural_light_level( pos.z ) ); p.activity->placement = pos; // charges to use are handled by the activity @@ -2667,7 +2667,7 @@ int cast_spell_actor::use( player &p, item &it, bool, const tripoint & ) const cast_spell->values.emplace_back( 0 ); } p.assign_activity( std::move( cast_spell ), false ); - p.activity->targets.push_back( &it ); + p.activity->targets.emplace_back( &it ); return 0; } @@ -3049,7 +3049,7 @@ int ammobelt_actor::use( player &p, item &, bool, const tripoint & ) const if( opt ) { p.assign_activity( ACT_RELOAD, opt.moves(), opt.qty() ); p.activity->targets.emplace_back( &*mag ); - p.activity->targets.push_back( opt.ammo ); + p.activity->targets.emplace_back( opt.ammo ); p.i_add( std::move( mag ) ); } @@ -3708,7 +3708,7 @@ int heal_actor::use( player &p, item &it, bool, const tripoint &pos ) const // Assign first aid long action. /** @EFFECT_FIRSTAID speeds up firstaid activity */ p.assign_activity( ACT_FIRSTAID, cost, 0, 0, it.tname() ); - p.activity->targets.push_back( &it ); + p.activity->targets.emplace_back( &it ); p.activity->values.push_back( hpp ); p.moves = 0; return 0; @@ -4800,7 +4800,7 @@ void sew_advanced_actor::load( const JsonObject &obj ) materials.emplace( line ); } for( const std::string line : obj.get_array( "clothing_mods" ) ) { - clothing_mods.push_back( clothing_mod_id( line ) ); + clothing_mods.emplace_back( line ); } // TODO: Make skill non-mandatory while still erroring on invalid skill @@ -4990,7 +4990,7 @@ int sew_advanced_actor::use( player &p, item &it, bool, const tripoint & ) const const auto &repair_item = clothing_mods[choice].obj().item_string; std::vector<item_comp> comps; - comps.push_back( item_comp( repair_item, items_needed ) ); + comps.emplace_back( repair_item, items_needed ); // TODO: this may take up to 2 minutes, and so should start an activity instead p.moves -= to_moves<int>( 30_seconds * character_funcs::fine_detail_vision_mod( p ) ); p.practice( used_skill, items_needed * 3 + 3 ); diff --git a/src/iuse_software_lightson.cpp b/src/iuse_software_lightson.cpp index ffd516142e9e..9d5f6ab26950 100644 --- a/src/iuse_software_lightson.cpp +++ b/src/iuse_software_lightson.cpp @@ -151,9 +151,9 @@ int lightson_game::start_game() ui.on_redraw( [&]( const ui_adaptor & ) { std::vector<std::string> shortcuts; - shortcuts.push_back( _( "<spacebar or 5> toggle lights" ) ); - shortcuts.push_back( _( "<r>eset" ) ); - shortcuts.push_back( _( "<q>uit" ) ); + shortcuts.emplace_back( _( "<spacebar or 5> toggle lights" ) ); + shortcuts.emplace_back( _( "<r>eset" ) ); + shortcuts.emplace_back( _( "<q>uit" ) ); int iWidth = 0; for( auto &shortcut : shortcuts ) { diff --git a/src/iuse_software_minesweeper.cpp b/src/iuse_software_minesweeper.cpp index 9fdee2d7ffa7..7789ac624030 100644 --- a/src/iuse_software_minesweeper.cpp +++ b/src/iuse_software_minesweeper.cpp @@ -181,9 +181,9 @@ int minesweeper_game::start_game() draw_border( w_minesweeper_border ); std::vector<std::string> shortcuts; - shortcuts.push_back( _( "<n>ew level" ) ); - shortcuts.push_back( _( "<f>lag" ) ); - shortcuts.push_back( _( "<q>uit" ) ); + shortcuts.emplace_back( _( "<n>ew level" ) ); + shortcuts.emplace_back( _( "<f>lag" ) ); + shortcuts.emplace_back( _( "<q>uit" ) ); int iWidth = 0; for( auto &shortcut : shortcuts ) { diff --git a/src/iuse_software_snake.cpp b/src/iuse_software_snake.cpp index 7b1093bb7bf7..659db8f9b364 100644 --- a/src/iuse_software_snake.cpp +++ b/src/iuse_software_snake.cpp @@ -61,18 +61,18 @@ void snake_game::snake_over( const catacurses::window &w_snake, int iScore ) mvwputch( w_snake, point( 71, body_length + 2 ), c_green, 'v' ); std::vector<std::string> game_over_text; - game_over_text.push_back( R"( ________ _____ _____ ___________)" ); - game_over_text.push_back( R"( / _____/ / _ \ / \ \_ _____/)" ); - game_over_text.push_back( R"(/ \ ___ / /_\ \ / \ / \ | __)_ )" ); - game_over_text.push_back( R"(\ \_\ \/ | \/ Y \ | \)" ); - game_over_text.push_back( R"( \______ /\____|__ /\____|__ //_______ /)" ); - game_over_text.push_back( R"( \/ \/ \/ \/ )" ); - game_over_text.push_back( R"( ________ ____ _________________________ )" ); - game_over_text.push_back( R"( \_____ \\ \ / /\_ _____/\______ \ )" ); - game_over_text.push_back( R"( / | \\ Y / | __)_ | _/ )" ); - game_over_text.push_back( R"( / | \\ / | \ | | \ )" ); - game_over_text.push_back( R"( \_______ / \___/ /_______ / |____|_ / )" ); - game_over_text.push_back( R"( \/ \/ \/ )" ); + game_over_text.emplace_back( R"( ________ _____ _____ ___________)" ); + game_over_text.emplace_back( R"( / _____/ / _ \ / \ \_ _____/)" ); + game_over_text.emplace_back( R"(/ \ ___ / /_\ \ / \ / \ | __)_ )" ); + game_over_text.emplace_back( R"(\ \_\ \/ | \/ Y \ | \)" ); + game_over_text.emplace_back( R"( \______ /\____|__ /\____|__ //_______ /)" ); + game_over_text.emplace_back( R"( \/ \/ \/ \/ )" ); + game_over_text.emplace_back( R"( ________ ____ _________________________ )" ); + game_over_text.emplace_back( R"( \_____ \\ \ / /\_ _____/\______ \ )" ); + game_over_text.emplace_back( R"( / | \\ Y / | __)_ | _/ )" ); + game_over_text.emplace_back( R"( / | \\ / | \ | | \ )" ); + game_over_text.emplace_back( R"( \_______ / \___/ /_______ / |____|_ / )" ); + game_over_text.emplace_back( R"( \/ \/ \/ )" ); for( size_t i = 0; i < game_over_text.size(); i++ ) { mvwprintz( w_snake, point( 17, i + 3 ), c_light_red, game_over_text[i] ); @@ -103,7 +103,7 @@ int snake_game::start_game() ui.mark_resize(); //Snake start position - vSnakeBody.push_back( std::make_pair( FULL_SCREEN_HEIGHT / 2, FULL_SCREEN_WIDTH / 2 ) ); + vSnakeBody.emplace_back( FULL_SCREEN_HEIGHT / 2, FULL_SCREEN_WIDTH / 2 ); mSnakeBody[FULL_SCREEN_HEIGHT / 2][FULL_SCREEN_WIDTH / 2] = true; //Snake start direction @@ -144,28 +144,28 @@ int snake_game::start_game() do { //Check if we hit a border if( vSnakeBody[vSnakeBody.size() - 1].first + iDirY == 0 ) { - vSnakeBody.push_back( std::make_pair( vSnakeBody[vSnakeBody.size() - 1].first + - iDirY + FULL_SCREEN_HEIGHT - 2, - vSnakeBody[vSnakeBody.size() - 1].second + iDirX ) ); + vSnakeBody.emplace_back( vSnakeBody[vSnakeBody.size() - 1].first + + iDirY + FULL_SCREEN_HEIGHT - 2, + vSnakeBody[vSnakeBody.size() - 1].second + iDirX ); } else if( vSnakeBody[vSnakeBody.size() - 1].first + iDirY == FULL_SCREEN_HEIGHT - 1 ) { - vSnakeBody.push_back( std::make_pair( vSnakeBody[vSnakeBody.size() - 1].first + - iDirY - FULL_SCREEN_HEIGHT + 2, - vSnakeBody[vSnakeBody.size() - 1].second + iDirX ) ); + vSnakeBody.emplace_back( vSnakeBody[vSnakeBody.size() - 1].first + + iDirY - FULL_SCREEN_HEIGHT + 2, + vSnakeBody[vSnakeBody.size() - 1].second + iDirX ); } else if( vSnakeBody[vSnakeBody.size() - 1].second + iDirX == 0 ) { - vSnakeBody.push_back( std::make_pair( vSnakeBody[vSnakeBody.size() - 1].first + iDirY, - vSnakeBody[vSnakeBody.size() - 1].second + - iDirX + FULL_SCREEN_WIDTH - 2 ) ); + vSnakeBody.emplace_back( vSnakeBody[vSnakeBody.size() - 1].first + iDirY, + vSnakeBody[vSnakeBody.size() - 1].second + + iDirX + FULL_SCREEN_WIDTH - 2 ); } else if( vSnakeBody[vSnakeBody.size() - 1].second + iDirX == FULL_SCREEN_WIDTH - 1 ) { - vSnakeBody.push_back( std::make_pair( vSnakeBody[vSnakeBody.size() - 1].first + iDirY, - vSnakeBody[vSnakeBody.size() - 1].second + - iDirX - FULL_SCREEN_WIDTH + 2 ) ); + vSnakeBody.emplace_back( vSnakeBody[vSnakeBody.size() - 1].first + iDirY, + vSnakeBody[vSnakeBody.size() - 1].second + + iDirX - FULL_SCREEN_WIDTH + 2 ); } else { - vSnakeBody.push_back( std::make_pair( vSnakeBody[vSnakeBody.size() - 1].first + iDirY, - vSnakeBody[vSnakeBody.size() - 1].second + iDirX ) ); + vSnakeBody.emplace_back( vSnakeBody[vSnakeBody.size() - 1].first + iDirY, + vSnakeBody[vSnakeBody.size() - 1].second + iDirX ); } //Check if we hit ourselves diff --git a/src/iuse_software_sokoban.cpp b/src/iuse_software_sokoban.cpp index 9731c4309f2e..cd260327a785 100644 --- a/src/iuse_software_sokoban.cpp +++ b/src/iuse_software_sokoban.cpp @@ -90,8 +90,8 @@ void sokoban_game::parse_level( std::istream &fin ) } if( sLine[i] == '.' || sLine[i] == '*' || sLine[i] == '+' ) { - vLevelDone[iNumLevel].push_back( std::make_pair( static_cast<int> - ( mLevelInfo[iNumLevel]["MaxLevelY"] ), static_cast<int>( i ) ) ); + vLevelDone[iNumLevel].emplace_back( static_cast<int> + ( mLevelInfo[iNumLevel]["MaxLevelY"] ), static_cast<int>( i ) ); } vLevel[iNumLevel][mLevelInfo[iNumLevel]["MaxLevelY"]][i] = sLine[i]; @@ -246,11 +246,11 @@ int sokoban_game::start_game() draw_border( w_sokoban, BORDER_COLOR, _( "Sokoban" ), hilite( c_white ) ); std::vector<std::string> shortcuts; - shortcuts.push_back( _( "<+> next" ) ); // '+': next - shortcuts.push_back( _( "<-> prev" ) ); // '-': prev - shortcuts.push_back( _( "<r>eset" ) ); // 'r': reset - shortcuts.push_back( _( "<q>uit" ) ); // 'q': quit - shortcuts.push_back( _( "<u>ndo move" ) ); // 'u': undo move + shortcuts.emplace_back( _( "<+> next" ) ); // '+': next + shortcuts.emplace_back( _( "<-> prev" ) ); // '-': prev + shortcuts.emplace_back( _( "<r>eset" ) ); // 'r': reset + shortcuts.emplace_back( _( "<q>uit" ) ); // 'q': quit + shortcuts.emplace_back( _( "<u>ndo move" ) ); // 'u': undo move int indent = 10; for( auto &shortcut : shortcuts ) { @@ -372,7 +372,7 @@ int sokoban_game::start_game() bMovePlayer = true; mLevel[p_pack.y][p_pack.x] = sMovePackTo == "." ? "*" : "$"; - vUndo.push_back( cUndo( dir, sMoveTo ) ); + vUndo.emplace_back( dir, sMoveTo ); iMoves--; } @@ -382,7 +382,7 @@ int sokoban_game::start_game() if( bMovePlayer ) { //move player - vUndo.push_back( cUndo( pl, mLevel[pl.y][pl.x] ) ); + vUndo.emplace_back( pl, mLevel[pl.y][pl.x] ); mLevel[pl.y][pl.x] = mLevel[pl.y][pl.x] == "+" ? "." : " "; mLevel[pl.y + dir.y][pl.x + dir.x] = sMoveTo == "." || sMoveTo == "*" ? "+" : "@"; diff --git a/src/language.cpp b/src/language.cpp index 5b12ebf95eb9..da7c57a00568 100644 --- a/src/language.cpp +++ b/src/language.cpp @@ -242,7 +242,7 @@ static std::vector<language_info> load_languages( const std::string &filepath ) } } if( info.genders.empty() ) { - info.genders.push_back( "n" ); + info.genders.emplace_back( "n" ); } } diff --git a/src/lightmap.cpp b/src/lightmap.cpp index cbd0841eb1a3..1c8e15b8e800 100644 --- a/src/lightmap.cpp +++ b/src/lightmap.cpp @@ -530,7 +530,7 @@ void map::generate_lightmap( const int zlev ) } const float light_override = cur->local_light_override(); if( light_override >= 0.0 ) { - lm_override.push_back( std::pair<tripoint, float>( p, light_override ) ); + lm_override.emplace_back( p, light_override ); } } } diff --git a/src/line.cpp b/src/line.cpp index 5ec0fc195149..f21d8ce4d433 100644 --- a/src/line.cpp +++ b/src/line.cpp @@ -596,16 +596,16 @@ std::vector<point> squares_in_direction( point p1, point p2 ) adjacent_squares.push_back( center_square ); if( p1.x == center_square.x ) { // Horizontally adjacent. - adjacent_squares.push_back( point( p1.x + 1, center_square.y ) ); - adjacent_squares.push_back( point( p1.x - 1, center_square.y ) ); + adjacent_squares.emplace_back( p1.x + 1, center_square.y ); + adjacent_squares.emplace_back( p1.x - 1, center_square.y ); } else if( p1.y == center_square.y ) { // Vertically adjacent. - adjacent_squares.push_back( point( center_square.x, p1.y + 1 ) ); - adjacent_squares.push_back( point( center_square.x, p1.y - 1 ) ); + adjacent_squares.emplace_back( center_square.x, p1.y + 1 ); + adjacent_squares.emplace_back( center_square.x, p1.y - 1 ); } else { // Diagonally adjacent. - adjacent_squares.push_back( point( p1.x, center_square.y ) ); - adjacent_squares.push_back( point( center_square.x, p1.y ) ); + adjacent_squares.emplace_back( p1.x, center_square.y ); + adjacent_squares.emplace_back( center_square.x, p1.y ); } return adjacent_squares; } diff --git a/src/map_field.cpp b/src/map_field.cpp index 20a6d3b7b912..423ffd33fe79 100644 --- a/src/map_field.cpp +++ b/src/map_field.cpp @@ -1357,19 +1357,19 @@ void map::player_in_field( player &u ) if( !u.is_on_ground() ) { switch( adjusted_intensity ) { case 3: - parts_burned.push_back( bodypart_id( "hand_l" ) ); - parts_burned.push_back( bodypart_id( "hand_r" ) ); - parts_burned.push_back( bodypart_id( "arm_l" ) ); - parts_burned.push_back( bodypart_id( "arm_r" ) ); + parts_burned.emplace_back( "hand_l" ); + parts_burned.emplace_back( "hand_r" ); + parts_burned.emplace_back( "arm_l" ); + parts_burned.emplace_back( "arm_r" ); /* fallthrough */ case 2: - parts_burned.push_back( bodypart_id( "torso" ) ); + parts_burned.emplace_back( "torso" ); /* fallthrough */ case 1: - parts_burned.push_back( bodypart_id( "foot_l" ) ); - parts_burned.push_back( bodypart_id( "foot_r" ) ); - parts_burned.push_back( bodypart_id( "leg_l" ) ); - parts_burned.push_back( bodypart_id( "leg_r" ) ); + parts_burned.emplace_back( "foot_l" ); + parts_burned.emplace_back( "foot_r" ); + parts_burned.emplace_back( "leg_l" ); + parts_burned.emplace_back( "leg_r" ); } } else { // Lying in the fire is BAAAD news, hits every body part. @@ -1941,7 +1941,7 @@ void map::propagate_field( const tripoint ¢er, const field_type_id &type, in using gas_blast = std::pair<float, tripoint>; std::priority_queue<gas_blast, std::vector<gas_blast>, pair_greater_cmp_first> open; std::set<tripoint> closed; - open.push( { 0.0f, center } ); + open.emplace( 0.0f, center ); const bool not_gas = type.obj().phase != GAS; @@ -1995,7 +1995,7 @@ void map::propagate_field( const tripoint ¢er, const field_type_id &type, in continue; } if( !obstructed_by_vehicle_rotation( gp.second, pt ) ) { - open.push( { static_cast<float>( rl_dist( center, pt ) ), pt } ); + open.emplace( static_cast<float>( rl_dist( center, pt ) ), pt ); } } } diff --git a/src/map_item_stack.cpp b/src/map_item_stack.cpp index b2c832955157..a32cbc42b22b 100644 --- a/src/map_item_stack.cpp +++ b/src/map_item_stack.cpp @@ -21,7 +21,7 @@ map_item_stack::item_group::item_group( const tripoint &p, const int arg_count ) map_item_stack::map_item_stack() : example( nullptr ), totalcount( 0 ) { - vIG.push_back( item_group() ); + vIG.emplace_back( ); } map_item_stack::map_item_stack( const item *const it, const tripoint &pos ) : example( it ), diff --git a/src/mapgen.cpp b/src/mapgen.cpp index d50bb98f3613..a7c84a6844f4 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -3840,37 +3840,37 @@ void map::draw_lab( mapgendata &dat ) if( is_ot_match( "stairs", terrain_type, ot_match_type::contains ) ) { // Stairs going down std::vector<point> stair_points; if( tw != 0 ) { - stair_points.push_back( point( SEEX - 1, 2 ) ); - stair_points.push_back( point( SEEX - 1, 2 ) ); - stair_points.push_back( point( SEEX, 2 ) ); - stair_points.push_back( point( SEEX, 2 ) ); + stair_points.emplace_back( SEEX - 1, 2 ); + stair_points.emplace_back( SEEX - 1, 2 ); + stair_points.emplace_back( SEEX, 2 ); + stair_points.emplace_back( SEEX, 2 ); } if( rw != 1 ) { - stair_points.push_back( point( SEEX * 2 - 3, SEEY - 1 ) ); - stair_points.push_back( point( SEEX * 2 - 3, SEEY - 1 ) ); - stair_points.push_back( point( SEEX * 2 - 3, SEEY ) ); - stair_points.push_back( point( SEEX * 2 - 3, SEEY ) ); + stair_points.emplace_back( SEEX * 2 - 3, SEEY - 1 ); + stair_points.emplace_back( SEEX * 2 - 3, SEEY - 1 ); + stair_points.emplace_back( SEEX * 2 - 3, SEEY ); + stair_points.emplace_back( SEEX * 2 - 3, SEEY ); } if( bw != 1 ) { - stair_points.push_back( point( SEEX - 1, SEEY * 2 - 3 ) ); - stair_points.push_back( point( SEEX - 1, SEEY * 2 - 3 ) ); - stair_points.push_back( point( SEEX, SEEY * 2 - 3 ) ); - stair_points.push_back( point( SEEX, SEEY * 2 - 3 ) ); + stair_points.emplace_back( SEEX - 1, SEEY * 2 - 3 ); + stair_points.emplace_back( SEEX - 1, SEEY * 2 - 3 ); + stair_points.emplace_back( SEEX, SEEY * 2 - 3 ); + stair_points.emplace_back( SEEX, SEEY * 2 - 3 ); } if( lw != 0 ) { - stair_points.push_back( point( 2, SEEY - 1 ) ); - stair_points.push_back( point( 2, SEEY - 1 ) ); - stair_points.push_back( point( 2, SEEY ) ); - stair_points.push_back( point( 2, SEEY ) ); + stair_points.emplace_back( 2, SEEY - 1 ); + stair_points.emplace_back( 2, SEEY - 1 ); + stair_points.emplace_back( 2, SEEY ); + stair_points.emplace_back( 2, SEEY ); } - stair_points.push_back( point( int( SEEX / 2 ), SEEY ) ); - stair_points.push_back( point( int( SEEX / 2 ), SEEY - 1 ) ); - stair_points.push_back( point( int( SEEX / 2 ) + SEEX, SEEY ) ); - stair_points.push_back( point( int( SEEX / 2 ) + SEEX, SEEY - 1 ) ); - stair_points.push_back( point( SEEX, int( SEEY / 2 ) ) ); - stair_points.push_back( point( SEEX + 2, int( SEEY / 2 ) ) ); - stair_points.push_back( point( SEEX, int( SEEY / 2 ) + SEEY ) ); - stair_points.push_back( point( SEEX + 2, int( SEEY / 2 ) + SEEY ) ); + stair_points.emplace_back( int( SEEX / 2 ), SEEY ); + stair_points.emplace_back( int( SEEX / 2 ), SEEY - 1 ); + stair_points.emplace_back( int( SEEX / 2 ) + SEEX, SEEY ); + stair_points.emplace_back( int( SEEX / 2 ) + SEEX, SEEY - 1 ); + stair_points.emplace_back( SEEX, int( SEEY / 2 ) ); + stair_points.emplace_back( SEEX + 2, int( SEEY / 2 ) ); + stair_points.emplace_back( SEEX, int( SEEY / 2 ) + SEEY ); + stair_points.emplace_back( SEEX + 2, int( SEEY / 2 ) + SEEY ); const point p = random_entry( stair_points ); ter_set( p, t_stairs_down ); } @@ -4506,7 +4506,7 @@ void map::draw_temple( mapgendata &dat ) static const std::vector<ter_id> terrains = { t_floor_red, t_floor_green, t_floor_blue, }; - path.push_back( point( x, y ) ); + path.emplace_back( x, y ); ter_set( point( x, y ), random_entry( terrains ) ); if( y == SEEY * 2 - 2 ) { if( x < SEEX - 1 ) { @@ -4519,7 +4519,7 @@ void map::draw_temple( mapgendata &dat ) for( int nx = x - 1; nx <= x + 1; nx++ ) { for( int ny = y; ny <= y + 1; ny++ ) { if( ter( point( nx, ny ) ) == t_rock_floor ) { - next.push_back( point( nx, ny ) ); + next.emplace_back( nx, ny ); } } } diff --git a/src/melee.cpp b/src/melee.cpp index 915b3a3b8657..7e84dc059259 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -1688,15 +1688,15 @@ bool Character::block_hit( Creature *source, bodypart_id &bp_hit, damage_instanc } else { std::vector<bodypart_id> block_parts; if( martial_arts_data->can_leg_block( *this ) ) { - block_parts.emplace_back( bodypart_id( "leg_l" ) ); - block_parts.emplace_back( bodypart_id( "leg_r" ) ); + block_parts.emplace_back( "leg_l" ); + block_parts.emplace_back( "leg_r" ); } // If you have no martial arts you can still try to block with your arms. // But martial arts with leg blocks only don't magically get arm blocks. // Edge case: Leg block only martial arts gain arm blocks if both legs broken. if( martial_arts_data->can_arm_block( *this ) || block_parts.empty() ) { - block_parts.emplace_back( bodypart_id( "arm_l" ) ); - block_parts.emplace_back( bodypart_id( "arm_r" ) ); + block_parts.emplace_back( "arm_l" ); + block_parts.emplace_back( "arm_r" ); } block_parts.erase( std::remove_if( block_parts.begin(), block_parts.end(), [this]( bodypart_id & bpid ) { diff --git a/src/mission.cpp b/src/mission.cpp index eeca0b3bb5b9..fe1dc0fbbfb1 100644 --- a/src/mission.cpp +++ b/src/mission.cpp @@ -308,7 +308,7 @@ void mission::wrap_up() for( std::pair<const itype_id, int> &cnt : matches ) { if( cnt.second >= type->item_count ) { - comps.push_back( item_comp( cnt.first, type->item_count ) ); + comps.emplace_back( cnt.first, type->item_count ); } } @@ -317,10 +317,10 @@ void mission::wrap_up() if( remove_container ) { std::vector<item_comp> container_comp = std::vector<item_comp>(); if( !empty_container.is_null() ) { - container_comp.push_back( item_comp( empty_container, type->item_count ) ); + container_comp.emplace_back( empty_container, type->item_count ); u.consume_items( container_comp ); } else { - container_comp.push_back( item_comp( container, type->item_count ) ); + container_comp.emplace_back( container, type->item_count ); u.consume_items( container_comp ); } } @@ -328,7 +328,7 @@ void mission::wrap_up() break; case MGOAL_FIND_ITEM: - comps.push_back( item_comp( type->item_id, item_count ) ); + comps.emplace_back( type->item_id, item_count ); u.consume_items( comps ); break; case MGOAL_FIND_ANY_ITEM: diff --git a/src/monattack.cpp b/src/monattack.cpp index d2acb080480e..15f213031190 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -1019,7 +1019,7 @@ bool mattack::resurrect( monster *z ) int raise_score = ( i->damage_level( 4 ) + 1 ) * mt->hp + i->burnt; lowest_raise_score = std::min( lowest_raise_score, raise_score ); if( raise_score <= raising_level ) { - corpses.push_back( std::make_pair( p, i ) ); + corpses.emplace_back( p, i ); } } } diff --git a/src/mondeath.cpp b/src/mondeath.cpp index 9ed0fe3c7566..220a4ef06338 100644 --- a/src/mondeath.cpp +++ b/src/mondeath.cpp @@ -829,15 +829,15 @@ void mdeath::detonate( monster &z ) std::vector<std::pair<std::string, long>> dets; for( const itype_id &bomb_id : pre_dets ) { if( bomb_id.str() == "bot_grenade_hack" ) { - dets.push_back( std::make_pair( "grenade_act", 5 ) ); + dets.emplace_back( "grenade_act", 5 ); } else if( bomb_id.str() == "bot_flashbang_hack" ) { - dets.push_back( std::make_pair( "flashbang_act", 5 ) ); + dets.emplace_back( "flashbang_act", 5 ); } else if( bomb_id.str() == "bot_gasbomb_hack" ) { - dets.push_back( std::make_pair( "gasbomb_act", 20 ) ); + dets.emplace_back( "gasbomb_act", 20 ); } else if( bomb_id.str() == "bot_c4_hack" ) { - dets.push_back( std::make_pair( "c4armed", 10 ) ); + dets.emplace_back( "c4armed", 10 ); } else if( bomb_id.str() == "bot_mininuke_hack" ) { - dets.push_back( std::make_pair( "mininuke_act", 20 ) ); + dets.emplace_back( "mininuke_act", 20 ); } else { // Get the transformation item const iuse_transform *actor = dynamic_cast<const iuse_transform *>( diff --git a/src/monexamine.cpp b/src/monexamine.cpp index fc9ba9d9b760..b2a7a0d9df6a 100644 --- a/src/monexamine.cpp +++ b/src/monexamine.cpp @@ -361,9 +361,9 @@ void monexamine::shear_animal( monster &z ) // pin the sheep in place if it isn't already if( !z.has_effect( effect_tied ) ) { z.add_effect( effect_tied, 1_turns ); - you.activity->str_values.push_back( "temp_tie" ); + you.activity->str_values.emplace_back( "temp_tie" ); } - you.activity->targets.push_back( you.best_quality_item( qual_shear ) ); + you.activity->targets.emplace_back( you.best_quality_item( qual_shear ) ); add_msg( _( "You start shearing the %s." ), z.get_name() ); } @@ -952,7 +952,7 @@ void monexamine::milk_source( monster &source_mon ) bool temp_tie = !source_mon.has_effect( effect_tied ); if( temp_tie ) { source_mon.add_effect( effect_tied, 1_turns, num_bp ); - you.activity->str_values.push_back( "temp_tie" ); + you.activity->str_values.emplace_back( "temp_tie" ); } add_msg( _( "You milk the %s." ), source_mon.get_name() ); } else { diff --git a/src/mongroup.cpp b/src/mongroup.cpp index 70262368c9a1..d3f053531668 100644 --- a/src/mongroup.cpp +++ b/src/mongroup.cpp @@ -125,13 +125,13 @@ MonsterGroupResult MonsterGroupManager::GetResultFromGroup( //Collect valid time of day ranges if( elem == "DAY" || elem == "NIGHT" || elem == "DUSK" || elem == "DAWN" ) { if( elem == "DAY" ) { - valid_times_of_day.push_back( std::make_pair( sunrise, sunset ) ); + valid_times_of_day.emplace_back( sunrise, sunset ); } else if( elem == "NIGHT" ) { - valid_times_of_day.push_back( std::make_pair( sunset, sunrise ) ); + valid_times_of_day.emplace_back( sunset, sunrise ); } else if( elem == "DUSK" ) { - valid_times_of_day.push_back( std::make_pair( sunset - 1_hours, sunset + 1_hours ) ); + valid_times_of_day.emplace_back( sunset - 1_hours, sunset + 1_hours ); } else if( elem == "DAWN" ) { - valid_times_of_day.push_back( std::make_pair( sunrise - 1_hours, sunrise + 1_hours ) ); + valid_times_of_day.emplace_back( sunrise - 1_hours, sunrise + 1_hours ); } } diff --git a/src/monmove.cpp b/src/monmove.cpp index 9abea01b7138..9b72f6e1881c 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -1386,7 +1386,7 @@ static std::vector<tripoint> get_bashing_zone( const tripoint &bashee, const tri for( const tripoint &p : path ) { std::vector<point> swath = squares_in_direction( previous.xy(), p.xy() ); for( point q : swath ) { - zone.push_back( tripoint( q, bashee.z ) ); + zone.emplace_back( q, bashee.z ); } previous = p; @@ -1921,9 +1921,9 @@ void monster::stumble() for( const tripoint &dest : here.points_in_radius( pos(), 1 ) ) { if( dest != pos() ) { if( here.has_flag( TFLAG_RAMP_DOWN, dest ) ) { - valid_stumbles.push_back( tripoint( dest.xy(), dest.z - 1 ) ); + valid_stumbles.emplace_back( dest.xy(), dest.z - 1 ); } else if( here.has_flag( TFLAG_RAMP_UP, dest ) ) { - valid_stumbles.push_back( tripoint( dest.xy(), dest.z + 1 ) ); + valid_stumbles.emplace_back( dest.xy(), dest.z + 1 ); } else { valid_stumbles.push_back( dest ); } diff --git a/src/mutation_data.cpp b/src/mutation_data.cpp index 994ec211643a..952ad9802ce9 100644 --- a/src/mutation_data.cpp +++ b/src/mutation_data.cpp @@ -460,7 +460,7 @@ void mutation_branch::load( const JsonObject &jo, const std::string & ) optional( jo, was_loaded, "enchantments", enchantments ); for( const std::string s : jo.get_array( "no_cbm_on_bp" ) ) { - no_cbm_on_bp.emplace( bodypart_str_id( s ) ); + no_cbm_on_bp.emplace( s ); } optional( jo, was_loaded, "body_size", body_size ); @@ -724,7 +724,7 @@ void mutation_branch::finalize() { for( const mutation_branch &branch : get_all() ) { for( const std::string &cat : branch.category ) { - mutations_category[cat].push_back( trait_id( branch.id ) ); + mutations_category[cat].emplace_back( branch.id ); } } finalize_trait_blacklist(); diff --git a/src/newcharacter.cpp b/src/newcharacter.cpp index 506959946783..0c2dcf670a51 100644 --- a/src/newcharacter.cpp +++ b/src/newcharacter.cpp @@ -2499,10 +2499,10 @@ tab_direction set_description( avatar &you, const bool allow_reroll, std::vector<std::string> vStatNames; mvwprintz( w_stats, point_zero, COL_HEADER, _( "Stats:" ) ); - vStatNames.push_back( _( "Strength:" ) ); - vStatNames.push_back( _( "Dexterity:" ) ); - vStatNames.push_back( _( "Intelligence:" ) ); - vStatNames.push_back( _( "Perception:" ) ); + vStatNames.emplace_back( _( "Strength:" ) ); + vStatNames.emplace_back( _( "Dexterity:" ) ); + vStatNames.emplace_back( _( "Intelligence:" ) ); + vStatNames.emplace_back( _( "Perception:" ) ); int pos = 0; for( size_t i = 0; i < vStatNames.size(); i++ ) { pos = ( utf8_width( vStatNames[i] ) > pos ? diff --git a/src/npc.cpp b/src/npc.cpp index a5bc00b74d36..4ec5277c2d6d 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -249,10 +249,10 @@ void npc_template::load( const JsonObject &jsobj ) guy.mission = static_cast<npc_mission>( jsobj.get_int( "mission" ) ); guy.chatbin.first_topic = jsobj.get_string( "chat" ); if( jsobj.has_string( "mission_offered" ) ) { - guy.miss_ids.emplace_back( mission_type_id( jsobj.get_string( "mission_offered" ) ) ); + guy.miss_ids.emplace_back( jsobj.get_string( "mission_offered" ) ); } else if( jsobj.has_array( "mission_offered" ) ) { for( const std::string line : jsobj.get_array( "mission_offered" ) ) { - guy.miss_ids.emplace_back( mission_type_id( line ) ); + guy.miss_ids.emplace_back( line ); } } npc_templates.emplace( string_id<npc_template>( guy.idz ), std::move( tem ) ); diff --git a/src/npcmove.cpp b/src/npcmove.cpp index 4f5a24651c6d..a6d11ca49919 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -1220,7 +1220,7 @@ void npc::execute_action( npc_action action ) my_spot = priority; } - seats.push_back( std::make_pair( priority, static_cast<int>( vp.part_index() ) ) ); + seats.emplace_back( priority, static_cast<int>( vp.part_index() ) ); } if( my_spot >= 3 ) { @@ -3217,7 +3217,7 @@ void npc::drop_items( units::mass drop_weight, units::volume drop_volume, int mi } } if( !added_wgt ) { - rWgt.push_back( ratio_index( wgt_ratio, i ) ); + rWgt.emplace_back( wgt_ratio, i ); } for( size_t j = 0; j < rVol.size() && !added_vol; j++ ) { if( vol_ratio > rVol[j].ratio ) { @@ -3226,7 +3226,7 @@ void npc::drop_items( units::mass drop_weight, units::volume drop_volume, int mi } } if( !added_vol ) { - rVol.push_back( ratio_index( vol_ratio, i ) ); + rVol.emplace_back( vol_ratio, i ); } } diff --git a/src/npctalk.cpp b/src/npctalk.cpp index 7a7755fb17ad..0ae6dafb5a9d 100644 --- a/src/npctalk.cpp +++ b/src/npctalk.cpp @@ -1697,7 +1697,7 @@ void parse_tags( std::string &phrase, const Character &u, const Character &me, void dialogue::add_topic( const std::string &topic_id ) { - topic_stack.push_back( talk_topic( topic_id ) ); + topic_stack.emplace_back( topic_id ); } void dialogue::add_topic( const talk_topic &topic ) @@ -2132,7 +2132,7 @@ void talk_effect_fun_t::set_u_buy_item( const itype_id &item_name, int cost, int // Update structure used by mission descriptions. if( cost <= 0 ) { - likely_rewards.push_back( std::pair<int, itype_id>( count, item_name ) ); + likely_rewards.emplace_back( count, item_name ); } } diff --git a/src/options.cpp b/src/options.cpp index c6ca07cb30d7..bdaf6a37e84e 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -1471,7 +1471,7 @@ void options_manager::add_options_interface() { "", translate_marker( "System language" ) }, }; for( const language_info &info : list_available_languages() ) { - lang_options.push_back( {info.id, no_translation( info.name )} ); + lang_options.emplace_back( info.id, no_translation( info.name ) ); } add( "USE_LANG", interface, translate_marker( "Language" ), diff --git a/src/output.cpp b/src/output.cpp index 1ed11a8e1431..978af7aad7ba 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -1820,7 +1820,7 @@ void scrollingcombattext::add( point pos, direction p_oDir, iter->advanceStepOffset(); } } - vSCT.push_back( cSCT( pos, p_oDir, p_sText, p_gmt, p_sText2, p_gmt2, p_sType ) ); + vSCT.emplace_back( pos, p_oDir, p_sText, p_gmt, p_sText2, p_gmt2, p_sType ); } } diff --git a/src/overmap.cpp b/src/overmap.cpp index 24b946335388..0489fde184b5 100644 --- a/src/overmap.cpp +++ b/src/overmap.cpp @@ -1764,10 +1764,10 @@ bool overmap::generate_sub( const int z ) sewer_points.emplace_back( i, j ); } else if( oter_above == "anthill" || oter_above == "acid_anthill" ) { const int size = rng( MIN_ANT_SIZE, MAX_ANT_SIZE ); - ant_points.push_back( city( p.xy(), size ) ); + ant_points.emplace_back( p.xy(), size ); } else if( oter_above == "slimepit_down" ) { const int size = rng( MIN_GOO_SIZE, MAX_GOO_SIZE ); - goo_points.push_back( city( p.xy(), size ) ); + goo_points.emplace_back( p.xy(), size ); } else if( oter_above == "forest_water" ) { ter_set( p, oter_id( "cavern" ) ); chip_rock( p ); @@ -1788,11 +1788,11 @@ bool overmap::generate_sub( const int z ) } else if( is_ot_match( "hidden_lab_stairs", oter_above, ot_match_type::contains ) ) { handle_lab_core( p, lab_points, lab_type::standard ); } else if( is_ot_match( "mine_entrance", oter_ground, ot_match_type::prefix ) && z == -2 ) { - mine_points.push_back( city( ( p + tripoint_west ).xy(), rng( 6 + z, 10 + z ) ) ); + mine_points.emplace_back( ( p + tripoint_west ).xy(), rng( 6 + z, 10 + z ) ); requires_sub = true; } else if( oter_above == "mine_down" ) { ter_set( p, oter_id( "mine" ) ); - mine_points.push_back( city( p.xy(), rng( 6 + z, 10 + z ) ) ); + mine_points.emplace_back( p.xy(), rng( 6 + z, 10 + z ) ); // technically not all finales need a sub level, // but at this point we don't know requires_sub = true; @@ -2866,10 +2866,10 @@ void overmap::place_rivers( const overmap *north, const overmap *east, const ove while( river_start.empty() || river_start.size() + 1 < river_end.size() ) { new_rivers.clear(); if( north == nullptr && one_in( river_chance ) ) { - new_rivers.push_back( point_om_omt( rng( 10, OMAPX - 11 ), 0 ) ); + new_rivers.emplace_back( rng( 10, OMAPX - 11 ), 0 ); } if( west == nullptr && one_in( river_chance ) ) { - new_rivers.push_back( point_om_omt( 0, rng( 10, OMAPY - 11 ) ) ); + new_rivers.emplace_back( 0, rng( 10, OMAPY - 11 ) ); } river_start.push_back( random_entry( new_rivers ) ); } @@ -2878,10 +2878,10 @@ void overmap::place_rivers( const overmap *north, const overmap *east, const ove while( river_end.empty() || river_end.size() + 1 < river_start.size() ) { new_rivers.clear(); if( south == nullptr && one_in( river_chance ) ) { - new_rivers.push_back( point_om_omt( rng( 10, OMAPX - 11 ), OMAPY - 1 ) ); + new_rivers.emplace_back( rng( 10, OMAPX - 11 ), OMAPY - 1 ); } if( east == nullptr && one_in( river_chance ) ) { - new_rivers.push_back( point_om_omt( OMAPX - 1, rng( 10, OMAPY - 11 ) ) ); + new_rivers.emplace_back( OMAPX - 1, rng( 10, OMAPY - 11 ) ); } river_end.push_back( random_entry( new_rivers ) ); } @@ -2912,8 +2912,8 @@ void overmap::place_rivers( const overmap *north, const overmap *east, const ove } } else if( !river_end.empty() ) { if( river_start.size() != river_end.size() ) { - river_start.push_back( point_om_omt( rng( OMAPX / 4, ( OMAPX * 3 ) / 4 ), - rng( OMAPY / 4, ( OMAPY * 3 ) / 4 ) ) ); + river_start.emplace_back( rng( OMAPX / 4, ( OMAPX * 3 ) / 4 ), + rng( OMAPY / 4, ( OMAPY * 3 ) / 4 ) ); } for( size_t i = 0; i < river_start.size(); i++ ) { place_river( river_start[i], river_end[i] ); @@ -4801,27 +4801,27 @@ void overmap::place_radios() // Since location have id such as "radio_tower_1_north", we must check the beginning of the id if( is_ot_match( "radio_tower", ter( pos_omt ), ot_match_type::prefix ) ) { if( one_in( 3 ) ) { - radios.push_back( radio_tower( pos_sm, strength(), "", radio_type::WEATHER_RADIO ) ); + radios.emplace_back( pos_sm, strength(), "", radio_type::WEATHER_RADIO ); } else { message = SNIPPET.expand( SNIPPET.random_from_category( "radio_archive" ).value_or( translation() ).translated() ); - radios.push_back( radio_tower( pos_sm, strength(), message ) ); + radios.emplace_back( pos_sm, strength(), message ); } } else if( is_ot_match( "lmoe", ter( pos_omt ), ot_match_type::prefix ) ) { message = string_format( _( "This is automated emergency shelter beacon %d%d." " Supplies, amenities and shelter are stocked." ), i, j ); - radios.push_back( radio_tower( pos_sm, strength() / 2, message ) ); + radios.emplace_back( pos_sm, strength() / 2, message ); } else if( is_ot_match( "fema_entrance", ter( pos_omt ), ot_match_type::prefix ) ) { message = string_format( _( "This is FEMA camp %d%d." " Supplies are limited, please bring supplemental food, water, and bedding." " This is FEMA camp %d%d. A designated long-term emergency shelter." ), i, j, i, j ); - radios.push_back( radio_tower( pos_sm, strength(), message ) ); + radios.emplace_back( pos_sm, strength(), message ); } else if( ter( pos_omt ) == "central_lab_entrance" && pos() == point_abs_om() ) { std::string message = _( "If you can hear this message, the probe to 021XC is functioning correctly." ); // Repeat the message on different frequencies for( int i = 0; i < 10; i++ ) { - radios.push_back( radio_tower( pos_sm, RADIO_MAX_STRENGTH, message ) ); + radios.emplace_back( pos_sm, RADIO_MAX_STRENGTH, message ); } } } diff --git a/src/overmap_location.cpp b/src/overmap_location.cpp index 1a981f585d39..b28bd581e790 100644 --- a/src/overmap_location.cpp +++ b/src/overmap_location.cpp @@ -58,7 +58,7 @@ std::vector<oter_type_id> overmap_location::get_all_terrains() const std::vector<oter_type_id> ret; ret.reserve( terrains.size() ); for( oter_type_str_id elem : terrains ) { - ret.push_back( elem ); + ret.emplace_back( elem ); } return ret; } diff --git a/src/overmapbuffer.cpp b/src/overmapbuffer.cpp index a7f4d3d3e741..80d16045450a 100644 --- a/src/overmapbuffer.cpp +++ b/src/overmapbuffer.cpp @@ -1514,10 +1514,10 @@ overmapbuffer::t_notes_vector overmapbuffer::get_notes( int z, const std::string if( pattern != nullptr && lcmatch( note.text, *pattern ) ) { continue; } - result.push_back( t_point_with_note( - project_combine( it.first, note.p ), - note.text - ) ); + result.emplace_back( + project_combine( it.first, note.p ), + note.text + ); } } return result; @@ -1540,10 +1540,10 @@ overmapbuffer::t_extras_vector overmapbuffer::get_extras( int z, const std::stri // pattern not found in note text continue; } - result.push_back( t_point_with_extra( - project_combine( om.pos(), p.xy() ), - om.extra( p ) - ) ); + result.emplace_back( + project_combine( om.pos(), p.xy() ), + om.extra( p ) + ); } } } diff --git a/src/panels.cpp b/src/panels.cpp index cdffebb918cd..070c308184e9 100644 --- a/src/panels.cpp +++ b/src/panels.cpp @@ -933,20 +933,20 @@ static void draw_stealth( avatar &u, const catacurses::window &w ) static void draw_time_graphic( const catacurses::window &w ) { std::vector<std::pair<char, nc_color> > vGlyphs; - vGlyphs.push_back( std::make_pair( '_', c_red ) ); - vGlyphs.push_back( std::make_pair( '_', c_cyan ) ); - vGlyphs.push_back( std::make_pair( '.', c_brown ) ); - vGlyphs.push_back( std::make_pair( ',', c_blue ) ); - vGlyphs.push_back( std::make_pair( '+', c_yellow ) ); - vGlyphs.push_back( std::make_pair( 'c', c_light_blue ) ); - vGlyphs.push_back( std::make_pair( '*', c_yellow ) ); - vGlyphs.push_back( std::make_pair( 'C', c_white ) ); - vGlyphs.push_back( std::make_pair( '+', c_yellow ) ); - vGlyphs.push_back( std::make_pair( 'c', c_light_blue ) ); - vGlyphs.push_back( std::make_pair( '.', c_brown ) ); - vGlyphs.push_back( std::make_pair( ',', c_blue ) ); - vGlyphs.push_back( std::make_pair( '_', c_red ) ); - vGlyphs.push_back( std::make_pair( '_', c_cyan ) ); + vGlyphs.emplace_back( '_', c_red ); + vGlyphs.emplace_back( '_', c_cyan ); + vGlyphs.emplace_back( '.', c_brown ); + vGlyphs.emplace_back( ',', c_blue ); + vGlyphs.emplace_back( '+', c_yellow ); + vGlyphs.emplace_back( 'c', c_light_blue ); + vGlyphs.emplace_back( '*', c_yellow ); + vGlyphs.emplace_back( 'C', c_white ); + vGlyphs.emplace_back( '+', c_yellow ); + vGlyphs.emplace_back( 'c', c_light_blue ); + vGlyphs.emplace_back( '.', c_brown ); + vGlyphs.emplace_back( ',', c_blue ); + vGlyphs.emplace_back( '_', c_red ); + vGlyphs.emplace_back( '_', c_cyan ); const int iHour = hour_of_day<int>( calendar::turn ); wprintz( w, c_white, "[" ); @@ -2042,31 +2042,31 @@ static std::vector<window_panel> initialize_default_classic_panels() { std::vector<window_panel> ret; - ret.emplace_back( window_panel( draw_health_classic, translate_marker( "Health" ), 7, 44, true ) ); - ret.emplace_back( window_panel( draw_location_classic, translate_marker( "Location" ), 1, 44, - true ) ); - ret.emplace_back( window_panel( draw_mana_classic, translate_marker( "Mana" ), 1, 44, true, - spell_panel ) ); - ret.emplace_back( window_panel( draw_weather_classic, translate_marker( "Weather" ), 1, 44, - true ) ); - ret.emplace_back( window_panel( draw_lighting_classic, translate_marker( "Lighting" ), 1, 44, - true ) ); - ret.emplace_back( window_panel( draw_weapon_classic, translate_marker( "Weapon" ), 1, 44, true ) ); - ret.emplace_back( window_panel( draw_weapon_classic_alt, translate_marker( "Weapon_alt" ), 2, 44, - false ) ); - ret.emplace_back( window_panel( draw_weightvolume_classic, translate_marker( "Wgt/Vol" ), 1, 44, - true ) ); - ret.emplace_back( window_panel( draw_time_classic, translate_marker( "Time" ), 1, 44, true ) ); - ret.emplace_back( window_panel( draw_wind, translate_marker( "Wind" ), 1, 44, false ) ); - ret.emplace_back( window_panel( draw_armor, translate_marker( "Armor" ), 5, 44, false ) ); - ret.emplace_back( window_panel( draw_compass_padding, translate_marker( "Compass" ), 8, 44, - true ) ); - ret.emplace_back( window_panel( draw_messages_classic, translate_marker( "Log" ), -2, 44, true ) ); + ret.emplace_back( draw_health_classic, translate_marker( "Health" ), 7, 44, true ); + ret.emplace_back( draw_location_classic, translate_marker( "Location" ), 1, 44, + true ); + ret.emplace_back( draw_mana_classic, translate_marker( "Mana" ), 1, 44, true, + spell_panel ); + ret.emplace_back( draw_weather_classic, translate_marker( "Weather" ), 1, 44, + true ); + ret.emplace_back( draw_lighting_classic, translate_marker( "Lighting" ), 1, 44, + true ); + ret.emplace_back( draw_weapon_classic, translate_marker( "Weapon" ), 1, 44, true ); + ret.emplace_back( draw_weapon_classic_alt, translate_marker( "Weapon_alt" ), 2, 44, + false ); + ret.emplace_back( draw_weightvolume_classic, translate_marker( "Wgt/Vol" ), 1, 44, + true ); + ret.emplace_back( draw_time_classic, translate_marker( "Time" ), 1, 44, true ); + ret.emplace_back( draw_wind, translate_marker( "Wind" ), 1, 44, false ); + ret.emplace_back( draw_armor, translate_marker( "Armor" ), 5, 44, false ); + ret.emplace_back( draw_compass_padding, translate_marker( "Compass" ), 8, 44, + true ); + ret.emplace_back( draw_messages_classic, translate_marker( "Log" ), -2, 44, true ); #if defined(TILES) - ret.emplace_back( window_panel( draw_mminimap, translate_marker( "Map" ), -1, 44, true, - default_render, true ) ); + ret.emplace_back( draw_mminimap, translate_marker( "Map" ), -1, 44, true, + default_render, true ); #endif // TILES - ret.emplace_back( window_panel( draw_ai_goal, "AI Needs", 1, 44, false ) ); + ret.emplace_back( draw_ai_goal, "AI Needs", 1, 44, false ); return ret; } @@ -2074,25 +2074,25 @@ static std::vector<window_panel> initialize_default_compact_panels() { std::vector<window_panel> ret; - ret.emplace_back( window_panel( draw_limb2, translate_marker( "Limbs" ), 3, 32, true ) ); - ret.emplace_back( window_panel( draw_stealth, translate_marker( "Sound" ), 1, 32, true ) ); - ret.emplace_back( window_panel( draw_stats, translate_marker( "Stats" ), 1, 32, true ) ); - ret.emplace_back( window_panel( draw_mana_compact, translate_marker( "Mana" ), 1, 32, true, - spell_panel ) ); - ret.emplace_back( window_panel( draw_time, translate_marker( "Time" ), 1, 32, true ) ); - ret.emplace_back( window_panel( draw_needs_compact, translate_marker( "Needs" ), 3, 32, true ) ); - ret.emplace_back( window_panel( draw_env_compact, translate_marker( "Env" ), 6, 32, true ) ); - ret.emplace_back( window_panel( draw_veh_compact, translate_marker( "Vehicle" ), 1, 32, true ) ); - ret.emplace_back( window_panel( draw_weightvolume_compact, translate_marker( "Wgt/Vol" ), 2, 32, - true ) ); - ret.emplace_back( window_panel( draw_armor, translate_marker( "Armor" ), 5, 32, false ) ); - ret.emplace_back( window_panel( draw_messages_classic, translate_marker( "Log" ), -2, 32, true ) ); - ret.emplace_back( window_panel( draw_compass, translate_marker( "Compass" ), 8, 32, true ) ); + ret.emplace_back( draw_limb2, translate_marker( "Limbs" ), 3, 32, true ); + ret.emplace_back( draw_stealth, translate_marker( "Sound" ), 1, 32, true ); + ret.emplace_back( draw_stats, translate_marker( "Stats" ), 1, 32, true ); + ret.emplace_back( draw_mana_compact, translate_marker( "Mana" ), 1, 32, true, + spell_panel ); + ret.emplace_back( draw_time, translate_marker( "Time" ), 1, 32, true ); + ret.emplace_back( draw_needs_compact, translate_marker( "Needs" ), 3, 32, true ); + ret.emplace_back( draw_env_compact, translate_marker( "Env" ), 6, 32, true ); + ret.emplace_back( draw_veh_compact, translate_marker( "Vehicle" ), 1, 32, true ); + ret.emplace_back( draw_weightvolume_compact, translate_marker( "Wgt/Vol" ), 2, 32, + true ); + ret.emplace_back( draw_armor, translate_marker( "Armor" ), 5, 32, false ); + ret.emplace_back( draw_messages_classic, translate_marker( "Log" ), -2, 32, true ); + ret.emplace_back( draw_compass, translate_marker( "Compass" ), 8, 32, true ); #if defined(TILES) - ret.emplace_back( window_panel( draw_mminimap, translate_marker( "Map" ), -1, 32, true, - default_render, true ) ); + ret.emplace_back( draw_mminimap, translate_marker( "Map" ), -1, 32, true, + default_render, true ); #endif // TILES - ret.emplace_back( window_panel( draw_ai_goal, "AI Needs", 1, 32, false ) ); + ret.emplace_back( draw_ai_goal, "AI Needs", 1, 32, false ); return ret; } @@ -2101,30 +2101,30 @@ static std::vector<window_panel> initialize_default_label_narrow_panels() { std::vector<window_panel> ret; - ret.emplace_back( window_panel( draw_hint, translate_marker( "Hint" ), 1, 32, true ) ); - ret.emplace_back( window_panel( draw_limb_narrow, translate_marker( "Limbs" ), 3, 32, true ) ); - ret.emplace_back( window_panel( draw_char_narrow, translate_marker( "Movement" ), 3, 32, true ) ); - ret.emplace_back( window_panel( draw_mana_narrow, translate_marker( "Mana" ), 1, 32, true, - spell_panel ) ); - ret.emplace_back( window_panel( draw_stat_narrow, translate_marker( "Stats" ), 3, 32, true ) ); - ret.emplace_back( window_panel( draw_veh_padding, translate_marker( "Vehicle" ), 1, 32, true ) ); - ret.emplace_back( window_panel( draw_loc_narrow, translate_marker( "Location" ), 5, 32, true ) ); - ret.emplace_back( window_panel( draw_wind_padding, translate_marker( "Wind" ), 1, 32, false ) ); - ret.emplace_back( window_panel( draw_weapon_labels, translate_marker( "Weapon" ), 2, 32, true ) ); - ret.emplace_back( window_panel( draw_weightvolume_narrow, translate_marker( "Wgt/Vol" ), 2, 32, - true ) ); - ret.emplace_back( window_panel( draw_needs_narrow, translate_marker( "Needs" ), 5, 32, true ) ); - ret.emplace_back( window_panel( draw_sound_narrow, translate_marker( "Sound" ), 1, 32, true ) ); - ret.emplace_back( window_panel( draw_messages, translate_marker( "Log" ), -2, 32, true ) ); - ret.emplace_back( window_panel( draw_moon_narrow, translate_marker( "Moon" ), 2, 32, false ) ); - ret.emplace_back( window_panel( draw_armor_padding, translate_marker( "Armor" ), 5, 32, false ) ); - ret.emplace_back( window_panel( draw_compass_padding, translate_marker( "Compass" ), 8, 32, - true ) ); + ret.emplace_back( draw_hint, translate_marker( "Hint" ), 1, 32, true ); + ret.emplace_back( draw_limb_narrow, translate_marker( "Limbs" ), 3, 32, true ); + ret.emplace_back( draw_char_narrow, translate_marker( "Movement" ), 3, 32, true ); + ret.emplace_back( draw_mana_narrow, translate_marker( "Mana" ), 1, 32, true, + spell_panel ); + ret.emplace_back( draw_stat_narrow, translate_marker( "Stats" ), 3, 32, true ); + ret.emplace_back( draw_veh_padding, translate_marker( "Vehicle" ), 1, 32, true ); + ret.emplace_back( draw_loc_narrow, translate_marker( "Location" ), 5, 32, true ); + ret.emplace_back( draw_wind_padding, translate_marker( "Wind" ), 1, 32, false ); + ret.emplace_back( draw_weapon_labels, translate_marker( "Weapon" ), 2, 32, true ); + ret.emplace_back( draw_weightvolume_narrow, translate_marker( "Wgt/Vol" ), 2, 32, + true ); + ret.emplace_back( draw_needs_narrow, translate_marker( "Needs" ), 5, 32, true ); + ret.emplace_back( draw_sound_narrow, translate_marker( "Sound" ), 1, 32, true ); + ret.emplace_back( draw_messages, translate_marker( "Log" ), -2, 32, true ); + ret.emplace_back( draw_moon_narrow, translate_marker( "Moon" ), 2, 32, false ); + ret.emplace_back( draw_armor_padding, translate_marker( "Armor" ), 5, 32, false ); + ret.emplace_back( draw_compass_padding, translate_marker( "Compass" ), 8, 32, + true ); #if defined(TILES) - ret.emplace_back( window_panel( draw_mminimap, translate_marker( "Map" ), -1, 32, true, - default_render, true ) ); + ret.emplace_back( draw_mminimap, translate_marker( "Map" ), -1, 32, true, + default_render, true ); #endif // TILES - ret.emplace_back( window_panel( draw_ai_goal, "AI Needs", 1, 32, false ) ); + ret.emplace_back( draw_ai_goal, "AI Needs", 1, 32, false ); return ret; } @@ -2133,31 +2133,31 @@ static std::vector<window_panel> initialize_default_label_panels() { std::vector<window_panel> ret; - ret.emplace_back( window_panel( draw_hint, translate_marker( "Hint" ), 1, 44, true ) ); - ret.emplace_back( window_panel( draw_limb_wide, translate_marker( "Limbs" ), 2, 44, true ) ); - ret.emplace_back( window_panel( draw_char_wide, translate_marker( "Movement" ), 2, 44, true ) ); - ret.emplace_back( window_panel( draw_mana_wide, translate_marker( "Mana" ), 1, 44, true, - spell_panel ) ); - ret.emplace_back( window_panel( draw_stat_wide, translate_marker( "Stats" ), 2, 44, true ) ); - ret.emplace_back( window_panel( draw_veh_padding, translate_marker( "Vehicle" ), 1, 44, true ) ); - ret.emplace_back( window_panel( draw_loc_wide_map, translate_marker( "Location" ), 5, 44, true ) ); - ret.emplace_back( window_panel( draw_wind_padding, translate_marker( "Wind" ), 1, 44, false ) ); - ret.emplace_back( window_panel( draw_loc_wide, translate_marker( "Location Alt" ), 5, 44, false ) ); - ret.emplace_back( window_panel( draw_weapon_labels, translate_marker( "Weapon" ), 2, 44, true ) ); - ret.emplace_back( window_panel( draw_weightvolume_labels, translate_marker( "Wgt/Vol" ), 1, 44, - true ) ); - ret.emplace_back( window_panel( draw_needs_labels, translate_marker( "Needs" ), 3, 44, true ) ); - ret.emplace_back( window_panel( draw_sound_labels, translate_marker( "Sound" ), 1, 44, true ) ); - ret.emplace_back( window_panel( draw_messages, translate_marker( "Log" ), -2, 44, true ) ); - ret.emplace_back( window_panel( draw_moon_wide, translate_marker( "Moon" ), 1, 44, false ) ); - ret.emplace_back( window_panel( draw_armor_padding, translate_marker( "Armor" ), 5, 44, false ) ); - ret.emplace_back( window_panel( draw_compass_padding, translate_marker( "Compass" ), 8, 44, - true ) ); + ret.emplace_back( draw_hint, translate_marker( "Hint" ), 1, 44, true ); + ret.emplace_back( draw_limb_wide, translate_marker( "Limbs" ), 2, 44, true ); + ret.emplace_back( draw_char_wide, translate_marker( "Movement" ), 2, 44, true ); + ret.emplace_back( draw_mana_wide, translate_marker( "Mana" ), 1, 44, true, + spell_panel ); + ret.emplace_back( draw_stat_wide, translate_marker( "Stats" ), 2, 44, true ); + ret.emplace_back( draw_veh_padding, translate_marker( "Vehicle" ), 1, 44, true ); + ret.emplace_back( draw_loc_wide_map, translate_marker( "Location" ), 5, 44, true ); + ret.emplace_back( draw_wind_padding, translate_marker( "Wind" ), 1, 44, false ); + ret.emplace_back( draw_loc_wide, translate_marker( "Location Alt" ), 5, 44, false ); + ret.emplace_back( draw_weapon_labels, translate_marker( "Weapon" ), 2, 44, true ); + ret.emplace_back( draw_weightvolume_labels, translate_marker( "Wgt/Vol" ), 1, 44, + true ); + ret.emplace_back( draw_needs_labels, translate_marker( "Needs" ), 3, 44, true ); + ret.emplace_back( draw_sound_labels, translate_marker( "Sound" ), 1, 44, true ); + ret.emplace_back( draw_messages, translate_marker( "Log" ), -2, 44, true ); + ret.emplace_back( draw_moon_wide, translate_marker( "Moon" ), 1, 44, false ); + ret.emplace_back( draw_armor_padding, translate_marker( "Armor" ), 5, 44, false ); + ret.emplace_back( draw_compass_padding, translate_marker( "Compass" ), 8, 44, + true ); #if defined(TILES) - ret.emplace_back( window_panel( draw_mminimap, translate_marker( "Map" ), -1, 44, true, - default_render, true ) ); + ret.emplace_back( draw_mminimap, translate_marker( "Map" ), -1, 44, true, + default_render, true ); #endif // TILES - ret.emplace_back( window_panel( draw_ai_goal, "AI Needs", 1, 44, false ) ); + ret.emplace_back( draw_ai_goal, "AI Needs", 1, 44, false ); return ret; } @@ -2166,11 +2166,11 @@ static std::map<std::string, std::vector<window_panel>> initialize_default_panel { std::map<std::string, std::vector<window_panel>> ret; - ret.emplace( std::make_pair( translate_marker( "classic" ), initialize_default_classic_panels() ) ); - ret.emplace( std::make_pair( translate_marker( "compact" ), initialize_default_compact_panels() ) ); - ret.emplace( std::make_pair( translate_marker( "labels-narrow" ), - initialize_default_label_narrow_panels() ) ); - ret.emplace( std::make_pair( translate_marker( "labels" ), initialize_default_label_panels() ) ); + ret.emplace( translate_marker( "classic" ), initialize_default_classic_panels() ); + ret.emplace( translate_marker( "compact" ), initialize_default_compact_panels() ); + ret.emplace( translate_marker( "labels-narrow" ), + initialize_default_label_narrow_panels() ); + ret.emplace( translate_marker( "labels" ), initialize_default_label_panels() ); return ret; } diff --git a/src/pathfinding.cpp b/src/pathfinding.cpp index d9a7941459d2..87234646c512 100644 --- a/src/pathfinding.cpp +++ b/src/pathfinding.cpp @@ -100,7 +100,7 @@ struct pathfinder { layer.gscore[index] = gscore; layer.parent[index] = from; layer.score [index] = score; - open.push( std::make_pair( score, to ) ); + open.emplace( score, to ); } void close_point( const tripoint &p ) { diff --git a/src/pixel_minimap.cpp b/src/pixel_minimap.cpp index 6f8bb554c02f..68d6c054e072 100644 --- a/src/pixel_minimap.cpp +++ b/src/pixel_minimap.cpp @@ -344,7 +344,7 @@ void pixel_minimap::update_cache_at( const tripoint &sm_pos ) if( current_color != color ) { current_color = color; - cache_item.update_list.push_back( { x, y } ); + cache_item.update_list.emplace_back( x, y ); } } } diff --git a/src/player_activity.cpp b/src/player_activity.cpp index 7c01fa789668..60f80b78be74 100644 --- a/src/player_activity.cpp +++ b/src/player_activity.cpp @@ -83,11 +83,11 @@ void player_activity::migrate_item_position( Character &guy ) type == ACT_ATM; if( simple_action_replace ) { - targets.push_back( &guy.i_at( position ) ); + targets.emplace_back( &guy.i_at( position ) ); } else if( type == ACT_GUNMOD_ADD ) { // this activity has two indices; "position" = gun and "values[0]" = mod - targets.push_back( &guy.i_at( position ) ); - targets.push_back( &guy.i_at( values[0] ) ); + targets.emplace_back( &guy.i_at( position ) ); + targets.emplace_back( &guy.i_at( values[0] ) ); } } diff --git a/src/profession.cpp b/src/profession.cpp index c55958e943db..0c348604d631 100644 --- a/src/profession.cpp +++ b/src/profession.cpp @@ -604,7 +604,7 @@ void json_item_substitution::load( const JsonObject &jo ) if( check_duplicate_item( old_it ) ) { sub.throw_error( "Duplicate definition of item" ); } - s.trait_reqs.present.push_back( trait_id( title ) ); + s.trait_reqs.present.emplace_back( title ); for( const JsonValue info : sub.get_array( "new" ) ) { s.infos.emplace_back( info ); } diff --git a/src/ranged.cpp b/src/ranged.cpp index dae37aba791b..363cfdec34f4 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -2877,7 +2877,7 @@ std::vector<weak_ptr_fast<Creature>> target_ui::list_friendlies_in_lof() ( cr->is_npc() && a != Creature::A_HOSTILE ) || ( !cr->is_npc() && a == Creature::A_FRIENDLY ) ) { - ret.push_back( g->shared_from( *cr ) ); + ret.emplace_back( g->shared_from( *cr ) ); } } } diff --git a/src/recipe.cpp b/src/recipe.cpp index e4dbeb62baa7..3c4449627bf4 100644 --- a/src/recipe.cpp +++ b/src/recipe.cpp @@ -261,20 +261,20 @@ void recipe::load( const JsonObject &jo, const std::string &src ) bp_resources.emplace_back( resource ); } for( JsonObject provide : jo.get_array( "blueprint_provides" ) ) { - bp_provides.emplace_back( std::make_pair( provide.get_string( "id" ), - provide.get_int( "amount", 1 ) ) ); + bp_provides.emplace_back( provide.get_string( "id" ), + provide.get_int( "amount", 1 ) ); } // all blueprints provide themselves with needing it written in JSON - bp_provides.emplace_back( std::make_pair( result_.str(), 1 ) ); + bp_provides.emplace_back( result_.str(), 1 ); for( JsonObject require : jo.get_array( "blueprint_requires" ) ) { - bp_requires.emplace_back( std::make_pair( require.get_string( "id" ), - require.get_int( "amount", 1 ) ) ); + bp_requires.emplace_back( require.get_string( "id" ), + require.get_int( "amount", 1 ) ); } // all blueprints exclude themselves with needing it written in JSON - bp_excludes.emplace_back( std::make_pair( result_.str(), 1 ) ); + bp_excludes.emplace_back( result_.str(), 1 ); for( JsonObject exclude : jo.get_array( "blueprint_excludes" ) ) { - bp_excludes.emplace_back( std::make_pair( exclude.get_string( "id" ), - exclude.get_int( "amount", 1 ) ) ); + bp_excludes.emplace_back( exclude.get_string( "id" ), + exclude.get_int( "amount", 1 ) ); } if( jo.has_member( "blueprint_needs" ) ) { has_blueprint_needs = true; @@ -575,7 +575,7 @@ std::string recipe::primary_skill_string( const Character *c, bool print_skill_l std::vector< std::pair<skill_id, int> > skillList; if( !skill_used.is_null() ) { - skillList.push_back( std::pair<skill_id, int>( skill_used, difficulty ) ); + skillList.emplace_back( skill_used, difficulty ); } return required_skills_as_string( skillList.begin(), skillList.end(), c, print_skill_level ); diff --git a/src/safemode_ui.cpp b/src/safemode_ui.cpp index f1f95aaf956c..77a0b953d046 100644 --- a/src/safemode_ui.cpp +++ b/src/safemode_ui.cpp @@ -284,15 +284,15 @@ void safemode::show( const std::string &custom_name_in, bool is_safemode_in ) } } else if( action == "ADD_DEFAULT_RULESET" ) { changes_made = true; - current_tab.push_back( rules_class( "*", true, false, Creature::A_HOSTILE, - get_option<int>( "SAFEMODEPROXIMITY" ) - , HOSTILE_SPOTTED ) ); - current_tab.push_back( rules_class( "*", true, true, Creature::A_HOSTILE, 5, SOUND ) ); + current_tab.emplace_back( "*", true, false, Creature::A_HOSTILE, + get_option<int>( "SAFEMODEPROXIMITY" ) + , HOSTILE_SPOTTED ); + current_tab.emplace_back( "*", true, true, Creature::A_HOSTILE, 5, SOUND ); line = current_tab.size() - 1; } else if( action == "ADD_RULE" ) { changes_made = true; - current_tab.push_back( rules_class( "", true, false, Creature::A_HOSTILE, - get_option<int>( "SAFEMODEPROXIMITY" ), HOSTILE_SPOTTED ) ); + current_tab.emplace_back( "", true, false, Creature::A_HOSTILE, + get_option<int>( "SAFEMODEPROXIMITY" ), HOSTILE_SPOTTED ); line = current_tab.size() - 1; } else if( action == "REMOVE_RULE" && !current_tab.empty() ) { changes_made = true; @@ -599,8 +599,8 @@ void safemode::add_rule( const std::string &rule_in, const Creature::Attitude at const int proximity_in, const rule_state state_in ) { - character_rules.push_back( rules_class( rule_in, true, ( state_in == RULE_WHITELISTED ), - attitude_in, proximity_in, HOSTILE_SPOTTED ) ); + character_rules.emplace_back( rule_in, true, ( state_in == RULE_WHITELISTED ), + attitude_in, proximity_in, HOSTILE_SPOTTED ); create_rules(); if( !get_option<bool>( "SAFEMODE" ) && @@ -850,8 +850,7 @@ void safemode::deserialize( JsonIn &jsin ) const Categories cat = jo.has_member( "category" ) ? static_cast<Categories> ( jo.get_int( "category" ) ) : HOSTILE_SPOTTED; - temp_rules.push_back( - rules_class( rule, active, whitelist, attitude, proximity, cat ) - ); + temp_rules.emplace_back( rule, active, whitelist, attitude, proximity, cat + ); } } diff --git a/src/sounds.cpp b/src/sounds.cpp index cf41018f8a25..39005bc6d131 100644 --- a/src/sounds.cpp +++ b/src/sounds.cpp @@ -187,10 +187,10 @@ void sounds::sound( const tripoint &p, int vol, sound_t category, const std::str if( description.empty() ) { debugmsg( "Sound at %d:%d has no description!", p.x, p.y ); } - recent_sounds.emplace_back( std::make_pair( p, vol ) ); - sounds_since_last_turn.emplace_back( std::make_pair( p, + recent_sounds.emplace_back( p, vol ); + sounds_since_last_turn.emplace_back( p, sound_event {vol, category, description, ambient, - false, id, variant} ) ); + false, id, variant} ); } void sounds::sound( const tripoint &p, int vol, sound_t category, const translation &description, @@ -202,8 +202,8 @@ void sounds::sound( const tripoint &p, int vol, sound_t category, const translat void sounds::add_footstep( const tripoint &p, int volume, int, monster *, const std::string &footstep ) { - sounds_since_last_turn.emplace_back( std::make_pair( p, sound_event { volume, - sound_t::movement, footstep, false, true, "", ""} ) ); + sounds_since_last_turn.emplace_back( p, sound_event { volume, + sound_t::movement, footstep, false, true, "", ""} ); } template <typename C> diff --git a/src/string_utils.cpp b/src/string_utils.cpp index 4c7c6d108577..bcf873eef61f 100644 --- a/src/string_utils.cpp +++ b/src/string_utils.cpp @@ -116,7 +116,7 @@ std::vector<std::string> string_split( const std::string &text_in, char delim_in } if( text_in.back() == delim_in ) { - elems.push_back( "" ); + elems.emplace_back( "" ); } return elems; diff --git a/src/trap.cpp b/src/trap.cpp index 21a9ef8d8469..32aab8f766fc 100644 --- a/src/trap.cpp +++ b/src/trap.cpp @@ -140,7 +140,7 @@ void trap::load( const JsonObject &jo, const std::string & ) charges = 1; } if( !item_type.is_empty() && quantity > 0 && charges > 0 ) { - components.emplace_back( std::make_tuple( item_type, quantity, charges ) ); + components.emplace_back( item_type, quantity, charges ); } } if( jo.has_object( "vehicle_data" ) ) { diff --git a/src/veh_type.cpp b/src/veh_type.cpp index be3a4618bf16..7d008872a850 100644 --- a/src/veh_type.cpp +++ b/src/veh_type.cpp @@ -228,7 +228,7 @@ void vpart_info::load_engine( std::optional<vpslot_engine> &eptr, const JsonObje if( !fuel_opts.empty() ) { e_info.fuel_opts.clear(); for( const std::string line : fuel_opts ) { - e_info.fuel_opts.push_back( itype_id( line ) ); + e_info.fuel_opts.emplace_back( line ); } } else if( e_info.fuel_opts.empty() && fuel_type != itype_id( "null" ) ) { e_info.fuel_opts.push_back( fuel_type ); @@ -1044,15 +1044,15 @@ void vehicle_prototype::load( const JsonObject &jo ) spawn_info.read( "items", next_spawn.item_ids, true ); } else if( spawn_info.has_string( "items" ) ) { //Treat single item as array - next_spawn.item_ids.push_back( itype_id( spawn_info.get_string( "items" ) ) ); + next_spawn.item_ids.emplace_back( spawn_info.get_string( "items" ) ); } if( spawn_info.has_array( "item_groups" ) ) { //Pick from a group of items, just like map::place_items for( const std::string line : spawn_info.get_array( "item_groups" ) ) { - next_spawn.item_groups.push_back( item_group_id( line ) ); + next_spawn.item_groups.emplace_back( line ); } } else if( spawn_info.has_string( "item_groups" ) ) { - next_spawn.item_groups.push_back( item_group_id( spawn_info.get_string( "item_groups" ) ) ); + next_spawn.item_groups.emplace_back( spawn_info.get_string( "item_groups" ) ); } vproto.item_spawns.push_back( std::move( next_spawn ) ); } diff --git a/src/vehicle.cpp b/src/vehicle.cpp index b49de01076c6..74e1ebf29e3a 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -384,7 +384,7 @@ void vehicle::add_steerable_wheels() axle = vp.mount().x; } - wheels.push_back( std::make_pair( static_cast<int>( vp.part_index() ), steerable_id ) ); + wheels.emplace_back( static_cast<int>( vp.part_index() ), steerable_id ); } } } diff --git a/src/vehicle_use.cpp b/src/vehicle_use.cpp index 7ed575708db6..1a8eda135e9b 100644 --- a/src/vehicle_use.cpp +++ b/src/vehicle_use.cpp @@ -135,7 +135,7 @@ void vehicle::add_toggle_to_opts( std::vector<uilist_entry> &options, name ); options.emplace_back( -1, allow, key, msg ); - actions.push_back( [ = ] { + actions.emplace_back( [ = ] { for( const vpart_reference &vp : found ) { vehicle_part &e = vp.part(); @@ -323,14 +323,14 @@ void vehicle::set_electronics_menu_options( std::vector<uilist_entry> &options, if( has_part( "DOOR_MOTOR" ) ) { options.emplace_back( _( "Toggle doors" ), keybind( "TOGGLE_DOORS" ) ); - actions.push_back( [&] { control_doors(); refresh(); } ); + actions.emplace_back( [&] { control_doors(); refresh(); } ); } if( camera_on || ( has_part( "CAMERA" ) && has_part( "CAMERA_CONTROL" ) ) ) { options.emplace_back( camera_on ? colorize( _( "Turn off camera system" ), c_pink ) : _( "Turn on camera system" ), keybind( "TOGGLE_CAMERA" ) ); - actions.push_back( [&] { + actions.emplace_back( [&] { if( camera_on ) { camera_on = false; @@ -365,7 +365,7 @@ void vehicle::control_electronics() if( has_part( "ENGINE" ) ) { options.emplace_back( engine_on ? _( "Turn off the engine" ) : _( "Turn on the engine" ), keybind( "TOGGLE_ENGINE" ) ); - actions.push_back( [&] { + actions.emplace_back( [&] { if( engine_on ) { engine_on = false; @@ -673,7 +673,7 @@ void vehicle::use_controls( const tripoint &pos ) if( remote ) { options.emplace_back( _( "Stop controlling" ), keybind( "RELEASE_CONTROLS" ) ); - actions.push_back( [&] { + actions.emplace_back( [&] { if( confirm_stop_driving() ) { you.controlling_vehicle = false; @@ -688,7 +688,7 @@ void vehicle::use_controls( const tripoint &pos ) } else if( veh_pointer_or_null( g->m.veh_at( pos ) ) == this ) { if( you.controlling_vehicle ) { options.emplace_back( _( "Let go of controls" ), keybind( "RELEASE_CONTROLS" ) ); - actions.push_back( [&] { + actions.emplace_back( [&] { if( confirm_stop_driving() ) { you.controlling_vehicle = false; @@ -714,7 +714,7 @@ void vehicle::use_controls( const tripoint &pos ) if( has_part( "ENGINE" ) ) { if( you.controlling_vehicle || ( remote && engine_on ) ) { options.emplace_back( _( "Stop driving" ), keybind( "TOGGLE_ENGINE" ) ); - actions.push_back( [&] { + actions.emplace_back( [&] { if( !confirm_stop_driving() ) { return; @@ -759,7 +759,7 @@ void vehicle::use_controls( const tripoint &pos ) } else if( has_engine_type_not( fuel_type_muscle, true ) ) { options.emplace_back( engine_on ? _( "Turn off the engine" ) : _( "Turn on the engine" ), keybind( "TOGGLE_ENGINE" ) ); - actions.push_back( [&] { + actions.emplace_back( [&] { if( engine_on ) { engine_on = false; @@ -777,13 +777,13 @@ void vehicle::use_controls( const tripoint &pos ) if( has_part( "HORN" ) ) { options.emplace_back( _( "Honk horn" ), keybind( "SOUND_HORN" ) ); - actions.push_back( [&] { honk_horn(); refresh(); } ); + actions.emplace_back( [&] { honk_horn(); refresh(); } ); } if( has_part( "AUTOPILOT" ) && ( has_part( "CTRL_ELECTRONIC" ) || has_part( "REMOTE_CONTROLS" ) ) ) { options.emplace_back( _( "Control autopilot" ), keybind( "CONTROL_AUTOPILOT" ) ); - actions.push_back( [&] { toggle_autopilot(); refresh(); } ); + actions.emplace_back( [&] { toggle_autopilot(); refresh(); } ); } options.emplace_back( cruise_on ? _( "Disable cruise control" ) : _( "Enable cruise control" ), @@ -797,32 +797,32 @@ void vehicle::use_controls( const tripoint &pos ) if( has_electronic_controls ) { set_electronics_menu_options( options, actions ); options.emplace_back( _( "Control multiple electronics" ), keybind( "CONTROL_MANY_ELECTRONICS" ) ); - actions.push_back( [&] { control_electronics(); refresh(); } ); + actions.emplace_back( [&] { control_electronics(); refresh(); } ); } options.emplace_back( tracking_on ? _( "Forget vehicle position" ) : _( "Remember vehicle position" ), keybind( "TOGGLE_TRACKING" ) ); - actions.push_back( [&] { toggle_tracking(); } ); + actions.emplace_back( [&] { toggle_tracking(); } ); if( ( is_foldable() || tags.count( "convertible" ) ) && !remote ) { options.emplace_back( string_format( _( "Fold %s" ), name ), keybind( "FOLD_VEHICLE" ) ); - actions.push_back( [&] { fold_up(); } ); + actions.emplace_back( [&] { fold_up(); } ); } if( has_part( "ENGINE" ) ) { options.emplace_back( _( "Control individual engines" ), keybind( "CONTROL_ENGINES" ) ); - actions.push_back( [&] { control_engines(); refresh(); } ); + actions.emplace_back( [&] { control_engines(); refresh(); } ); } if( is_alarm_on ) { if( velocity == 0 && !remote ) { options.emplace_back( _( "Try to disarm alarm." ), keybind( "TOGGLE_ALARM" ) ); - actions.push_back( [&] { smash_security_system(); refresh(); } ); + actions.emplace_back( [&] { smash_security_system(); refresh(); } ); } else if( has_electronic_controls && has_part( "SECURITY" ) ) { options.emplace_back( _( "Trigger alarm" ), keybind( "TOGGLE_ALARM" ) ); - actions.push_back( [&] { + actions.emplace_back( [&] { is_alarm_on = true; add_msg( _( "You trigger the alarm" ) ); refresh(); @@ -832,21 +832,21 @@ void vehicle::use_controls( const tripoint &pos ) if( has_part( "TURRET" ) ) { options.emplace_back( _( "Set turret targeting modes" ), keybind( "TURRET_TARGET_MODE" ) ); - actions.push_back( [&] { turrets_set_targeting(); refresh(); } ); + actions.emplace_back( [&] { turrets_set_targeting(); refresh(); } ); options.emplace_back( _( "Set turret firing modes" ), keybind( "TURRET_FIRE_MODE" ) ); - actions.push_back( [&] { turrets_set_mode(); refresh(); } ); + actions.emplace_back( [&] { turrets_set_mode(); refresh(); } ); // We can also fire manual turrets with ACTION_FIRE while standing at the controls. options.emplace_back( _( "Aim turrets manually" ), keybind( "TURRET_MANUAL_AIM" ) ); - actions.push_back( [&] { turrets_aim_and_fire_all_manual( true ); refresh(); } ); + actions.emplace_back( [&] { turrets_aim_and_fire_all_manual( true ); refresh(); } ); // This lets us manually override and set the target for the automatic turrets instead. options.emplace_back( _( "Aim automatic turrets" ), keybind( "TURRET_MANUAL_OVERRIDE" ) ); - actions.push_back( [&] { turrets_override_automatic_aim(); refresh(); } ); + actions.emplace_back( [&] { turrets_override_automatic_aim(); refresh(); } ); options.emplace_back( _( "Aim individual turret" ), keybind( "TURRET_SINGLE_FIRE" ) ); - actions.push_back( [&] { turrets_aim_and_fire_single(); refresh(); } ); + actions.emplace_back( [&] { turrets_aim_and_fire_single(); refresh(); } ); } uilist menu; @@ -1230,7 +1230,7 @@ void vehicle::reload_seeds( const tripoint &pos ) } ); auto seed_entries = iexamine::get_seed_entries( seed_inv ); - seed_entries.emplace( seed_entries.begin(), seed_tuple( itype_id( "null" ), _( "No seed" ), 0 ) ); + seed_entries.emplace( seed_entries.begin(), itype_id( "null" ), _( "No seed" ), 0 ); int seed_index = iexamine::query_seed( seed_entries ); @@ -1703,7 +1703,7 @@ void vehicle::use_washing_machine( int p ) } std::vector<item_comp> detergent; - detergent.push_back( item_comp( det_types[chosen_detergent], 5 ) ); + detergent.emplace_back( det_types[chosen_detergent], 5 ); g->u.consume_items( detergent, 1, is_crafting_component ); add_msg( m_good, @@ -1759,7 +1759,7 @@ void vehicle::use_dishwasher( int p ) } std::vector<item_comp> detergent; - detergent.push_back( item_comp( itype_detergent, 5 ) ); + detergent.emplace_back( itype_detergent, 5 ); g->u.consume_items( detergent, 1, is_crafting_component ); add_msg( m_good, @@ -2194,7 +2194,7 @@ void vehicle::interact_with( const tripoint &pos, int interact_part ) if( opt ) { you.assign_activity( ACT_RELOAD, opt.moves(), opt.qty() ); you.activity->targets.emplace_back( turret.base() ); - you.activity->targets.push_back( opt.ammo ); + you.activity->targets.emplace_back( opt.ammo ); } return; } diff --git a/src/weather.cpp b/src/weather.cpp index b0dafacfd2fc..c73895d21b92 100644 --- a/src/weather.cpp +++ b/src/weather.cpp @@ -1133,7 +1133,7 @@ int weather_manager::get_temperature( const tripoint &location ) const ? 0 : g->m.get_temperature( location ) + temp_mod ); - temperature_cache.emplace( std::make_pair( location, temp ) ); + temperature_cache.emplace( location, temp ); return temp; } diff --git a/src/worldfactory.cpp b/src/worldfactory.cpp index 9dbdb5922f59..26430963eb2c 100644 --- a/src/worldfactory.cpp +++ b/src/worldfactory.cpp @@ -119,9 +119,9 @@ worldfactory::worldfactory() , mman_ui( *mman ) { // prepare tab display order - tabs.push_back( std::bind( &worldfactory::show_worldgen_tab_modselection, this, _1, _2, _3 ) ); - tabs.push_back( std::bind( &worldfactory::show_worldgen_tab_options, this, _1, _2, _3 ) ); - tabs.push_back( std::bind( &worldfactory::show_worldgen_tab_confirm, this, _1, _2, _3 ) ); + tabs.emplace_back( std::bind( &worldfactory::show_worldgen_tab_modselection, this, _1, _2, _3 ) ); + tabs.emplace_back( std::bind( &worldfactory::show_worldgen_tab_options, this, _1, _2, _3 ) ); + tabs.emplace_back( std::bind( &worldfactory::show_worldgen_tab_confirm, this, _1, _2, _3 ) ); } worldfactory::~worldfactory() = default; @@ -968,8 +968,8 @@ int worldfactory::show_modselection_window( const catacurses::window &win, ui.on_screen_resize( init_windows ); std::vector<std::string> headers; - headers.push_back( _( "Mod List" ) ); - headers.push_back( _( "Mod Load Order" ) ); + headers.emplace_back( _( "Mod List" ) ); + headers.emplace_back( _( "Mod Load Order" ) ); size_t active_header = 0; int startsel[2] = {0, 0};