From 0d29d94800f3522b572fd1e3261cd03fc5c01d94 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 18 Sep 2019 15:18:59 -0400 Subject: [PATCH 1/3] Bugfixes --- core/src/io/anuke/mindustry/editor/MapEditorDialog.java | 2 +- core/src/io/anuke/mindustry/entities/type/Unit.java | 1 + core/src/io/anuke/mindustry/input/InputHandler.java | 2 +- core/src/io/anuke/mindustry/net/Net.java | 4 +++- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/src/io/anuke/mindustry/editor/MapEditorDialog.java b/core/src/io/anuke/mindustry/editor/MapEditorDialog.java index 773ce88749..95b5869e24 100644 --- a/core/src/io/anuke/mindustry/editor/MapEditorDialog.java +++ b/core/src/io/anuke/mindustry/editor/MapEditorDialog.java @@ -168,7 +168,7 @@ public class MapEditorDialog extends Dialog implements Disposable{ } platform.publishMap(map); - }).padTop(-3).size(swidth * 2f + 10, 60f); + }).padTop(-3).size(swidth * 2f + 10, 60f).update(b -> b.setText(editor.getTags().containsKey("steamid") ? "$view.workshop" : "$editor.publish.workshop")); menu.cont.row(); } diff --git a/core/src/io/anuke/mindustry/entities/type/Unit.java b/core/src/io/anuke/mindustry/entities/type/Unit.java index bbf3197621..63289f53e1 100644 --- a/core/src/io/anuke/mindustry/entities/type/Unit.java +++ b/core/src/io/anuke/mindustry/entities/type/Unit.java @@ -227,6 +227,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ float radScl = 1.5f; for(Unit en : arr){ + if(en.isFlying() != isFlying()) continue; float dst = dst(en); float scl = Mathf.clamp(1f - dst / (getSize()/(radScl*2f) + en.getSize()/(radScl*2f))); moveVector.add(Tmp.v1.set((x - en.x) * scl, (y - en.y) * scl).limit(0.4f)); diff --git a/core/src/io/anuke/mindustry/input/InputHandler.java b/core/src/io/anuke/mindustry/input/InputHandler.java index e4e8dadfc7..3ea3302194 100644 --- a/core/src/io/anuke/mindustry/input/InputHandler.java +++ b/core/src/io/anuke/mindustry/input/InputHandler.java @@ -58,7 +58,7 @@ public abstract class InputHandler implements InputProcessor{ @Remote(targets = Loc.both, forward = true, called = Loc.server) public static void transferInventory(Player player, Tile tile){ - if(!player.timer.get(Player.timerTransfer, 40)) return; + if(player == null || player.timer == null || !player.timer.get(Player.timerTransfer, 40)) return; if(net.server() && (player.item().amount <= 0 || player.isTransferring|| !tile.interactable(player.getTeam()))){ throw new ValidateException(player, "Player cannot transfer an item."); } diff --git a/core/src/io/anuke/mindustry/net/Net.java b/core/src/io/anuke/mindustry/net/Net.java index 66482ab729..eddd19c1e6 100644 --- a/core/src/io/anuke/mindustry/net/Net.java +++ b/core/src/io/anuke/mindustry/net/Net.java @@ -46,7 +46,9 @@ public class Net{ t = t.getCause(); } - String error = t.getMessage() == null ? "" : t.getMessage().toLowerCase(); + String baseError = Strings.getFinalMesage(e); + + String error = baseError == null ? "" : baseError.toLowerCase(); String type = t.getClass().toString().toLowerCase(); boolean isError = false; From 5a0669d4377469e2e427b4be8f5d1fd37673843f Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 18 Sep 2019 19:24:49 -0400 Subject: [PATCH 2/3] SAF is terrible --- .../io/anuke/mindustry/AndroidLauncher.java | 24 +++++++++++++++++-- .../mindustry/entities/effect/Lightning.java | 2 +- .../mindustry/entities/type/BaseUnit.java | 3 ++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/android/src/io/anuke/mindustry/AndroidLauncher.java b/android/src/io/anuke/mindustry/AndroidLauncher.java index 138d00c224..2cc928d322 100644 --- a/android/src/io/anuke/mindustry/AndroidLauncher.java +++ b/android/src/io/anuke/mindustry/AndroidLauncher.java @@ -1,5 +1,6 @@ package io.anuke.mindustry; +import android.*; import android.app.*; import android.content.*; import android.content.pm.*; @@ -21,6 +22,7 @@ import io.anuke.mindustry.ui.dialogs.*; import java.io.*; import java.lang.System; +import java.util.*; import static io.anuke.mindustry.Vars.*; @@ -68,10 +70,10 @@ public class AndroidLauncher extends AndroidApplication{ @Override public void showFileChooser(boolean open, String extension, Consumer cons){ - if(VERSION.SDK_INT >= 19){ + if(VERSION.SDK_INT >= VERSION_CODES.Q){ Intent intent = new Intent(open ? Intent.ACTION_OPEN_DOCUMENT : Intent.ACTION_CREATE_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); - intent.setType("*/*"); + intent.setType(extension.equals("zip") ? "application/zip" : "*/*"); addResultListener(i -> startActivityForResult(intent, i), (code, in) -> { if(code == Activity.RESULT_OK && in != null && in.getData() != null){ Uri uri = in.getData(); @@ -99,6 +101,24 @@ public class AndroidLauncher extends AndroidApplication{ }))); } }); + }else if(VERSION.SDK_INT >= VERSION_CODES.M && !(checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED && + checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)){ + chooser = new FileChooser(open ? "$open" : "$save", file -> file.extension().equalsIgnoreCase(extension), open, file -> { + if(!open){ + cons.accept(file.parent().child(file.nameWithoutExtension() + "." + extension)); + }else{ + cons.accept(file); + } + }); + + ArrayList perms = new ArrayList<>(); + if(checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED){ + perms.add(Manifest.permission.WRITE_EXTERNAL_STORAGE); + } + if(checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED){ + perms.add(Manifest.permission.READ_EXTERNAL_STORAGE); + } + requestPermissions(perms.toArray(new String[0]), PERMISSION_REQUEST_CODE); }else{ super.showFileChooser(open, extension, cons); } diff --git a/core/src/io/anuke/mindustry/entities/effect/Lightning.java b/core/src/io/anuke/mindustry/entities/effect/Lightning.java index db8eeb5b1b..83dedb94be 100644 --- a/core/src/io/anuke/mindustry/entities/effect/Lightning.java +++ b/core/src/io/anuke/mindustry/entities/effect/Lightning.java @@ -47,7 +47,7 @@ public class Lightning extends TimedEntity implements DrawTrait, TimeTrait{ } /** Do not invoke! */ - @Remote(called = Loc.server) + @Remote(called = Loc.server, unreliable = true) public static void createLighting(int seed, Team team, Color color, float damage, float x, float y, float rotation, int length){ Lightning l = Pools.obtain(Lightning.class, Lightning::new); diff --git a/core/src/io/anuke/mindustry/entities/type/BaseUnit.java b/core/src/io/anuke/mindustry/entities/type/BaseUnit.java index 4a9d8695f3..9d3a92a170 100644 --- a/core/src/io/anuke/mindustry/entities/type/BaseUnit.java +++ b/core/src/io/anuke/mindustry/entities/type/BaseUnit.java @@ -16,6 +16,7 @@ import io.anuke.mindustry.game.*; import io.anuke.mindustry.gen.*; import io.anuke.mindustry.type.*; import io.anuke.mindustry.world.*; +import io.anuke.mindustry.world.blocks.*; import io.anuke.mindustry.world.blocks.defense.DeflectorWall.*; import io.anuke.mindustry.world.blocks.units.CommandCenter.*; import io.anuke.mindustry.world.blocks.units.UnitFactory.*; @@ -273,7 +274,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{ return; } - if(!isFlying() && (world.tileWorld(x, y) != null && world.tileWorld(x, y).solid())){ + if(!isFlying() && (world.tileWorld(x, y) != null && !(world.tileWorld(x, y).block() instanceof BuildBlock) && world.tileWorld(x, y).solid())){ kill(); } From d6a4149175329db0be49857357c6279c5c44c8ac Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 19 Sep 2019 19:01:48 -0400 Subject: [PATCH 3/3] Testing iOS file chooser --- core/src/io/anuke/mindustry/editor/MapEditorDialog.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/io/anuke/mindustry/editor/MapEditorDialog.java b/core/src/io/anuke/mindustry/editor/MapEditorDialog.java index 8f2dd20d92..f73d3909bf 100644 --- a/core/src/io/anuke/mindustry/editor/MapEditorDialog.java +++ b/core/src/io/anuke/mindustry/editor/MapEditorDialog.java @@ -85,7 +85,7 @@ public class MapEditorDialog extends Dialog implements Disposable{ t.row(); - if(!ios){ + //if(!ios){ t.addImageTextButton("$editor.import", Icon.loadMapSmall, () -> createDialog("$editor.import", "$editor.importmap", "$editor.importmap.description", Icon.loadMap, (Runnable)loadDialog::show, @@ -113,7 +113,7 @@ public class MapEditorDialog extends Dialog implements Disposable{ } }))) ); - } + //} Cell cell = t.addImageTextButton("$editor.export", Icon.saveMapSmall, () -> { if(!ios){