Skip to content

Commit f97f944

Browse files
committed
don't copy compression dictionary files to each dimension, as it's appearently not needed
1 parent 94d6d9f commit f97f944

File tree

6 files changed

+19
-41
lines changed

6 files changed

+19
-41
lines changed

src/game.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12771,8 +12771,6 @@ bool game::travel_to_dimension( const std::string &new_prefix )
1277112771
right now they're all the same and it's hard to tell if it's working or not. */
1277212772
// weather.set_nextweather( calendar::turn );
1277312773
//}
12774-
// Ensure the new world has compression files
12775-
world_generator->active_world->assure_compression_files_present();
1277612774
// Clear the immediate game area around the player
1277712775
MAPBUFFER.clear();
1277812776
// hack to prevent crashes from temperature checks

src/map_memory.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ shared_ptr_fast<mm_submap> map_memory::load_submap( const tripoint_abs_sm &sm_po
379379

380380
if( world_generator->active_world->has_compression_enabled() ) {
381381
std::shared_ptr<zzip_stack> z = zzip_stack::load( mm_dir.get_unrelative_path(),
382-
( PATH_INFO::current_dimension_save_path() / "mmr.dict" ).get_unrelative_path() );
382+
( PATH_INFO::world_base_save_path() / "mmr.dict" ).get_unrelative_path() );
383383
if( !z ) {
384384
return nullptr;
385385
}
@@ -494,7 +494,7 @@ bool map_memory::save( const tripoint_abs_ms &pos )
494494
std::shared_ptr<zzip_stack> z;
495495
if( world_generator->active_world->has_compression_enabled() ) {
496496
z = zzip_stack::load( dirname.get_unrelative_path(),
497-
( PATH_INFO::current_dimension_save_path() / "mmr.dict" ).get_unrelative_path() );
497+
( PATH_INFO::world_base_save_path() / "mmr.dict" ).get_unrelative_path() );
498498
}
499499
for( auto &it : regions ) {
500500
const tripoint &regp = it.first;

src/mapbuffer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ bool mapbuffer::submap_exists_approx( const tripoint_abs_sm &p )
163163
return false;
164164
}
165165
std::shared_ptr<zzip> z = zzip::load( zzip_name.get_unrelative_path(),
166-
( PATH_INFO::current_dimension_save_path() / "maps.dict" ).get_unrelative_path() );
166+
( PATH_INFO::world_base_save_path() / "maps.dict" ).get_unrelative_path() );
167167
return z->has_file( std::filesystem::u8path( file_name ) );
168168
} else {
169169
return file_exist( dirname / file_name );
@@ -257,7 +257,7 @@ void mapbuffer::save_quad(
257257
cata_path zzip_name = dirname;
258258
zzip_name += ".zzip";
259259
z = zzip::load( zzip_name.get_unrelative_path(),
260-
( PATH_INFO::current_dimension_save_path() / "maps.dict" ).get_unrelative_path() );
260+
( PATH_INFO::world_base_save_path() / "maps.dict" ).get_unrelative_path() );
261261
if( !z ) {
262262
throw std::runtime_error( "Failed opening compressed save file " +
263263
zzip_name.get_unrelative_path().generic_u8string() );
@@ -376,7 +376,7 @@ submap *mapbuffer::unserialize_submaps( const tripoint_abs_sm &p )
376376
return false;
377377
}
378378
std::shared_ptr<zzip> z = zzip::load( zzip_name.get_unrelative_path(),
379-
( PATH_INFO::current_dimension_save_path() / "maps.dict" ).get_unrelative_path() );
379+
( PATH_INFO::world_base_save_path() / "maps.dict" ).get_unrelative_path() );
380380
if( !z->has_file( file_name_path ) ) {
381381
return false;
382382
}

src/overmap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6690,7 +6690,7 @@ void overmap::open( overmap_special_batch &enabled_specials )
66906690
".zzip";
66916691
if( file_exist( zzip_path ) ) {
66926692
std::shared_ptr<zzip> z = zzip::load( zzip_path.get_unrelative_path(),
6693-
( PATH_INFO::current_dimension_save_path() / "overmaps.dict" ).get_unrelative_path()
6693+
( PATH_INFO::world_base_save_path() / "overmaps.dict" ).get_unrelative_path()
66946694
);
66956695

66966696
if( read_from_zzip_optional( z, terfilename_path, [this]( std::string_view sv ) {
@@ -6743,7 +6743,7 @@ void overmap::save() const
67436743
assure_dir_exist( overmaps_folder );
67446744
const cata_path zzip_path = overmaps_folder / terfilename_path + ".zzip";
67456745
std::shared_ptr<zzip> z = zzip::load( zzip_path.get_unrelative_path(),
6746-
( PATH_INFO::current_dimension_save_path() / "overmaps.dict" ).get_unrelative_path()
6746+
( PATH_INFO::world_base_save_path() / "overmaps.dict" ).get_unrelative_path()
67476747
);
67486748
if( !z ) {
67496749
throw std::runtime_error(

src/worldfactory.cpp

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,6 +2115,11 @@ bool WORLD::set_compression_enabled( bool enabled ) const
21152115

21162116
std::vector<cata_path> dimension_folders = get_directories( world_folder_path / "dimensions" );
21172117
dimension_folders.push_back( world_folder_path );
2118+
2119+
copy_file( maps_dict, world_folder_path / "maps.dict" );
2120+
copy_file( overmaps_dict, world_folder_path / "overmaps.dict" );
2121+
copy_file( mmr_dict, world_folder_path / "mmr.dict" );
2122+
21182123
for( const cata_path &dimension_folder : dimension_folders ) {
21192124
{
21202125
std::vector<cata_path> maps_folders = get_directories( dimension_folder / "maps" );
@@ -2247,9 +2252,7 @@ bool WORLD::set_compression_enabled( bool enabled ) const
22472252
files_to_clean.push_back( save );
22482253
}
22492254
}
2250-
copy_file( maps_dict, dimension_folder / "maps.dict" );
2251-
copy_file( overmaps_dict, dimension_folder / "overmaps.dict" );
2252-
copy_file( mmr_dict, dimension_folder / "mmr.dict" );
2255+
22532256
size_t done = 0;
22542257
size_t to_do = folders_to_clean.size() + files_to_clean.size();
22552258
for( const cata_path &folder : folders_to_clean ) {
@@ -2273,10 +2276,13 @@ bool WORLD::set_compression_enabled( bool enabled ) const
22732276
} else {
22742277
std::vector<cata_path> dimension_folders = get_directories( world_folder_path / "dimensions" );
22752278
dimension_folders.push_back( world_folder_path );
2279+
2280+
cata_path maps_dict = world_folder_path / "maps.dict";
2281+
cata_path overmaps_dict = world_folder_path / "overmaps.dict";
2282+
cata_path mmr_dict = world_folder_path / "mmr.dict";
2283+
22762284
for( const cata_path &dimension_folder : dimension_folders ) {
2277-
cata_path maps_dict = dimension_folder / "maps.dict";
2278-
cata_path overmaps_dict = dimension_folder / "overmaps.dict";
2279-
cata_path mmr_dict = dimension_folder / "mmr.dict";
2285+
22802286
std::vector<cata_path> zzips_to_clean;
22812287

22822288
std::vector<cata_path> maps_zzips = get_files_from_path( "zzip", dimension_folder / "maps", false,
@@ -2389,31 +2395,6 @@ bool WORLD::set_compression_enabled( bool enabled ) const
23892395
return true;
23902396
}
23912397

2392-
// For dimension stuff
2393-
void WORLD::assure_compression_files_present() const
2394-
{
2395-
// Check if there's compression enabled in the save file
2396-
if( has_compression_enabled() ) {
2397-
// Make sure the dimension folder actually exists before doing checks on it
2398-
assure_dir_exist( PATH_INFO::current_dimension_save_path() );
2399-
// Check if we're not overwriting already pre-existing .dict files
2400-
if( !std::filesystem::exists( ( PATH_INFO::current_dimension_save_path() /
2401-
"maps.dict" ).get_unrelative_path() ) ||
2402-
!std::filesystem::exists( ( PATH_INFO::current_dimension_save_path() /
2403-
"mmr.dict" ).get_unrelative_path() ) ||
2404-
!std::filesystem::exists( ( PATH_INFO::current_dimension_save_path() /
2405-
"overmaps.dict" ).get_unrelative_path() ) ) {
2406-
cata_path dictionary_folder = PATH_INFO::compression_folder_path();
2407-
cata_path maps_dict = dictionary_folder / "maps.dict";
2408-
cata_path mmr_dict = dictionary_folder / "mmr.dict";
2409-
cata_path overmaps_dict = dictionary_folder / "overmaps.dict";
2410-
copy_file( maps_dict, PATH_INFO::current_dimension_save_path() / "maps.dict" );
2411-
copy_file( mmr_dict, PATH_INFO::current_dimension_save_path() / "mmr.dict" );
2412-
copy_file( overmaps_dict, PATH_INFO::current_dimension_save_path() / "overmaps.dict" );
2413-
}
2414-
}
2415-
}
2416-
24172398
mod_manager &worldfactory::get_mod_manager()
24182399
{
24192400
return *mman;

src/worldfactory.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ struct WORLD {
8686

8787
bool has_compression_enabled() const;
8888
bool set_compression_enabled( bool enabled ) const;
89-
void assure_compression_files_present() const;
9089

9190
};
9291

0 commit comments

Comments
 (0)