Remove preloaded worlds

master
MoNTE48 2021-07-06 10:58:35 +02:00
parent a59bc6946c
commit 06dd435139
16 changed files with 50 additions and 54 deletions

View File

@ -66,10 +66,5 @@ else
echo "You forgot to clone with submodules!" echo "You forgot to clone with submodules!"
fi fi
echo "**** Creating worlds.zip"
ZIPDEST=$FOLDER/worlds.zip
rm -f $ZIPDEST
zip -0qr $ZIPDEST -- worlds
echo echo
echo "*** All done! You can continue in Android Studio! ***" echo "*** All done! You can continue in Android Studio! ***"

View File

@ -100,7 +100,7 @@ public class MainActivity extends AppCompatActivity implements CallBackListener,
"HU", "IE", "IT", "LV", "LT", "LU", "HU", "IE", "IT", "LV", "LT", "LU",
"MT", "NL", "PL", "PT", "RO", "SK", "MT", "NL", "PL", "PT", "RO", "SK",
"SI", "ES", "SE", "GB", "IS", "LI", "NO"); "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 final String versionName = BuildConfig.VERSION_NAME;
private String unzipLocation, appData; private String unzipLocation, appData;
private boolean consent; private boolean consent;
@ -179,11 +179,9 @@ public class MainActivity extends AppCompatActivity implements CallBackListener,
cachePath = unzipLocation + "cache" + File.separator; cachePath = unzipLocation + "cache" + File.separator;
FILES = cachePath + "Files.zip"; FILES = cachePath + "Files.zip";
WORLDS = cachePath + "worlds.zip";
GAMES = cachePath + "games.zip"; GAMES = cachePath + "games.zip";
zipLocations.put(FILES, appData); zipLocations.put(FILES, appData);
zipLocations.put(GAMES, appData); zipLocations.put(GAMES, appData);
zipLocations.put(WORLDS, unzipLocation);
} }
private void addLaunchTimes() { private void addLaunchTimes() {
@ -283,7 +281,7 @@ public class MainActivity extends AppCompatActivity implements CallBackListener,
} }
private void runGame() { private void runGame() {
deleteFiles(Arrays.asList(FILES, WORLDS, GAMES)); deleteFiles(Arrays.asList(FILES, GAMES));
pf.saveSettings(TAG_BUILD_NUMBER, versionName); pf.saveSettings(TAG_BUILD_NUMBER, versionName);
connectionSub = checkConnection(); connectionSub = checkConnection();
} }
@ -372,7 +370,7 @@ public class MainActivity extends AppCompatActivity implements CallBackListener,
private void startCopy(boolean isAll) { private void startCopy(boolean isAll) {
String[] zips; String[] zips;
if (isAll) if (isAll)
zips = new String[]{FILES, WORLDS, GAMES}; zips = new String[]{FILES, GAMES};
else else
zips = new String[]{FILES, GAMES}; zips = new String[]{FILES, GAMES};
copySub = Completable.fromAction(() -> copyAssets(zips)) copySub = Completable.fromAction(() -> copyAssets(zips))

View File

@ -235,7 +235,6 @@
F8E6C7D51DCA476800F64426 /* libIrrlicht.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F8E6C7D41DCA476800F64426 /* libIrrlicht.a */; }; F8E6C7D51DCA476800F64426 /* libIrrlicht.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F8E6C7D41DCA476800F64426 /* libIrrlicht.a */; };
F8E6C7D71DCA477600F64426 /* libfreetype.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F8E6C7D61DCA477600F64426 /* libfreetype.a */; }; F8E6C7D71DCA477600F64426 /* libfreetype.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F8E6C7D61DCA477600F64426 /* libfreetype.a */; };
F8E6C7E11DCA4EB300F64426 /* assets.zip in Resources */ = {isa = PBXBuildFile; fileRef = F8E6C7E01DCA4EB300F64426 /* assets.zip */; }; 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 */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase 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 = "<group>"; }; F8E6C7D41DCA476800F64426 /* libIrrlicht.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libIrrlicht.a; path = ../deps/irrlicht/libIrrlicht.a; sourceTree = "<group>"; };
F8E6C7D61DCA477600F64426 /* libfreetype.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libfreetype.a; path = ../deps/freetype/lib/libfreetype.a; sourceTree = "<group>"; }; F8E6C7D61DCA477600F64426 /* libfreetype.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libfreetype.a; path = ../deps/freetype/lib/libfreetype.a; sourceTree = "<group>"; };
F8E6C7E01DCA4EB300F64426 /* assets.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; name = assets.zip; path = ../../assets.zip; sourceTree = "<group>"; }; F8E6C7E01DCA4EB300F64426 /* assets.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; name = assets.zip; path = ../../assets.zip; sourceTree = "<group>"; };
F8E6C7E21DCA511700F64426 /* worlds.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; name = worlds.zip; path = ../../worlds.zip; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@ -860,7 +858,6 @@
842A808A2339174B00A89418 /* ads.h */, 842A808A2339174B00A89418 /* ads.h */,
842A808B2339174C00A89418 /* ads.mm */, 842A808B2339174C00A89418 /* ads.mm */,
F8E6C7E01DCA4EB300F64426 /* assets.zip */, F8E6C7E01DCA4EB300F64426 /* assets.zip */,
F8E6C7E21DCA511700F64426 /* worlds.zip */,
); );
name = "Supporting Files"; name = "Supporting Files";
sourceTree = "<group>"; sourceTree = "<group>";
@ -1477,7 +1474,6 @@
849C4F86209656D3005EB041 /* ru.lproj in Resources */, 849C4F86209656D3005EB041 /* ru.lproj in Resources */,
F8E6C4EC1DCA3B7900F64426 /* LaunchScreen.storyboard in Resources */, F8E6C4EC1DCA3B7900F64426 /* LaunchScreen.storyboard in Resources */,
F8E6C7E11DCA4EB300F64426 /* assets.zip in Resources */, F8E6C7E11DCA4EB300F64426 /* assets.zip in Resources */,
F8E6C7E31DCA511700F64426 /* worlds.zip in Resources */,
84B9C11824A4D82400016BCE /* ConsentAlertViewController.xib in Resources */, 84B9C11824A4D82400016BCE /* ConsentAlertViewController.xib in Resources */,
84CD4A65248782720019B81D /* ProgressViewController.xib in Resources */, 84CD4A65248782720019B81D /* ProgressViewController.xib in Resources */,
84CD4A66248782720019B81D /* MessageViewController.xib in Resources */, 84CD4A66248782720019B81D /* MessageViewController.xib in Resources */,

View File

@ -9,7 +9,6 @@ private enum Constants {
private struct Asset { private struct Asset {
let name: String let name: String
let path: UnzipPath let path: UnzipPath
let versioned: Bool
var destinationPath: String { var destinationPath: String {
switch path { switch path {
@ -61,8 +60,7 @@ final class VersionManager {
} }
final class ZipManager: NSObject { final class ZipManager: NSObject {
private var assets: [Asset] = [.init(name: "assets", path: .library, versioned: true), private var assets: [Asset] = [.init(name: "assets", path: .library)]
.init(name: "worlds", path: .documents, versioned: false)]
@objc func runProcess(_ progress: @escaping (_ percent: Int) -> Void, _ errorBlock: @escaping (Error) -> Void) { @objc func runProcess(_ progress: @escaping (_ percent: Int) -> Void, _ errorBlock: @escaping (Error) -> Void) {
let versionRuntime = VersionManager.parseVersion() let versionRuntime = VersionManager.parseVersion()
@ -71,10 +69,6 @@ final class ZipManager: NSObject {
let zippath = Bundle.main.path(forResource: asset.name, ofType: "zip") ?? "" let zippath = Bundle.main.path(forResource: asset.name, ofType: "zip") ?? ""
let versionDisk = VersionManager.readVersion(withPath: asset.destinationPath) let versionDisk = VersionManager.readVersion(withPath: asset.destinationPath)
if !asset.versioned && versionDisk != 0 { // worlds
continue
}
#if !DEBUG #if !DEBUG
if versionDisk == versionRuntime { if versionDisk == versionRuntime {
continue continue

View File

@ -63,11 +63,3 @@ if [[ -z "$PASSWORD" ]]; then
fi fi
cd $DEST; zip -P $PASSWORD -1r $ZIPDEST -- * cd $DEST; zip -P $PASSWORD -1r $ZIPDEST -- *
cd $FOLDER; rm -rf $DEST cd $FOLDER; rm -rf $DEST
###########
echo "Creating worlds.zip"
ZIPDEST=$FOLDER/worlds.zip
rm -f $ZIPDEST
cd ../..; zip -r $ZIPDEST -- worlds

View File

@ -18,7 +18,53 @@
local lang = core.settings:get("language") local lang = core.settings:get("language")
if not (lang and (lang ~= "")) then lang = os.getenv("LANG") end 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() 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, local index = filterlist.get_current_index(menudata.worldlist,
tonumber(core.settings:get("mainmenu_last_selected_world"))) tonumber(core.settings:get("mainmenu_last_selected_world")))
local creative_checkbox = core.settings:get_bool("creative_mode") and local creative_checkbox = core.settings:get_bool("creative_mode") and

View File

@ -1,4 +0,0 @@
water_level = 1
mg_name = v7p
seed = 15823438331521897617
[end_of_params]

View File

@ -1 +0,0 @@
gameid = default

View File

@ -1,4 +0,0 @@
water_level = 1
mg_name = v7p
seed = 1841722166046826822
[end_of_params]

View File

@ -1 +0,0 @@
gameid = default

View File

@ -1,4 +0,0 @@
water_level = 1
mg_name = v7p
seed = CC
[end_of_params]

View File

@ -1 +0,0 @@
gameid = default

View File

@ -1,4 +0,0 @@
water_level = 1
mg_name = valleys
seed = 8572
[end_of_params]

View File

@ -1 +0,0 @@
gameid = default

View File

@ -1,4 +0,0 @@
water_level = 1
mg_name = flat
seed = 2
[end_of_params]

View File

@ -1 +0,0 @@
gameid = default