@@ -18,14 +18,17 @@ bool Dimension::operator==(const Dimension &other) const {
1818}
1919
2020fs::path Dimension::suffix () const {
21+ return fs::path (fmt::format (" dimensions/{}/{}/region" , ns, id));
22+ }
23+
24+ fs::path Dimension::special_suffix () const {
2125 if (id == " overworld" )
2226 return " region" ;
2327 else if (id == " the_nether" )
2428 return fs::path (" DIM-1/region" );
2529 else if (id == " the_end" )
2630 return fs::path (" DIM1/region" );
27- else
28- return fs::path (fmt::format (" dimensions/{}/{}/region" , ns, id));
31+ return " " ;
2932}
3033
3134bool assert_save (const fs::path &root) {
@@ -67,36 +70,41 @@ SaveFile::SaveFile(const fs::path &_folder) : folder(_folder) {
6770 getDimensions ();
6871}
6972
73+ #define VALID (path ) (fs::exists((path)) && !fs::is_empty((path)))
7074void SaveFile::getDimensions () {
71- #define VALID (path ) fs::exists((path)) && !fs::is_empty((path))
72- if (VALID (folder / " region" ))
73- dimensions.push_back (Dimension (" overworld" ));
75+ if VALID (folder / " region" )
76+ dimensions.push_back (Dimension (" minecraft" , " overworld" ));
7477
75- if ( VALID (folder / " DIM1/region" ) )
76- dimensions.push_back (Dimension (" the_end" ));
78+ if VALID (folder / " DIM1/region" )
79+ dimensions.push_back (Dimension (" minecraft " , " the_end" ));
7780
78- if ( VALID (folder / " DIM-1/region" ) )
79- dimensions.push_back (Dimension (" the_nether" ));
81+ if VALID (folder / " DIM-1/region" )
82+ dimensions.push_back (Dimension (" minecraft " , " the_nether" ));
8083
8184 fs::path dim_folder = folder / " dimensions" ;
8285
83- if ( VALID (dim_folder) )
86+ if VALID (dim_folder)
8487 for (auto &ns : fs::directory_iterator (dim_folder))
8588 for (auto &id : fs::directory_iterator (ns.path ()))
8689 dimensions.push_back (Dimension (ns.path ().filename ().string (),
8790 id.path ().filename ().string ()));
88- #undef VALID
8991}
9092
9193fs::path
92- SaveFile::region (const Dimension &dim = std::string( " overworld " ) ) const {
94+ SaveFile::region (const Dimension &dim) const {
9395 auto found = std::find (dimensions.begin (), dimensions.end (), dim);
9496
9597 if (found == dimensions.end ())
9698 return " " ;
9799
100+ // Check now for the old region/DIM1/DIM-1
101+ if VALID (folder / dim.special_suffix ()) {
102+ return folder / dim.special_suffix ();
103+ }
104+
98105 return folder / dim.suffix ();
99106}
107+ #undef VALID
100108
101109void to_json (json &j, const Dimension &d) {
102110 j = fmt::format (" {}:{}" , d.ns , d.id );
0 commit comments