From 97ed12a76e6ff068f92e52d27e635bc85091160f Mon Sep 17 00:00:00 2001 From: WhiteCloud0123 <112397151+WhiteCloud0123@users.noreply.github.com> Date: Sat, 15 Jul 2023 21:26:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9D=82=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/activity_actor.cpp | 2 +- src/activity_actor_definitions.h | 4 ++-- src/bodypart.cpp | 2 +- src/cata_small_literal_vector.h | 6 +++++- src/cata_tiles.cpp | 2 +- src/crafting_gui.cpp | 8 ++++---- src/debug.cpp | 2 +- src/debug_menu.cpp | 7 ++++--- src/effect.cpp | 2 +- src/game.cpp | 4 ++-- src/game_inventory.cpp | 4 ++-- src/handle_action.cpp | 2 +- src/harvest.cpp | 15 +++++++++------ src/iexamine.cpp | 2 +- src/item.cpp | 9 ++++++--- src/item_factory.cpp | 2 +- src/item_location.cpp | 2 +- src/item_pocket.cpp | 3 +-- src/iuse.cpp | 6 +++--- src/json.cpp | 2 +- src/magic_enchantment.cpp | 3 ++- src/magic_teleporter_list.cpp | 2 +- src/map.cpp | 2 +- src/mapbuffer.cpp | 4 ++-- src/medical_ui.cpp | 2 +- src/melee.cpp | 2 +- src/mission_companion.cpp | 2 +- src/mod_manager.cpp | 1 + src/mod_manager_ui.cpp | 2 +- src/mongroup.h | 4 +--- src/name.cpp | 2 +- src/npc.cpp | 2 +- src/overmap.cpp | 2 +- src/player_activity.cpp | 2 +- src/player_display.cpp | 4 ++-- src/ranged.cpp | 2 +- src/reachability_cache.cpp | 2 +- src/recipe_dictionary.cpp | 2 +- src/safe_reference.cpp | 4 ++-- src/sdlsound.cpp | 4 ++-- src/simple_pathfinding.cpp | 2 +- src/skill.cpp | 4 ++-- src/sounds.cpp | 6 ++++-- src/trait_group.cpp | 2 +- src/veh_utils.cpp | 2 +- src/vehicle_part.cpp | 2 +- src/weighted_list.h | 2 +- src/worldfactory.cpp | 4 ++-- 48 files changed, 86 insertions(+), 74 deletions(-) diff --git a/src/activity_actor.cpp b/src/activity_actor.cpp index 1bd3422d..7647728e 100644 --- a/src/activity_actor.cpp +++ b/src/activity_actor.cpp @@ -2471,7 +2471,7 @@ std::unique_ptr ebooksave_activity_actor::deserialize( JsonValue return actor.clone(); } -constexpr time_duration ebooksave_activity_actor::time_per_page; + void migration_cancel_activity_actor::do_turn( player_activity &act, Character &who ) { diff --git a/src/activity_actor_definitions.h b/src/activity_actor_definitions.h index 920e5825..1e3bfe5e 100644 --- a/src/activity_actor_definitions.h +++ b/src/activity_actor_definitions.h @@ -712,10 +712,10 @@ class consume_activity_actor : public activity_actor type( type ) {} explicit consume_activity_actor( const item_location &consume_location ) : - consume_location( consume_location ), consume_menu_selections( std::vector() ) {} + consume_location(consume_location) {} explicit consume_activity_actor( const item &consume_item ) : - consume_item( consume_item ), consume_menu_selections( std::vector() ) {} + consume_item(consume_item) {} activity_id get_type() const override { return activity_id( "ACT_CONSUME" ); diff --git a/src/bodypart.cpp b/src/bodypart.cpp index c3b2e22d..1c61a4b7 100644 --- a/src/bodypart.cpp +++ b/src/bodypart.cpp @@ -272,7 +272,7 @@ sub_bodypart_id body_part_type::random_sub_part( bool secondary ) const } } // should never get here - return ( sub_bodypart_id() ); + return sub_bodypart_id(); } const std::vector &body_part_type::get_all() diff --git a/src/cata_small_literal_vector.h b/src/cata_small_literal_vector.h index 3b8b11bd..553e5442 100644 --- a/src/cata_small_literal_vector.h +++ b/src/cata_small_literal_vector.h @@ -3,6 +3,7 @@ #define CATA_SRC_CATA_SMALL_LITERAL_VECTOR_H #include +#include #include #include #include @@ -20,7 +21,10 @@ template struct alignas( T * ) small_literal_vector { // To avoid having to invoke constructors and destructors when copying Elements // around or inserting new ones, we enforce it is a literal type. - static_assert( std::is_literal_type::value, "T must be literal." ); + static_assert(std::is_trivially_destructible_v, "T must be trivially destructible."); + static_assert(std::is_trivially_copyable_v, "T must be trivially copyable."); + static_assert(std::is_trivially_default_constructible_v, + "T must be trivially default constuctible."); small_literal_vector() : heap_( nullptr ), capacity_( kInlineCount ), len_( 0 ) {} small_literal_vector( const small_literal_vector &other ) : capacity_( kInlineCount ), len_( 0 ) { diff --git a/src/cata_tiles.cpp b/src/cata_tiles.cpp index e7ed051c..8944a1c6 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -2443,7 +2443,7 @@ bool cata_tiles::draw_from_id_string( const std::string &id, TILE_CATEGORY categ if( display_tile.animated ) { // idle animations run during the user's turn, and the animation speed // needs to be defined by the tileset to look good, so we use system clock: - auto now = std::chrono::system_clock::now(); + std::chrono::system_clock::time_point now = std::chrono::system_clock::now(); auto now_ms = std::chrono::time_point_cast( now ); auto value = now_ms.time_since_epoch(); // aiming roughly at the standard 60 frames per second: diff --git a/src/crafting_gui.cpp b/src/crafting_gui.cpp index 93f84c76..13bd41dd 100644 --- a/src/crafting_gui.cpp +++ b/src/crafting_gui.cpp @@ -770,7 +770,7 @@ static recipe_subset filter_recipes( const recipe_subset &available_recipes, // Find next ',' qry_end = qry.find_first_of( ',', qry_begin ); - auto qry_filter_str = trim( qry.substr( qry_begin, qry_end - qry_begin ) ); + std::string qry_filter_str = trim(qry.substr(qry_begin, qry_end - qry_begin)); // Process filter if( qry_filter_str.size() > 2 && qry_filter_str[1] == ':' ) { switch( qry_filter_str[0] ) { @@ -1404,12 +1404,12 @@ const recipe *select_crafting_recipe( int &batch_size_out, const recipe_id &goto indent.assign( current.size(), 0 ); } else { static_popup popup; - auto last_update = std::chrono::steady_clock::now(); + std::chrono::steady_clock::time_point last_update = std::chrono::steady_clock::now(); static constexpr std::chrono::milliseconds update_interval( 500 ); std::function progress_callback = [&]( size_t at, size_t out_of ) { - auto now = std::chrono::steady_clock::now(); + std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now(); if( now - last_update < update_interval ) { return; } @@ -1423,7 +1423,7 @@ const recipe *select_crafting_recipe( int &batch_size_out, const recipe_id &goto std::vector picking; if( !filterstring.empty() ) { - auto qry = trim( filterstring ); + std::string qry = trim(filterstring); recipe_subset filtered_recipes = filter_recipes( available_recipes, qry, player_character, progress_callback ); picking.insert( picking.end(), filtered_recipes.begin(), filtered_recipes.end() ); diff --git a/src/debug.cpp b/src/debug.cpp index fa63a3be..81a5683c 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -417,7 +417,7 @@ struct time_info { using char_t = typename Stream::char_type; using base = std::basic_ostream; - static_assert( std::is_base_of::value, "" ); + static_assert(std::is_base_of::value); out << std::setfill( '0' ); out << std::setw( 2 ) << t.hours << ':' << std::setw( 2 ) << t.minutes << ':' << diff --git a/src/debug_menu.cpp b/src/debug_menu.cpp index 8b071172..6833f839 100644 --- a/src/debug_menu.cpp +++ b/src/debug_menu.cpp @@ -1964,7 +1964,8 @@ static void character_edit_menu() uilist ssmenu; std::vector> mutation_categories_list; mutation_categories_list.reserve( mutations_category.size() ); - for( const std::pair > mut_cat : mutations_category ) { + for (const std::pair >& mut_cat : + mutations_category) { mutation_categories_list.emplace_back( mut_cat.first.c_str(), mut_cat.first ); } ssmenu.text = _( "Choose mutation category:" ); @@ -2324,8 +2325,8 @@ void mission_debug::edit_mission( mission &m ) static void draw_benchmark( const int max_difference ) { // call the draw procedure as many times as possible in max_difference milliseconds - auto start_tick = std::chrono::steady_clock::now(); - auto end_tick = std::chrono::steady_clock::now(); + std::chrono::steady_clock::time_point start_tick = std::chrono::steady_clock::now(); + std::chrono::steady_clock::time_point end_tick = std::chrono::steady_clock::now(); int64_t difference = 0; int draw_counter = 0; diff --git a/src/effect.cpp b/src/effect.cpp index 476c450e..6d3e95cb 100644 --- a/src/effect.cpp +++ b/src/effect.cpp @@ -714,7 +714,7 @@ std::string effect::disp_desc( bool reduced ) const std::string ret; std::string timestr; - time_duration effect_dur_elapsed = ( calendar::turn - start_time ); + time_duration effect_dur_elapsed = calendar::turn - start_time; if( to_turns( effect_dur_elapsed ) == 0 ) { timestr = _( "just now" ); } else { diff --git a/src/game.cpp b/src/game.cpp index 6e41dfab..23488947 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2398,7 +2398,7 @@ std::pair game::mouse_edge_scrolling( input_context &ctxt, c ( void ) speed; ( void ) iso; #if (defined TILES || defined _WIN32 || defined WINDOWS) - auto now = std::chrono::steady_clock::now(); + std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now(); if( now < last_mouse_edge_scroll + std::chrono::milliseconds( rate ) ) { return ret; } else { @@ -6109,7 +6109,7 @@ void game::print_all_tile_info( const tripoint &lp, const catacurses::window &w_ } const int max_width = getmaxx( w_look ) - column - 1; - auto this_sound = sounds::sound_at( lp ); + std::string this_sound = sounds::sound_at(lp); if( !this_sound.empty() ) { const int lines = fold_and_print( w_look, point( 1, ++line ), max_width, c_light_gray, _( "From here you heard %s" ), diff --git a/src/game_inventory.cpp b/src/game_inventory.cpp index f929ac80..e8223c79 100644 --- a/src/game_inventory.cpp +++ b/src/game_inventory.cpp @@ -853,7 +853,7 @@ class comestible_inventory_preset : public inventory_selector_preset static std::string get_consume_needs_hint( Character &you ) { - auto hint = std::string(); + std::string hint = std::string(); auto desc = display::hunger_text_color( you ); hint.append( string_format( "%s %s", _( "Food:" ), colorize( desc.first, desc.second ) ) ); hint.append( string_format( " %s ", LINE_XOXO_S ) ); @@ -1836,7 +1836,7 @@ class repair_inventory_preset: public inventory_selector_preset static std::string get_repair_hint( const Character &you, const repair_item_actor *actor, const item *main_tool ) { - auto hint = std::string(); + std::string hint = std::string(); hint.append( string_format( _( "Tool: %s" ), main_tool->display_name() ) ); hint.append( string_format( " | " ) ); hint.append( string_format( _( "Skill used: %s (%d)" ), diff --git a/src/handle_action.cpp b/src/handle_action.cpp index 9e09e122..12b79400 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -452,7 +452,7 @@ class user_turn if (turn_duration <= 0.005) { return 0; } - auto now = std::chrono::steady_clock::now(); + std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now(); std::chrono::milliseconds elapsed_ms = std::chrono::duration_cast(now - user_turn_start); return elapsed_ms.count() / (10.0 * turn_duration); diff --git a/src/harvest.cpp b/src/harvest.cpp index fa9173a8..6b829d3e 100644 --- a/src/harvest.cpp +++ b/src/harvest.cpp @@ -43,20 +43,23 @@ bool string_id::is_valid() const translation harvest_drop_type::field_dress_msg( bool succeeded ) const { - return SNIPPET.random_from_category( succeeded ? msg_fielddress_success : - msg_fielddress_fail ).value_or( translation() ); + // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) + return SNIPPET.random_from_category( + succeeded ? msg_fielddress_success : msg_fielddress_fail).value_or(translation()); } translation harvest_drop_type::butcher_msg( bool succeeded ) const { - return SNIPPET.random_from_category( succeeded ? msg_butcher_success : msg_butcher_fail ).value_or( - translation() ); + // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) + return SNIPPET.random_from_category( + succeeded ? msg_butcher_success : msg_butcher_fail).value_or(translation()); } translation harvest_drop_type::dissect_msg( bool succeeded ) const { - return SNIPPET.random_from_category( succeeded ? msg_dissect_success : msg_dissect_fail ).value_or( - translation() ); + // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) + return SNIPPET.random_from_category( + succeeded ? msg_dissect_success : msg_dissect_fail).value_or(translation()); } /** @relates string_id */ diff --git a/src/iexamine.cpp b/src/iexamine.cpp index 8d0e1751..fb0b6c2d 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -4519,7 +4519,7 @@ cata::optional iexamine::getNearFilledGasTank( const tripoint ¢er, map &here = get_map(); for( const tripoint &tmp : here.points_in_radius( center, SEEX * 2 ) ) { - auto check_for_fuel_tank = here.furn( tmp ); + furn_id check_for_fuel_tank = here.furn(tmp); if( ( fuel_type == FUEL_TYPE_GASOLINE && check_for_fuel_tank != furn_f_gas_tank ) || ( fuel_type == FUEL_TYPE_DIESEL && check_for_fuel_tank != furn_f_diesel_tank ) ) { diff --git a/src/item.cpp b/src/item.cpp index c63a6470..3c5a968c 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -216,7 +216,7 @@ static const std::string flag_SILENT( "SILENT" ); // item pricing static const int PRICE_FILTHY_MALUS = 100; // cents -constexpr units::volume armor_portion_data::volume_per_encumbrance; + class npc_class; @@ -10483,13 +10483,16 @@ int item::get_chapters() const } int item::get_remaining_chapters( const Character &u ) const -{ +{ + // NOLINTNEXTLINE(cata-translate-string-literal) const std::string var = string_format( "remaining-chapters-%d", u.getID().get_value() ); return get_var( var, get_chapters() ); } void item::mark_chapter_as_read( const Character &u ) -{ +{ + + // NOLINTNEXTLINE(cata-translate-string-literal) const std::string var = string_format( "remaining-chapters-%d", u.getID().get_value() ); if( type->book && type->book->chapters == 0 ) { // books without chapters will always have remaining chapters == 0, so we don't need to store them diff --git a/src/item_factory.cpp b/src/item_factory.cpp index e5707432..6e554300 100644 --- a/src/item_factory.cpp +++ b/src/item_factory.cpp @@ -4763,7 +4763,7 @@ void Item_factory::emplace_usage( std::map &container std::pair Item_factory::usage_from_object( const JsonObject &obj ) { - auto type = obj.get_string( "type" ); + std::string type = obj.get_string("type"); if( type == "repair_item" ) { type = obj.get_string( "item_action_type" ); diff --git a/src/item_location.cpp b/src/item_location.cpp index 0b0ff179..0ce538b1 100644 --- a/src/item_location.cpp +++ b/src/item_location.cpp @@ -777,7 +777,7 @@ void item_location::serialize( JsonOut &js ) const void item_location::deserialize( const JsonObject &obj ) { - auto type = obj.get_string( "type" ); + std::string type = obj.get_string("type"); int idx = -1; tripoint pos = tripoint_min; diff --git a/src/item_pocket.cpp b/src/item_pocket.cpp index f0745ca1..546f7f37 100644 --- a/src/item_pocket.cpp +++ b/src/item_pocket.cpp @@ -55,8 +55,7 @@ std::string enum_to_string( item_pocket::pocket_type d // *INDENT-ON* } // namespace io -constexpr units::volume pocket_data::max_volume_for_container; -constexpr units::mass pocket_data::max_weight_for_container; + std::string pocket_data::check_definition() const { diff --git a/src/iuse.cpp b/src/iuse.cpp index 1e30bcb8..78a18b2c 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -4728,7 +4728,7 @@ cata::optional iuse::blood_draw( Character *p, item *it, bool, const tripoi drew_blood = true; blood_temp = map_it.temperature; - auto bloodtype( map_it.get_mtype()->bloodType() ); + field_type_id bloodtype(map_it.get_mtype()->bloodType()); if( bloodtype.obj().has_acid ) { acid_blood = true; } else { @@ -5979,7 +5979,7 @@ static bool einkpc_download_memory_card( Character &p, item &eink, item &mc ) something_downloaded = true; p.add_msg_if_player( m_good, _( "You have updated your monster collection." ) ); - auto photos = eink.get_var( "EINK_MONSTER_PHOTOS" ); + std::string photos = eink.get_var("EINK_MONSTER_PHOTOS"); if( photos.empty() ) { eink.set_var( "EINK_MONSTER_PHOTOS", monster_photos ); } else { @@ -8649,7 +8649,7 @@ cata::optional iuse::cable_attach( Character *p, item *it, bool, const trip } const tripoint posp = *posp_; const optional_vpart_position vp = here.veh_at( posp ); - auto ter = here.ter( posp ); + ter_id ter = here.ter(posp); if( !vp && ter != t_chainfence ) { p->add_msg_if_player( _( "There's no vehicle there." ) ); return cata::nullopt; diff --git a/src/json.cpp b/src/json.cpp index 204f0804..929acb9d 100644 --- a/src/json.cpp +++ b/src/json.cpp @@ -141,7 +141,7 @@ void TextJsonObject::report_unvisited() const { #ifndef CATA_IN_TOOL if( report_unvisited_members && !reported_unvisited_members && - !std::uncaught_exception() ) { + !std::uncaught_exceptions()) { reported_unvisited_members = true; for( const std::pair &p : positions ) { const std::string &name = p.first; diff --git a/src/magic_enchantment.cpp b/src/magic_enchantment.cpp index 481a9f23..c7fd931c 100644 --- a/src/magic_enchantment.cpp +++ b/src/magic_enchantment.cpp @@ -426,7 +426,8 @@ void enchant_cache::serialize( JsonOut &jsout ) const jsout.start_object(); jsout.member( "effects" ); jsout.start_array(); - for( const std::pair> pair : intermittent_activation ) { + for (const std::pair>& pair : + intermittent_activation) { jsout.start_object(); jsout.member( "frequency", to_string_writable( pair.first ) ); jsout.member( "spell_effects", pair.second ); diff --git a/src/magic_teleporter_list.cpp b/src/magic_teleporter_list.cpp index 722fae18..459a5ae6 100644 --- a/src/magic_teleporter_list.cpp +++ b/src/magic_teleporter_list.cpp @@ -135,7 +135,7 @@ void teleporter_list::serialize( JsonOut &json ) const json.member( "known_teleporters" ); json.start_array(); - for( std::pair pair : known_teleporters ) { + for (const std::pair& pair : known_teleporters) { json.start_object(); json.member( "position", pair.first ); json.member( "name", pair.second ); diff --git a/src/map.cpp b/src/map.cpp index 2e5b7927..6eb2a2f6 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -9377,7 +9377,7 @@ void map::scent_blockers( std::array, MAPSIZE_Y> &bl // Now vehicles - auto vehs = get_vehicles(); + VehicleList vehs = get_vehicles(); for( wrapped_vehicle &wrapped_veh : vehs ) { vehicle &veh = *( wrapped_veh.v ); for( const vpart_reference &vp : veh.get_all_parts_with_fakes() ) { diff --git a/src/mapbuffer.cpp b/src/mapbuffer.cpp index 27852549..aa54abe4 100644 --- a/src/mapbuffer.cpp +++ b/src/mapbuffer.cpp @@ -135,10 +135,10 @@ void mapbuffer::save( bool delete_after_save ) std::set saved_submaps; std::list submaps_to_delete; static constexpr std::chrono::milliseconds update_interval( 500 ); - auto last_update = std::chrono::steady_clock::now(); + std::chrono::steady_clock::time_point last_update = std::chrono::steady_clock::now(); for( auto &elem : submaps ) { - auto now = std::chrono::steady_clock::now(); + std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now(); if( last_update + update_interval < now ) { popup.message( _( "Please wait as the map saves [%d/%d]" ), num_saved_submaps, num_total_submaps ); diff --git a/src/medical_ui.cpp b/src/medical_ui.cpp index dad59f42..f9cbc050 100644 --- a/src/medical_ui.cpp +++ b/src/medical_ui.cpp @@ -670,7 +670,7 @@ static medical_column draw_stats_summary( const int column_count, avatar *player } for( const std::pair &speed_effect : speed_effects ) { - nc_color col = ( speed_effect.second > 0 ? c_green : c_red ); + nc_color col = speed_effect.second > 0 ? c_green : c_red; speed_detail_str += colorize( string_format( _( "%s %s%d%%\n" ), speed_effect.first, ( speed_effect.second > 0 ? "+" : "-" ), std::abs( speed_effect.second ) ), col ); diff --git a/src/melee.cpp b/src/melee.cpp index 839c180b..60554cf3 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -260,7 +260,7 @@ bool Character::handle_melee_wear( item_location shield, float wear_multiplier ) return false; } - auto str = shield->tname(); // save name before we apply damage + std::string str = shield->tname(); // save name before we apply damage if( !shield->inc_damage() ) { add_msg_player_or_npc( m_bad, _( "Your %s is damaged by the force of the blow!" ), diff --git a/src/mission_companion.cpp b/src/mission_companion.cpp index 0f169d97..55e72876 100644 --- a/src/mission_companion.cpp +++ b/src/mission_companion.cpp @@ -933,7 +933,7 @@ bool talk_function::display_and_choose_opts( size_t list_line = 2; for( size_t current = name_index; list_line < info_height + 2 && current < cur_key_list.size(); current++ ) { - nc_color col = ( current == sel ? h_white : c_white ); + nc_color col = current == sel ? h_white : c_white; //highlight important missions for( const mission_entry &k : mission_key.entries[0] ) { if( is_equal( cur_key_list[current].id, k.id ) ) { diff --git a/src/mod_manager.cpp b/src/mod_manager.cpp index 98191af8..adce89cd 100644 --- a/src/mod_manager.cpp +++ b/src/mod_manager.cpp @@ -324,6 +324,7 @@ bool mod_manager::copy_mod_contents( const t_mod_list &mods_to_copy, } // create needed directories + // NOLINTNEXTLINE(cata-translate-string-literal) const cata_path cur_mod_dir = output_base_path / string_format( "mod_%05d", i + 1 ); std::queue dir_to_make; diff --git a/src/mod_manager_ui.cpp b/src/mod_manager_ui.cpp index b4f4c1ca..011b3958 100644 --- a/src/mod_manager_ui.cpp +++ b/src/mod_manager_ui.cpp @@ -40,7 +40,7 @@ std::string mod_ui::get_information( const MOD_INFORMATION *mod ) if( !mod->dependencies.empty() ) { const auto &deps = mod->dependencies; - auto str = enumerate_as_string( deps.begin(), deps.end(), [&]( const mod_id & e ) { + std::string str = enumerate_as_string(deps.begin(), deps.end(), [&](const mod_id& e) { if( e.is_valid() ) { return string_format( "[%s]", e->name() ); } else { diff --git a/src/mongroup.h b/src/mongroup.h index a9f5f5c5..8341b674 100644 --- a/src/mongroup.h +++ b/src/mongroup.h @@ -48,7 +48,6 @@ struct MonsterGroupEntry { int new_pack_max, const spawn_data &new_data, const time_duration &new_starts, const time_duration &new_ends, holiday new_event ) : name( id ) - , group( mongroup_id() ) , frequency( new_freq ) , cost_multiplier( new_cost ) , pack_minimum( new_pack_min ) @@ -62,8 +61,7 @@ struct MonsterGroupEntry { MonsterGroupEntry( const mongroup_id &id, int new_freq, int new_cost, int new_pack_min, int new_pack_max, const spawn_data &new_data, const time_duration &new_starts, const time_duration &new_ends, holiday new_event ) - : name( mtype_id() ) - , group( id ) + : group(id) , frequency( new_freq ) , cost_multiplier( new_cost ) , pack_minimum( new_pack_min ) diff --git a/src/name.cpp b/src/name.cpp index 07da2035..a60e6772 100644 --- a/src/name.cpp +++ b/src/name.cpp @@ -111,7 +111,7 @@ static names_vec get_matching_groups( nameFlags searchFlags ) // Get a random name with the specified flag std::string get( nameFlags searchFlags ) { - auto matching_groups = get_matching_groups( searchFlags ); + Name::names_vec matching_groups = get_matching_groups(searchFlags); if( !matching_groups.empty() ) { // get number of choices size_t nChoices = 0; diff --git a/src/npc.cpp b/src/npc.cpp index c993f6ea..dda130c9 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -3285,7 +3285,7 @@ void npc::on_load() shop_restock(); } -constexpr tripoint_abs_omt npc::no_goal_point; + bool npc::query_yn( const std::string &/*msg*/ ) const { diff --git a/src/overmap.cpp b/src/overmap.cpp index a1583c78..39c98458 100644 --- a/src/overmap.cpp +++ b/src/overmap.cpp @@ -6664,7 +6664,7 @@ std::string enum_to_string( ot_match_type data ) } } // namespace io -constexpr tripoint_abs_omt overmap::invalid_tripoint; + static const std::array suffixes = {{ "_north", "_west", "_south", "_east" }}; std::string oter_no_dir( const oter_id &oter ) diff --git a/src/player_activity.cpp b/src/player_activity.cpp index 5b631d84..8f4b8e46 100644 --- a/src/player_activity.cpp +++ b/src/player_activity.cpp @@ -73,7 +73,7 @@ static const std::vector consuming { ACT_CONSUME_DRINK_MENU, ACT_CONSUME_MEDS_MENU }; -constexpr tripoint_abs_ms player_activity::invalid_place; + player_activity::player_activity() : type( activity_id::NULL_ID() ) { } diff --git a/src/player_display.cpp b/src/player_display.cpp index ef9e01fe..3d77dfe7 100644 --- a/src/player_display.cpp +++ b/src/player_display.cpp @@ -998,7 +998,7 @@ static void draw_speed_tab( const catacurses::window &w_speed, } for( const std::pair &speed_effect : speed_effects ) { - nc_color col = ( speed_effect.second > 0 ? c_green : c_red ); + nc_color col = speed_effect.second > 0 ? c_green : c_red; mvwprintz( w_speed, point( 1, line ), col, "%s", speed_effect.first ); mvwprintz( w_speed, point( 21, line ), col, ( speed_effect.second > 0 ? "+" : "-" ) ); mvwprintz( w_speed, point( std::abs( speed_effect.second ) >= 10 ? 22 : 23, line ), col, "%d%%", @@ -1007,7 +1007,7 @@ static void draw_speed_tab( const catacurses::window &w_speed, } int runcost = you.run_cost( 100 ); - nc_color col = ( runcost <= 100 ? c_green : c_red ); + nc_color col = runcost <= 100 ? c_green : c_red; mvwprintz( w_speed, point( 21 + ( runcost >= 100 ? 0 : ( runcost < 10 ? 2 : 1 ) ), 1 ), col, "%d", runcost ); col = ( newmoves >= 100 ? c_green : c_red ); diff --git a/src/ranged.cpp b/src/ranged.cpp index 7d1bb5ee..8d7d34ae 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -3315,7 +3315,7 @@ bool target_ui::action_switch_mode() // gun mode select const std::map all_gun_modes = relevant->gun_all_modes(); int skip = menu.ret - firing_modes_range.first; - for( std::pair it : all_gun_modes ) { + for (const std::pair& it : all_gun_modes) { if( skip-- == 0 ) { if( relevant->gun_current_mode().melee() ) { refresh = true; diff --git a/src/reachability_cache.cpp b/src/reachability_cache.cpp index 71185e21..6c06260b 100644 --- a/src/reachability_cache.cpp +++ b/src/reachability_cache.cpp @@ -171,7 +171,7 @@ bool reachability_cache::has_potential_los( dirty_any = false; } - point dp = ( to - from ); + point dp = to - from; int d = std::abs( dp.x ) + std::abs( dp.y ); bool south = to.y > from.y; diff --git a/src/recipe_dictionary.cpp b/src/recipe_dictionary.cpp index 76f2813c..9468daf5 100644 --- a/src/recipe_dictionary.cpp +++ b/src/recipe_dictionary.cpp @@ -428,7 +428,7 @@ recipe &recipe_dictionary::load( const JsonObject &jo, const std::string &src, // defer entries dependent upon as-yet unparsed definitions if( jo.has_string( "copy-from" ) ) { - auto base = recipe_id( jo.get_string( "copy-from" ) ); + recipe_id base = recipe_id(jo.get_string("copy-from")); if( !out.count( base ) ) { deferred.emplace_back( jo, src ); jo.allow_omitted_members(); diff --git a/src/safe_reference.cpp b/src/safe_reference.cpp index 2264915a..2d63b8fe 100644 --- a/src/safe_reference.cpp +++ b/src/safe_reference.cpp @@ -1,7 +1,7 @@ #include "safe_reference.h" -static_assert( std::is_nothrow_move_constructible::value, "" ); -static_assert( std::is_nothrow_move_assignable::value, "" ); +static_assert(std::is_nothrow_move_constructible::value); +static_assert(std::is_nothrow_move_assignable::value); safe_reference_anchor::safe_reference_anchor() { diff --git a/src/sdlsound.cpp b/src/sdlsound.cpp index c22729d9..24547b1f 100644 --- a/src/sdlsound.cpp +++ b/src/sdlsound.cpp @@ -434,8 +434,8 @@ void play_music( const std::string &playlist ) // Son't need to worry about the determinism check here because it only // affects audio, not game logic. // NOLINTNEXTLINE(cata-determinism) - static auto eng = cata_default_random_engine( - std::chrono::system_clock::now().time_since_epoch().count() ); + static cata_default_random_engine eng = cata_default_random_engine( + std::chrono::system_clock::now().time_since_epoch().count()); std::shuffle( playlist_indexes.begin(), playlist_indexes.end(), eng ); } diff --git a/src/simple_pathfinding.cpp b/src/simple_pathfinding.cpp index e7905ad8..72f9e08c 100644 --- a/src/simple_pathfinding.cpp +++ b/src/simple_pathfinding.cpp @@ -294,7 +294,7 @@ simple_path find_overmap_path( const tripoint_abs_omt &source, constexpr int max_search_count = 100000; constexpr auto report_period = std::chrono::milliseconds( 100 ); - auto report_next = std::chrono::steady_clock::now(); + std::chrono::steady_clock::time_point report_next = std::chrono::steady_clock::now(); int progress = 0; while( !open_set.empty() ) { const node_address cur_addr = open_set.top().addr; diff --git a/src/skill.cpp b/src/skill.cpp index 539d9019..b83f0491 100644 --- a/src/skill.cpp +++ b/src/skill.cpp @@ -481,7 +481,7 @@ int SkillLevelMap::get_skill_level( const skill_id &ident ) const int SkillLevelMap::get_skill_level( const skill_id &ident, const item &context ) const { - const auto id = context.is_null() ? ident : context.contextualize_skill( ident ); + const skill_id id = context.is_null() ? ident : context.contextualize_skill(ident); return get_skill_level( id ); } @@ -492,7 +492,7 @@ int SkillLevelMap::get_knowledge_level( const skill_id &ident ) const int SkillLevelMap::get_knowledge_level( const skill_id &ident, const item &context ) const { - const auto id = context.is_null() ? ident : context.contextualize_skill( ident ); + const skill_id id = context.is_null() ? ident : context.contextualize_skill(ident); return get_knowledge_level( id ); } diff --git a/src/sounds.cpp b/src/sounds.cpp index 244d7879..1dcc1261 100644 --- a/src/sounds.cpp +++ b/src/sounds.cpp @@ -68,8 +68,10 @@ static bool audio_muted = false; static weather_type_id previous_weather; static cata::optional previous_is_night; static float g_sfx_volume_multiplier = 1.0f; -static auto start_sfx_timestamp = std::chrono::high_resolution_clock::now(); -static auto end_sfx_timestamp = std::chrono::high_resolution_clock::now(); +static std::chrono::high_resolution_clock::time_point start_sfx_timestamp = +std::chrono::high_resolution_clock::now(); +static std::chrono::high_resolution_clock::time_point end_sfx_timestamp = +std::chrono::high_resolution_clock::now(); static auto sfx_time = end_sfx_timestamp - start_sfx_timestamp; static activity_id act; static std::pair engine_external_id_and_variant; diff --git a/src/trait_group.cpp b/src/trait_group.cpp index bcad2fc1..17c117ed 100644 --- a/src/trait_group.cpp +++ b/src/trait_group.cpp @@ -122,7 +122,7 @@ void trait_group::debug_spawn() Trait_list Trait_creation_data::create() const { RecursionList rec; - auto result = create( rec ); + trait_group::Trait_list result = create(rec); return result; } diff --git a/src/veh_utils.cpp b/src/veh_utils.cpp index faae9f1e..fbf0b628 100644 --- a/src/veh_utils.cpp +++ b/src/veh_utils.cpp @@ -163,7 +163,7 @@ bool repair_part( vehicle &veh, vehicle_part &pt, Character &who, const std::str if( wasbroken ) { const units::angle dir = pt.direction; point loc = pt.mount; - auto replacement_id = pt.info().get_id(); + vpart_id replacement_id = pt.info().get_id(); get_map().spawn_items( who.pos(), pt.pieces_for_broken_part() ); veh.remove_part( part_index ); const int partnum = veh.install_part( loc, replacement_id, std::move( base ), variant ); diff --git a/src/vehicle_part.cpp b/src/vehicle_part.cpp index efa59690..0c8f7113 100644 --- a/src/vehicle_part.cpp +++ b/src/vehicle_part.cpp @@ -101,7 +101,7 @@ item vehicle_part::properties_to_item() const std::string vehicle_part::name( bool with_prefix ) const { - auto res = info().name(); + std::string res = info().name(); if( base.engine_displacement() > 0 ) { res.insert( 0, string_format( _( "%2.1fL " ), base.engine_displacement() / 100.0 ) ); diff --git a/src/weighted_list.h b/src/weighted_list.h index 173681f5..2489e579 100644 --- a/src/weighted_list.h +++ b/src/weighted_list.h @@ -254,7 +254,7 @@ template struct weighted_int_list : public weighted_list { std::vector precalc_array; }; -static_assert( std::is_nothrow_move_constructible>::value, "" ); +static_assert(std::is_nothrow_move_constructible>::value); template struct weighted_float_list : public weighted_list { diff --git a/src/worldfactory.cpp b/src/worldfactory.cpp index 8548c0c9..88b087f6 100644 --- a/src/worldfactory.cpp +++ b/src/worldfactory.cpp @@ -2121,8 +2121,8 @@ void load_world_option( const JsonObject &jo ) //load external option from json void load_external_option( const JsonObject &jo ) { - auto name = jo.get_string( "name" ); - auto stype = jo.get_string( "stype" ); + std::string name = jo.get_string("name"); + std::string stype = jo.get_string("stype"); options_manager &opts = get_options(); if( !opts.has_option( name ) ) { translation sinfo;