From 26acf7cbbce379dea7d4796e7e86c221006cedc2 Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 18 Aug 2020 16:56:30 -0400 Subject: [PATCH] Bugfixes --- .../src/mindustry/entities/comp/BuildingComp.java | 4 ++-- core/src/mindustry/game/EventType.java | 11 ----------- core/src/mindustry/input/InputHandler.java | 11 +---------- core/src/mindustry/net/Administration.java | 3 +-- core/src/mindustry/net/BeControl.java | 4 ++++ core/src/mindustry/world/blocks/BuildBlock.java | 4 ++-- core/src/mindustry/world/blocks/defense/Door.java | 4 ++-- server/src/mindustry/server/ServerControl.java | 15 +++++++++++++++ 8 files changed, 27 insertions(+), 29 deletions(-) diff --git a/core/src/mindustry/entities/comp/BuildingComp.java b/core/src/mindustry/entities/comp/BuildingComp.java index 20693b378b..a6887a0512 100644 --- a/core/src/mindustry/entities/comp/BuildingComp.java +++ b/core/src/mindustry/entities/comp/BuildingComp.java @@ -843,8 +843,8 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc, } } - /** Called when the block is tapped.*/ - public void tapped(Player player){ + /** Called when the block is tapped by the local player. */ + public void tapped(){ } diff --git a/core/src/mindustry/game/EventType.java b/core/src/mindustry/game/EventType.java index 8f19756096..575b2e5c61 100644 --- a/core/src/mindustry/game/EventType.java +++ b/core/src/mindustry/game/EventType.java @@ -166,17 +166,6 @@ public class EventType{ } } - /** Called when the player taps a block. */ - public static class TapEvent{ - public final Building tile; - public final Player player; - - public TapEvent(Building tile, Player player){ - this.tile = tile; - this.player = player; - } - } - /** Called when the player sets a specific block. */ public static class TapConfigEvent{ public final Building tile; diff --git a/core/src/mindustry/input/InputHandler.java b/core/src/mindustry/input/InputHandler.java index 84861cf569..476d335fd6 100644 --- a/core/src/mindustry/input/InputHandler.java +++ b/core/src/mindustry/input/InputHandler.java @@ -206,15 +206,6 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ ); } - @Remote(targets = Loc.both, called = Loc.server, forward = true) - public static void tileTapped(Player player, Building tile){ - if(tile == null || player == null) return; - if(net.server() && (!Units.canInteract(player, tile) || - !netServer.admins.allowAction(player, ActionType.tapTile, tile.tile(), action -> {}))) throw new ValidateException(player, "Player cannot tap a tile."); - tile.tapped(player); - Core.app.post(() -> Events.fire(new TapEvent(tile, player))); - } - @Remote(targets = Loc.both, called = Loc.both, forward = true) public static void tileConfig(Player player, Building tile, @Nullable Object value){ if(tile == null) return; @@ -778,7 +769,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ //call tapped event if(!consumed && tile.interactable(player.team())){ - Call.tileTapped(player, tile); + tile.tapped(); } //consume tap event if necessary diff --git a/core/src/mindustry/net/Administration.java b/core/src/mindustry/net/Administration.java index f55f7d0d4a..0f289328d0 100644 --- a/core/src/mindustry/net/Administration.java +++ b/core/src/mindustry/net/Administration.java @@ -75,7 +75,6 @@ public class Administration{ addActionFilter(action -> { if(action.type != ActionType.breakBlock && action.type != ActionType.placeBlock && - action.type != ActionType.tapTile && Config.antiSpam.bool() && //make sure players can configure their own stuff, e.g. in schematics lastPlaced.get(action.tile.pos(), -1) != action.player.id()){ @@ -720,7 +719,7 @@ public class Administration{ } public enum ActionType{ - breakBlock, placeBlock, rotate, configure, tapTile, withdrawItem, depositItem + breakBlock, placeBlock, rotate, configure, withdrawItem, depositItem } } diff --git a/core/src/mindustry/net/BeControl.java b/core/src/mindustry/net/BeControl.java index 5e05aebced..c7338319a5 100644 --- a/core/src/mindustry/net/BeControl.java +++ b/core/src/mindustry/net/BeControl.java @@ -10,6 +10,7 @@ import arc.util.serialization.*; import mindustry.core.*; import mindustry.gen.*; import mindustry.graphics.*; +import mindustry.io.*; import mindustry.net.Administration.*; import mindustry.net.Packets.*; import mindustry.ui.*; @@ -129,6 +130,9 @@ public class BeControl{ progress -> {}, () -> false, () -> Core.app.post(() -> { + Log.info("&lcSaving..."); + SaveIO.save(saveDirectory.child("autosavebe." + saveExtension)); + netServer.kickAll(KickReason.serverRestarting); Threads.sleep(32); diff --git a/core/src/mindustry/world/blocks/BuildBlock.java b/core/src/mindustry/world/blocks/BuildBlock.java index 7692db85c8..e16f01aad2 100644 --- a/core/src/mindustry/world/blocks/BuildBlock.java +++ b/core/src/mindustry/world/blocks/BuildBlock.java @@ -148,9 +148,9 @@ public class BuildBlock extends Block{ } @Override - public void tapped(Player player){ + public void tapped(){ //if the target is constructible, begin constructing - if(!headless && cblock != null){ + if(cblock != null){ if(control.input.buildWasAutoPaused && !control.input.isBuilding && player.isBuilder()){ control.input.isBuilding = true; } diff --git a/core/src/mindustry/world/blocks/defense/Door.java b/core/src/mindustry/world/blocks/defense/Door.java index 5c750156a5..c85c8247ea 100644 --- a/core/src/mindustry/world/blocks/defense/Door.java +++ b/core/src/mindustry/world/blocks/defense/Door.java @@ -84,7 +84,7 @@ public class Door extends Wall{ if(type == LAccess.enabled){ boolean shouldOpen = !Mathf.zero(p1); - if(open == shouldOpen || (Units.anyEntities(tile) && !shouldOpen) || !origin().timer(timerToggle, 60f)){ + if(net.client() || open == shouldOpen || (Units.anyEntities(tile) && !shouldOpen) || !origin().timer(timerToggle, 60f)){ return; } @@ -133,7 +133,7 @@ public class Door extends Wall{ } @Override - public void tapped(Player player){ + public void tapped(){ if((Units.anyEntities(tile) && open) || !origin().timer(timerToggle, 50f)){ return; } diff --git a/server/src/mindustry/server/ServerControl.java b/server/src/mindustry/server/ServerControl.java index 7110342f81..4756013b53 100644 --- a/server/src/mindustry/server/ServerControl.java +++ b/server/src/mindustry/server/ServerControl.java @@ -86,6 +86,21 @@ public class ServerControl implements ApplicationListener{ registerCommands(); Core.app.post(() -> { + //try to load auto-update save if possible + if(Config.autoUpdate.bool()){ + Fi fi = saveDirectory.child("autosavebe." + saveExtension); + if(fi.exists()){ + try{ + SaveIO.load(fi); + info("Auto-save loaded."); + state.set(State.playing); + netServer.openServer(); + }catch(Throwable e){ + Log.err(e); + } + } + } + Seq commands = new Seq<>(); if(args.length > 0){