From 032f0529cc902d2912c25b4bbf5e09e6a4c29a28 Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Fri, 14 May 2021 14:45:12 -0400 Subject: [PATCH] clang-tidy modernize-use-emplace (#48661) * Port code to emplace_back This is clang-tidy making automated changes to convert push_back into emplace_back whenever the argument to push_back is either a constructor call for the type in question of an expression of a type implicitly convertible to the type in question. This should eliminate one move-construction of the inserted object for each call. * Enable clang-tidy modernize-use-emplace --- .clang-tidy | 1 - src/activity_handlers.cpp | 4 +- src/activity_item_handling.cpp | 36 +- src/armor_layers.cpp | 24 +- src/avatar.cpp | 4 +- src/bionics.cpp | 16 +- src/bionics_ui.cpp | 4 +- src/character.cpp | 2 +- src/clzones.cpp | 2 +- src/construction.cpp | 4 +- src/crafting.cpp | 2 +- src/crafting_gui.cpp | 6 +- src/creature.cpp | 8 +- src/debug_menu.cpp | 3 +- src/dialogue_win.cpp | 2 +- src/editmap.cpp | 4 +- src/effect.cpp | 46 +- src/event_field_transformations.cpp | 2 +- src/faction_camp.cpp | 18 +- src/game.cpp | 16 +- src/handle_liquid.cpp | 2 +- src/iexamine.cpp | 24 +- src/inventory_ui.cpp | 4 +- src/item.cpp | 911 ++++++++++++++-------------- src/item_contents.cpp | 8 +- src/item_factory.cpp | 6 +- src/item_pocket.cpp | 32 +- src/iuse.cpp | 28 +- src/iuse_actor.cpp | 12 +- src/iuse_software_lightson.cpp | 6 +- src/iuse_software_minesweeper.cpp | 6 +- src/iuse_software_snake.cpp | 54 +- src/iuse_software_sokoban.cpp | 14 +- src/lightmap.cpp | 2 +- src/line.cpp | 12 +- src/main_menu.cpp | 59 +- src/map.cpp | 6 +- src/map_field.cpp | 20 +- src/map_item_stack.cpp | 2 +- src/mapgen.cpp | 54 +- src/mattack_actors.cpp | 2 +- src/memorial_logger.cpp | 2 +- src/mission.cpp | 8 +- src/mod_manager.cpp | 2 +- src/monattack.cpp | 2 +- src/monexamine.cpp | 8 +- src/mongroup.cpp | 8 +- src/monmove.cpp | 6 +- src/newcharacter.cpp | 8 +- src/npcmove.cpp | 8 +- src/npctalk.cpp | 4 +- src/output.cpp | 4 +- src/overmap.cpp | 36 +- src/overmap_ui.cpp | 2 +- src/panels.cpp | 28 +- src/past_games_info.cpp | 2 +- src/pixel_minimap.cpp | 2 +- src/player.cpp | 4 +- src/player_activity.cpp | 6 +- src/player_display.cpp | 32 +- src/profession.cpp | 2 +- src/proficiency.cpp | 6 +- src/ranged.cpp | 2 +- src/recipe.cpp | 2 +- src/safemode_ui.cpp | 23 +- src/talker_avatar.cpp | 2 +- src/talker_npc.cpp | 28 +- src/translations.cpp | 2 +- src/veh_interact.cpp | 6 +- src/veh_type.cpp | 9 +- src/vehicle_use.cpp | 46 +- src/wish.cpp | 2 +- src/worldfactory.cpp | 10 +- tests/behavior_test.cpp | 2 +- tests/crafting_test.cpp | 6 +- tests/encumbrance_test.cpp | 2 +- tests/generic_factory_test.cpp | 4 +- tests/invlet_test.cpp | 6 +- tests/iteminfo_test.cpp | 2 +- tests/modify_morale_test.cpp | 18 +- tests/npc_talk_test.cpp | 2 +- tests/player_helpers.cpp | 2 +- tests/ranged_balance_test.cpp | 2 +- tests/reading_test.cpp | 12 +- tests/reload_option_test.cpp | 8 +- tests/reloading_test.cpp | 2 +- tests/string_ids_test.cpp | 6 +- tests/vehicle_part_test.cpp | 6 +- tests/visitable_remove_test.cpp | 2 +- 89 files changed, 929 insertions(+), 933 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 4f11f89b67c59..1e041e5b16011 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -53,7 +53,6 @@ readability-*,\ -modernize-pass-by-value,\ -modernize-return-braced-init-list,\ -modernize-use-default-member-init,\ --modernize-use-emplace,\ -performance-unnecessary-value-param,\ -readability-else-after-return,\ -readability-implicit-bool-conversion,\ diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index 9aaf8ac47b233..1afb2a5f04532 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -1555,7 +1555,7 @@ void activity_handlers::fill_liquid_do_turn( player_activity *act, player *p ) act_ref.set_to_null(); } else { if( act_ref.str_values.empty() ) { - act_ref.str_values.push_back( std::string() ); + act_ref.str_values.emplace_back( ); } act_ref.str_values.at( 0 ) = serialize( liquid ); } @@ -3963,7 +3963,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 c01a5269f0f46..651c6bfd93fd7 100644 --- a/src/activity_item_handling.cpp +++ b/src/activity_item_handling.cpp @@ -513,13 +513,13 @@ void activity_handlers::washing_finish( player_activity *act, player *p ) } std::vector 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 ); p->consume_items( comps, 1, is_liquid_crafting_component ); std::vector 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 ); p->consume_items( comps1 ); p->add_msg_if_player( m_good, _( "You washed your items." ) ); @@ -1469,7 +1469,7 @@ static std::vector> 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. @@ -1493,8 +1493,8 @@ static std::vector> 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( quantity_here, - quantity_required ) ) ); + final_map.emplace_back( pos_here, item_here, std::min( quantity_here, + quantity_required ) ); if( quantity_here >= quantity_required ) { line_found = true; break; @@ -1520,10 +1520,10 @@ static std::vector> 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; } } @@ -1551,8 +1551,8 @@ static std::vector> 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( quantity_here, - quantity_required ) ) ); + final_map.emplace_back( pos_here, item_here, std::min( quantity_here, + quantity_required ) ); if( quantity_here >= quantity_required ) { line_found = true; break; @@ -1578,10 +1578,10 @@ static std::vector> 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; } } @@ -1604,7 +1604,7 @@ static std::vector> requirements_map( player item test_item = item( item_here, calendar::turn_zero ); 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; } @@ -2002,14 +2002,14 @@ void activity_on_turn_move_loot( player_activity &act, player &p ) src_veh = &vp->vehicle(); src_part = vp->part_index(); for( auto &it : src_veh->get_items( src_part ) ) { - items.push_back( std::make_pair( &it, true ) ); + items.emplace_back( &it, true ); } } else { src_veh = nullptr; src_part = -1; } for( item &it : here.i_at( src_loc ) ) { - items.push_back( std::make_pair( &it, false ) ); + items.emplace_back( &it, false ); } //Skip items that have already been processed @@ -2158,7 +2158,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( item_location( p, chosen_item ) ); + p.activity.targets.emplace_back( p, chosen_item ); p.activity.placement = here.getabs( src_loc ); return true; @@ -2648,7 +2648,7 @@ static bool generic_multi_activity_do( player &p, const activity_id &act_id, item *best_rod = p.best_quality_item( qual_FISHING ); p.assign_activity( ACT_FISH, to_moves( 5_hours ), 0, 0, best_rod->tname() ); - p.activity.targets.push_back( item_location( p, best_rod ) ); + p.activity.targets.emplace_back( p, 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 ) { diff --git a/src/armor_layers.cpp b/src/armor_layers.cpp index 7883df1a5f18b..65583dffff262 100644 --- a/src/armor_layers.cpp +++ b/src/armor_layers.cpp @@ -330,40 +330,40 @@ std::vector clothing_flags_description( const item &worn_item ) std::vector 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." ) ); } return description_stack; diff --git a/src/avatar.cpp b/src/avatar.cpp index 3dfec0de48bf6..9a1b9b3a8d87c 100644 --- a/src/avatar.cpp +++ b/src/avatar.cpp @@ -745,11 +745,11 @@ void avatar::do_read( item &book ) 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/bionics.cpp b/src/bionics.cpp index e80aaff137285..a064a5ce3877e 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -2199,13 +2199,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 &elem : b_id->occupied_bodyparts ) { add_effect( effect_under_operation, difficulty * 20_minutes, elem.first.id(), true, difficulty ); @@ -2486,18 +2486,18 @@ bool Character::install_bionics( const itype &type, player &installer, bool auto activity.values.push_back( success ); activity.values.push_back( units::to_millijoule( 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 &elem : bioid->occupied_bodyparts ) { add_effect( effect_under_operation, difficulty * 20_minutes, elem.first.id(), true, difficulty ); diff --git a/src/bionics_ui.cpp b/src/bionics_ui.cpp index f02653a929e2a..96c6b08f17428 100644 --- a/src/bionics_ui.cpp +++ b/src/bionics_ui.cpp @@ -314,10 +314,10 @@ static std::string build_bionic_poweronly_string( const bionic &bio ) bio_data.charge_time ) ); } if( bio_data.has_flag( STATIC( json_character_flag( "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.get_safe_fuel_thresh() > 0 && ( !bio.info().fuel_opts.empty() || bio.info().is_remote_fueled ) ) { diff --git a/src/character.cpp b/src/character.cpp index 5e737bf2c5d2e..ea06d97750ea4 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -3496,7 +3496,7 @@ std::vector Character::find_reloadables() node->remaining_ammo_capacity() > 0; } if( reloadable ) { - reloadables.push_back( item_location( *this, node ) ); + reloadables.emplace_back( *this, node ); } return VisitResponse::NEXT; } ); diff --git a/src/clzones.cpp b/src/clzones.cpp index 177fc14c0bd1c..1e4c5319441cb 100644 --- a/src/clzones.cpp +++ b/src/clzones.cpp @@ -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/construction.cpp b/src/construction.cpp index 9309c99ef917e..1da0ae0440230 100644 --- a/src/construction.cpp +++ b/src/construction.cpp @@ -523,7 +523,7 @@ 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++; } } @@ -1813,7 +1813,7 @@ void finalize_constructions() if( !vp.has_flag( flag_INITIAL_PART ) ) { continue; } - frame_items.push_back( item_comp( vp.base_item, 1 ) ); + frame_items.emplace_back( vp.base_item, 1 ); } if( frame_items.empty() ) { diff --git a/src/crafting.cpp b/src/crafting.cpp index da150228ba2b3..980130372a99c 100644 --- a/src/crafting.cpp +++ b/src/crafting.cpp @@ -2304,7 +2304,7 @@ void Character::disassemble_all( bool one_pass ) bool found_any = false; std::vector to_disassemble; for( item &it : get_map().i_at( pos() ) ) { - to_disassemble.push_back( item_location( map_cursor( pos() ), &it ) ); + to_disassemble.emplace_back( map_cursor( pos() ), &it ); } for( item_location &it_loc : to_disassemble ) { // Prevent disassembling an in process disassembly because it could have been created by a previous iteration of this loop diff --git a/src/crafting_gui.cpp b/src/crafting_gui.cpp index a5629e5723052..dc8ea31b791f0 100644 --- a/src/crafting_gui.cpp +++ b/src/crafting_gui.cpp @@ -680,7 +680,7 @@ const recipe *select_crafting_recipe( int &batch_size_out ) current.clear(); for( int i = 1; i <= 50; i++ ) { current.push_back( chosen ); - available.push_back( availability( chosen, i ) ); + available.emplace_back( chosen, i ); } } else { static_popup popup; @@ -1091,7 +1091,7 @@ std::string peek_related_recipe( const recipe *current, const recipe_subset &ava const requirement_data &req = current->simple_requirements(); for( const std::vector &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 ); @@ -1104,7 +1104,7 @@ std::string peek_related_recipe( const recipe *current, const recipe_subset &ava get_player_character().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 6d8a4f4651fc0..583b9ec6ceb60 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -1427,7 +1427,7 @@ void Creature::process_effects() // Add any effects that others remove to the removal list for( const auto &removed_effect : _it.second.get_removes_effects() ) { rem_ids.push_back( removed_effect ); - rem_bps.push_back( bodypart_str_id::NULL_ID() ); + rem_bps.emplace_back( bodypart_str_id::NULL_ID() ); } effect &e = _it.second; const int prev_int = e.get_intensity(); @@ -2115,7 +2115,7 @@ std::vector Creature::get_all_body_parts( get_body_part_flags flags if( only_main && elem.first->main_part != elem.first ) { continue; } - all_bps.push_back( elem.first ); + all_bps.emplace_back( elem.first ); } if( flags & get_body_part_flags::sorted ) { @@ -2596,11 +2596,11 @@ void Creature::describe_infrared( std::vector &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 &buf ) const { - buf.push_back( _( "You sense a creature here." ) ); + buf.emplace_back( _( "You sense a creature here." ) ); } diff --git a/src/debug_menu.cpp b/src/debug_menu.cpp index 850b391a78caf..ff26a6bef399e 100644 --- a/src/debug_menu.cpp +++ b/src/debug_menu.cpp @@ -1974,7 +1974,8 @@ static void debug_menu_game_state() std::vector> sorted; sorted.reserve( m_flag::MF_MAX ); for( int f = 0; f < m_flag::MF_MAX; f++ ) { - sorted.push_back( {static_cast( f ), MonsterGenerator::generator().m_flag_usage_stats[f]} ); + sorted.emplace_back( static_cast( f ), + MonsterGenerator::generator().m_flag_usage_stats[f] ); } std::sort( sorted.begin(), sorted.end(), []( std::pair a, std::pair 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 7a8f6a3c331c6..2d7681d3fb623 100644 --- a/src/dialogue_win.cpp +++ b/src/dialogue_win.cpp @@ -71,7 +71,7 @@ size_t dialogue_window::add_to_history( const std::string &text ) // Empty line between lines of dialogue void dialogue_window::add_history_separator() { - history.push_back( "" ); + history.emplace_back( "" ); } void dialogue_window::print_history( const size_t hilight_lines ) diff --git a/src/editmap.cpp b/src/editmap.cpp index eeed0847399bc..e658635e93d46 100644 --- a/src/editmap.cpp +++ b/src/editmap.cpp @@ -2095,7 +2095,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 ); } } } @@ -2161,7 +2161,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 fad0aae5fc147..e5d4b91774938 100644 --- a/src/effect.cpp +++ b/src/effect.cpp @@ -517,7 +517,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; } @@ -627,32 +627,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 ) { @@ -1312,16 +1312,16 @@ void load_effect_type( const JsonObject &jo ) jo.read( "blood_analysis_description", new_etype.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 0dc6badbd3030..4699b19ac8a4e 100644 --- a/src/event_field_transformations.cpp +++ b/src/event_field_transformations.cpp @@ -60,7 +60,7 @@ static std::vector species_of_monster( const cata_variant &v ) std::vector 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/faction_camp.cpp b/src/faction_camp.cpp index 9129ba68fae1c..5cc54c28ab3d6 100644 --- a/src/faction_camp.cpp +++ b/src/faction_camp.cpp @@ -2786,10 +2786,10 @@ void basecamp::recruit_return( const std::string &task, int score ) description += _( "Select an option:" ); std::vector 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( rec_m ) >= rec_options.size() ) { @@ -3300,19 +3300,19 @@ void om_range_mark( const tripoint_abs_omt &origin, int range, bool add_notes, std::vector 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 ) { @@ -3544,7 +3544,7 @@ std::vector> 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/game.cpp b/src/game.cpp index 303aaf3787285..f207dc5f5cb75 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -861,15 +861,15 @@ vehicle *game::place_vehicle_nearby( if( search_types.empty() ) { vehicle veh( id ); if( veh.max_ground_velocity() > 0 ) { - search_types.push_back( "road" ); - search_types.push_back( "field" ); + search_types.emplace_back( "road" ); + search_types.emplace_back( "field" ); } else 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 { // some default locations - search_types.push_back( "road" ); - search_types.push_back( "field" ); + search_types.emplace_back( "road" ); + search_types.emplace_back( "field" ); } } for( const std::string &search_type : search_types ) { @@ -10135,7 +10135,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; } } @@ -12384,7 +12384,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_liquid.cpp b/src/handle_liquid.cpp index 34e7bc818fd15..310f29bca0f49 100644 --- a/src/handle_liquid.cpp +++ b/src/handle_liquid.cpp @@ -86,7 +86,7 @@ static void serialize_liquid_target( player_activity &act, const item_location & act.values.push_back( static_cast( liquid_target_type::CONTAINER ) ); act.values.push_back( 0 ); // dummy act.targets.push_back( container_item ); - act.coords.push_back( tripoint() ); // dummy + act.coords.emplace_back( ); // dummy } static void serialize_liquid_target( player_activity &act, const tripoint &pos ) diff --git a/src/iexamine.cpp b/src/iexamine.cpp index bb4387ec497d3..21340ebaa2ae0 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -748,7 +748,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( item_location( u, dst ) ); + u.activity.targets.emplace_back( u, dst ); break; } // should we check for max capacity here? @@ -1384,7 +1384,7 @@ void iexamine::pit( player &p, const tripoint &examp ) return; } std::vector 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?" ) ) ) { @@ -3565,7 +3565,7 @@ void iexamine::tree_maple( player &p, const tripoint &examp ) } std::vector 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( 20_seconds ) ); @@ -4032,7 +4032,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() ) { @@ -4757,9 +4757,9 @@ void iexamine::autodoc( player &p, const tripoint &examp ) } case 2: { std::vector 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 ) { @@ -4838,7 +4838,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 ); drug_count += anesthesia_item->ammo_remaining(); } } @@ -4868,7 +4868,7 @@ void iexamine::autodoc( player &p, const tripoint &examp ) if( !install_programs.empty() ) { has_install_program = true; - progs.push_back( item_comp( install_programs[0]->typeId(), 1 ) ); + progs.emplace_back( install_programs[0]->typeId(), 1 ); } const int weight = units::to_kilogram( patient.bodyweight() ) / 10; @@ -5428,7 +5428,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 ); } } @@ -5477,7 +5477,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 ); Character &player_character = get_player_character(); // select from where to get the items from and place them @@ -5537,7 +5537,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 ); } } @@ -5586,7 +5586,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 ); Character &player_character = get_player_character(); // select from where to get the items from and place them diff --git a/src/inventory_ui.cpp b/src/inventory_ui.cpp index 1f712504b272b..a0de6ee2ca11b 100644 --- a/src/inventory_ui.cpp +++ b/src/inventory_ui.cpp @@ -1044,8 +1044,8 @@ void inventory_column::draw( const catacurses::window &win, const point &p, const int hx_max = p.x + get_width() + contained_offset; inclusive_rectangle rect = inclusive_rectangle( point( x1, yy ), point( hx_max - 1, yy ) ); - rect_entry_map.push_back( std::pair, inventory_entry *>( rect, - &entry ) ); + rect_entry_map.emplace_back( rect, + &entry ); if( selected && visible_cells() > 1 ) { for( int hx = x1; hx < hx_max; ++hx ) { diff --git a/src/item.cpp b/src/item.cpp index 437450f384ad4..af31100f3a17d 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -1506,7 +1506,7 @@ void item::validate_ownership() const static void insert_separation_line( std::vector &info ) { if( info.empty() || info.back().sName != "--" ) { - info.push_back( iteminfo( "DESCRIPTION", "--" ) ); + info.emplace_back( "DESCRIPTION", "--" ); } } @@ -1673,7 +1673,7 @@ void item::basic_info( std::vector &info, const iteminfo_query *parts, []( const material_type * material ) { return string_format( "%s", 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 ) ) { @@ -1684,18 +1684,18 @@ void item::basic_info( std::vector &info, const iteminfo_query *parts, info.back().bNewLine = true; } if( parts->test( iteminfo_parts::BASE_LENGTH ) && length() > 0_mm ) { - info.push_back( iteminfo( "BASE", _( "Length: " ), - string_format( " %s", length_units( length() ) ), - iteminfo::lower_is_better, - convert_length( length() ) ) ); + info.emplace_back( "BASE", _( "Length: " ), + string_format( " %s", length_units( length() ) ), + iteminfo::lower_is_better, + convert_length( length() ) ); } if( parts->test( iteminfo_parts::BASE_OWNER ) && !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: " ), - "
" + get_category_shallow().name() + "
" ) ); + info.emplace_back( "BASE", _( "Category: " ), + "
" + get_category_shallow().name() + "
" ); } if( parts->test( iteminfo_parts::DESCRIPTION ) ) { @@ -1705,16 +1705,16 @@ void item::basic_info( std::vector &info, const iteminfo_query *parts, const cata::optional 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_gun_variant() ) { - info.push_back( iteminfo( "DESCRIPTION", gun_variant().alt_description.translated() ) ); + info.emplace_back( "DESCRIPTION", gun_variant().alt_description.translated() ); } else { if( has_flag( flag_MAGIC_FOCUS ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "This item is a magical focus. " - "You can cast spells with it in your hand." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "This item is a magical focus. " + "You can cast spells with it in your hand." ) ); } if( is_craft() ) { const std::string desc = ( typeId() == itype_disassembly ) ? @@ -1722,11 +1722,11 @@ void item::basic_info( std::vector &info, const iteminfo_query *parts, "It is %d percent complete." ) : _( "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 ); @@ -1760,13 +1760,13 @@ void item::basic_info( std::vector &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: " ), "", iteminfo::no_flags, - charges * batch ) ); + info.emplace_back( "BASE", _( "Amount: " ), "", iteminfo::no_flags, + charges * batch ); } } @@ -1775,66 +1775,66 @@ void item::debug_info( std::vector &info, const iteminfo_query *parts, { if( debug && parts->test( iteminfo_parts::BASE_DEBUG ) ) { if( g != nullptr ) { - info.push_back( iteminfo( "BASE", string_format( "itype_id: %s", - typeId().str() ) ) ); + info.emplace_back( "BASE", string_format( "itype_id: %s", + typeId().str() ) ); if( !old_owner.is_null() ) { - info.push_back( iteminfo( "BASE", string_format( _( "Old owner: %s" ), - _( get_old_owner_name() ) ) ) ); - } - info.push_back( iteminfo( "BASE", _( "age (hours): " ), "", iteminfo::lower_is_better, - to_hours( 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( _( "Old owner: %s" ), + _( get_old_owner_name() ) ) ); + } + info.emplace_back( "BASE", _( "age (hours): " ), "", iteminfo::lower_is_better, + to_hours( 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 std::string space = " "; if( goes_bad() ) { - info.push_back( iteminfo( "BASE", _( "age (turns): " ), - "", iteminfo::lower_is_better, - to_turns( age() ) ) ); - info.push_back( iteminfo( "BASE", _( "rot (turns): " ), - "", iteminfo::lower_is_better, - to_turns( rot ) ) ); - info.push_back( iteminfo( "BASE", space + _( "max rot (turns): " ), - "", iteminfo::lower_is_better, - to_turns( get_shelf_life() ) ) ); + info.emplace_back( "BASE", _( "age (turns): " ), + "", iteminfo::lower_is_better, + to_turns( age() ) ); + info.emplace_back( "BASE", _( "rot (turns): " ), + "", iteminfo::lower_is_better, + to_turns( rot ) ); + info.emplace_back( "BASE", space + _( "max rot (turns): " ), + "", iteminfo::lower_is_better, + to_turns( get_shelf_life() ) ); } if( has_temperature() ) { - info.push_back( iteminfo( "BASE", _( "last temp: " ), - "", iteminfo::lower_is_better, - to_turn( last_temp_check ) ) ); - info.push_back( iteminfo( "BASE", _( "Temp: " ), "", iteminfo::lower_is_better, - temperature ) ); - info.push_back( iteminfo( "BASE", _( "Spec ener: " ), "", - iteminfo::lower_is_better, - specific_energy ) ); - info.push_back( iteminfo( "BASE", _( "Spec heat lq: " ), "", - iteminfo::lower_is_better | iteminfo::is_decimal, - get_specific_heat_liquid() ) ); - info.push_back( iteminfo( "BASE", _( "Spec heat sld: " ), "", - iteminfo::lower_is_better | iteminfo::is_decimal, - get_specific_heat_solid() ) ); - info.push_back( iteminfo( "BASE", _( "latent heat: " ), "", - iteminfo::lower_is_better, - get_latent_heat() ) ); - info.push_back( iteminfo( "BASE", _( "Freeze point: " ), "", - iteminfo::lower_is_better | iteminfo::is_decimal, - get_freeze_point() ) ); + info.emplace_back( "BASE", _( "last temp: " ), + "", iteminfo::lower_is_better, + to_turn( last_temp_check ) ); + info.emplace_back( "BASE", _( "Temp: " ), "", iteminfo::lower_is_better, + temperature ); + info.emplace_back( "BASE", _( "Spec ener: " ), "", + iteminfo::lower_is_better, + specific_energy ); + info.emplace_back( "BASE", _( "Spec heat lq: " ), "", + iteminfo::lower_is_better | iteminfo::is_decimal, + get_specific_heat_liquid() ); + info.emplace_back( "BASE", _( "Spec heat sld: " ), "", + iteminfo::lower_is_better | iteminfo::is_decimal, + get_specific_heat_solid() ); + info.emplace_back( "BASE", _( "latent heat: " ), "", + iteminfo::lower_is_better, + get_latent_heat() ); + info.emplace_back( "BASE", _( "Freeze point: " ), "", + iteminfo::lower_is_better | iteminfo::is_decimal, + get_freeze_point() ); } } } @@ -1845,29 +1845,29 @@ void item::med_info( const item *med_item, std::vector &info, const it { const cata::value_ptr &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 ); } Character &player_character = get_player_character(); if( med_item->get_comestible_fun() != 0 && parts->test( iteminfo_parts::MED_JOY ) ) { - info.push_back( iteminfo( "MED", _( "Enjoyability: " ), - player_character.fun_for( *med_item ).first ) ); + info.emplace_back( "MED", _( "Enjoyability: " ), + player_character.fun_for( *med_item ).first ); } if( med_com->stim != 0 && parts->test( iteminfo_parts::MED_STIMULATION ) ) { std::string name = string_format( "%s %s", _( "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( med_item->charges ) * batch ) ) ); + info.emplace_back( "MED", _( "Portions: " ), + std::abs( static_cast( med_item->charges ) * batch ) ); } if( parts->test( iteminfo_parts::MED_CONSUME_TIME ) ) { - info.push_back( iteminfo( "MED", _( "Consume time: " ), - to_string( player_character.get_consume_time( *med_item ) ) ) ); + info.emplace_back( "MED", _( "Consume time: " ), + to_string( player_character.get_consume_time( *med_item ) ) ); } if( med_com->addict && parts->test( iteminfo_parts::DESCRIPTION_MED_ADDICTING ) ) { @@ -1904,51 +1904,51 @@ void item::food_info( const item *food_item, std::vector &info, if( max_nutr.kcal() != 0 || food_item->get_comestible()->quench != 0 ) { if( parts->test( iteminfo_parts::FOOD_NUTRITION ) ) { - info.push_back( iteminfo( "FOOD", _( "Calories (kcal): " ), - "", iteminfo::no_newline, min_nutr.kcal() ) ); + info.emplace_back( "FOOD", _( "Calories (kcal): " ), + "", 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 ) ) { const std::string space = " "; - info.push_back( iteminfo( "FOOD", space + _( "Quench: " ), - food_item->get_comestible()->quench ) ); + info.emplace_back( "FOOD", space + _( "Quench: " ), + food_item->get_comestible()->quench ); } if( parts->test( iteminfo_parts::FOOD_SATIATION ) ) { if( max_nutr.kcal() == min_nutr.kcal() ) { - info.push_back( iteminfo( "FOOD", _( "Satiety: " ), - satiety_bar( player_character.compute_calories_per_effective_volume( *food_item ) ) ) ); + info.emplace_back( "FOOD", _( "Satiety: " ), + satiety_bar( player_character.compute_calories_per_effective_volume( *food_item ) ) ); } else { - info.push_back( iteminfo( "FOOD", _( "Satiety: " ), - satiety_bar( player_character.compute_calories_per_effective_volume( *food_item, &min_nutr ) ), - iteminfo::no_newline - ) ); - info.push_back( iteminfo( "FOOD", _( " - " ), - satiety_bar( player_character.compute_calories_per_effective_volume( *food_item, &max_nutr ) ) ) ); + info.emplace_back( "FOOD", _( "Satiety: " ), + satiety_bar( player_character.compute_calories_per_effective_volume( *food_item, &min_nutr ) ), + iteminfo::no_newline + ); + info.emplace_back( "FOOD", _( " - " ), + satiety_bar( player_character.compute_calories_per_effective_volume( *food_item, &max_nutr ) ) ); } } } const std::pair fun_for_food_item = player_character.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( food_item->charges ) * batch ) ) ); + info.emplace_back( "FOOD", _( "Portions: " ), + std::abs( static_cast( food_item->charges ) * batch ) ); } if( food_item->corpse != nullptr && parts->test( iteminfo_parts::FOOD_SMELL ) && ( debug || ( g != nullptr && player_character.has_trait( trait_CARNIVORE ) ) ) ) { - info.push_back( iteminfo( "FOOD", _( "Smells like: " ) + food_item->corpse->nname() ) ); + info.emplace_back( "FOOD", _( "Smells like: " ) + food_item->corpse->nname() ); } if( parts->test( iteminfo_parts::FOOD_CONSUME_TIME ) ) { - info.push_back( iteminfo( "FOOD", _( "Consume time: " ), - to_string( player_character.get_consume_time( *food_item ) ) ) ); + info.emplace_back( "FOOD", _( "Consume time: " ), + to_string( player_character.get_consume_time( *food_item ) ) ); } auto format_vitamin = [&]( const std::pair &v, bool display_vitamins ) { @@ -2062,19 +2062,19 @@ void item::food_info( const item *food_item, std::vector &info, } if( food_item->rotten() ) { if( player_character.has_bionic( bio_digestion ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "This food has started to rot, " - "but your bionic digestion can tolerate " - "it." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "This food has started to rot, " + "but your bionic digestion can tolerate " + "it." ) ); } else if( player_character.has_flag( json_flag_IMMUNE_SPOIL ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "This food has started to rot, " - "but you can tolerate it." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "This food has started to rot, " + "but you can tolerate it." ) ); } else { - info.push_back( iteminfo( "DESCRIPTION", - _( "This food has started to rot. " - "Eating it would be a very bad " - "idea." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "This food has started to rot. " + "Eating it would be a very bad " + "idea." ) ); } } } @@ -2267,8 +2267,8 @@ void item::gun_info( const item *mod, std::vector &info, const iteminf if( parts->test( iteminfo_parts::GUN_DAMAGE ) ) { insert_separation_line( info ); - info.push_back( iteminfo( "GUN", _( "Ranged damage: " ), "", iteminfo::no_newline, - mod->gun_damage( false ).total_damage() ) ); + info.emplace_back( "GUN", _( "Ranged damage: " ), "", iteminfo::no_newline, + mod->gun_damage( false ).total_damage() ); } if( mod->ammo_required() ) { @@ -2279,36 +2279,36 @@ void item::gun_info( const item *mod, std::vector &info, const iteminf } if( dmg_mult != 1.0f ) { if( parts->test( iteminfo_parts::GUN_DAMAGE_AMMOPROP ) ) { - info.push_back( iteminfo( "GUN", "ammo_mult", "*", - iteminfo::no_newline | iteminfo::no_name | iteminfo::is_decimal, dmg_mult ) ); + info.emplace_back( "GUN", "ammo_mult", "*", + iteminfo::no_newline | iteminfo::no_name | iteminfo::is_decimal, dmg_mult ); } } else { if( parts->test( iteminfo_parts::GUN_DAMAGE_LOADEDAMMO ) ) { damage_instance ammo_dam = curammo->ammo->damage; - info.push_back( iteminfo( "GUN", "ammo_damage", "", - iteminfo::no_newline | iteminfo::no_name | - iteminfo::show_plus, ammo_dam.total_damage() ) ); + info.emplace_back( "GUN", "ammo_damage", "", + iteminfo::no_newline | iteminfo::no_name | + iteminfo::show_plus, ammo_dam.total_damage() ); } } if( damage_level() > 0 ) { int dmg_penalty = damage_level() * -2; - info.push_back( iteminfo( "GUN", "damaged_weapon_penalty", "", - iteminfo::no_newline | iteminfo::no_name, dmg_penalty ) ); + info.emplace_back( "GUN", "damaged_weapon_penalty", "", + iteminfo::no_newline | iteminfo::no_name, dmg_penalty ); } if( parts->test( iteminfo_parts::GUN_DAMAGE_TOTAL ) ) { - info.push_back( iteminfo( "GUN", "sum_of_damage", _( " = " ), - iteminfo::no_newline | iteminfo::no_name, - loaded_mod->gun_damage( true ).total_damage() ) ); + info.emplace_back( "GUN", "sum_of_damage", _( " = " ), + iteminfo::no_newline | iteminfo::no_name, + loaded_mod->gun_damage( true ).total_damage() ); } } info.back().bNewLine = true; if( mod->ammo_required() && curammo->ammo->critical_multiplier != 1.0 ) { if( parts->test( iteminfo_parts::AMMO_DAMAGE_CRIT_MULTIPLIER ) ) { - info.push_back( iteminfo( "GUN", _( "Critical multiplier: " ), "", - iteminfo::no_flags, curammo->ammo->critical_multiplier ) ); + info.emplace_back( "GUN", _( "Critical multiplier: " ), "", + iteminfo::no_flags, curammo->ammo->critical_multiplier ); } } @@ -2322,43 +2322,43 @@ void item::gun_info( const item *mod, std::vector &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() ) { 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", _( " = " ), - iteminfo::no_name, - get_ranged_pierce( gun ) + ammo_pierce ) ); + info.emplace_back( "GUN", "sum_of_armor_pierce", _( " = " ), + iteminfo::no_name, + get_ranged_pierce( gun ) + ammo_pierce ); } } 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", _( " = " ), - iteminfo::lower_is_better | iteminfo::no_name, - loaded_mod->gun_dispersion( true, false ) ) ); + info.emplace_back( "GUN", "sum_of_dispersion", _( " = " ), + iteminfo::lower_is_better | iteminfo::no_name, + loaded_mod->gun_dispersion( true, false ) ); } } info.back().bNewLine = true; @@ -2369,17 +2369,17 @@ void item::gun_info( const item *mod, std::vector &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", _( " = " ), - 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", _( " = " ), + iteminfo::lower_is_better | iteminfo::no_name, + eff_disp ); } } @@ -2416,8 +2416,8 @@ void item::gun_info( const item *mod, std::vector &info, const iteminf } if( parts->test( iteminfo_parts::GUN_USEDSKILL ) ) { - info.push_back( iteminfo( "GUN", _( "Skill used: " ), - "" + skill.name() + "" ) ); + info.emplace_back( "GUN", _( "Skill used: " ), + "" + skill.name() + "" ); } if( mod->magazine_integral() || mod->magazine_current() ) { @@ -2542,7 +2542,7 @@ void item::gun_info( const item *mod, std::vector &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 ) ) { @@ -2554,8 +2554,8 @@ void item::gun_info( const item *mod, std::vector &info, const iteminf if( is_gun() && has_flag( flag_FIRE_TWOHAND ) && parts->test( iteminfo_parts::DESCRIPTION_TWOHANDED ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "This weapon needs two free hands to fire." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "This weapon needs two free hands to fire." ) ); } } @@ -2568,52 +2568,52 @@ void item::gunmod_info( std::vector &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 must be attached to a gun, " - "it can not be fired separately." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "This mod must be attached to a gun, " + "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, allows making " - "reach melee attacks with it." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "When attached to a gun, allows making " + "reach melee attacks with it." ) ); } if( is_gunmod() && has_flag( flag_DISABLE_SIGHTS ) && parts->test( iteminfo_parts::DESCRIPTION_GUNMOD_DISABLESSIGHTS ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "This mod obscures sights of the " - "base weapon." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "This mod obscures sights 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 suffer wear when firing " - "the base weapon." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "This mod might suffer wear when firing " + "the base weapon." ) ); } 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::no_flags, mod.aim_speed ) ); + info.emplace_back( "GUNMOD", _( "Aim speed: " ), "", + iteminfo::lower_is_better, mod.aim_speed ); } int total_damage = static_cast( 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: " ), "", @@ -2621,8 +2621,8 @@ void item::gunmod_info( std::vector &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: %s" ), - at->name() ) ) ); + info.emplace_back( "GUNMOD", string_format( _( "Ammo: %s" ), + at->name() ) ); } } if( mod.reload_modifier != 0 && parts->test( iteminfo_parts::GUNMOD_RELOAD ) ) { @@ -2630,8 +2630,8 @@ void item::gunmod_info( std::vector &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 ); @@ -2649,7 +2649,7 @@ void item::gunmod_info( std::vector &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 ); @@ -2659,12 +2659,12 @@ void item::gunmod_info( std::vector &info, const iteminfo_query *parts enumerate_as_string( mod.usable.begin(), mod.usable.end(), []( const gun_type_type & used_on ) { return string_format( "%s", used_on.name() ); } ); - 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 ) ) { @@ -2679,7 +2679,7 @@ void item::gunmod_info( std::vector &info, const iteminfo_query *parts iternum++; } mod_black_str += "."; - info.push_back( iteminfo( "GUNMOD", mod_black_str ) ); + info.emplace_back( "GUNMOD", mod_black_str ); } } @@ -2710,7 +2710,7 @@ void item::armor_encumbrance_info( std::vector &info, int reduce_encum } } - info.push_back( iteminfo( "ARMOR", _( "Encumbrance:" ) + format ) ); + info.emplace_back( "ARMOR", _( "Encumbrance:" ) + format ); if( const islot_armor *t = find_armor_data() ) { if( !t->data.empty() ) { @@ -2771,30 +2771,30 @@ void item::armor_encumbrance_info( std::vector &info, int reduce_encum } } if( piece.second.active ) { - 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( piece.second.portion.encumber != piece.second.portion.max_encumber ) { - info.push_back( iteminfo( "ARMOR", when_full_message, "", - iteminfo::no_newline | iteminfo::lower_is_better, - piece.second.portion.max_encumber ) ); + info.emplace_back( "ARMOR", when_full_message, "", + iteminfo::no_newline | iteminfo::lower_is_better, + piece.second.portion.max_encumber ); } - info.push_back( iteminfo( "ARMOR", coverage_message, "", - iteminfo::no_flags, - piece.second.portion.coverage ) ); + info.emplace_back( "ARMOR", coverage_message, "", + iteminfo::no_flags, + piece.second.portion.coverage ); } } } } else if( is_gun() && has_flag( flag_IS_ARMOR ) ) { //right now all eligible gunmods (shoulder_strap, belt_clip) have the is_armor flag and use the torso - info.push_back( iteminfo( "ARMOR", _( "Torso:" ) + space, "", - iteminfo::no_newline | iteminfo::lower_is_better, get_avg_encumber( get_avatar() ) ) ); + info.emplace_back( "ARMOR", _( "Torso:" ) + space, "", + iteminfo::no_newline | iteminfo::lower_is_better, get_avg_encumber( get_avatar() ) ); - info.push_back( iteminfo( "ARMOR", space + _( "Coverage:" ) + space, "", - iteminfo::no_flags, get_coverage( body_part_torso.id() ) ) ); + info.emplace_back( "ARMOR", space + _( "Coverage:" ) + space, "", + iteminfo::no_flags, get_coverage( body_part_torso.id() ) ); } } @@ -2808,36 +2808,36 @@ void item::armor_protection_info( std::vector &info, const iteminfo_qu if( parts->test( iteminfo_parts::ARMOR_PROTECTION ) ) { const std::string space = " "; - info.push_back( iteminfo( "ARMOR", _( "Protection: Bash: " ), "", - iteminfo::no_newline | iteminfo::is_decimal, bash_resist() ) ); - info.push_back( iteminfo( "ARMOR", space + _( "Cut: " ), "", - iteminfo::no_newline | iteminfo::is_decimal, cut_resist() ) ); - info.push_back( iteminfo( "ARMOR", space + _( "Ballistic: " ), "", iteminfo::is_decimal, - bullet_resist() ) ); - info.push_back( iteminfo( "ARMOR", space + _( "Acid: " ), "", - iteminfo::no_newline | iteminfo::is_decimal, acid_resist() ) ); - info.push_back( iteminfo( "ARMOR", space + _( "Fire: " ), "", - iteminfo::no_newline | iteminfo::is_decimal, fire_resist() ) ); - info.push_back( iteminfo( "ARMOR", space + _( "Environmental: " ), - get_base_env_resist( *this ) ) ); + info.emplace_back( "ARMOR", _( "Protection: Bash: " ), "", + iteminfo::no_newline | iteminfo::is_decimal, bash_resist() ); + info.emplace_back( "ARMOR", space + _( "Cut: " ), "", + iteminfo::no_newline | iteminfo::is_decimal, cut_resist() ); + info.emplace_back( "ARMOR", space + _( "Ballistic: " ), "", iteminfo::is_decimal, + bullet_resist() ); + info.emplace_back( "ARMOR", space + _( "Acid: " ), "", + iteminfo::no_newline | iteminfo::is_decimal, acid_resist() ); + info.emplace_back( "ARMOR", space + _( "Fire: " ), "", + iteminfo::no_newline | iteminfo::is_decimal, 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", - _( "Protection when active: " ) ) ); - info.push_back( iteminfo( "ARMOR", space + _( "Acid: " ), "", - iteminfo::no_newline | iteminfo::is_decimal, - acid_resist( false, get_base_env_resist_w_filter() ) ) ); - info.push_back( iteminfo( "ARMOR", space + _( "Fire: " ), "", - iteminfo::no_newline | iteminfo::is_decimal, - 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", + _( "Protection when active: " ) ); + info.emplace_back( "ARMOR", space + _( "Acid: " ), "", + iteminfo::no_newline | iteminfo::is_decimal, + acid_resist( false, get_base_env_resist_w_filter() ) ); + info.emplace_back( "ARMOR", space + _( "Fire: " ), "", + iteminfo::no_newline | iteminfo::is_decimal, + 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 reduced by damage and " - "you may be able to improve them by repairing this " - "item." ) ) ); + info.emplace_back( "ARMOR", + _( "Protection values are reduced by damage and " + "you may be able to improve them by repairing this " + "item." ) ); } } } @@ -2913,7 +2913,7 @@ void item::armor_info( std::vector &info, const iteminfo_query *parts, coverage += _( " Nothing." ); } - info.push_back( iteminfo( "ARMOR", coverage ) ); + info.emplace_back( "ARMOR", coverage ); } if( parts->test( iteminfo_parts::ARMOR_LAYER ) && covers_anything ) { @@ -2934,15 +2934,15 @@ void item::armor_info( std::vector &info, const iteminfo_query *parts, layering += _( " Normal." ); } - 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: " ), "%", - iteminfo::no_newline, get_avg_coverage() ) ); + info.emplace_back( "ARMOR", _( "Average Coverage: " ), "%", + 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 ); @@ -2962,7 +2962,7 @@ void item::armor_info( std::vector &info, const iteminfo_query *parts, tmp.armor_protection_info( info, parts, batch, debug ); insert_separation_line( info ); - info.push_back( iteminfo( "ARMOR", _( "When active:" ) ) ); + info.emplace_back( "ARMOR", _( "When active:" ) ); tmp = tmp.convert( itype_id( tmp.typeId().str() + "_on" ) ); } @@ -2994,9 +2994,9 @@ void item::armor_info( std::vector &info, const iteminfo_query *parts, } else { modifier = "x"; } - info.push_back( iteminfo( "ARMOR", - _( "Weight capacity modifier: " ), modifier, - iteminfo::no_newline | iteminfo::is_decimal, weight_modif ) ); + info.emplace_back( "ARMOR", + _( "Weight capacity modifier: " ), modifier, + iteminfo::no_newline | iteminfo::is_decimal, weight_modif ); } if( weight_bonus != 0_gram ) { std::string bonus; @@ -3005,9 +3005,9 @@ void item::armor_info( std::vector &info, const iteminfo_query *parts, } else { bonus = string_format( " %s", weight_units() ); } - info.push_back( iteminfo( "ARMOR", _( "Weight capacity bonus: " ), bonus, - iteminfo::no_newline | iteminfo::is_decimal, - convert_weight( weight_bonus ) ) ); + info.emplace_back( "ARMOR", _( "Weight capacity bonus: " ), bonus, + iteminfo::no_newline | iteminfo::is_decimal, + convert_weight( weight_bonus ) ); } } @@ -3032,9 +3032,9 @@ void item::armor_fit_info( std::vector &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 worn with a " - "helmet." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* This item can be worn with a " + "helmet." ) ); } if( parts->test( iteminfo_parts::DESCRIPTION_FLAGS_FITS ) ) { @@ -3118,7 +3118,7 @@ void item::armor_fit_info( std::vector &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 ) { @@ -3141,7 +3141,7 @@ void item::armor_fit_info( std::vector &info, const iteminfo_query *pa } std::string info_str = string_format( _( "* This clothing can be " "refitted%s." ), resize_str ); - info.push_back( iteminfo( "DESCRIPTION", info_str ) ); + info.emplace_back( "DESCRIPTION", info_str ); } } else { info.emplace_back( "DESCRIPTION", _( "* This clothing can not be refitted, " @@ -3150,32 +3150,32 @@ void item::armor_fit_info( std::vector &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 either side of " - "the body." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* This item can be worn on either side of " + "the body." ) ); } if( is_power_armor() && parts->test( iteminfo_parts::DESCRIPTION_FLAGS_POWERARMOR ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "* This gear is a part of power armor." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* This gear is a part of power armor." ) ); if( parts->test( iteminfo_parts::DESCRIPTION_FLAGS_POWERARMOR_RADIATIONHINT ) ) { if( covers( bodypart_id( "head" ) ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "* When worn with a power armor suit, it will " - "fully protect you from " - "radiation." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* When worn with a power armor suit, it will " + "fully protect you from " + "radiation." ) ); } else { - info.push_back( iteminfo( "DESCRIPTION", - _( "* When worn with a power armor helmet, it will " - "fully protect you from " - "radiation." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* When worn with a power armor helmet, it will " + "fully protect you from " + "radiation." ) ); } } } 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 ) ) ); } } @@ -3190,31 +3190,31 @@ void item::book_info( std::vector &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." ) ); } avatar &player_character = get_avatar(); if( type->can_use( "MA_MANUAL" ) && parts->test( iteminfo_parts::BOOK_SUMMARY ) ) { - info.push_back( iteminfo( "BOOK", - _( "Some sort of martial arts training " - "manual." ) ) ); + info.emplace_back( "BOOK", + _( "Some sort of martial arts training " + "manual." ) ); if( player_character.has_identified( typeId() ) ) { const matype_id style_to_learn = martial_art_learned_from( *type ); - info.push_back( iteminfo( "BOOK", - string_format( _( "You can learn %s style " - "from it." ), style_to_learn->name ) ) ); - info.push_back( iteminfo( "BOOK", - string_format( _( "This fighting style is %s " - "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 %s." ), - style_to_learn->primary_skill->name() ) ) ); + info.emplace_back( "BOOK", + string_format( _( "You can learn %s style " + "from it." ), style_to_learn->name ) ); + info.emplace_back( "BOOK", + string_format( _( "This fighting style is %s " + "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 %s." ), + 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 understood by " - "beginners." ) ) ); + info.emplace_back( "BOOK", _( "It can be understood by " + "beginners." ) ); } if( player_character.has_identified( typeId() ) ) { if( book.skill ) { @@ -3223,31 +3223,31 @@ void item::book_info( std::vector &info, const iteminfo_query *parts, const std::string skill_name = book.skill->name(); std::string fmt = string_format( _( "Can bring your %s skill to " "." ), 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 %s skill is ." ), 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( _( "Requires %s level 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 intelligence of to easily " - "read." ), iteminfo::lower_is_better, book.intel ) ); + info.emplace_back( "BOOK", "", + _( "Requires intelligence of to easily " + "read." ), iteminfo::lower_is_better, book.intel ); } if( player_character.book_fun_for( *this, player_character ) != 0 && parts->test( iteminfo_parts::BOOK_MORALECHANGE ) ) { - info.push_back( iteminfo( "BOOK", "", - _( "Reading this book affects your morale by " ), - iteminfo::show_plus, player_character.book_fun_for( *this, player_character ) ) ); + info.emplace_back( "BOOK", "", + _( "Reading this book affects your morale by " ), + iteminfo::show_plus, player_character.book_fun_for( *this, player_character ) ); } if( parts->test( iteminfo_parts::BOOK_TIMEPERCHAPTER ) ) { std::string fmt = ngettext( @@ -3262,8 +3262,8 @@ void item::book_info( std::vector &info, const iteminfo_query *parts, "A training session with this book takes " " minutes.", 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 ) ) { @@ -3271,7 +3271,7 @@ void item::book_info( std::vector &info, const iteminfo_query *parts, std::string fmt = ngettext( "This book has unread chapter.", "This book has unread chapters.", unread ); - info.push_back( iteminfo( "BOOK", "", fmt, iteminfo::no_flags, unread ) ); + info.emplace_back( "BOOK", "", fmt, iteminfo::no_flags, unread ); } if( !book.proficiencies.empty() ) { @@ -3284,7 +3284,7 @@ void item::book_info( std::vector &info, const iteminfo_query *parts, book.proficiencies.begin(), book.proficiencies.end(), enumerate_profs ) ); - info.push_back( iteminfo( "BOOK", profs ) ); + info.emplace_back( "BOOK", profs ); } if( parts->test( iteminfo_parts::BOOK_INCLUDED_RECIPES ) ) { @@ -3317,22 +3317,22 @@ void item::book_info( std::vector &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 more " - "recipes." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "It might help you figuring out some more " + "recipes." ) ); } } } else { if( parts->test( iteminfo_parts::BOOK_UNREAD ) ) { - info.push_back( iteminfo( "BOOK", - _( "You need to read this book to see its " - "contents." ) ) ); + info.emplace_back( "BOOK", + _( "You need to read this book to see its " + "contents." ) ); } } } @@ -3406,24 +3406,24 @@ void item::tool_info( std::vector &info, const iteminfo_query *parts, // UPS, rechargeable power cells, and bionic power if( has_flag( flag_USE_UPS ) && parts->test( iteminfo_parts::DESCRIPTION_RECHARGE_UPSMODDED ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "* This tool has been modified to use a universal " - "power supply and is not compatible" - " with standard batteries." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* This tool has been modified to use a universal " + "power supply and is not compatible" + " with standard batteries." ) ); } 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 rechargeable power cell " - "and is not compatible with " - "standard batteries." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* This tool has a rechargeable power cell " + "and is not compatible with " + "standard batteries." ) ); } else if( has_flag( flag_RECHARGE ) && parts->test( iteminfo_parts::DESCRIPTION_RECHARGE_UPSCAPABLE ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "* This tool has a rechargeable power cell " - "and can be recharged in any UPS-compatible " - "recharging station. You could charge it with " - "standard batteries, but unloading it is " - "impossible." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* This tool has a rechargeable power cell " + "and can be recharged in any UPS-compatible " + "recharging station. You could charge it with " + "standard batteries, but unloading it is " + "impossible." ) ); } else if( has_flag( flag_USES_BIONIC_POWER ) ) { info.emplace_back( "DESCRIPTION", _( "* This tool runs on bionic power." ) ); @@ -3444,7 +3444,7 @@ void item::tool_info( std::vector &info, const iteminfo_query *parts, feedback = _( "Almost completely burned out." ); } feedback = _( "Fuel: " ) + feedback; - info.push_back( iteminfo( "DESCRIPTION", feedback ) ); + info.emplace_back( "DESCRIPTION", feedback ); } } @@ -3455,11 +3455,11 @@ void item::component_info( std::vector &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() ) ); } else { - 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() ) ); } } @@ -3536,7 +3536,7 @@ void item::disassembly_info( std::vector &info, const iteminfo_query * } insert_separation_line( info ); - info.push_back( iteminfo( "DESCRIPTION", descr ) ); + info.emplace_back( "DESCRIPTION", descr ); } } @@ -3597,15 +3597,15 @@ void item::bionic_info( std::vector &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 ); if( is_bionic() && has_flag( flag_NO_STERILE ) ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "* This bionic is not sterile, use an autoclave and an autoclave pouch to sterilize it. " ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* This bionic is not sterile, use an autoclave and an autoclave pouch to sterilize it. " ) ); } insert_separation_line( info ); @@ -3614,79 +3614,78 @@ void item::bionic_info( std::vector &info, const iteminfo_query *parts if( !fuels.empty() ) { const int &fuel_numb = fuels.size(); - info.push_back( iteminfo( "DESCRIPTION", - ngettext( "* 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 material_id & id ) -> std::string { return "" + id->name() + ""; } ) ) ); + info.emplace_back( "DESCRIPTION", + ngettext( "* 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 material_id & id ) -> std::string { return "" + id->name() + ""; } ) ); } insert_separation_line( info ); if( bid->capacity > 0_mJ ) { - info.push_back( iteminfo( "CBM", _( "Power Capacity:" ), _( " mJ" ), - iteminfo::no_newline, - units::to_millijoule( bid->capacity ) ) ); + info.emplace_back( "CBM", _( "Power Capacity:" ), _( " mJ" ), + iteminfo::no_newline, + units::to_millijoule( bid->capacity ) ); } insert_separation_line( info ); // TODO refactor these almost identical blocks if( !bid->encumbrance.empty() ) { - info.push_back( iteminfo( "DESCRIPTION", _( "Encumbrance:" ), - iteminfo::no_newline ) ); + info.emplace_back( "DESCRIPTION", _( "Encumbrance:" ), + iteminfo::no_newline ); for( const std::pair &element : sorted_lex( bid->encumbrance ) ) { - info.push_back( - iteminfo( "CBM", " " + body_part_name_as_heading( element.first.id(), 1 ), - " ", iteminfo::no_newline, element.second ) ); + info.emplace_back( "CBM", " " + body_part_name_as_heading( element.first.id(), 1 ), + " ", iteminfo::no_newline, element.second ); } } if( !bid->env_protec.empty() ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "Environmental Protection:" ), - iteminfo::no_newline ) ); + info.emplace_back( "DESCRIPTION", + _( "Environmental Protection:" ), + iteminfo::no_newline ); for( const std::pair< bodypart_str_id, size_t > &element : sorted_lex( bid->env_protec ) ) { - info.push_back( iteminfo( "CBM", " " + body_part_name_as_heading( element.first, 1 ), - " ", iteminfo::no_newline, element.second ) ); + info.emplace_back( "CBM", " " + body_part_name_as_heading( element.first, 1 ), + " ", iteminfo::no_newline, element.second ); } } if( !bid->bash_protec.empty() ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "Bash Protection:" ), - iteminfo::no_newline ) ); + info.emplace_back( "DESCRIPTION", + _( "Bash Protection:" ), + iteminfo::no_newline ); for( const std::pair< bodypart_str_id, size_t > &element : sorted_lex( bid->bash_protec ) ) { - info.push_back( iteminfo( "CBM", " " + body_part_name_as_heading( element.first, 1 ), - " ", iteminfo::no_newline, element.second ) ); + info.emplace_back( "CBM", " " + body_part_name_as_heading( element.first, 1 ), + " ", iteminfo::no_newline, element.second ); } } if( !bid->cut_protec.empty() ) { - info.push_back( iteminfo( "DESCRIPTION", - _( "Cut Protection:" ), - iteminfo::no_newline ) ); + info.emplace_back( "DESCRIPTION", + _( "Cut Protection:" ), + iteminfo::no_newline ); for( const std::pair< bodypart_str_id, size_t > &element : sorted_lex( bid->cut_protec ) ) { - info.push_back( iteminfo( "CBM", " " + body_part_name_as_heading( element.first, 1 ), - " ", iteminfo::no_newline, element.second ) ); + info.emplace_back( "CBM", " " + body_part_name_as_heading( element.first, 1 ), + " ", iteminfo::no_newline, element.second ); } } if( !bid->bullet_protec.empty() ) { - info.push_back( iteminfo( "DESCRIPTION", _( "Ballistic Protection:" ), - iteminfo::no_newline ) ); + info.emplace_back( "DESCRIPTION", _( "Ballistic Protection:" ), + iteminfo::no_newline ); for( const std::pair< bodypart_str_id, size_t > &element : sorted_lex( bid->bullet_protec ) ) { - info.push_back( iteminfo( "CBM", " " + body_part_name_as_heading( element.first, 1 ), - " ", iteminfo::no_newline, element.second ) ); + info.emplace_back( "CBM", " " + body_part_name_as_heading( element.first, 1 ), + " ", iteminfo::no_newline, element.second ); } } if( !bid->stat_bonus.empty() ) { - info.push_back( iteminfo( "DESCRIPTION", _( "Stat Bonus:" ), - iteminfo::no_newline ) ); + info.emplace_back( "DESCRIPTION", _( "Stat Bonus:" ), + iteminfo::no_newline ); for( const auto &element : bid->stat_bonus ) { - info.push_back( iteminfo( "CBM", " " + get_stat_name( element.first ), " ", - iteminfo::no_newline, element.second ) ); + info.emplace_back( "CBM", " " + get_stat_name( element.first ), " ", + iteminfo::no_newline, element.second ); } } @@ -3699,10 +3698,10 @@ void item::bionic_info( std::vector &info, const iteminfo_query *parts } else { modifier = "x"; } - info.push_back( iteminfo( "CBM", - _( "Weight capacity modifier: " ), modifier, - iteminfo::no_newline | iteminfo::is_decimal, - weight_modif ) ); + info.emplace_back( "CBM", + _( "Weight capacity modifier: " ), modifier, + iteminfo::no_newline | iteminfo::is_decimal, + weight_modif ); } if( weight_bonus != 0_gram ) { std::string bonus; @@ -3711,9 +3710,9 @@ void item::bionic_info( std::vector &info, const iteminfo_query *parts } else { bonus = string_format( " %s", weight_units() ); } - info.push_back( iteminfo( "CBM", _( "Weight capacity bonus: " ), bonus, - iteminfo::no_newline | iteminfo::is_decimal, - convert_weight( weight_bonus ) ) ); + info.emplace_back( "CBM", _( "Weight capacity bonus: " ), bonus, + iteminfo::no_newline | iteminfo::is_decimal, + convert_weight( weight_bonus ) ); } } @@ -3729,30 +3728,30 @@ void item::combat_info( std::vector &info, const iteminfo_query *parts insert_separation_line( info ); std::string sep; if( dmg_bash || dmg_cut || dmg_stab ) { - info.push_back( iteminfo( "BASE", _( "Melee damage: " ), "", iteminfo::no_newline ) ); + info.emplace_back( "BASE", _( "Melee damage: " ), "", 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_time() ) ); + info.emplace_back( "BASE", _( "Moves per attack: " ), "", + iteminfo::lower_is_better, attack_time() ); } @@ -3777,11 +3776,11 @@ void item::combat_info( std::vector &info, const iteminfo_query *parts if( !all_techniques.empty() ) { const std::vector all_tec_sorted = sorted_lex( all_techniques ); insert_separation_line( info ); - info.push_back( iteminfo( "DESCRIPTION", _( "Techniques when wielded: " ) + + info.emplace_back( "DESCRIPTION", _( "Techniques when wielded: " ) + enumerate_as_string( all_tec_sorted.begin(), all_tec_sorted.end(), []( const matec_id & tid ) { return string_format( "%s: %s", tid.obj().name, tid.obj().description ); - } ) ) ); + } ) ); } } @@ -3792,9 +3791,9 @@ void item::combat_info( std::vector &info, const iteminfo_query *parts 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 ); } } @@ -3802,13 +3801,13 @@ void item::combat_info( std::vector &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 long reach " - "attacks." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* This item can be used to make long reach " + "attacks." ) ); } else { - info.push_back( iteminfo( "DESCRIPTION", - _( "* This item can be used to make reach " - "attacks." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* This item can be used to make reach " + "attacks." ) ); } } @@ -3822,50 +3821,50 @@ void item::combat_info( std::vector &info, const iteminfo_query *parts int attack_cost = player_character.attack_speed( *this ); insert_separation_line( info ); if( parts->test( iteminfo_parts::DESCRIPTION_MELEEDMG ) ) { - info.push_back( iteminfo( "DESCRIPTION", _( "Average melee damage:" ) ) ); + info.emplace_back( "DESCRIPTION", _( "Average melee damage:" ) ); } // Chance of critical hit if( parts->test( iteminfo_parts::DESCRIPTION_MELEEDMG_CRIT ) ) { - info.push_back( iteminfo( "DESCRIPTION", - string_format( _( "Critical hit chance %d%% - %d%%" ), + info.emplace_back( "DESCRIPTION", + string_format( _( "Critical hit chance %d%% - %d%%" ), static_cast( player_character.crit_chance( 0, 100, *this ) * 100 ), static_cast( player_character.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 for DESCRIPTION info) - info.push_back( iteminfo( "BASE", _( "Bashing: " ), "", iteminfo::no_newline, - non_crit.type_damage( damage_type::BASH ) ) ); - info.push_back( iteminfo( "BASE", space + _( "Critical bash: " ), "", iteminfo::no_flags, - crit.type_damage( damage_type::BASH ) ) ); + info.emplace_back( "BASE", _( "Bashing: " ), "", iteminfo::no_newline, + non_crit.type_damage( damage_type::BASH ) ); + info.emplace_back( "BASE", space + _( "Critical bash: " ), "", iteminfo::no_flags, + crit.type_damage( damage_type::BASH ) ); } // Cut damage if( ( non_crit.type_damage( damage_type::CUT ) > 0.0f || crit.type_damage( damage_type::CUT ) > 0.0f ) && parts->test( iteminfo_parts::DESCRIPTION_MELEEDMG_CUT ) ) { - info.push_back( iteminfo( "BASE", _( "Cutting: " ), "", iteminfo::no_newline, - non_crit.type_damage( damage_type::CUT ) ) ); - info.push_back( iteminfo( "BASE", space + _( "Critical cut: " ), "", iteminfo::no_flags, - crit.type_damage( damage_type::CUT ) ) ); + info.emplace_back( "BASE", _( "Cutting: " ), "", iteminfo::no_newline, + non_crit.type_damage( damage_type::CUT ) ); + info.emplace_back( "BASE", space + _( "Critical cut: " ), "", iteminfo::no_flags, + crit.type_damage( damage_type::CUT ) ); } // Pierce/stab damage if( ( non_crit.type_damage( damage_type::STAB ) > 0.0f || crit.type_damage( damage_type::STAB ) > 0.0f ) && parts->test( iteminfo_parts::DESCRIPTION_MELEEDMG_PIERCE ) ) { - info.push_back( iteminfo( "BASE", _( "Piercing: " ), "", iteminfo::no_newline, - non_crit.type_damage( damage_type::STAB ) ) ); - info.push_back( iteminfo( "BASE", space + _( "Critical pierce: " ), "", iteminfo::no_flags, - crit.type_damage( damage_type::STAB ) ) ); + info.emplace_back( "BASE", _( "Piercing: " ), "", iteminfo::no_newline, + non_crit.type_damage( damage_type::STAB ) ); + info.emplace_back( "BASE", space + _( "Critical pierce: " ), "", iteminfo::no_flags, + crit.type_damage( damage_type::STAB ) ); } // Moves if( parts->test( iteminfo_parts::DESCRIPTION_MELEEDMG_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 ); } insert_separation_line( info ); } @@ -3951,14 +3950,14 @@ void item::final_info( std::vector &info, const iteminfo_query *parts, if( parts->test( iteminfo_parts::DESCRIPTION_CONDUCTIVITY ) ) { if( !conductive() ) { - info.push_back( iteminfo( "BASE", _( "* This item does not " - "conduct electricity." ) ) ); + info.emplace_back( "BASE", _( "* This item does not " + "conduct electricity." ) ); } else if( has_flag( flag_CONDUCTIVE ) ) { - info.push_back( iteminfo( "BASE", - _( "* This item effectively conducts " - "electricity, as it has no guard." ) ) ); + info.emplace_back( "BASE", + _( "* This item effectively conducts " + "electricity, as it has no guard." ) ); } else { - info.push_back( iteminfo( "BASE", _( "* This item conducts electricity." ) ) ); + info.emplace_back( "BASE", _( "* This item conducts electricity." ) ); } } @@ -4024,16 +4023,16 @@ void item::final_info( std::vector &info, const iteminfo_query *parts, 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 cracked, " - "revealing an ominous green glow." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* The casing of this item has cracked, " + "revealing an ominous green glow." ) ); } 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 surrounded by a " - "sickly green glow." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "* This object is surrounded by a " + "sickly green glow." ) ); } if( is_brewable() ) { @@ -4043,25 +4042,25 @@ void item::final_info( std::vector &info, const iteminfo_query *parts, int btime_i = to_days( btime ); if( btime <= 2_days ) { btime_i = to_hours( btime ); - info.push_back( iteminfo( "DESCRIPTION", - string_format( ngettext( "* Once set in a vat, this " + info.emplace_back( "DESCRIPTION", + string_format( ngettext( "* 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( ngettext( "* Once set in a vat, this " + info.emplace_back( "DESCRIPTION", + string_format( ngettext( "* 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 " - "%s." ), - nname( res, brewed.charges ) ) ) ); + info.emplace_back( "DESCRIPTION", + string_format( _( "* Fermenting this will produce " + "%s." ), + nname( res, brewed.charges ) ) ); } } } @@ -4105,13 +4104,13 @@ void item::final_info( std::vector &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 can be activated." ) ) ); + info.emplace_back( "DESCRIPTION", + _( "It's done and can be activated." ) ); } 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() ) ); } } } @@ -4138,7 +4137,7 @@ void item::final_info( std::vector &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( parts->test( iteminfo_parts::DESCRIPTION_DIE ) && this->get_var( "die_num_sides", 0 ) != 0 ) { @@ -4154,15 +4153,15 @@ void item::final_info( std::vector &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: " ), _( "$" ), - iteminfo::is_decimal | iteminfo::lower_is_better | iteminfo::no_newline, - static_cast( price_preapoc ) / 100 ) ); + info.emplace_back( "BASE", _( "Price: " ), _( "$" ), + iteminfo::is_decimal | iteminfo::lower_is_better | iteminfo::no_newline, + static_cast( price_preapoc ) / 100 ); } if( price_preapoc != price_postapoc && parts->test( iteminfo_parts::BASE_BARTER ) ) { const std::string space = " "; - info.push_back( iteminfo( "BASE", space + _( "Barter value: " ), _( "$" ), - iteminfo::is_decimal | iteminfo::lower_is_better, - static_cast( price_postapoc ) / 100 ) ); + info.emplace_back( "BASE", space + _( "Barter value: " ), _( "$" ), + iteminfo::is_decimal | iteminfo::lower_is_better, + static_cast( price_postapoc ) / 100 ); } // Recipes using this item as an ingredient @@ -4176,17 +4175,17 @@ void item::final_info( std::vector &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> result_names; @@ -4209,9 +4208,9 @@ void item::final_info( std::vector &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 ) ); } } } @@ -4220,9 +4219,9 @@ void item::final_info( std::vector &info, const iteminfo_query *parts, const ret_val can_wear = player_character.can_wear( *this, true ); if( ! can_wear.success() ) { insert_separation_line( info ); - info.push_back( iteminfo( "DESCRIPTION", - // can_wear returns a translated string - string_format( "%s", can_wear.str() ) ) ); + info.emplace_back( "DESCRIPTION", + // can_wear returns a translated string + string_format( "%s", can_wear.str() ) ); } } @@ -4236,7 +4235,7 @@ void item::final_info( std::vector &info, const iteminfo_query *parts, } if( art.is_valid() ) { for( const std::string &line : art->picture ) { - info.push_back( iteminfo( "DESCRIPTION", line ) ); + info.emplace_back( "DESCRIPTION", line ); } } } @@ -7567,7 +7566,7 @@ std::vector> item::get_available_recipes( const C 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" ) ) { @@ -7584,7 +7583,7 @@ std::vector> item::get_available_recipes( const C 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; } @@ -10796,7 +10795,7 @@ std::vector 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_contents.cpp b/src/item_contents.cpp index 2c055e1cdef65..911b5274ced9c 100644 --- a/src/item_contents.cpp +++ b/src/item_contents.cpp @@ -201,7 +201,7 @@ item_contents::item_contents( const std::vector &pockets ) { for( const pocket_data &data : pockets ) { - contents.push_back( item_pocket( &data ) ); + contents.emplace_back( &data ); } } @@ -1252,7 +1252,7 @@ void item_contents::update_modified_pockets( // in case the debugmsg wasn't clear, this should never happen debugmsg( "Oops! deleted some items when updating pockets that were added via toolmods" ); } - contents.push_back( item_pocket( *mag_or_mag_well ) ); + contents.emplace_back( *mag_or_mag_well ); pocket_iter = contents.erase( pocket_iter ); } else { ++pocket_iter; @@ -1268,7 +1268,7 @@ void item_contents::update_modified_pockets( // we've deleted all of the superfluous copies already, so time to add the new pockets for( const pocket_data *container_pocket : container_pockets ) { - contents.push_back( item_pocket( container_pocket ) ); + contents.emplace_back( container_pocket ); } } @@ -1549,7 +1549,7 @@ int item_contents::best_quality( const quality_id &id ) const static void insert_separation_line( std::vector &info ) { if( info.empty() || info.back().sName != "--" ) { - info.push_back( iteminfo( "DESCRIPTION", "--" ) ); + info.emplace_back( "DESCRIPTION", "--" ); } } diff --git a/src/item_factory.cpp b/src/item_factory.cpp index 9b4ce667f0f4b..c7f736d1e3eef 100644 --- a/src/item_factory.cpp +++ b/src/item_factory.cpp @@ -2575,7 +2575,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" ); } } @@ -3402,10 +3402,10 @@ bool Item_factory::load_sub_ref( std::unique_ptr &ptr, const Js iname, gname ) ); } 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 ); } const std::string subcontext = name + " of " + parent.context(); diff --git a/src/item_pocket.cpp b/src/item_pocket.cpp index e24dcdf436702..77528f33c5b26 100644 --- a/src/item_pocket.cpp +++ b/src/item_pocket.cpp @@ -822,7 +822,7 @@ void item_pocket::set_item_defaults() static void insert_separation_line( std::vector &info ) { if( info.empty() || info.back().sName != "--" ) { - info.push_back( iteminfo( "DESCRIPTION", "--" ) ); + info.emplace_back( "DESCRIPTION", "--" ); } } @@ -851,10 +851,10 @@ void item_pocket::general_info( std::vector &info, int pocket_number, if( data->max_item_length != 0_mm ) { info.back().bNewLine = true; - info.push_back( iteminfo( "BASE", _( "Maximum item length: " ), - string_format( " %s", length_units( data->max_item_length ) ), - iteminfo::no_flags, - convert_length( data->max_item_length ) ) ); + info.emplace_back( "BASE", _( "Maximum item length: " ), + string_format( " %s", length_units( data->max_item_length ) ), + iteminfo::no_flags, + convert_length( data->max_item_length ) ); } if( data->min_item_volume > 0_ml ) { @@ -1677,19 +1677,19 @@ std::string enumerate( cata::flat_set container ) void item_pocket::favorite_settings::info( std::vector &info ) const { - info.push_back( iteminfo( "BASE", string_format( "%s %d", _( "Priority:" ), priority_rating ) ) ); - info.push_back( iteminfo( "BASE", string_format( _( "Item Whitelist: %s" ), - item_whitelist.empty() ? _( "(empty)" ) : + info.emplace_back( "BASE", string_format( "%s %d", _( "Priority:" ), priority_rating ) ); + info.emplace_back( "BASE", string_format( _( "Item Whitelist: %s" ), + item_whitelist.empty() ? _( "(empty)" ) : enumerate_as_string( item_whitelist.begin(), item_whitelist.end(), []( const itype_id & id ) { return id->nname( 1 ); - } ) ) ) ); - info.push_back( iteminfo( "BASE", string_format( _( "Item Blacklist: %s" ), - item_blacklist.empty() ? _( "(empty)" ) : + } ) ) ); + info.emplace_back( "BASE", string_format( _( "Item Blacklist: %s" ), + item_blacklist.empty() ? _( "(empty)" ) : enumerate_as_string( item_blacklist.begin(), item_blacklist.end(), []( const itype_id & id ) { return id->nname( 1 ); - } ) ) ) ); - info.push_back( iteminfo( "BASE", string_format( _( "Category Whitelist: %s" ), - category_whitelist.empty() ? _( "(empty)" ) : enumerate( category_whitelist ) ) ) ); - info.push_back( iteminfo( "BASE", string_format( _( "Category Blacklist: %s" ), - category_blacklist.empty() ? _( "(empty)" ) : enumerate( category_blacklist ) ) ) ); + } ) ) ); + info.emplace_back( "BASE", string_format( _( "Category Whitelist: %s" ), + category_whitelist.empty() ? _( "(empty)" ) : enumerate( category_whitelist ) ) ); + info.emplace_back( "BASE", string_format( _( "Category Blacklist: %s" ), + category_blacklist.empty() ? _( "(empty)" ) : enumerate( category_blacklist ) ) ); } diff --git a/src/iuse.cpp b/src/iuse.cpp index 7162bdd046581..7bd216aace0ba 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -1856,7 +1856,7 @@ cata::optional 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( 5_hours ), 0, 0, it->tname() ); - p->activity.targets.push_back( item_location( *p, it ) ); + p->activity.targets.emplace_back( *p, it ); p->activity.coord_set = g->get_fishable_locations( 60, *found ); return 0; } @@ -2128,7 +2128,7 @@ cata::optional iuse::pack_cbm( player *p, item *it, bool, const tripoint & } std::vector 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; @@ -3378,7 +3378,7 @@ cata::optional iuse::jackhammer( player *p, item *it, bool, const tripoint } p->assign_activity( ACT_JACKHAMMER, moves ); - p->activity.targets.push_back( item_location( *p, it ) ); + p->activity.targets.emplace_back( *p, it ); p->activity.placement = here.getabs( pnt ); // You can mine either furniture or terrain, and furniture goes first, @@ -3490,7 +3490,7 @@ cata::optional iuse::pickaxe( player *p, item *it, bool, const tripoint &po } p->assign_activity( ACT_PICKAXE, moves, -1 ); - p->activity.targets.push_back( item_location( *p, it ) ); + p->activity.targets.emplace_back( *p, it ); p->activity.placement = here.getabs( pnt ); // You can mine either furniture or terrain, and furniture goes first, @@ -4497,11 +4497,11 @@ cata::optional iuse::portable_game( player *p, item *it, bool active, const if( loaded_software == "null" ) { p->assign_activity( ACT_GENERIC_GAME, to_moves( 1_hours ), -1, p->get_item_position( it ), "gaming" ); - p->activity.targets.push_back( item_location( *p, it ) ); + p->activity.targets.emplace_back( *p, it ); return 0; } p->assign_activity( ACT_GAME, moves, -1, 0, "gaming" ); - p->activity.targets.push_back( item_location( *p, it ) ); + p->activity.targets.emplace_back( *p, it ); std::map game_data; game_data.clear(); int game_score = 0; @@ -4588,7 +4588,7 @@ cata::optional 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( item_location( *p, it ) ); + p->activity.targets.emplace_back( *p, 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() ); @@ -4634,7 +4634,7 @@ cata::optional 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( item_location( *p, it ) ); + p->activity.targets.emplace_back( *p, it ); } return it->type->charges_to_use(); } @@ -4811,7 +4811,7 @@ cata::optional iuse::mind_splicer( player *p, item *it, bool, const tripoin skill_firstaid ) - 1 ) - 10_minutes * ( p->get_dex() - 8 ), 30_minutes ); player_activity act( ACT_MIND_SPLICER, to_moves( time ) ); - act.targets.push_back( item_location( *p, &data_card ) ); + act.targets.emplace_back( *p, &data_card ); p->assign_activity( act ); return it->type->charges_to_use(); } @@ -5086,7 +5086,7 @@ cata::optional 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( ter ) ); - p->activity.targets.push_back( item_location( *p, it ) ); + p->activity.targets.emplace_back( *p, it ); p->activity.placement = pnt; p->activity.values.push_back( charges ); @@ -5402,7 +5402,7 @@ static bool heat_item( player &p ) } p.add_msg_if_player( m_info, _( "You start heating up the food." ) ); p.assign_activity( ACT_HEATING, duration ); - p.activity.targets.push_back( item_location( p, target ) ); + p.activity.targets.emplace_back( p, target ); return true; } @@ -6520,7 +6520,7 @@ cata::optional iuse::einktabletpc( player *p, item *it, bool t, const tripo 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(); @@ -7656,7 +7656,7 @@ cata::optional 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; @@ -9615,7 +9615,7 @@ cata::optional iuse::break_stick( player *p, item *it, bool, const tripoint return 0; } std::vector comps; - comps.push_back( item_comp( it->typeId(), 1 ) ); + comps.emplace_back( it->typeId(), 1 ); p->consume_items( comps, 1, is_crafting_component ); int chance = rng( 0, 100 ); map &here = get_map(); diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index eff27743159a1..01fba89c81ce6 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -1116,7 +1116,7 @@ void reveal_map_actor::load( const JsonObject &obj ) ter_match_type = jo.get_enum_value( "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 ); } } @@ -1319,7 +1319,7 @@ cata::optional firestarter_actor::use( player &p, item &it, bool t, 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( item_location( p, &it ) ); + p.activity.targets.emplace_back( p, &it ); p.activity.values.push_back( g->natural_light_level( pos.z ) ); p.activity.placement = pos; // charges to use are handled by the activity @@ -3176,8 +3176,8 @@ cata::optional heal_actor::use( player &p, item &it, bool, const tripoint & // 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( item_location( p, &it ) ); - p.activity.str_values.push_back( hpp.c_str() ); + p.activity.targets.emplace_back( p, &it ); + p.activity.str_values.emplace_back( hpp.c_str() ); p.moves = 0; return 0; } @@ -4244,7 +4244,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 @@ -4428,7 +4428,7 @@ cata::optional sew_advanced_actor::use( player &p, item &it, bool, const tr const auto &repair_item = clothing_mods[choice].obj().item_string; std::vector comps; - comps.push_back( item_comp( repair_item, items_needed ) ); + comps.emplace_back( repair_item, items_needed ); p.moves -= to_moves( 30_seconds * p.fine_detail_vision_mod() ); p.practice( used_skill, items_needed * 3 + 3 ); /** @EFFECT_TAILOR randomly improves clothing modification efforts */ diff --git a/src/iuse_software_lightson.cpp b/src/iuse_software_lightson.cpp index c2d31d366fe64..5da853e453317 100644 --- a/src/iuse_software_lightson.cpp +++ b/src/iuse_software_lightson.cpp @@ -154,9 +154,9 @@ int lightson_game::start_game() ui.on_redraw( [&]( const ui_adaptor & ) { std::vector shortcuts; - shortcuts.push_back( _( " toggle lights" ) ); - shortcuts.push_back( _( "eset" ) ); - shortcuts.push_back( _( "uit" ) ); + shortcuts.emplace_back( _( " toggle lights" ) ); + shortcuts.emplace_back( _( "eset" ) ); + shortcuts.emplace_back( _( "uit" ) ); int iWidth = 0; for( auto &shortcut : shortcuts ) { diff --git a/src/iuse_software_minesweeper.cpp b/src/iuse_software_minesweeper.cpp index 3b48b64ed08c1..ef59e867203c3 100644 --- a/src/iuse_software_minesweeper.cpp +++ b/src/iuse_software_minesweeper.cpp @@ -183,9 +183,9 @@ int minesweeper_game::start_game() draw_border( w_minesweeper_border ); std::vector shortcuts; - shortcuts.push_back( _( "ew level" ) ); - shortcuts.push_back( _( "lag" ) ); - shortcuts.push_back( _( "uit" ) ); + shortcuts.emplace_back( _( "ew level" ) ); + shortcuts.emplace_back( _( "lag" ) ); + shortcuts.emplace_back( _( "uit" ) ); int iWidth = 0; for( auto &shortcut : shortcuts ) { diff --git a/src/iuse_software_snake.cpp b/src/iuse_software_snake.cpp index a5baba6558447..0ae65f9f414c2 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 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 d321c0b39baec..bd46d21555229 100644 --- a/src/iuse_software_sokoban.cpp +++ b/src/iuse_software_sokoban.cpp @@ -248,11 +248,11 @@ int sokoban_game::start_game() draw_border( w_sokoban, BORDER_COLOR, _( "Sokoban" ), hilite( c_white ) ); std::vector shortcuts; - shortcuts.push_back( _( "<+> next" ) ); // '+': next - shortcuts.push_back( _( "<-> prev" ) ); // '-': prev - shortcuts.push_back( _( "eset" ) ); // 'r': reset - shortcuts.push_back( _( "uit" ) ); // 'q': quit - shortcuts.push_back( _( "ndo move" ) ); // 'u': undo move + shortcuts.emplace_back( _( "<+> next" ) ); // '+': next + shortcuts.emplace_back( _( "<-> prev" ) ); // '-': prev + shortcuts.emplace_back( _( "eset" ) ); // 'r': reset + shortcuts.emplace_back( _( "uit" ) ); // 'q': quit + shortcuts.emplace_back( _( "ndo move" ) ); // 'u': undo move int indent = 10; for( auto &shortcut : shortcuts ) { @@ -378,7 +378,7 @@ int sokoban_game::start_game() bMovePlayer = true; mLevel[iPlayerY + iDirY * 2][iPlayerX + iDirX * 2] = sMovePackTo == "." ? "*" : "$"; - vUndo.push_back( cUndo( point( iDirX, iDirY ), sMoveTo ) ); + vUndo.emplace_back( point( iDirX, iDirY ), sMoveTo ); iMoves--; } @@ -388,7 +388,7 @@ int sokoban_game::start_game() if( bMovePlayer ) { //move player - vUndo.push_back( cUndo( point( iPlayerX, iPlayerY ), mLevel[iPlayerY][iPlayerX] ) ); + vUndo.emplace_back( point( iPlayerX, iPlayerY ), mLevel[iPlayerY][iPlayerX] ); mLevel[iPlayerY][iPlayerX] = mLevel[iPlayerY][iPlayerX] == "+" ? "." : " "; mLevel[iPlayerY + iDirY][iPlayerX + iDirX] = sMoveTo == "." || sMoveTo == "*" ? "+" : "@"; diff --git a/src/lightmap.cpp b/src/lightmap.cpp index 9c0de7c0b5aff..e82fb2c985608 100644 --- a/src/lightmap.cpp +++ b/src/lightmap.cpp @@ -493,7 +493,7 @@ void map::generate_lightmap( const int zlev ) } const float light_override = cur->get_intensity_level().local_light_override; if( light_override >= 0.0f ) { - lm_override.push_back( std::pair( p, light_override ) ); + lm_override.emplace_back( p, light_override ); } } } diff --git a/src/line.cpp b/src/line.cpp index 98bf894853642..4c3959731b03f 100644 --- a/src/line.cpp +++ b/src/line.cpp @@ -548,16 +548,16 @@ std::vector squares_in_direction( const point &p1, const 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/main_menu.cpp b/src/main_menu.cpp index 79a464c2eb188..45ea33525edeb 100644 --- a/src/main_menu.cpp +++ b/src/main_menu.cpp @@ -351,15 +351,15 @@ void main_menu::init_strings() // fill menu with translated menu items vMenuItems.clear(); - vMenuItems.push_back( pgettext( "Main Menu", "OTD" ) ); - vMenuItems.push_back( pgettext( "Main Menu", "ew Game" ) ); - vMenuItems.push_back( pgettext( "Main Menu", "Lod" ) ); - vMenuItems.push_back( pgettext( "Main Menu", "orld" ) ); - vMenuItems.push_back( pgettext( "Main Menu", "pecial" ) ); - vMenuItems.push_back( pgettext( "Main Menu", "Setings" ) ); - vMenuItems.push_back( pgettext( "Main Menu", "Hlp" ) ); - vMenuItems.push_back( pgettext( "Main Menu", "redits" ) ); - vMenuItems.push_back( pgettext( "Main Menu", "uit" ) ); + vMenuItems.emplace_back( pgettext( "Main Menu", "OTD" ) ); + vMenuItems.emplace_back( pgettext( "Main Menu", "ew Game" ) ); + vMenuItems.emplace_back( pgettext( "Main Menu", "Lod" ) ); + vMenuItems.emplace_back( pgettext( "Main Menu", "orld" ) ); + vMenuItems.emplace_back( pgettext( "Main Menu", "pecial" ) ); + vMenuItems.emplace_back( pgettext( "Main Menu", "Setings" ) ); + vMenuItems.emplace_back( pgettext( "Main Menu", "Hlp" ) ); + vMenuItems.emplace_back( pgettext( "Main Menu", "redits" ) ); + vMenuItems.emplace_back( pgettext( "Main Menu", "uit" ) ); // determine hotkeys from translated menu item text vMenuHotkeys.clear(); @@ -368,11 +368,11 @@ void main_menu::init_strings() } vWorldSubItems.clear(); - vWorldSubItems.push_back( pgettext( "Main Menu|World", "elete World" ) ); - vWorldSubItems.push_back( pgettext( "Main Menu|World", "eset World" ) ); - vWorldSubItems.push_back( pgettext( "Main Menu|World", "how World Mods" ) ); - vWorldSubItems.push_back( pgettext( "Main Menu|World", "opy World Settings" ) ); - vWorldSubItems.push_back( pgettext( "Main Menu|World", "Character to emplate" ) ); + vWorldSubItems.emplace_back( pgettext( "Main Menu|World", "elete World" ) ); + vWorldSubItems.emplace_back( pgettext( "Main Menu|World", "eset World" ) ); + vWorldSubItems.emplace_back( pgettext( "Main Menu|World", "how World Mods" ) ); + vWorldSubItems.emplace_back( pgettext( "Main Menu|World", "opy World Settings" ) ); + vWorldSubItems.emplace_back( pgettext( "Main Menu|World", "Character to emplate" ) ); vWorldHotkeys.clear(); for( const std::string &item : vWorldSubItems ) { @@ -380,11 +380,11 @@ void main_menu::init_strings() } vSettingsSubItems.clear(); - vSettingsSubItems.push_back( pgettext( "Main Menu|Settings", "ptions" ) ); - vSettingsSubItems.push_back( pgettext( "Main Menu|Settings", "Kybindings" ) ); - vSettingsSubItems.push_back( pgettext( "Main Menu|Settings", "utopickup" ) ); - vSettingsSubItems.push_back( pgettext( "Main Menu|Settings", "afemode" ) ); - vSettingsSubItems.push_back( pgettext( "Main Menu|Settings", "olors" ) ); + vSettingsSubItems.emplace_back( pgettext( "Main Menu|Settings", "ptions" ) ); + vSettingsSubItems.emplace_back( pgettext( "Main Menu|Settings", "Kybindings" ) ); + vSettingsSubItems.emplace_back( pgettext( "Main Menu|Settings", "utopickup" ) ); + vSettingsSubItems.emplace_back( pgettext( "Main Menu|Settings", "afemode" ) ); + vSettingsSubItems.emplace_back( pgettext( "Main Menu|Settings", "olors" ) ); vSettingsHotkeys.clear(); for( const std::string &item : vSettingsSubItems ) { @@ -747,23 +747,22 @@ bool main_menu::opening_screen() bool main_menu::new_character_tab() { std::vector vSubItems; - vSubItems.push_back( pgettext( "Main Menu|New Game", "ustom Character" ) ); - vSubItems.push_back( pgettext( "Main Menu|New Game", "reset Character" ) ); - vSubItems.push_back( pgettext( "Main Menu|New Game", "andom Character" ) ); + vSubItems.emplace_back( pgettext( "Main Menu|New Game", "ustom Character" ) ); + vSubItems.emplace_back( pgettext( "Main Menu|New Game", "reset Character" ) ); + vSubItems.emplace_back( pgettext( "Main Menu|New Game", "andom Character" ) ); if( !MAP_SHARING::isSharing() ) { // "Play Now" function doesn't play well together with shared maps - vSubItems.push_back( pgettext( "Main Menu|New Game", "Play Now! (ixed Scenario)" ) ); - vSubItems.push_back( pgettext( "Main Menu|New Game", "Play ow!" ) ); + vSubItems.emplace_back( pgettext( "Main Menu|New Game", "Play Now! (ixed Scenario)" ) ); + vSubItems.emplace_back( pgettext( "Main Menu|New Game", "Play ow!" ) ); } std::vector hints; - hints.push_back( + hints.emplace_back( _( "Allows you to fully customize points pool, scenario, and character's profession, stats, traits, skills and other parameters." ) ); - hints.push_back( - _( "Select from one of previously created character templates." ) ); - hints.push_back( + hints.emplace_back( _( "Select from one of previously created character templates." ) ); + hints.emplace_back( _( "Creates random character, but lets you preview the generated character and the scenario and change character and/or scenario if needed." ) ); - hints.push_back( + hints.emplace_back( _( "Puts you right in the game, randomly choosing character's traits, profession, skills and other parameters. Scenario is fixed to Evacuee." ) ); - hints.push_back( + hints.emplace_back( _( "Puts you right in the game, randomly choosing scenario and character's traits, profession, skills and other parameters." ) ); std::vector> vNewGameHotkeys; diff --git a/src/map.cpp b/src/map.cpp index dbc0a112b5fe1..1f40aaf68e2a9 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -3078,7 +3078,7 @@ void map::smash_items( const tripoint &p, const int power, const std::string &ca // But save the contents, except for irremovable gunmods for( item *elem : i->contents.all_items_top() ) { if( !elem->is_irremovable() ) { - contents.push_back( item( *elem ) ); + contents.emplace_back( *elem ); } } @@ -3491,7 +3491,7 @@ void map::bash_items( const tripoint &p, bash_params ¶ms ) params.did_bash = true; smashed_glass = true; for( const item *bashed_content : bashed_item->contents.all_items_top() ) { - smashed_contents.push_back( item( *bashed_content ) ); + smashed_contents.emplace_back( *bashed_content ); } bashed_item = bashed_items.erase( bashed_item ); } else { @@ -5149,7 +5149,7 @@ std::list > map::get_rc_items( const tripoint &p ) map_stack items = i_at( pos ); for( auto &elem : items ) { if( elem.has_flag( flag_RADIO_ACTIVATION ) || elem.has_flag( flag_RADIO_CONTAINER ) ) { - rc_pairs.push_back( std::make_pair( pos, &elem ) ); + rc_pairs.emplace_back( pos, &elem ); } } } diff --git a/src/map_field.cpp b/src/map_field.cpp index dfa2eacfc8623..59d7b0e00f42e 100644 --- a/src/map_field.cpp +++ b/src/map_field.cpp @@ -979,7 +979,7 @@ void field_processor_fd_fire( const tripoint &p, field_entry &cur, field_proc_da const std::list content_list = fuel->contents.all_items_top(); for( item *it : content_list ) { if( !it->is_irremovable() ) { - new_content.push_back( item( *it ) ); + new_content.emplace_back( *it ); } } fuel = items_here.erase( fuel ); @@ -1516,19 +1516,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. diff --git a/src/map_item_stack.cpp b/src/map_item_stack.cpp index 362ee16528200..4d18fb414bdd9 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 d6ebf48bb3446..763673c2bcca1 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -1328,7 +1328,7 @@ class jmapgen_monster : public jmapgen_piece for( const JsonObject p_pt : patrol_pts ) { jmapgen_int ptx = jmapgen_int( p_pt, "x" ); jmapgen_int pty = jmapgen_int( p_pt, "y" ); - data.patrol_points_rel_ms.push_back( point( ptx.get(), pty.get() ) ); + data.patrol_points_rel_ms.emplace_back( ptx.get(), pty.get() ); } } } @@ -3224,37 +3224,37 @@ void map::draw_lab( mapgendata &dat ) if( is_ot_match( "stairs", terrain_type, ot_match_type::contains ) ) { // Stairs going down std::vector 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( static_cast( SEEX / 2 ), SEEY ) ); - stair_points.push_back( point( static_cast( SEEX / 2 ), SEEY - 1 ) ); - stair_points.push_back( point( static_cast( SEEX / 2 ) + SEEX, SEEY ) ); - stair_points.push_back( point( static_cast( SEEX / 2 ) + SEEX, SEEY - 1 ) ); - stair_points.push_back( point( SEEX, static_cast( SEEY / 2 ) ) ); - stair_points.push_back( point( SEEX + 2, static_cast( SEEY / 2 ) ) ); - stair_points.push_back( point( SEEX, static_cast( SEEY / 2 ) + SEEY ) ); - stair_points.push_back( point( SEEX + 2, static_cast( SEEY / 2 ) + SEEY ) ); + stair_points.emplace_back( static_cast( SEEX / 2 ), SEEY ); + stair_points.emplace_back( static_cast( SEEX / 2 ), SEEY - 1 ); + stair_points.emplace_back( static_cast( SEEX / 2 ) + SEEX, SEEY ); + stair_points.emplace_back( static_cast( SEEX / 2 ) + SEEX, SEEY - 1 ); + stair_points.emplace_back( SEEX, static_cast( SEEY / 2 ) ); + stair_points.emplace_back( SEEX + 2, static_cast( SEEY / 2 ) ); + stair_points.emplace_back( SEEX, static_cast( SEEY / 2 ) + SEEY ); + stair_points.emplace_back( SEEX + 2, static_cast( SEEY / 2 ) + SEEY ); const point p = random_entry( stair_points ); ter_set( p, t_stairs_down ); } @@ -4098,7 +4098,7 @@ void map::draw_temple( const mapgendata &dat ) static const std::vector 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 ) { @@ -4111,7 +4111,7 @@ void map::draw_temple( const 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/mattack_actors.cpp b/src/mattack_actors.cpp index 77069b8f8e3e4..a54ebc7400933 100644 --- a/src/mattack_actors.cpp +++ b/src/mattack_actors.cpp @@ -548,7 +548,7 @@ void gun_actor::shoot( monster &z, Creature &target, const gun_mode_id &mode ) c standard_npc tmp( _( "The " ) + z.name(), z.pos(), {}, 8, fake_str, fake_dex, fake_int, fake_per ); - tmp.worn.push_back( item( "backpack" ) ); + tmp.worn.emplace_back( "backpack" ); tmp.set_fake( true ); tmp.set_attitude( z.friendly ? NPCATT_FOLLOW : NPCATT_KILL ); tmp.recoil = 0; // no need to aim diff --git a/src/memorial_logger.cpp b/src/memorial_logger.cpp index c5982bb223d8f..2475bb41d5c07 100644 --- a/src/memorial_logger.cpp +++ b/src/memorial_logger.cpp @@ -130,7 +130,7 @@ void memorial_logger::add( const std::string &male_msg, const oter_type_str_id cur_oter_type = cur_ter->get_type_id(); const std::string &oter_name = cur_ter->get_name(); - log.push_back( { calendar::turn, cur_oter_type, oter_name, msg } ); + log.emplace_back( calendar::turn, cur_oter_type, oter_name, msg ); } /** diff --git a/src/mission.cpp b/src/mission.cpp index 64848fb2f96ed..5df75c4ecfa90 100644 --- a/src/mission.cpp +++ b/src/mission.cpp @@ -358,7 +358,7 @@ void mission::wrap_up() container, itype_id( "null" ), specific_container_required ); for( std::pair &cnt : matches ) { - comps.push_back( item_comp( cnt.first, cnt.second ) ); + comps.emplace_back( cnt.first, cnt.second ); } @@ -367,10 +367,10 @@ void mission::wrap_up() if( remove_container ) { std::vector container_comp = std::vector(); 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 ); player_character.consume_items( container_comp ); } else { - container_comp.push_back( item_comp( container, type->item_count ) ); + container_comp.emplace_back( container, type->item_count ); player_character.consume_items( container_comp ); } } @@ -390,7 +390,7 @@ void mission::wrap_up() } } } else { - comps.push_back( item_comp( type->item_id, item_count ) ); + comps.emplace_back( type->item_id, item_count ); player_character.consume_items( comps ); } } diff --git a/src/mod_manager.cpp b/src/mod_manager.cpp index bfc3361287005..12fd9c587479b 100644 --- a/src/mod_manager.cpp +++ b/src/mod_manager.cpp @@ -290,7 +290,7 @@ bool mod_manager::copy_mod_contents( const t_mod_list &mods_to_copy, return true; } std::vector search_extensions; - search_extensions.push_back( ".json" ); + search_extensions.emplace_back( ".json" ); DebugLog( D_INFO, DC_ALL ) << "Copying mod contents into directory: " << output_base_path; diff --git a/src/monattack.cpp b/src/monattack.cpp index 1bbe02df5254a..a3dea16795534 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -985,7 +985,7 @@ bool mattack::resurrect( monster *z ) int raise_score = ( i.damage_level() + 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/monexamine.cpp b/src/monexamine.cpp index 3d23556174d14..29aa3a909ef21 100644 --- a/src/monexamine.cpp +++ b/src/monexamine.cpp @@ -302,10 +302,10 @@ 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, true ); - player_character.activity.str_values.push_back( "temp_tie" ); + player_character.activity.str_values.emplace_back( "temp_tie" ); } - player_character.activity.targets.push_back( item_location( player_character, - player_character.best_quality_item( qual_SHEAR ) ) ); + player_character.activity.targets.emplace_back( player_character, + player_character.best_quality_item( qual_SHEAR ) ); add_msg( _( "You start shearing the %s." ), z.get_name() ); } @@ -805,7 +805,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, true ); - str_values.push_back( "temp_tie" ); + str_values.emplace_back( "temp_tie" ); } player_character.assign_activity( player_activity( milk_activity_actor( moves, coords, str_values ) ) ); diff --git a/src/mongroup.cpp b/src/mongroup.cpp index 599a33a4650d6..7c4ffcdaf57e7 100644 --- a/src/mongroup.cpp +++ b/src/mongroup.cpp @@ -128,13 +128,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 21644a2101bb8..1687bc7cb05b3 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -1401,7 +1401,7 @@ static std::vector get_bashing_zone( const tripoint &bashee, const tri for( const tripoint &p : path ) { std::vector swath = squares_in_direction( previous.xy(), p.xy() ); for( const point &q : swath ) { - zone.push_back( tripoint( q, bashee.z ) ); + zone.emplace_back( q, bashee.z ); } previous = p; @@ -1928,9 +1928,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/newcharacter.cpp b/src/newcharacter.cpp index 5b96fdd1d3a19..7a04272a385c8 100644 --- a/src/newcharacter.cpp +++ b/src/newcharacter.cpp @@ -2862,10 +2862,10 @@ tab_direction set_description( avatar &you, const bool allow_reroll, std::vector 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/npcmove.cpp b/src/npcmove.cpp index a27cd05da9531..2f3aa940d2244 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -1267,7 +1267,7 @@ void npc::execute_action( npc_action action ) my_spot = priority; } - seats.push_back( std::make_pair( priority, static_cast( vp.part_index() ) ) ); + seats.emplace_back( priority, static_cast( vp.part_index() ) ); } if( my_spot >= 3 ) { @@ -1406,7 +1406,7 @@ npc_action npc::method_of_attack() std::vector> modes; if( rules.has_flag( ally_rule::use_guns ) || !is_player_ally() ) { for( const auto &e : weapon.gun_all_modes() ) { - modes.push_back( e ); + modes.emplace_back( e ); } modes.erase( std::remove_if( modes.begin(), modes.end(), @@ -3149,7 +3149,7 @@ void npc::drop_items( const units::mass &drop_weight, const units::volume &drop_ } } 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 ) { @@ -3158,7 +3158,7 @@ void npc::drop_items( const units::mass &drop_weight, const units::volume &drop_ } } 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 9c1807edd5e80..7a7b671266463 100644 --- a/src/npctalk.cpp +++ b/src/npctalk.cpp @@ -1343,7 +1343,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 ) @@ -1767,7 +1767,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( count, item_name ) ); + likely_rewards.emplace_back( count, item_name ); } } diff --git a/src/output.cpp b/src/output.cpp index e8c22e2f1ee70..4d9f402a0d509 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -2116,7 +2116,7 @@ void scrollingcombattext::add( const 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 ); } } @@ -2354,7 +2354,7 @@ std::vector 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/overmap.cpp b/src/overmap.cpp index 6a668e7a29d5b..1c0b0e9022879 100644 --- a/src/overmap.cpp +++ b/src/overmap.cpp @@ -1545,35 +1545,35 @@ 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 ); } else if( oter_above == "lab_core" || ( z == -1 && oter_above == "lab_stairs" ) ) { - lab_points.push_back( city( p.xy(), rng( 1, 5 + z ) ) ); + lab_points.emplace_back( p.xy(), rng( 1, 5 + z ) ); } else if( oter_above == "lab_stairs" ) { ter_set( p, oter_id( "lab" ) ); } else if( oter_above == "ice_lab_core" || ( z == -1 && oter_above == "ice_lab_stairs" ) ) { - ice_lab_points.push_back( city( p.xy(), rng( 1, 5 + z ) ) ); + ice_lab_points.emplace_back( p.xy(), rng( 1, 5 + z ) ); } else if( oter_above == "ice_lab_stairs" ) { ter_set( p, oter_id( "ice_lab" ) ); } else if( oter_above == "central_lab_core" ) { - central_lab_points.push_back( city( p.xy(), rng( std::max( 1, 7 + z ), 9 + z ) ) ); + central_lab_points.emplace_back( p.xy(), rng( std::max( 1, 7 + z ), 9 + z ) ); } else if( oter_above == "central_lab_stairs" ) { ter_set( p, oter_id( "central_lab" ) ); } else if( is_ot_match( "hidden_lab_stairs", oter_above, ot_match_type::contains ) ) { - lab_points.push_back( city( p.xy(), rng( 1, 5 + z ) ) ); + lab_points.emplace_back( p.xy(), rng( 1, 5 + z ) ); } 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; @@ -2604,10 +2604,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 ) ); } @@ -2616,10 +2616,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 ) ); } @@ -2650,8 +2650,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] ); @@ -4421,21 +4421,21 @@ 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 ); } } } diff --git a/src/overmap_ui.cpp b/src/overmap_ui.cpp index 7f294b6c5102d..7af7a90245283 100644 --- a/src/overmap_ui.cpp +++ b/src/overmap_ui.cpp @@ -654,7 +654,7 @@ void draw( npc *npc_to_add = elem.get(); if( npc_to_add->mission == NPC_MISSION_TRAVELLING && !npc_to_add->omt_path.empty() ) { for( auto &elem : npc_to_add->omt_path ) { - path_route.push_back( tripoint_abs_omt( elem.xy(), npc_to_add->posz() ) ); + path_route.emplace_back( elem.xy(), npc_to_add->posz() ); } } } diff --git a/src/panels.cpp b/src/panels.cpp index 9132293f7551d..4425efc018454 100644 --- a/src/panels.cpp +++ b/src/panels.cpp @@ -1112,20 +1112,20 @@ static void draw_stealth( avatar &u, const catacurses::window &w ) static void draw_time_graphic( const catacurses::window &w ) { std::vector > 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( calendar::turn ); wprintz( w, c_white, "[" ); diff --git a/src/past_games_info.cpp b/src/past_games_info.cpp index d34c2bd08a09a..fa35621131500 100644 --- a/src/past_games_info.cpp +++ b/src/past_games_info.cpp @@ -116,7 +116,7 @@ void past_games_info::ensure_loaded() std::istringstream iss( read_entire_file( filename ) ); try { JsonIn jsin( iss ); - info_.push_back( past_game_info( jsin ) ); + info_.emplace_back( jsin ); } catch( const JsonError &err ) { debugmsg( "Error reading memorial file %s: %s", filename, err.what() ); } catch( const too_old_memorial_file_error & ) { diff --git a/src/pixel_minimap.cpp b/src/pixel_minimap.cpp index 1bd963238bff2..e9acb49a43de2 100644 --- a/src/pixel_minimap.cpp +++ b/src/pixel_minimap.cpp @@ -334,7 +334,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.cpp b/src/player.cpp index a78429aad4264..5704cb9e133fa 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -2238,8 +2238,8 @@ void player::gunmod_add( item &gun, item &mod ) const int moves = !has_trait( trait_DEBUG_HS ) ? mod.type->gunmod->install_time : 0; assign_activity( activity_id( "ACT_GUNMOD_ADD" ), moves, -1, 0, tool ); - activity.targets.push_back( item_location( *this, &gun ) ); - activity.targets.push_back( item_location( *this, &mod ) ); + activity.targets.emplace_back( *this, &gun ); + activity.targets.emplace_back( *this, &mod ); activity.values.push_back( 0 ); // dummy value activity.values.push_back( roll ); // chance of success (%) activity.values.push_back( risk ); // chance of damage (%) diff --git a/src/player_activity.cpp b/src/player_activity.cpp index f0417d4e5250f..e7e4a877c8b76 100644 --- a/src/player_activity.cpp +++ b/src/player_activity.cpp @@ -64,11 +64,11 @@ void player_activity::migrate_item_position( Character &guy ) type == ACT_ATM; if( simple_action_replace ) { - targets.push_back( item_location( guy, &guy.i_at( position ) ) ); + targets.emplace_back( guy, &guy.i_at( position ) ); } else if( type == ACT_GUNMOD_ADD ) { // this activity has two indices; "position" = gun and "values[0]" = mod - targets.push_back( item_location( guy, &guy.i_at( position ) ) ); - targets.push_back( item_location( guy, &guy.i_at( values[0] ) ) ); + targets.emplace_back( guy, &guy.i_at( position ) ); + targets.emplace_back( guy, &guy.i_at( values[0] ) ); } } diff --git a/src/player_display.cpp b/src/player_display.cpp index 835f085759dd7..cc403e8e0c21b 100644 --- a/src/player_display.cpp +++ b/src/player_display.cpp @@ -1192,7 +1192,7 @@ void player::disp_info() if( 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( get_perceived_pain() > 0 ) { @@ -1208,7 +1208,7 @@ void player::disp_info() 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 = get_bmi(); @@ -1237,30 +1237,30 @@ void player::disp_info() 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( has_trait( trait_id( "TROGLO" ) ) && g->is_in_sunlight( 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( has_trait( trait_id( "TROGLO2" ) ) && g->is_in_sunlight( 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( has_trait( trait_id( "TROGLO3" ) ) && g->is_in_sunlight( 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 : 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/profession.cpp b/src/profession.cpp index 7349369fa0551..92f84f13f2139 100644 --- a/src/profession.cpp +++ b/src/profession.cpp @@ -608,7 +608,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( jo.get_string( "trait" ) ) ); + s.trait_reqs.present.emplace_back( jo.get_string( "trait" ) ); for( const JsonValue info : sub.get_array( "new" ) ) { s.infos.emplace_back( info ); } diff --git a/src/proficiency.cpp b/src/proficiency.cpp index 263c19121bc6b..88009471a21fa 100644 --- a/src/proficiency.cpp +++ b/src/proficiency.cpp @@ -120,11 +120,11 @@ std::vector proficiency_set::display() const std::vector> sorted_learning; for( const proficiency_id &cur : known ) { - sorted_known.push_back( { cur->name(), cur } ); + sorted_known.emplace_back( cur->name(), cur ); } for( const learning_proficiency &cur : learning ) { - sorted_learning.push_back( { cur.id->name(), cur.id } ); + sorted_learning.emplace_back( cur.id->name(), cur.id ); } std::sort( sorted_known.begin(), sorted_known.end(), localized_compare ); @@ -170,7 +170,7 @@ bool proficiency_set::practice( const proficiency_id &practicing, const time_dur return false; } if( !has_practiced( practicing ) ) { - learning.push_back( learning_proficiency( practicing, 0_seconds ) ); + learning.emplace_back( practicing, 0_seconds ); } learning_proficiency ¤t = fetch_learning( practicing ); diff --git a/src/ranged.cpp b/src/ranged.cpp index a3d9eaae8a7ba..7966a97f9e30f 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -2670,7 +2670,7 @@ std::vector> target_ui::list_friendlies_in_lof() ( cr->is_npc() && a != Creature::Attitude::HOSTILE ) || ( !cr->is_npc() && a == Creature::Attitude::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 25424b2e92624..e73a45c07a6c9 100644 --- a/src/recipe.cpp +++ b/src/recipe.cpp @@ -805,7 +805,7 @@ std::string recipe::primary_skill_string( const Character *c, bool print_skill_l std::vector< std::pair > skillList; if( !skill_used.is_null() ) { - skillList.push_back( std::pair( 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 24b9b5620b22d..1b51dc0b2f6fc 100644 --- a/src/safemode_ui.cpp +++ b/src/safemode_ui.cpp @@ -303,16 +303,16 @@ 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::Attitude::HOSTILE, - get_option( "SAFEMODEPROXIMITY" ) - , Categories::HOSTILE_SPOTTED ) ); - current_tab.push_back( rules_class( "*", true, true, Creature::Attitude::HOSTILE, 5, - Categories::SOUND ) ); + current_tab.emplace_back( "*", true, false, Creature::Attitude::HOSTILE, + get_option( "SAFEMODEPROXIMITY" ) + , Categories::HOSTILE_SPOTTED ); + current_tab.emplace_back( "*", true, true, Creature::Attitude::HOSTILE, 5, + Categories::SOUND ); line = current_tab.size() - 1; } else if( action == "ADD_RULE" ) { changes_made = true; - current_tab.push_back( rules_class( "", true, false, Creature::Attitude::HOSTILE, - get_option( "SAFEMODEPROXIMITY" ), Categories::HOSTILE_SPOTTED ) ); + current_tab.emplace_back( "", true, false, Creature::Attitude::HOSTILE, + get_option( "SAFEMODEPROXIMITY" ), Categories::HOSTILE_SPOTTED ); line = current_tab.size() - 1; } else if( action == "REMOVE_RULE" && !current_tab.empty() ) { changes_made = true; @@ -640,8 +640,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_state::WHITELISTED ), - attitude_in, proximity_in, Categories::HOSTILE_SPOTTED ) ); + character_rules.emplace_back( rule_in, true, ( state_in == rule_state::WHITELISTED ), + attitude_in, proximity_in, Categories::HOSTILE_SPOTTED ); create_rules(); if( !get_option( "SAFEMODE" ) && @@ -891,8 +891,7 @@ void safemode::deserialize( JsonIn &jsin ) const Categories cat = jo.has_member( "category" ) ? static_cast ( jo.get_int( "category" ) ) : Categories::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/talker_avatar.cpp b/src/talker_avatar.cpp index e43ca0e9c7e3c..75d303e70627f 100644 --- a/src/talker_avatar.cpp +++ b/src/talker_avatar.cpp @@ -31,7 +31,7 @@ std::vector talker_avatar::get_topics( bool ) std::vector add_topics; if( has_trait( trait_PROF_FOODP ) && !( is_wearing( itype_id( "foodperson_mask" ) ) || is_wearing( itype_id( "foodperson_mask_on" ) ) ) ) { - add_topics.push_back( "TALK_NOFACE" ); + add_topics.emplace_back( "TALK_NOFACE" ); } return add_topics; } diff --git a/src/talker_npc.cpp b/src/talker_npc.cpp index 0e065a909b4c2..ac51ee3df2fcd 100644 --- a/src/talker_npc.cpp +++ b/src/talker_npc.cpp @@ -108,19 +108,19 @@ std::vector talker_npc::get_topics( bool radio_contact ) add_topics.push_back( me_npc->chatbin.first_topic ); if( radio_contact ) { - add_topics.push_back( "TALK_RADIO" ); + add_topics.emplace_back( "TALK_RADIO" ); } else if( me_npc->is_leader() ) { - add_topics.push_back( "TALK_LEADER" ); + add_topics.emplace_back( "TALK_LEADER" ); } else if( me_npc->is_player_ally() && ( me_npc->is_walking_with() || me_npc->has_activity() ) ) { - add_topics.push_back( "TALK_FRIEND" ); + add_topics.emplace_back( "TALK_FRIEND" ); } else if( me_npc->get_attitude() == NPCATT_RECOVER_GOODS ) { - add_topics.push_back( "TALK_STOLE_ITEM" ); + add_topics.emplace_back( "TALK_STOLE_ITEM" ); } int most_difficult_mission = 0; for( auto &mission : me_npc->chatbin.missions ) { const auto &type = mission->get_type(); if( type.urgent && type.difficulty > most_difficult_mission ) { - add_topics.push_back( "TALK_MISSION_DESCRIBE_URGENT" ); + add_topics.emplace_back( "TALK_MISSION_DESCRIBE_URGENT" ); me_npc->chatbin.mission_selected = mission; most_difficult_mission = type.difficulty; } @@ -136,7 +136,7 @@ std::vector talker_npc::get_topics( bool radio_contact ) if( ( type.urgent && !chosen_urgent ) || ( type.difficulty > most_difficult_mission && ( type.urgent || !chosen_urgent ) ) ) { chosen_urgent = type.urgent; - add_topics.push_back( "TALK_MISSION_INQUIRE" ); + add_topics.emplace_back( "TALK_MISSION_INQUIRE" ); me_npc->chatbin.mission_selected = mission; most_difficult_mission = type.difficulty; } @@ -144,13 +144,13 @@ std::vector talker_npc::get_topics( bool radio_contact ) // Needs if( me_npc->has_effect( effect_npc_suspend ) ) { - add_topics.push_back( "TALK_REBOOT" ); + add_topics.emplace_back( "TALK_REBOOT" ); } if( me_npc->has_effect( effect_sleep ) || me_npc->has_effect( effect_lying_down ) ) { if( me_npc->has_effect( effect_narcosis ) ) { - add_topics.push_back( "TALK_SEDATED" ); + add_topics.emplace_back( "TALK_SEDATED" ); } else { - add_topics.push_back( "TALK_WAKE_UP" ); + add_topics.emplace_back( "TALK_WAKE_UP" ); } } @@ -163,25 +163,25 @@ std::vector talker_npc::get_topics( bool radio_contact ) if( add_topics.back() == "TALK_MUG" || add_topics.back() == "TALK_STRANGER_AGGRESSIVE" ) { me_npc->make_angry(); - add_topics.push_back( "TALK_DEAF_ANGRY" ); + add_topics.emplace_back( "TALK_DEAF_ANGRY" ); } else { - add_topics.push_back( "TALK_DEAF" ); + add_topics.emplace_back( "TALK_DEAF" ); } } if( player_character.is_mute() ) { if( add_topics.back() == "TALK_MUG" || add_topics.back() == "TALK_STRANGER_AGGRESSIVE" ) { me_npc->make_angry(); - add_topics.push_back( "TALK_MUTE_ANGRY" ); + add_topics.emplace_back( "TALK_MUTE_ANGRY" ); } else { - add_topics.push_back( "TALK_MUTE" ); + add_topics.emplace_back( "TALK_MUTE" ); } } if( me_npc->has_trait( trait_PROF_FOODP ) && !( me_npc->is_wearing( itype_id( "foodperson_mask_on" ) ) || me_npc->is_wearing( itype_id( "foodperson_mask" ) ) ) ) { - add_topics.push_back( "TALK_NPC_NOFACE" ); + add_topics.emplace_back( "TALK_NPC_NOFACE" ); } me_npc->decide_needs(); diff --git a/src/translations.cpp b/src/translations.cpp index fa0ee479b2c93..645e1fc59ae43 100644 --- a/src/translations.cpp +++ b/src/translations.cpp @@ -434,7 +434,7 @@ std::string gettext_gendered( const GenderMap &genders, const std::string &msg ) sanity_check_genders( language_genders ); if( language_genders.empty() ) { - language_genders.push_back( "n" ); + language_genders.emplace_back( "n" ); } std::vector chosen_genders; diff --git a/src/veh_interact.cpp b/src/veh_interact.cpp index 97fd98fa40858..8c207deaf0172 100644 --- a/src/veh_interact.cpp +++ b/src/veh_interact.cpp @@ -912,15 +912,15 @@ void veh_interact::do_install() for( const vpart_category &cat : vpart_category::all() ) { tab_list.push_back( cat ); if( cat.get_id() == "_all" ) { - tab_filters.push_back( []( const vpart_info * ) { + tab_filters.emplace_back( []( const vpart_info * ) { return true; } ); } else if( cat.get_id() == "_filter" ) { - tab_filters.push_back( [&filter]( const vpart_info * p ) { + tab_filters.emplace_back( [&filter]( const vpart_info * p ) { return lcmatch( p->name(), filter ); } ); } else { - tab_filters.push_back( [ &, cat = cat.get_id()]( const vpart_info * p ) { + tab_filters.emplace_back( [ &, cat = cat.get_id()]( const vpart_info * p ) { return p->has_category( cat ); } ); } diff --git a/src/veh_type.cpp b/src/veh_type.cpp index 630749df0cdd8..5398ae4fb1e69 100644 --- a/src/veh_type.cpp +++ b/src/veh_type.cpp @@ -267,7 +267,7 @@ void vpart_info::load_engine( cata::optional &eptr, const JsonObj 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 ); @@ -1173,17 +1173,16 @@ void vehicle_prototype::load( const JsonObject &jo ) const std::string variant = spawn_info.get_string( "variant" ); next_spawn.variant_ids.emplace_back( itype_id( spawn_info.get_string( "items" ) ), variant ); } else { - 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_use.cpp b/src/vehicle_use.cpp index ad7a282830213..9dbe7ce27cfeb 100644 --- a/src/vehicle_use.cpp +++ b/src/vehicle_use.cpp @@ -136,7 +136,7 @@ void vehicle::add_toggle_to_opts( std::vector &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(); @@ -324,14 +324,14 @@ void vehicle::set_electronics_menu_options( std::vector &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; @@ -626,7 +626,7 @@ void vehicle::use_controls( const tripoint &pos ) if( remote ) { options.emplace_back( _( "Stop controlling" ), keybind( "RELEASE_CONTROLS" ) ); - actions.push_back( [&] { + actions.emplace_back( [&] { player_character.controlling_vehicle = false; g->setremoteveh( nullptr ); add_msg( _( "You stop controlling the vehicle." ) ); @@ -638,7 +638,7 @@ void vehicle::use_controls( const tripoint &pos ) } else if( veh_pointer_or_null( get_map().veh_at( pos ) ) == this ) { if( player_character.controlling_vehicle ) { options.emplace_back( _( "Let go of controls" ), keybind( "RELEASE_CONTROLS" ) ); - actions.push_back( [&] { + actions.emplace_back( [&] { player_character.controlling_vehicle = false; add_msg( _( "You let go of the controls." ) ); refresh(); @@ -661,7 +661,7 @@ void vehicle::use_controls( const tripoint &pos ) if( has_part( "ENGINE" ) ) { if( player_character.controlling_vehicle || ( remote && engine_on ) ) { options.emplace_back( _( "Stop driving" ), keybind( "TOGGLE_ENGINE" ) ); - actions.push_back( [&] { + actions.emplace_back( [&] { if( engine_on && has_engine_type_not( fuel_type_muscle, true ) ) { add_msg( _( "You turn the engine off and let go of the controls." ) ); @@ -704,7 +704,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; @@ -722,13 +722,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" ), @@ -742,28 +742,28 @@ 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( has_part( "SMART_ENGINE_CONTROLLER" ) ) { options.emplace_back( _( "Smart controller settings" ), keybind( "TOGGLE_SMART_ENGINE_CONTROLLER" ) ); - actions.push_back( [&] { + actions.emplace_back( [&] { if( !smart_controller_cfg ) { smart_controller_cfg = smart_controller_config(); @@ -783,11 +783,11 @@ void vehicle::use_controls( const tripoint &pos ) 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(); @@ -797,21 +797,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; @@ -1732,7 +1732,7 @@ void vehicle::use_washing_machine( int p ) } std::vector detergent; - detergent.push_back( item_comp( det_types[chosen_detergent], 5 ) ); + detergent.emplace_back( det_types[chosen_detergent], 5 ); player_character.consume_items( detergent, 1, is_crafting_component ); add_msg( m_good, @@ -1789,7 +1789,7 @@ void vehicle::use_dishwasher( int p ) } std::vector detergent; - detergent.push_back( item_comp( itype_detergent, 5 ) ); + detergent.emplace_back( itype_detergent, 5 ); player_character.consume_items( detergent, 1, is_crafting_component ); add_msg( m_good, diff --git a/src/wish.cpp b/src/wish.cpp index cc288a1922e9a..a6be648885d9d 100644 --- a/src/wish.cpp +++ b/src/wish.cpp @@ -845,7 +845,7 @@ void debug_menu::wishproficiency( player *p ) know_all = player_know; } - sorted_profs.push_back( { cur.prof_id(), player_know } ); + sorted_profs.emplace_back( cur.prof_id(), player_know ); } std::sort( sorted_profs.begin(), sorted_profs.end(), localized_compare ); diff --git a/src/worldfactory.cpp b/src/worldfactory.cpp index d71f563488fca..532b99a6b871e 100644 --- a/src/worldfactory.cpp +++ b/src/worldfactory.cpp @@ -117,9 +117,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_worldgen_tab_modselection( const catacurses::window &win, ui.on_screen_resize( init_windows ); std::vector 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}; diff --git a/tests/behavior_test.cpp b/tests/behavior_test.cpp index b458c5ceb8385..c54ada29b7539 100644 --- a/tests/behavior_test.cpp +++ b/tests/behavior_test.cpp @@ -160,7 +160,7 @@ TEST_CASE( "check_npc_behavior_tree", "[npc][behavior]" ) test_npc.update_bodytemp(); REQUIRE( oracle.needs_warmth_badly( "" ) == behavior::status_t::running ); CHECK( npc_needs.tick( &oracle ) == "idle" ); - test_npc.worn.push_back( item( "backpack" ) ); + test_npc.worn.emplace_back( "backpack" ); item &sweater = test_npc.i_add( item( itype_id( "sweater" ) ) ); CHECK( oracle.can_wear_warmer_clothes( "" ) == behavior::status_t::running ); CHECK( npc_needs.tick( &oracle ) == "wear_warmer_clothes" ); diff --git a/tests/crafting_test.cpp b/tests/crafting_test.cpp index 13c04e807cebd..9a0a6c99cedfc 100644 --- a/tests/crafting_test.cpp +++ b/tests/crafting_test.cpp @@ -165,7 +165,7 @@ TEST_CASE( "available_recipes", "[recipes]" ) } GIVEN( "an appropriate book" ) { - dummy.worn.push_back( item( "backpack" ) ); + dummy.worn.emplace_back( "backpack" ); item &craftbook = dummy.i_add( item( "manual_electronics" ) ); REQUIRE( craftbook.is_book() ); REQUIRE_FALSE( craftbook.type->book->recipes.empty() ); @@ -209,7 +209,7 @@ TEST_CASE( "available_recipes", "[recipes]" ) GIVEN( "an eink pc with a sushi recipe" ) { const recipe *r2 = &recipe_id( "sushi_rice" ).obj(); - dummy.worn.push_back( item( "backpack" ) ); + dummy.worn.emplace_back( "backpack" ); item &eink = dummy.i_add( item( "eink_tablet_pc" ) ); eink.set_var( "EIPC_RECIPES", ",sushi_rice," ); REQUIRE_FALSE( dummy.knows_recipe( r2 ) ); @@ -403,7 +403,7 @@ TEST_CASE( "UPS shows as a crafting component", "[crafting][ups]" ) { avatar dummy; clear_character( dummy ); - dummy.worn.push_back( item( "backpack" ) ); + dummy.worn.emplace_back( "backpack" ); item &ups = dummy.i_add( item( "UPS_off", calendar::turn_zero, 500 ) ); REQUIRE( dummy.has_item( ups ) ); REQUIRE( ups.charges == 500 ); diff --git a/tests/encumbrance_test.cpp b/tests/encumbrance_test.cpp index 97d4c74d7b74e..11de147f86488 100644 --- a/tests/encumbrance_test.cpp +++ b/tests/encumbrance_test.cpp @@ -63,7 +63,7 @@ static void test_encumbrance( std::vector clothing; clothing.reserve( clothing_types.size() ); for( const std::string &type : clothing_types ) { - clothing.push_back( item( type ) ); + clothing.emplace_back( type ); } test_encumbrance_items( clothing, body_part, expected_encumbrance ); } diff --git a/tests/generic_factory_test.cpp b/tests/generic_factory_test.cpp index 321d3f2285f74..bd48552245b48 100644 --- a/tests/generic_factory_test.cpp +++ b/tests/generic_factory_test.cpp @@ -347,7 +347,7 @@ TEST_CASE( "string_and_int_ids_benchmark", "[.][generic_factory][int_id][string_ std_uo_set_int_ids.emplace( int_id ); // do not add duplicates if( std_uo_set_int_ids.size() > vector_int_ids.size() ) { - vector_int_ids.push_back( flag ); + vector_int_ids.emplace_back( flag ); } } } item; @@ -382,7 +382,7 @@ TEST_CASE( "string_and_int_ids_benchmark", "[.][generic_factory][int_id][string_ std::vector test_dyn_str_ids; test_dyn_str_ids.reserve( test_flags.size() ); for( const auto &f : test_flags ) { - test_dyn_str_ids.push_back( dyn_str_id( f.str() ) ); + test_dyn_str_ids.emplace_back( f.str() ); } DYNAMIC_SECTION( "number_ids_in_collection: " << flags_in_item << "; only_hits: " << hits ) { diff --git a/tests/invlet_test.cpp b/tests/invlet_test.cpp index 0d3b8c7c0005b..bb8aaf0db7dde 100644 --- a/tests/invlet_test.cpp +++ b/tests/invlet_test.cpp @@ -464,7 +464,7 @@ static void invlet_test( player &dummy, const inventory_location from, const inv dummy.worn.clear(); dummy.remove_weapon(); get_map().i_clear( dummy.pos() ); - dummy.worn.push_back( item( "backpack" ) ); + dummy.worn.emplace_back( "backpack" ); // some two items that can be wielded, worn, and picked up item tshirt( "tshirt" ); @@ -546,7 +546,7 @@ static void stack_invlet_test( player &dummy, inventory_location from, inventory dummy.worn.clear(); dummy.remove_weapon(); get_map().i_clear( dummy.pos() ); - dummy.worn.push_back( item( "backpack" ) ); + dummy.worn.emplace_back( "backpack" ); // some stackable item that can be wielded and worn item tshirt1( "tshirt" ); @@ -682,7 +682,7 @@ static void merge_invlet_test( player &dummy, inventory_location from ) dummy.worn.clear(); dummy.remove_weapon(); get_map().i_clear( dummy.pos() ); - dummy.worn.push_back( item( "backpack" ) ); + dummy.worn.emplace_back( "backpack" ); // some stackable item item tshirt1( "tshirt" ); diff --git a/tests/iteminfo_test.cpp b/tests/iteminfo_test.cpp index 7c3a238772d75..422b8f86e8c17 100644 --- a/tests/iteminfo_test.cpp +++ b/tests/iteminfo_test.cpp @@ -2347,7 +2347,7 @@ TEST_CASE( "show available recipes with item as an ingredient", "[iteminfo][reci std::vector crafting = { iteminfo_parts::DESCRIPTION_APPLICABLE_RECIPES }; GIVEN( "character has a potassium iodide tablet and no skill" ) { - player_character.worn.push_back( item( "backpack" ) ); + player_character.worn.emplace_back( "backpack" ); item &iodine = player_character.i_add( item( "iodine" ) ); player_character.empty_skills(); REQUIRE( !player_character.knows_recipe( purtab ) ); diff --git a/tests/modify_morale_test.cpp b/tests/modify_morale_test.cpp index a60d643e03f00..cf5c4ea204837 100644 --- a/tests/modify_morale_test.cpp +++ b/tests/modify_morale_test.cpp @@ -46,7 +46,7 @@ static const trait_id trait_VEGETARIAN( "VEGETARIAN" ); TEST_CASE( "food enjoyability", "[food][modify_morale][fun]" ) { avatar dummy; - dummy.worn.push_back( item( "backpack" ) ); + dummy.worn.emplace_back( "backpack" ); std::pair fun; GIVEN( "food with positive fun" ) { @@ -80,7 +80,7 @@ TEST_CASE( "dining with table and chair", "[food][modify_morale][table][chair]" dummy.set_body(); const tripoint avatar_pos( 60, 60, 0 ); dummy.setpos( avatar_pos ); - dummy.worn.push_back( item( "backpack" ) ); + dummy.worn.emplace_back( "backpack" ); // Morale bonus only applies to unspoiled food that is not junk item &bread = dummy.i_add( item( "sourdough_bread" ) ); @@ -194,7 +194,7 @@ TEST_CASE( "dining with table and chair", "[food][modify_morale][table][chair]" TEST_CASE( "eating hot food", "[food][modify_morale][hot]" ) { avatar dummy; - dummy.worn.push_back( item( "backpack" ) ); + dummy.worn.emplace_back( "backpack" ); GIVEN( "some food that tastes better when hot" ) { item &bread = dummy.i_add( item( "sourdough_bread" ) ); @@ -268,7 +268,7 @@ TEST_CASE( "cannibalism", "[food][modify_morale][cannibal]" ) { avatar dummy; dummy.set_body(); - dummy.worn.push_back( item( "backpack" ) ); + dummy.worn.emplace_back( "backpack" ); item &human = dummy.i_add( item( "bone_human" ) ); REQUIRE( human.has_flag( flag_CANNIBALISM ) ); @@ -344,7 +344,7 @@ TEST_CASE( "sweet junk food", "[food][modify_morale][junk][sweet]" ) { avatar dummy; dummy.set_body(); - dummy.worn.push_back( item( "backpack" ) ); + dummy.worn.emplace_back( "backpack" ); GIVEN( "some sweet junk food" ) { item &necco = dummy.i_add( item( "neccowafers" ) ); @@ -398,7 +398,7 @@ TEST_CASE( "junk food that is not ingested", "[modify_morale][junk][no_ingest]" { avatar dummy; dummy.set_body(); - dummy.worn.push_back( item( "backpack" ) ); + dummy.worn.emplace_back( "backpack" ); item &caff_gum = dummy.i_add( item( "caff_gum" ) ); @@ -464,7 +464,7 @@ TEST_CASE( "food allergies and intolerances", "[food][modify_morale][allergy]" ) { avatar dummy; dummy.set_body(); - dummy.worn.push_back( item( "backpack" ) ); + dummy.worn.emplace_back( "backpack" ); int penalty = -75; GIVEN( "character is vegetarian" ) { @@ -551,7 +551,7 @@ TEST_CASE( "saprophage character", "[food][modify_morale][saprophage]" ) { avatar dummy; dummy.set_body(); - dummy.worn.push_back( item( "backpack" ) ); + dummy.worn.emplace_back( "backpack" ); GIVEN( "character is a saprophage, preferring rotted food" ) { dummy.clear_morale(); @@ -588,7 +588,7 @@ TEST_CASE( "ursine honey", "[food][modify_morale][ursine][honey]" ) { avatar dummy; dummy.set_body(); - dummy.worn.push_back( item( "backpack" ) ); + dummy.worn.emplace_back( "backpack" ); item &honeycomb = dummy.i_add( item( "honeycomb" ) ); REQUIRE( honeycomb.has_flag( flag_URSINE_HONEY ) ); diff --git a/tests/npc_talk_test.cpp b/tests/npc_talk_test.cpp index 5a5a9ef7d5d34..1b5f9937793ba 100644 --- a/tests/npc_talk_test.cpp +++ b/tests/npc_talk_test.cpp @@ -616,7 +616,7 @@ TEST_CASE( "npc_talk_items", "[npc_talk]" ) }; player_character.cash = 1000; player_character.int_cur = 8; - player_character.worn.push_back( item( "backpack" ) ); + player_character.worn.emplace_back( "backpack" ); d.add_topic( "TALK_TEST_EFFECTS" ); gen_response_lines( d, 19 ); // add and remove effect diff --git a/tests/player_helpers.cpp b/tests/player_helpers.cpp index 2442d881cca55..7907569b12b1e 100644 --- a/tests/player_helpers.cpp +++ b/tests/player_helpers.cpp @@ -123,7 +123,7 @@ void arm_shooter( npc &shooter, const std::string &gun_type, shooter.remove_weapon(); // XL so arrows can fit. if( !shooter.is_wearing( itype_id( "debug_backpack" ) ) ) { - shooter.worn.push_back( item( "debug_backpack" ) ); + shooter.worn.emplace_back( "debug_backpack" ); } const itype_id &gun_id{ itype_id( gun_type ) }; diff --git a/tests/ranged_balance_test.cpp b/tests/ranged_balance_test.cpp index b4623a4b9ccec..bc27c11728a90 100644 --- a/tests/ranged_balance_test.cpp +++ b/tests/ranged_balance_test.cpp @@ -227,7 +227,7 @@ TEST_CASE( "unskilled_shooter_accuracy", "[ranged] [balance] [slow]" ) clear_map(); standard_npc shooter( "Shooter", shooter_pos, {}, 0, 8, 8, 8, 7 ); shooter.set_body(); - shooter.worn.push_back( item( "backpack" ) ); + shooter.worn.emplace_back( "backpack" ); equip_shooter( shooter, { "bastsandals", "armguard_chitin", "armor_chitin", "beekeeping_gloves", "mask_guy_fawkes", "cowboy_hat" } ); assert_encumbrance( shooter, 10 ); diff --git a/tests/reading_test.cpp b/tests/reading_test.cpp index 8f6a45c8c219d..a362594c8fb65 100644 --- a/tests/reading_test.cpp +++ b/tests/reading_test.cpp @@ -44,7 +44,7 @@ TEST_CASE( "identifying unread books", "[reading][book][identify]" ) { clear_avatar(); Character &dummy = get_avatar(); - dummy.worn.push_back( item( "backpack" ) ); + dummy.worn.emplace_back( "backpack" ); GIVEN( "character has some unidentified books" ) { item &book1 = dummy.i_add( item( "novel_western" ) ); @@ -70,7 +70,7 @@ TEST_CASE( "reading a book for fun", "[reading][book][fun]" ) clear_avatar(); Character &dummy = get_avatar(); dummy.set_body(); - dummy.worn.push_back( item( "backpack" ) ); + dummy.worn.emplace_back( "backpack" ); GIVEN( "a fun book" ) { item &book = dummy.i_add( item( "novel_western" ) ); @@ -141,7 +141,7 @@ TEST_CASE( "character reading speed", "[reading][character][speed]" ) { clear_avatar(); Character &dummy = get_avatar(); - dummy.worn.push_back( item( "backpack" ) ); + dummy.worn.emplace_back( "backpack" ); // Note: read_speed() returns number of moves; // 6000 == 60 seconds @@ -186,7 +186,7 @@ TEST_CASE( "character reading speed", "[reading][character][speed]" ) TEST_CASE( "estimated reading time for a book", "[reading][book][time]" ) { avatar dummy; - dummy.worn.push_back( item( "backpack" ) ); + dummy.worn.emplace_back( "backpack" ); // Easy, medium, and hard books item &child = dummy.i_add( item( "child_book" ) ); @@ -274,7 +274,7 @@ TEST_CASE( "reasons for not being able to read", "[reading][reasons]" ) { avatar dummy; dummy.set_body(); - dummy.worn.push_back( item( "backpack" ) ); + dummy.worn.emplace_back( "backpack" ); std::vector reasons; std::vector expect_reasons; @@ -369,7 +369,7 @@ TEST_CASE( "determining book mastery", "[reading][book][mastery]" ) avatar dummy; dummy.set_body(); - dummy.worn.push_back( item( "backpack" ) ); + dummy.worn.emplace_back( "backpack" ); item &child = dummy.i_add( item( "child_book" ) ); item &alpha = dummy.i_add( item( "recipe_alpha" ) ); diff --git a/tests/reload_option_test.cpp b/tests/reload_option_test.cpp index 6778426537b93..416649bbe26be 100644 --- a/tests/reload_option_test.cpp +++ b/tests/reload_option_test.cpp @@ -15,7 +15,7 @@ TEST_CASE( "revolver_reload_option", "[reload],[reload_option],[gun]" ) { avatar dummy; - dummy.worn.push_back( item( "backpack" ) ); + dummy.worn.emplace_back( "backpack" ); item &gun = dummy.i_add( item( "sw_619", calendar::turn_zero, 0 ) ); const ammotype &gun_ammo_type = item::find_type( gun.ammo_default() )->ammo->type; @@ -46,7 +46,7 @@ TEST_CASE( "revolver_reload_option", "[reload],[reload_option],[gun]" ) TEST_CASE( "magazine_reload_option", "[reload],[reload_option],[gun]" ) { avatar dummy; - dummy.worn.push_back( item( "backpack" ) ); + dummy.worn.emplace_back( "backpack" ); item &magazine = dummy.i_add( item( "glockmag", calendar::turn_zero, 0 ) ); const ammotype &mag_ammo_type = item::find_type( magazine.ammo_default() )->ammo->type; @@ -69,7 +69,7 @@ TEST_CASE( "belt_reload_option", "[reload],[reload_option],[gun]" ) { avatar dummy; dummy.set_body(); - dummy.worn.push_back( item( "backpack" ) ); + dummy.worn.emplace_back( "backpack" ); item &belt = dummy.i_add( item( "belt308", calendar::turn_zero, 0 ) ); const ammotype &belt_ammo_type = item::find_type( belt.ammo_default() )->ammo->type; @@ -96,7 +96,7 @@ TEST_CASE( "belt_reload_option", "[reload],[reload_option],[gun]" ) TEST_CASE( "canteen_reload_option", "[reload],[reload_option],[liquid]" ) { avatar dummy; - dummy.worn.push_back( item( "backpack" ) ); + dummy.worn.emplace_back( "backpack" ); item &bottle = dummy.i_add( item( "bottle_plastic" ) ); item water( "water_clean", calendar::turn_zero, 2 ); diff --git a/tests/reloading_test.cpp b/tests/reloading_test.cpp index f75d39fbcf676..56b7b5d929c3a 100644 --- a/tests/reloading_test.cpp +++ b/tests/reloading_test.cpp @@ -211,7 +211,7 @@ TEST_CASE( "automatic_reloading_action", "[reload],[gun]" ) GIVEN( "a player wielding an unloaded gun, carrying an unloaded magazine, and carrying ammo for the magazine" ) { dummy.worn.clear(); - dummy.worn.push_back( item( "backpack" ) ); + dummy.worn.emplace_back( "backpack" ); item &ammo = dummy.i_add( item( "9mm", calendar::turn_zero, 50 ) ); const cata::value_ptr &ammo_type = ammo.type->ammo; REQUIRE( ammo_type ); diff --git a/tests/string_ids_test.cpp b/tests/string_ids_test.cpp index 5cc963592b0f4..f8479470721a2 100644 --- a/tests/string_ids_test.cpp +++ b/tests/string_ids_test.cpp @@ -39,7 +39,7 @@ TEST_CASE( "string_ids_intern_test", "[string_id]" ) // lots of ids to make sure that "interning" map gets expanded ids.reserve( num_ids ); for( int i = 0; i < num_ids; ++i ) { - ids.push_back( string_id( "test_id" + std::to_string( i ) ) ); + ids.emplace_back( "test_id" + std::to_string( i ) ); } // check that interning works @@ -107,7 +107,7 @@ TEST_CASE( "string_id_sorting_test", "[string_id]" ) SECTION( "vector of pairs sorting" ) { std::vector> vec; for( int i = 9; i >= 0; i-- ) { - vec.push_back( {id( "id" + std::to_string( i ) ), i} ); + vec.emplace_back( id( "id" + std::to_string( i ) ), i ); } int i = 0; @@ -122,7 +122,7 @@ TEST_CASE( "string_id_sorting_test", "[string_id]" ) std::vector vec; vec.reserve( 10 ); for( int i = 0; i < 10; ++i ) { - vec.push_back( id( "id" + std::to_string( i ) ) ); + vec.emplace_back( "id" + std::to_string( i ) ); } int i = 0; diff --git a/tests/vehicle_part_test.cpp b/tests/vehicle_part_test.cpp index d69bca02778da..4f8a4b8964982 100644 --- a/tests/vehicle_part_test.cpp +++ b/tests/vehicle_part_test.cpp @@ -196,19 +196,19 @@ TEST_CASE( "craft_available_via_vehicle_rig", "[vehicle][vehicle_craft]" ) } SECTION( "cook oatmeal without battery" ) { std::vector items; - items.push_back( item( itype_id( "oatmeal" ) ) ); + items.emplace_back( itype_id( "oatmeal" ) ); test_craft_via_rig( items, 0, 0, 1, 1, recipe_id( "oatmeal_cooked" ).obj(), false ); } SECTION( "cook oatmeal without water" ) { std::vector items; - items.push_back( item( itype_id( "oatmeal" ) ) ); + items.emplace_back( itype_id( "oatmeal" ) ); test_craft_via_rig( items, 2, 2, 0, 0, recipe_id( "oatmeal_cooked" ).obj(), false ); } SECTION( "cook oatmeal successfully" ) { std::vector items; - items.push_back( item( itype_id( "oatmeal" ) ) ); + items.emplace_back( itype_id( "oatmeal" ) ); test_craft_via_rig( items, 2, 0, 1, 0, recipe_id( "oatmeal_cooked" ).obj(), true ); } diff --git a/tests/visitable_remove_test.cpp b/tests/visitable_remove_test.cpp index b31263c8a9c3e..15544be8a2c4f 100644 --- a/tests/visitable_remove_test.cpp +++ b/tests/visitable_remove_test.cpp @@ -50,7 +50,7 @@ TEST_CASE( "visitable_remove", "[visitable]" ) Character &p = get_player_character(); p.worn.clear(); - p.worn.push_back( item( "backpack" ) ); + p.worn.emplace_back( "backpack" ); p.inv->clear(); p.remove_weapon(); p.wear_item( item( "backpack" ) ); // so we don't drop anything