Skip to content

Commit b307707

Browse files
authored
Actually respect default world compression setting (#82425)
1 parent d0b8e27 commit b307707

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

src/options.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,6 +1770,13 @@ void options_manager::add_options_general()
17701770

17711771
get_option( "AMBIENT_SOUND_VOLUME" ).setPrerequisite( "SOUND_ENABLED" );
17721772
} );
1773+
1774+
add_empty_line();
1775+
1776+
add( "WORLD_COMPRESSION2", "general", to_translation( "World data compression" ),
1777+
to_translation( "If true, new worlds store data in a compressed format." ),
1778+
true
1779+
);
17731780
}
17741781

17751782
void options_manager::add_options_interface()
@@ -2753,11 +2760,6 @@ void options_manager::add_options_world_default()
27532760
}, "reset"
27542761
);
27552762

2756-
add( "WORLD_COMPRESSION", "world_default", to_translation( "World data compression" ),
2757-
to_translation( "If true, new worlds store data in a compressed format." ),
2758-
false
2759-
);
2760-
27612763
add_empty_line();
27622764

27632765
// These optiosn are purposefully and permanently hidden. It can only be modified through the sliders when creating a new world.

src/worldfactory.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@ WORLD *worldfactory::add_world( std::unique_ptr<WORLD> retworld )
139139
if( !retworld->save() ) {
140140
return nullptr;
141141
}
142+
if( get_option<bool>( "WORLD_COMPRESSION2" ) ) {
143+
cata_path dictionary_folder = PATH_INFO::compression_folder_path();
144+
cata_path maps_dict = dictionary_folder / "maps.dict";
145+
cata_path mmr_dict = dictionary_folder / "mmr.dict";
146+
cata_path overmaps_dict = dictionary_folder / "overmaps.dict";
147+
148+
if( !copy_file( maps_dict, retworld->folder_path() / "maps.dict" ) ||
149+
!copy_file( mmr_dict, retworld->folder_path() / "mmr.dict" ) ||
150+
!copy_file( overmaps_dict, retworld->folder_path() / "overmaps.dict" ) ) {
151+
return nullptr;
152+
}
153+
}
142154
return ( all_worlds[ retworld->world_name ] = std::move( retworld ) ).get();
143155
}
144156

0 commit comments

Comments
 (0)