diff --git a/build/android/Start.sh b/build/android/Start.sh index 85ff2ae7..10f5465d 100755 --- a/build/android/Start.sh +++ b/build/android/Start.sh @@ -66,10 +66,5 @@ else echo "You forgot to clone with submodules!" fi -echo "**** Creating worlds.zip" -ZIPDEST=$FOLDER/worlds.zip -rm -f $ZIPDEST -zip -0qr $ZIPDEST -- worlds - echo echo "*** All done! You can continue in Android Studio! ***" diff --git a/build/android/app/src/main/java/com/multicraft/game/MainActivity.java b/build/android/app/src/main/java/com/multicraft/game/MainActivity.java index 2c8bcb25..48fc61e2 100644 --- a/build/android/app/src/main/java/com/multicraft/game/MainActivity.java +++ b/build/android/app/src/main/java/com/multicraft/game/MainActivity.java @@ -100,7 +100,7 @@ public class MainActivity extends AppCompatActivity implements CallBackListener, "HU", "IE", "IT", "LV", "LT", "LU", "MT", "NL", "PL", "PT", "RO", "SK", "SI", "ES", "SE", "GB", "IS", "LI", "NO"); - private static String FILES, WORLDS, GAMES; + private static String FILES, GAMES; private final String versionName = BuildConfig.VERSION_NAME; private String unzipLocation, appData; private boolean consent; @@ -179,11 +179,9 @@ public class MainActivity extends AppCompatActivity implements CallBackListener, cachePath = unzipLocation + "cache" + File.separator; FILES = cachePath + "Files.zip"; - WORLDS = cachePath + "worlds.zip"; GAMES = cachePath + "games.zip"; zipLocations.put(FILES, appData); zipLocations.put(GAMES, appData); - zipLocations.put(WORLDS, unzipLocation); } private void addLaunchTimes() { @@ -283,7 +281,7 @@ public class MainActivity extends AppCompatActivity implements CallBackListener, } private void runGame() { - deleteFiles(Arrays.asList(FILES, WORLDS, GAMES)); + deleteFiles(Arrays.asList(FILES, GAMES)); pf.saveSettings(TAG_BUILD_NUMBER, versionName); connectionSub = checkConnection(); } @@ -372,7 +370,7 @@ public class MainActivity extends AppCompatActivity implements CallBackListener, private void startCopy(boolean isAll) { String[] zips; if (isAll) - zips = new String[]{FILES, WORLDS, GAMES}; + zips = new String[]{FILES, GAMES}; else zips = new String[]{FILES, GAMES}; copySub = Completable.fromAction(() -> copyAssets(zips)) diff --git a/build/iOS/MultiCraft/MultiCraft.xcodeproj/project.pbxproj b/build/iOS/MultiCraft/MultiCraft.xcodeproj/project.pbxproj index 5186733b..2b01947a 100644 --- a/build/iOS/MultiCraft/MultiCraft.xcodeproj/project.pbxproj +++ b/build/iOS/MultiCraft/MultiCraft.xcodeproj/project.pbxproj @@ -235,7 +235,6 @@ F8E6C7D51DCA476800F64426 /* libIrrlicht.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F8E6C7D41DCA476800F64426 /* libIrrlicht.a */; }; F8E6C7D71DCA477600F64426 /* libfreetype.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F8E6C7D61DCA477600F64426 /* libfreetype.a */; }; F8E6C7E11DCA4EB300F64426 /* assets.zip in Resources */ = {isa = PBXBuildFile; fileRef = F8E6C7E01DCA4EB300F64426 /* assets.zip */; }; - F8E6C7E31DCA511700F64426 /* worlds.zip in Resources */ = {isa = PBXBuildFile; fileRef = F8E6C7E21DCA511700F64426 /* worlds.zip */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -720,7 +719,6 @@ F8E6C7D41DCA476800F64426 /* libIrrlicht.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libIrrlicht.a; path = ../deps/irrlicht/libIrrlicht.a; sourceTree = ""; }; F8E6C7D61DCA477600F64426 /* libfreetype.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libfreetype.a; path = ../deps/freetype/lib/libfreetype.a; sourceTree = ""; }; F8E6C7E01DCA4EB300F64426 /* assets.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; name = assets.zip; path = ../../assets.zip; sourceTree = ""; }; - F8E6C7E21DCA511700F64426 /* worlds.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; name = worlds.zip; path = ../../worlds.zip; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -860,7 +858,6 @@ 842A808A2339174B00A89418 /* ads.h */, 842A808B2339174C00A89418 /* ads.mm */, F8E6C7E01DCA4EB300F64426 /* assets.zip */, - F8E6C7E21DCA511700F64426 /* worlds.zip */, ); name = "Supporting Files"; sourceTree = ""; @@ -1477,7 +1474,6 @@ 849C4F86209656D3005EB041 /* ru.lproj in Resources */, F8E6C4EC1DCA3B7900F64426 /* LaunchScreen.storyboard in Resources */, F8E6C7E11DCA4EB300F64426 /* assets.zip in Resources */, - F8E6C7E31DCA511700F64426 /* worlds.zip in Resources */, 84B9C11824A4D82400016BCE /* ConsentAlertViewController.xib in Resources */, 84CD4A65248782720019B81D /* ProgressViewController.xib in Resources */, 84CD4A66248782720019B81D /* MessageViewController.xib in Resources */, diff --git a/build/iOS/MultiCraft/MultiCraft/Main/ZipManager.swift b/build/iOS/MultiCraft/MultiCraft/Main/ZipManager.swift index 414c0cb4..6615b3af 100644 --- a/build/iOS/MultiCraft/MultiCraft/Main/ZipManager.swift +++ b/build/iOS/MultiCraft/MultiCraft/Main/ZipManager.swift @@ -9,7 +9,6 @@ private enum Constants { private struct Asset { let name: String let path: UnzipPath - let versioned: Bool var destinationPath: String { switch path { @@ -61,8 +60,7 @@ final class VersionManager { } final class ZipManager: NSObject { - private var assets: [Asset] = [.init(name: "assets", path: .library, versioned: true), - .init(name: "worlds", path: .documents, versioned: false)] + private var assets: [Asset] = [.init(name: "assets", path: .library)] @objc func runProcess(_ progress: @escaping (_ percent: Int) -> Void, _ errorBlock: @escaping (Error) -> Void) { let versionRuntime = VersionManager.parseVersion() @@ -71,10 +69,6 @@ final class ZipManager: NSObject { let zippath = Bundle.main.path(forResource: asset.name, ofType: "zip") ?? "" let versionDisk = VersionManager.readVersion(withPath: asset.destinationPath) - if !asset.versioned && versionDisk != 0 { // worlds - continue - } - #if !DEBUG if versionDisk == versionRuntime { continue diff --git a/build/iOS/assets.sh b/build/iOS/assets.sh index 5632332a..b05ae92b 100755 --- a/build/iOS/assets.sh +++ b/build/iOS/assets.sh @@ -63,11 +63,3 @@ if [[ -z "$PASSWORD" ]]; then fi cd $DEST; zip -P $PASSWORD -1r $ZIPDEST -- * cd $FOLDER; rm -rf $DEST - -########### - -echo "Creating worlds.zip" -ZIPDEST=$FOLDER/worlds.zip -rm -f $ZIPDEST - -cd ../..; zip -r $ZIPDEST -- worlds diff --git a/builtin/mainmenu/tab_local.lua b/builtin/mainmenu/tab_local.lua index e8e6538f..c98960a8 100644 --- a/builtin/mainmenu/tab_local.lua +++ b/builtin/mainmenu/tab_local.lua @@ -18,7 +18,53 @@ local lang = core.settings:get("language") if not (lang and (lang ~= "")) then lang = os.getenv("LANG") end +local default_worlds = { + {name = "World 1", mg_name = "v7p", seed = "15823438331521897617"}, + {name = "World 2", mg_name = "v7p", seed = "1841722166046826822"}, + {name = "World 3", mg_name = "v7p", seed = "CC"}, + {name = "World 4", mg_name = "valleys", seed = "8572"}, + {name = "World 5 Flat", mg_name = "flat", seed = "2"} +} + +local function create_default_worlds() + local _, gameindex = gamemgr.find_by_gameid("default") + if not gameindex or gameindex == 0 then return end + + -- Preserve the old map seed and mapgen values + local old_map_seed = core.settings:get("fixed_map_seed") + local old_mapgen = core.settings:get("mg_name") + + -- Create the worlds + for _, world in ipairs(default_worlds) do + core.settings:set("fixed_map_seed", world.seed) + core.settings:set("mg_name", world.mg_name) + core.create_world(world.name, gameindex) + end + + -- Restore the old values + if old_map_seed then + core.settings:set("fixed_map_seed", old_map_seed) + else + core.settings:remove("fixed_map_seed") + end + if old_mapgen then + core.settings:set("mg_name", old_mapgen) + else + core.settings:remove("mg_name") + end + + menudata.worldlist:refresh() +end + +local checked_worlds = false + local function get_formspec() + -- Only check the worlds once (on restart) + if not checked_worlds and #menudata.worldlist:get_list() == 0 then + create_default_worlds() + end + checked_worlds = true + local index = filterlist.get_current_index(menudata.worldlist, tonumber(core.settings:get("mainmenu_last_selected_world"))) local creative_checkbox = core.settings:get_bool("creative_mode") and diff --git a/worlds/World 1/map_meta.txt b/worlds/World 1/map_meta.txt deleted file mode 100644 index e2af5f11..00000000 --- a/worlds/World 1/map_meta.txt +++ /dev/null @@ -1,4 +0,0 @@ -water_level = 1 -mg_name = v7p -seed = 15823438331521897617 -[end_of_params] diff --git a/worlds/World 1/world.mt b/worlds/World 1/world.mt deleted file mode 100644 index 8e268602..00000000 --- a/worlds/World 1/world.mt +++ /dev/null @@ -1 +0,0 @@ -gameid = default diff --git a/worlds/World 2/map_meta.txt b/worlds/World 2/map_meta.txt deleted file mode 100644 index 9c2e639d..00000000 --- a/worlds/World 2/map_meta.txt +++ /dev/null @@ -1,4 +0,0 @@ -water_level = 1 -mg_name = v7p -seed = 1841722166046826822 -[end_of_params] diff --git a/worlds/World 2/world.mt b/worlds/World 2/world.mt deleted file mode 100644 index 8e268602..00000000 --- a/worlds/World 2/world.mt +++ /dev/null @@ -1 +0,0 @@ -gameid = default diff --git a/worlds/World 3/map_meta.txt b/worlds/World 3/map_meta.txt deleted file mode 100644 index 73e8a97a..00000000 --- a/worlds/World 3/map_meta.txt +++ /dev/null @@ -1,4 +0,0 @@ -water_level = 1 -mg_name = v7p -seed = CC -[end_of_params] diff --git a/worlds/World 3/world.mt b/worlds/World 3/world.mt deleted file mode 100644 index 8e268602..00000000 --- a/worlds/World 3/world.mt +++ /dev/null @@ -1 +0,0 @@ -gameid = default diff --git a/worlds/World 4/map_meta.txt b/worlds/World 4/map_meta.txt deleted file mode 100644 index 3414244e..00000000 --- a/worlds/World 4/map_meta.txt +++ /dev/null @@ -1,4 +0,0 @@ -water_level = 1 -mg_name = valleys -seed = 8572 -[end_of_params] diff --git a/worlds/World 4/world.mt b/worlds/World 4/world.mt deleted file mode 100644 index 8e268602..00000000 --- a/worlds/World 4/world.mt +++ /dev/null @@ -1 +0,0 @@ -gameid = default diff --git a/worlds/World 5 Flat/map_meta.txt b/worlds/World 5 Flat/map_meta.txt deleted file mode 100644 index 7db9b3af..00000000 --- a/worlds/World 5 Flat/map_meta.txt +++ /dev/null @@ -1,4 +0,0 @@ -water_level = 1 -mg_name = flat -seed = 2 -[end_of_params] diff --git a/worlds/World 5 Flat/world.mt b/worlds/World 5 Flat/world.mt deleted file mode 100644 index 8e268602..00000000 --- a/worlds/World 5 Flat/world.mt +++ /dev/null @@ -1 +0,0 @@ -gameid = default