From c5a90759e5ef4ea2c3246ec55f78480f0e38625e Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 11 Sep 2021 08:45:17 -0400 Subject: [PATCH] Fixed #5971 / Fixed #5973 --- core/src/mindustry/core/Renderer.java | 2 +- core/src/mindustry/game/Schematics.java | 7 ++++++- core/src/mindustry/ui/dialogs/SettingsMenuDialog.java | 8 ++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/core/src/mindustry/core/Renderer.java b/core/src/mindustry/core/Renderer.java index 6605519266..d4368ddf15 100644 --- a/core/src/mindustry/core/Renderer.java +++ b/core/src/mindustry/core/Renderer.java @@ -114,7 +114,7 @@ public class Renderer implements ApplicationListener{ public void update(){ Color.white.set(1f, 1f, 1f, 1f); - float dest = Mathf.round(targetscale, 0.5f); + float dest = Mathf.clamp(Mathf.round(targetscale, 0.5f), minScale(), maxScale()); camerascale = Mathf.lerpDelta(camerascale, dest, 0.1f); if(Mathf.equal(camerascale, dest, 0.001f)) camerascale = dest; laserOpacity = settings.getInt("lasersopacity") / 100f; diff --git a/core/src/mindustry/game/Schematics.java b/core/src/mindustry/game/Schematics.java index 011d289f05..4c4109d6ef 100644 --- a/core/src/mindustry/game/Schematics.java +++ b/core/src/mindustry/game/Schematics.java @@ -292,15 +292,20 @@ public class Schematics implements Loadable{ private void checkLoadout(Schematic s, boolean validate){ Stile core = s.tiles.find(t -> t.block instanceof CoreBlock); int cores = s.tiles.count(t -> t.block instanceof CoreBlock); + int maxSize = getMaxLaunchSize(core.block); //make sure a core exists, and that the schematic is small enough. - if(core == null || (validate && (s.width > core.block.size + maxLoadoutSchematicPad *2 || s.height > core.block.size + maxLoadoutSchematicPad *2 + if(core == null || (validate && (s.width > maxSize || s.height > maxSize || s.tiles.contains(t -> t.block.buildVisibility == BuildVisibility.sandboxOnly || !t.block.unlocked()) || cores > 1))) return; //place in the cache loadouts.get((CoreBlock)core.block, Seq::new).add(s); } + public int getMaxLaunchSize(Block block){ + return block.size + maxLoadoutSchematicPad*2; + } + /** Adds a schematic to the list, also copying it into the files.*/ public void add(Schematic schematic){ all.add(schematic); diff --git a/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java b/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java index 0f8820bc2a..d8d0b40826 100644 --- a/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java +++ b/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java @@ -230,8 +230,12 @@ public class SettingsMenuDialog extends Dialog{ platform.shareFile(logs); }else{ platform.showFileChooser(false, "txt", file -> { - file.writeString(getLogs()); - app.post(() -> ui.showInfo("@crash.exported")); + try{ + file.writeBytes(getLogs().getBytes(Strings.utf8)); + app.post(() -> ui.showInfo("@crash.exported")); + }catch(Throwable e){ + ui.showException(e); + } }); } }