diff --git a/.clang-tidy b/.clang-tidy index 963979fa159c3..7970815bfe1f6 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -41,7 +41,6 @@ readability-*,\ -misc-redundant-expression,\ -modernize-avoid-c-arrays,\ -modernize-deprecated-headers,\ --modernize-make-unique,\ -modernize-pass-by-value,\ -modernize-raw-string-literal,\ -modernize-return-braced-init-list,\ diff --git a/src/game.cpp b/src/game.cpp index 0b57ae7ecaf60..f6b83f9cfcbb1 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -275,7 +276,7 @@ game::game() : { player_was_sleeping = false; reset_light_level(); - world_generator.reset( new worldfactory() ); + world_generator = std::make_unique(); // do nothing, everything that was in here is moved to init_data() which is called immediately after g = new game; in main.cpp // The reason for this move is so that g is not uninitialized when it gets to installing the parts into vehicles. } @@ -663,7 +664,7 @@ void game::load_map( const tripoint &pos_sm ) bool game::start_game() { if( !gamemode ) { - gamemode.reset( new special_game() ); + gamemode = std::make_unique(); } seed = rng_bits(); @@ -1206,7 +1207,7 @@ bool game::cleanup_at_end() popup( message.str(), PF_NONE ); } if( gamemode ) { - gamemode.reset( new special_game() ); // null gamemode or something.. + gamemode = std::make_unique(); // null gamemode or something.. } } @@ -2646,7 +2647,7 @@ void game::load( const save_t &name ) u.recalc_sight_limits(); if( !gamemode ) { - gamemode.reset( new special_game() ); + gamemode = std::make_unique(); } safe_mode = get_option( "SAFEMODE" ) ? SAFE_MODE_ON : SAFE_MODE_OFF; @@ -10160,7 +10161,7 @@ void game::vertical_move( int movez, bool force ) std::unique_ptr tmp_map_ptr; if( !m.has_zlevels() ) { - tmp_map_ptr.reset( new map() ); + tmp_map_ptr = std::make_unique(); } map &maybetmp = m.has_zlevels() ? m : *( tmp_map_ptr.get() ); diff --git a/src/gamemode.cpp b/src/gamemode.cpp index 0e34af481e012..bca76308b095a 100644 --- a/src/gamemode.cpp +++ b/src/gamemode.cpp @@ -1,5 +1,7 @@ #include "gamemode.h" +#include + #include "debug.h" #include "translations.h" @@ -23,17 +25,17 @@ std::unique_ptr get_special_game( special_game_id id ) std::unique_ptr ret; switch( id ) { case SGAME_NULL: - ret.reset( new special_game ); + ret = std::make_unique(); break; case SGAME_TUTORIAL: - ret.reset( new tutorial_game ); + ret = std::make_unique(); break; case SGAME_DEFENSE: - ret.reset( new defense_game ); + ret = std::make_unique(); break; default: debugmsg( "Missing something in gamemode.cpp:get_special_game()?" ); - ret.reset( new special_game ); + ret = std::make_unique(); break; } diff --git a/src/item_factory.cpp b/src/item_factory.cpp index 0df1bd6db99e3..f1267410c205c 100644 --- a/src/item_factory.cpp +++ b/src/item_factory.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -574,7 +575,7 @@ void Item_factory::add_item_type( const itype &def ) } auto &new_item_ptr = m_runtimes[ def.id ]; - new_item_ptr.reset( new itype( def ) ); + new_item_ptr = std::make_unique( def ); if( frozen ) { finalize_pre( *new_item_ptr ); finalize_post( *new_item_ptr ); @@ -812,7 +813,8 @@ void Item_factory::init() add_actor( new sew_advanced_actor() ); // An empty dummy group, it will not spawn anything. However, it makes that item group // id valid, so it can be used all over the place without need to explicitly check for it. - m_template_groups["EMPTY_GROUP"].reset( new Item_group( Item_group::G_COLLECTION, 100, 0, 0 ) ); + m_template_groups["EMPTY_GROUP"] = std::make_unique( Item_group::G_COLLECTION, 100, 0, + 0 ); } bool Item_factory::check_ammo_type( std::ostream &msg, const ammotype &ammo ) const @@ -2458,12 +2460,12 @@ void Item_factory::add_entry( Item_group &ig, JsonObject &obj ) int probability = obj.get_int( "prob", 100 ); JsonArray jarr; if( obj.has_member( "collection" ) ) { - gptr.reset( new Item_group( Item_group::G_COLLECTION, probability, ig.with_ammo, - ig.with_magazine ) ); + gptr = std::make_unique( Item_group::G_COLLECTION, probability, ig.with_ammo, + ig.with_magazine ); jarr = obj.get_array( "collection" ); } else if( obj.has_member( "distribution" ) ) { - gptr.reset( new Item_group( Item_group::G_DISTRIBUTION, probability, ig.with_ammo, - ig.with_magazine ) ); + gptr = std::make_unique( Item_group::G_DISTRIBUTION, probability, ig.with_ammo, + ig.with_magazine ); jarr = obj.get_array( "distribution" ); } if( gptr ) { @@ -2477,11 +2479,11 @@ void Item_factory::add_entry( Item_group &ig, JsonObject &obj ) std::unique_ptr sptr; if( obj.has_member( "item" ) ) { - sptr.reset( new Single_item_creator( obj.get_string( "item" ), Single_item_creator::S_ITEM, - probability ) ); + sptr = std::make_unique( + obj.get_string( "item" ), Single_item_creator::S_ITEM, probability ); } else if( obj.has_member( "group" ) ) { - sptr.reset( new Single_item_creator( obj.get_string( "group" ), Single_item_creator::S_ITEM_GROUP, - probability ) ); + sptr = std::make_unique( + obj.get_string( "group" ), Single_item_creator::S_ITEM_GROUP, probability ); } if( !sptr ) { return; diff --git a/src/loading_ui.cpp b/src/loading_ui.cpp index b8e5d79a39aed..c3d9336515ccd 100644 --- a/src/loading_ui.cpp +++ b/src/loading_ui.cpp @@ -1,5 +1,7 @@ #include "loading_ui.h" +#include + #include "color.h" #include "output.h" #include "ui.h" @@ -19,7 +21,7 @@ extern bool test_mode; loading_ui::loading_ui( bool display ) { if( display && !test_mode ) { - menu.reset( new uilist ); + menu = std::make_unique(); menu->settext( _( "Loading" ) ); } } diff --git a/src/main.cpp b/src/main.cpp index db6da7900822f..23afd7a9304fe 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -613,7 +613,7 @@ int main( int argc, char *argv[] ) rng_set_engine_seed( seed ); - g.reset( new game ); + g = std::make_unique(); // First load and initialize everything that does not // depend on the mods. try { diff --git a/src/mapgen.cpp b/src/mapgen.cpp index ff78283128f6a..4f135c1162033 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -7175,7 +7176,7 @@ computer *map::add_computer( const tripoint &p, const std::string &name, int sec { ter_set( p, t_console ); // TODO: Turn this off? submap *place_on_submap = get_submap_at( p ); - place_on_submap->comp.reset( new computer( name, security ) ); + place_on_submap->comp = std::make_unique( name, security ); return place_on_submap->comp.get(); } diff --git a/src/mutation_data.cpp b/src/mutation_data.cpp index 818236afbd48f..a88f8e17b44bb 100644 --- a/src/mutation_data.cpp +++ b/src/mutation_data.cpp @@ -1,6 +1,7 @@ #include "mutation.h" // IWYU pragma: associated #include +#include #include #include #include @@ -715,10 +716,10 @@ void mutation_branch::add_entry( Trait_group &tg, JsonObject &obj ) JsonArray jarr; if( obj.has_member( "collection" ) ) { - ptr.reset( new Trait_group_collection( probability ) ); + ptr = std::make_unique( probability ); jarr = obj.get_array( "collection" ); } else if( obj.has_member( "distribution" ) ) { - ptr.reset( new Trait_group_distribution( probability ) ); + ptr = std::make_unique( probability ); jarr = obj.get_array( "distribution" ); } @@ -734,10 +735,11 @@ void mutation_branch::add_entry( Trait_group &tg, JsonObject &obj ) if( obj.has_member( "trait" ) ) { trait_id id( obj.get_string( "trait" ) ); - ptr.reset( new Single_trait_creator( id, probability ) ); + ptr = std::make_unique( id, probability ); } else if( obj.has_member( "group" ) ) { - ptr.reset( new Trait_group_creator( trait_group::Trait_group_tag( obj.get_string( "group" ) ), - probability ) ); + ptr = std::make_unique( trait_group::Trait_group_tag( + obj.get_string( "group" ) ), + probability ); } if( !ptr ) { diff --git a/src/npcmove.cpp b/src/npcmove.cpp index 9d3a8c7d52a7b..681bafb7c4312 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -2162,7 +2162,7 @@ void npc::move_to( const tripoint &pt, bool no_bashing, std::set *nomo realnomove = nomove; } else { // create the no-move list - newnomove.reset( new std::set() ); + newnomove = std::make_unique>(); realnomove = newnomove.get(); } // other npcs should not try to move into this npc anymore, diff --git a/src/pixel_minimap.cpp b/src/pixel_minimap.cpp index 06044df9a563e..da12dbe2842e5 100644 --- a/src/pixel_minimap.cpp +++ b/src/pixel_minimap.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -379,7 +380,7 @@ void pixel_minimap::set_screen_rect( const SDL_Rect &screen_rect ) cache.clear(); main_tex = create_cache_texture( renderer, clip_rect.w, clip_rect.h ); - tex_pool.reset( new shared_texture_pool() ); + tex_pool = std::make_unique(); for( auto &elem : tex_pool->texture_pool ) { elem = create_cache_texture( renderer, tile_size.x * SEEX, tile_size.y * SEEY ); diff --git a/src/projectile.cpp b/src/projectile.cpp index 949787b148100..114af6e23aeb1 100644 --- a/src/projectile.cpp +++ b/src/projectile.cpp @@ -1,5 +1,6 @@ #include "projectile.h" +#include #include #include "explosion.h" @@ -50,7 +51,7 @@ void projectile::set_drop( const item &it ) if( it.is_null() ) { unset_drop(); } else { - drop.reset( new item( it ) ); + drop = std::make_unique( it ); } } @@ -59,7 +60,7 @@ void projectile::set_drop( item &&it ) if( it.is_null() ) { unset_drop(); } else { - drop.reset( new item( std::move( it ) ) ); + drop = std::make_unique( std::move( it ) ); } } @@ -80,7 +81,7 @@ const explosion_data &projectile::get_custom_explosion() const void projectile::set_custom_explosion( const explosion_data &ex ) { - custom_explosion.reset( new explosion_data( ex ) ); + custom_explosion = std::make_unique( ex ); } void projectile::unset_custom_explosion() diff --git a/src/sdltiles.cpp b/src/sdltiles.cpp index 360d85e78a9a3..9fdeb3b392fd7 100644 --- a/src/sdltiles.cpp +++ b/src/sdltiles.cpp @@ -3440,7 +3440,7 @@ void catacurses::init_interface() WinCreate(); dbg( D_INFO ) << "Initializing SDL Tiles context"; - tilecontext.reset( new cata_tiles( renderer ) ); + tilecontext = std::make_unique( renderer ); try { tilecontext->load_tileset( get_option( "TILES" ), true ); } catch( const std::exception &err ) { diff --git a/src/string_input_popup.cpp b/src/string_input_popup.cpp index f047ceb3eb5d2..fffe03c47b0da 100644 --- a/src/string_input_popup.cpp +++ b/src/string_input_popup.cpp @@ -18,6 +18,7 @@ #include #include +#include #include string_input_popup::string_input_popup() = default; @@ -92,7 +93,7 @@ void string_input_popup::create_window() void string_input_popup::create_context() { - ctxt_ptr.reset( new input_context( "STRING_INPUT" ) ); + ctxt_ptr = std::make_unique( "STRING_INPUT" ); ctxt = ctxt_ptr.get(); ctxt->register_action( "ANY_INPUT" ); } diff --git a/src/veh_type.cpp b/src/veh_type.cpp index 0b4ca5d8be654..aeb48f0690005 100644 --- a/src/veh_type.cpp +++ b/src/veh_type.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -1060,7 +1061,7 @@ void vehicle_prototype::finalize() // Calls the default constructor to create an empty vehicle. Calling the constructor with // the type as parameter would make it look up the type in the map and copy the // (non-existing) blueprint. - proto.blueprint.reset( new vehicle() ); + proto.blueprint = std::make_unique(); vehicle &blueprint = *proto.blueprint; blueprint.type = id; blueprint.name = _( proto.name ); diff --git a/src/worldfactory.cpp b/src/worldfactory.cpp index bdf1cde9db84e..d253e0020773b 100644 --- a/src/worldfactory.cpp +++ b/src/worldfactory.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -276,7 +277,7 @@ void worldfactory::init() worldname = native_to_utf8( world_dir.substr( name_index + 1 ) ); // create and store the world - all_worlds[worldname].reset( new WORLD() ); + all_worlds[worldname] = std::make_unique(); // give the world a name all_worlds[worldname]->world_name = worldname; // add sav files diff --git a/tests/test_main.cpp b/tests/test_main.cpp index ade48ede0e0e0..6d5e243d68314 100644 --- a/tests/test_main.cpp +++ b/tests/test_main.cpp @@ -129,7 +129,7 @@ static void init_global_game_state( const std::vector &mods, } init_colors(); - g.reset( new game ); + g = std::make_unique( ); g->new_game = true; g->load_static_data();