From 16b832f4f5ed8a5f235f078f5218157574e95a5f Mon Sep 17 00:00:00 2001 From: Andrew Krieger Date: Sun, 13 Oct 2024 20:12:17 -0700 Subject: [PATCH] s/_path_path()/_path()/g --- src/auto_note.cpp | 4 ++-- src/auto_pickup.cpp | 6 +++--- src/clzones.cpp | 4 ++-- src/debug_menu.cpp | 2 +- src/diary.cpp | 6 +++--- src/game.cpp | 32 ++++++++++++++++---------------- src/json_loader.cpp | 2 +- src/main_menu.cpp | 2 +- src/map_memory.cpp | 2 +- src/mapbuffer.cpp | 4 ++-- src/mod_manager.cpp | 2 +- src/overmapbuffer.cpp | 4 ++-- src/path_info.cpp | 2 +- src/path_info.h | 6 +++--- src/safemode_ui.cpp | 6 +++--- src/translations.cpp | 4 ++-- src/worldfactory.cpp | 18 +++++++++--------- src/worldfactory.h | 2 +- tests/name_test.cpp | 2 +- 19 files changed, 55 insertions(+), 55 deletions(-) diff --git a/src/auto_note.cpp b/src/auto_note.cpp index da41e961b41f7..7df0132a5db7d 100644 --- a/src/auto_note.cpp +++ b/src/auto_note.cpp @@ -31,7 +31,7 @@ namespace auto_notes { cata_path auto_note_settings::build_save_path() const { - return PATH_INFO::player_base_save_path_path() + ".ano.json"; + return PATH_INFO::player_base_save_path() + ".ano.json"; } void auto_note_settings::clear() @@ -42,7 +42,7 @@ void auto_note_settings::clear() bool auto_note_settings::save( bool bCharacter ) { - if( bCharacter && !file_exist( PATH_INFO::player_base_save_path_path() + ".sav" ) ) { + if( bCharacter && !file_exist( PATH_INFO::player_base_save_path() + ".sav" ) ) { return true; } cata_path sGlobalFile = PATH_INFO::autonote(); diff --git a/src/auto_pickup.cpp b/src/auto_pickup.cpp index 36b7c93284572..c8922fa3bce75 100644 --- a/src/auto_pickup.cpp +++ b/src/auto_pickup.cpp @@ -937,9 +937,9 @@ bool player_settings::save( const bool bCharacter ) cata_path savefile = PATH_INFO::autopickup(); if( bCharacter ) { - savefile = PATH_INFO::player_base_save_path_path() + ".apu.json"; + savefile = PATH_INFO::player_base_save_path() + ".apu.json"; - const cata_path player_save = PATH_INFO::player_base_save_path_path() + ".sav"; + const cata_path player_save = PATH_INFO::player_base_save_path() + ".sav"; //Character not saved yet. if( !file_exist( player_save ) ) { return true; @@ -966,7 +966,7 @@ void player_settings::load( const bool bCharacter ) { cata_path sFile = PATH_INFO::autopickup(); if( bCharacter ) { - sFile = PATH_INFO::player_base_save_path_path() + ".apu.json"; + sFile = PATH_INFO::player_base_save_path() + ".apu.json"; } read_from_file_optional_json( sFile, [&]( const JsonValue & jv ) { diff --git a/src/clzones.cpp b/src/clzones.cpp index ebc543ab82fb8..9f285e6eb0d0b 100644 --- a/src/clzones.cpp +++ b/src/clzones.cpp @@ -1693,9 +1693,9 @@ namespace cata_path _savefile( std::string const &suffix, bool player ) { if( player ) { - return PATH_INFO::player_base_save_path_path() + string_format( ".zones%s.json", suffix ); + return PATH_INFO::player_base_save_path() + string_format( ".zones%s.json", suffix ); } else { - return PATH_INFO::world_base_save_path_path() / string_format( "zones%s.json", suffix ); + return PATH_INFO::world_base_save_path() / string_format( "zones%s.json", suffix ); } } } // namespace diff --git a/src/debug_menu.cpp b/src/debug_menu.cpp index 4661a5f13545b..7041d3e9bf664 100644 --- a/src/debug_menu.cpp +++ b/src/debug_menu.cpp @@ -402,7 +402,7 @@ void write_min_archive() tripoint_abs_om const om = project_to( get_avatar().get_location() ); tripoint_range const oms = points_in_radius( tripoint{ om.raw().xy(), 0 }, 1 ); - fs::path const save_root( PATH_INFO::world_base_save_path_path() ); + fs::path const save_root( PATH_INFO::world_base_save_path() ); std::string const ofile = save_root.string() + "-trimmed.tar.gz"; tgz_archiver tgz( ofile ); diff --git a/src/diary.cpp b/src/diary.cpp index a4316083884f6..346527c7be05c 100644 --- a/src/diary.cpp +++ b/src/diary.cpp @@ -674,7 +674,7 @@ void diary::export_to_txt( bool lastexport ) { std::ofstream myfile; cata_path path = lastexport ? PATH_INFO::memorialdir_path() : - PATH_INFO::world_base_save_path_path(); + PATH_INFO::world_base_save_path(); path = path / ( owner + "s_diary.txt" ); myfile.open( path.get_unrelative_path() ); @@ -697,7 +697,7 @@ void diary::export_to_txt( bool lastexport ) bool diary::store() { std::string name = base64_encode( get_avatar().get_save_id() + "_diary" ); - cata_path path = PATH_INFO::world_base_save_path_path() / ( name + ".json" ); + cata_path path = PATH_INFO::world_base_save_path() / ( name + ".json" ); const bool iswriten = write_to_file( path, [&]( std::ostream & fout ) { serialize( fout ); }, _( "diary data" ) ); @@ -748,7 +748,7 @@ void diary::serialize( JsonOut &jsout ) void diary::load() { std::string name = base64_encode( get_avatar().get_save_id() + "_diary" ); - cata_path path = PATH_INFO::world_base_save_path_path() / ( name + ".json" ); + cata_path path = PATH_INFO::world_base_save_path() / ( name + ".json" ); if( file_exist( path ) ) { read_from_file_json( path, [&]( const JsonValue & jv ) { deserialize( jv ); diff --git a/src/game.cpp b/src/game.cpp index d9547889ebd1e..ec0a28c38bc9e 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2991,7 +2991,7 @@ static std::string timestamp_now() void game::move_save_to_graveyard() { - const cata_path save_dir = PATH_INFO::world_base_save_path_path(); + const cata_path save_dir = PATH_INFO::world_base_save_path(); const cata_path graveyard_dir = PATH_INFO::graveyarddir_path() / timestamp_now(); const std::string prefix = base64_encode( u.get_save_id() ) + "."; @@ -3023,7 +3023,7 @@ void game::move_save_to_graveyard() void game::load_master() { - const cata_path datafile = PATH_INFO::world_base_save_path_path() / SAVE_MASTER; + const cata_path datafile = PATH_INFO::world_base_save_path() / SAVE_MASTER; read_from_file_optional( datafile, [this, &datafile]( std::istream & is ) { unserialize_master( datafile, is ); } ); @@ -3055,8 +3055,8 @@ bool game::load( const std::string &world ) bool game::load( const save_t &name ) { - const cata_path worldpath = PATH_INFO::world_base_save_path_path(); - const cata_path save_file_path = PATH_INFO::world_base_save_path_path() / + const cata_path worldpath = PATH_INFO::world_base_save_path(); + const cata_path save_file_path = PATH_INFO::world_base_save_path() / ( name.base_path() + SAVE_EXTENSION ); bool abort = false; @@ -3138,7 +3138,7 @@ bool game::load( const save_t &name ) get_safemode().load_character(); // Load character safemode rules zone_manager::get_manager().load_zones(); // Load character world zones read_from_file_optional_json( - PATH_INFO::world_base_save_path_path() / "uistate.json", + PATH_INFO::world_base_save_path() / "uistate.json", []( const JsonValue & jsin ) { uistate.deserialize( jsin.get_object() ); } ); @@ -3243,8 +3243,8 @@ void game::load_world_modfiles() load_packs( _( "Loading files" ), mods ); // Load additional mods from that world-specific folder - load_mod_data_from_dir( PATH_INFO::world_base_save_path_path() / "mods", "custom" ); - load_mod_interaction_data_from_dir( PATH_INFO::world_base_save_path_path() / "mods" / + load_mod_data_from_dir( PATH_INFO::world_base_save_path() / "mods", "custom" ); + load_mod_interaction_data_from_dir( PATH_INFO::world_base_save_path() / "mods" / "mod_interactions", "custom" ); DynamicDataLoader::get_instance().finalize_loaded_data(); @@ -3328,7 +3328,7 @@ void game::reset_npc_dispositions() //Saves all factions and missions and npcs. bool game::save_factions_missions_npcs() { - cata_path masterfile = PATH_INFO::world_base_save_path_path() / SAVE_MASTER; + cata_path masterfile = PATH_INFO::world_base_save_path() / SAVE_MASTER; return write_to_file( masterfile, [&]( std::ostream & fout ) { serialize_master( fout ); }, _( "factions data" ) ); @@ -3349,7 +3349,7 @@ bool game::save_maps() bool game::save_player_data() { - const cata_path playerfile = PATH_INFO::player_base_save_path_path(); + const cata_path playerfile = PATH_INFO::player_base_save_path(); const bool saved_data = write_to_file( playerfile + SAVE_EXTENSION, [&]( std::ostream & fout ) { serialize( fout ); @@ -3495,7 +3495,7 @@ bool game::save() !get_auto_notes_settings().save( true ) || !get_safemode().save_character() || !zone_manager::get_manager().save_zones() || - !write_to_file( PATH_INFO::world_base_save_path_path() / "uistate.json", [&]( + !write_to_file( PATH_INFO::world_base_save_path() / "uistate.json", [&]( std::ostream & fout ) { JsonOut jsout( fout ); uistate.serialize( jsout ); @@ -3507,7 +3507,7 @@ bool game::save() world_generator->last_character_name = u.name; world_generator->save_last_world_info(); world_generator->active_world->add_save( save_t::from_save_id( u.get_save_id() ) ); - write_to_file( PATH_INFO::world_base_save_path_path() / ( base64_encode( + write_to_file( PATH_INFO::world_base_save_path() / ( base64_encode( u.get_save_id() ) + ".pt" ), [&total_time_played]( std::ostream & fout ) { fout.imbue( std::locale::classic() ); fout << total_time_played.count(); @@ -8015,7 +8015,7 @@ bool game::take_screenshot( const std::string &path ) const bool game::take_screenshot() const { // check that the current '/screenshots' directory exists - cata_path map_directory = PATH_INFO::world_base_save_path_path() / "screenshots"; + cata_path map_directory = PATH_INFO::world_base_save_path() / "screenshots"; assure_dir_exist( map_directory ); // build file name: /screenshots/[]_.png @@ -13264,17 +13264,17 @@ Creature *game::get_creature_if( const std::function & return nullptr; } -cata_path PATH_INFO::player_base_save_path_path() +cata_path PATH_INFO::player_base_save_path() { - return PATH_INFO::world_base_save_path_path() / base64_encode( get_avatar().get_save_id() ); + return PATH_INFO::world_base_save_path() / base64_encode( get_avatar().get_save_id() ); } -cata_path PATH_INFO::world_base_save_path_path() +cata_path PATH_INFO::world_base_save_path() { if( world_generator->active_world == nullptr ) { return PATH_INFO::savedir_path(); } - return world_generator->active_world->folder_path_path(); + return world_generator->active_world->folder_path(); } void game::shift_destination_preview( const point &delta ) diff --git a/src/json_loader.cpp b/src/json_loader.cpp index 45acdefba9010..0672ab8d75c03 100644 --- a/src/json_loader.cpp +++ b/src/json_loader.cpp @@ -14,7 +14,7 @@ namespace { flexbuffer_cache &base_cache() { - static flexbuffer_cache cache{ ( PATH_INFO::base_path_path() / "cache" ).get_unrelative_path(), PATH_INFO::base_path_path().get_unrelative_path() }; + static flexbuffer_cache cache{ ( PATH_INFO::base_path() / "cache" ).get_unrelative_path(), PATH_INFO::base_path().get_unrelative_path() }; return cache; } diff --git a/src/main_menu.cpp b/src/main_menu.cpp index e28a802323792..e6069426154c0 100644 --- a/src/main_menu.cpp +++ b/src/main_menu.cpp @@ -1126,7 +1126,7 @@ bool main_menu::load_game( std::string const &worldname, save_t const &savegame static std::optional get_playtime_from_save( const WORLD *world, const save_t &save ) { - cata_path playtime_file = world->folder_path_path() / ( save.base_path() + ".pt" ); + cata_path playtime_file = world->folder_path() / ( save.base_path() + ".pt" ); std::optional pt_seconds; if( file_exist( playtime_file ) ) { read_from_file( playtime_file, [&pt_seconds]( std::istream & fin ) { diff --git a/src/map_memory.cpp b/src/map_memory.cpp index da2ec7ae6ae7b..790801e283869 100644 --- a/src/map_memory.cpp +++ b/src/map_memory.cpp @@ -19,7 +19,7 @@ static constexpr int MM_SIZE = MAPSIZE * 2; static cata_path find_mm_dir() { - return PATH_INFO::player_base_save_path_path() + ".mm1"; + return PATH_INFO::player_base_save_path() + ".mm1"; } static cata_path find_region_path( const cata_path &dirname, const tripoint &p ) diff --git a/src/mapbuffer.cpp b/src/mapbuffer.cpp index bc9e5f905c223..0f0dd6216b3d8 100644 --- a/src/mapbuffer.cpp +++ b/src/mapbuffer.cpp @@ -40,7 +40,7 @@ static cata_path find_quad_path( const cata_path &dirname, const tripoint_abs_om static cata_path find_dirname( const tripoint_abs_omt &om_addr ) { const tripoint_abs_seg segment_addr = project_to( om_addr ); - return PATH_INFO::world_base_save_path_path() / "maps" / string_format( "%d.%d.%d", + return PATH_INFO::world_base_save_path() / "maps" / string_format( "%d.%d.%d", segment_addr.x(), segment_addr.y(), segment_addr.z() ); } @@ -136,7 +136,7 @@ bool mapbuffer::submap_exists( const tripoint_abs_sm &p ) void mapbuffer::save( bool delete_after_save ) { - assure_dir_exist( PATH_INFO::world_base_save_path_path() / "maps" ); + assure_dir_exist( PATH_INFO::world_base_save_path() / "maps" ); int num_saved_submaps = 0; int num_total_submaps = submaps.size(); diff --git a/src/mod_manager.cpp b/src/mod_manager.cpp index 579deec2b959d..2420f1a0ec88a 100644 --- a/src/mod_manager.cpp +++ b/src/mod_manager.cpp @@ -380,7 +380,7 @@ void mod_manager::load_mod_info( const cata_path &info_file_path ) cata_path mod_manager::get_mods_list_file( const WORLD *world ) { - return world->folder_path_path() / "mods.json"; + return world->folder_path() / "mods.json"; } void mod_manager::save_mods_list( const WORLD *world ) const diff --git a/src/overmapbuffer.cpp b/src/overmapbuffer.cpp index 244ee6b1c13a9..79d96a87e3966 100644 --- a/src/overmapbuffer.cpp +++ b/src/overmapbuffer.cpp @@ -71,12 +71,12 @@ int camp_reference::get_distance_from_bounds() const cata_path overmapbuffer::terrain_filename( const point_abs_om &p ) { - return PATH_INFO::world_base_save_path_path() / string_format( "o.%d.%d", p.x(), p.y() ); + return PATH_INFO::world_base_save_path() / string_format( "o.%d.%d", p.x(), p.y() ); } cata_path overmapbuffer::player_filename( const point_abs_om &p ) { - return PATH_INFO::player_base_save_path_path() + string_format( ".seen.%d.%d", p.x(), p.y() ); + return PATH_INFO::player_base_save_path() + string_format( ".seen.%d.%d", p.x(), p.y() ); } overmap &overmapbuffer::get( const point_abs_om &p ) diff --git a/src/path_info.cpp b/src/path_info.cpp index edd2c89afd719..10c748437ab91 100644 --- a/src/path_info.cpp +++ b/src/path_info.cpp @@ -223,7 +223,7 @@ cata_path PATH_INFO::base_colors() { return config_dir_path_value / "base_colors.json"; } -cata_path PATH_INFO::base_path_path() +cata_path PATH_INFO::base_path() { return base_path_path_value; } diff --git a/src/path_info.h b/src/path_info.h index d1d697abca142..4ecf948b839d6 100644 --- a/src/path_info.h +++ b/src/path_info.h @@ -54,7 +54,7 @@ std::string title( holiday current_holiday ); cata_path autopickup(); cata_path autonote(); cata_path base_colors(); -cata_path base_path_path(); +cata_path base_path(); cata_path color_templates(); cata_path color_themes(); cata_path colors(); @@ -82,7 +82,7 @@ cata_path mods_replacements(); cata_path names(); cata_path options(); cata_path panel_options(); -cata_path player_base_save_path_path(); +cata_path player_base_save_path(); cata_path pocket_presets(); cata_path safemode(); cata_path savedir_path(); @@ -92,7 +92,7 @@ cata_path user_gfx(); cata_path user_keybindings(); cata_path user_moddir_path(); cata_path user_sound(); -cata_path world_base_save_path_path(); +cata_path world_base_save_path(); void set_datadir( const std::string &datadir ); void set_config_dir( const std::string &config_dir ); diff --git a/src/safemode_ui.cpp b/src/safemode_ui.cpp index 6842b5d026c15..0e586dfd58282 100644 --- a/src/safemode_ui.cpp +++ b/src/safemode_ui.cpp @@ -785,8 +785,8 @@ bool safemode::save( const bool is_character_in ) cata_path file = PATH_INFO::safemode(); if( is_character ) { - file = PATH_INFO::player_base_save_path_path() + ".sfm.json"; - if( !file_exist( PATH_INFO::player_base_save_path_path() + ".sav" ) ) { + file = PATH_INFO::player_base_save_path() + ".sfm.json"; + if( !file_exist( PATH_INFO::player_base_save_path() + ".sav" ) ) { return true; //Character not saved yet. } } @@ -818,7 +818,7 @@ void safemode::load( const bool is_character_in ) std::ifstream fin; cata_path file = PATH_INFO::safemode(); if( is_character ) { - file = PATH_INFO::player_base_save_path_path() + ".sfm.json"; + file = PATH_INFO::player_base_save_path() + ".sfm.json"; } fs::path file_path = file.get_unrelative_path(); diff --git a/src/translations.cpp b/src/translations.cpp index 96c3a113951ff..84f1ec26860b4 100644 --- a/src/translations.cpp +++ b/src/translations.cpp @@ -53,8 +53,8 @@ std::string locale_dir() #endif #if !defined(__ANDROID__) && ((defined(__linux__) || defined(CATA_IS_ON_BSD) || (defined(MACOSX) && !defined(TILES)))) - if( !PATH_INFO::base_path_path().get_logical_root_path().empty() ) { - loc_dir = ( PATH_INFO::base_path_path() / "share" / "locale" ).generic_u8string(); + if( !PATH_INFO::base_path().get_logical_root_path().empty() ) { + loc_dir = ( PATH_INFO::base_path() / "share" / "locale" ).generic_u8string(); } else { loc_dir = PATH_INFO::langdir(); } diff --git a/src/worldfactory.cpp b/src/worldfactory.cpp index 90e9767da3133..ac0bc5109c16f 100644 --- a/src/worldfactory.cpp +++ b/src/worldfactory.cpp @@ -95,7 +95,7 @@ void WORLD::COPY_WORLD( const WORLD *world_to_copy ) active_mod_order = world_to_copy->active_mod_order; } -cata_path WORLD::folder_path_path() const +cata_path WORLD::folder_path() const { return PATH_INFO::savedir_path() / world_name; } @@ -295,7 +295,7 @@ void worldfactory::set_active_world( WORLD *world ) bool WORLD::save( const bool is_conversion ) const { - if( !assure_dir_exist( folder_path_path() ) ) { + if( !assure_dir_exist( folder_path() ) ) { debugmsg( "Unable to create or open world[%s] directory for saving", world_name ); DebugLog( D_ERROR, DC_ALL ) << "Unable to create or open world[" << world_name << "] directory for saving"; @@ -307,7 +307,7 @@ bool WORLD::save( const bool is_conversion ) const } if( !is_conversion ) { - const auto savefile = folder_path_path() / PATH_INFO::worldoptions(); + const auto savefile = folder_path() / PATH_INFO::worldoptions(); const bool saved = write_to_file( savefile, [&]( std::ostream & fout ) { JsonOut jout( fout ); @@ -421,12 +421,12 @@ void worldfactory::init() // save world as conversion world if( newworld->save( true ) ) { - const cata_path origin_path = old_world.folder_path_path(); + const cata_path origin_path = old_world.folder_path(); // move files from origin_path into new world path for( auto &origin_file : get_files_from_path( ".", origin_path, false ) ) { std::string filename = origin_file.get_relative_path().filename().generic_u8string(); - if( rename_file( origin_file, ( newworld->folder_path_path() / filename ) ) ) { + if( rename_file( origin_file, ( newworld->folder_path() / filename ) ) ) { debugmsg( "Error while moving world files: %s. World may have been corrupted", strerror( errno ) ); } @@ -2021,7 +2021,7 @@ bool WORLD::save_timestamp() const return true; } - const cata_path path = folder_path_path() / PATH_INFO::world_timestamp(); + const cata_path path = folder_path() / PATH_INFO::world_timestamp(); return write_to_file( path, [this]( std::ostream & file ) { JsonOut jsout( file ); jsout.write( timestamp ); @@ -2030,7 +2030,7 @@ bool WORLD::save_timestamp() const bool WORLD::load_timestamp() { - const cata_path path = folder_path_path() / PATH_INFO::world_timestamp(); + const cata_path path = folder_path() / PATH_INFO::world_timestamp(); return read_from_file_optional_json( path, [this]( const JsonValue & jv ) { const std::string ts = jv.get_string(); // Sanitize the string since it is used in paths @@ -2067,7 +2067,7 @@ bool WORLD::load_options() { WORLD_OPTIONS = get_options().get_world_defaults(); - const cata_path path = folder_path_path() / PATH_INFO::worldoptions(); + const cata_path path = folder_path() / PATH_INFO::worldoptions(); return read_from_file_optional_json( path, [this]( const JsonValue & jsin ) { this->load_options( jsin ); } ); @@ -2166,7 +2166,7 @@ static bool isForbidden( const cata_path &candidate ) void worldfactory::delete_world( const std::string &worldname, const bool delete_folder ) { - cata_path worldpath = get_world( worldname )->folder_path_path(); + cata_path worldpath = get_world( worldname )->folder_path(); std::set directory_paths; if( delete_folder ) { diff --git a/src/worldfactory.h b/src/worldfactory.h index a221ad600dd7a..9019b0945d362 100644 --- a/src/worldfactory.h +++ b/src/worldfactory.h @@ -56,7 +56,7 @@ struct WORLD { * all the world specific files. It depends on @ref world_name, * changing that will also change the result of this function. */ - cata_path folder_path_path() const; + cata_path folder_path() const; std::string world_name; options_manager::options_container WORLD_OPTIONS; diff --git a/tests/name_test.cpp b/tests/name_test.cpp index e3fdb847b7003..3cbb69b1bbcb9 100644 --- a/tests/name_test.cpp +++ b/tests/name_test.cpp @@ -27,7 +27,7 @@ class IsOneOf : public Catch::MatcherBase TEST_CASE( "name_generation", "[name]" ) { GIVEN( "Names loaded from tests/data/name.json" ) { - SNIPPET.reload_names( PATH_INFO::base_path_path() / "tests" / "data" / "name.json" ); + SNIPPET.reload_names( PATH_INFO::base_path() / "tests" / "data" / "name.json" ); WHEN( "Getting a town name" ) { std::string name = SNIPPET.expand( "" ); CHECK( name == "City" );