From de6cde6ddd6af84c5125749ec8e45c940fee9956 Mon Sep 17 00:00:00 2001 From: Anuken Date: Mon, 24 Aug 2020 23:16:24 -0400 Subject: [PATCH] Bugfixes --- core/assets/bundles/bundle.properties | 1 + .../mindustry/entities/comp/FlyingComp.java | 4 +- core/src/mindustry/input/Binding.java | 3 +- core/src/mindustry/input/DesktopInput.java | 37 +++++++++++++------ core/src/mindustry/net/Administration.java | 8 +++- core/src/mindustry/net/ArcNetProvider.java | 8 ++-- .../world/blocks/logic/LogicBlock.java | 2 +- .../src/mindustry/server/ServerControl.java | 3 ++ 8 files changed, 47 insertions(+), 19 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index f91c17be8e..2b740268fa 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -742,6 +742,7 @@ keybind.toggle_block_status.name = Toggle Block Statuses keybind.move_x.name = Move X keybind.move_y.name = Move Y keybind.mouse_move.name = Follow Mouse +keybind.pan.name = Pan keybind.boost.name = Boost keybind.schematic_select.name = Select Region keybind.schematic_menu.name = Schematic Menu diff --git a/core/src/mindustry/entities/comp/FlyingComp.java b/core/src/mindustry/entities/comp/FlyingComp.java index bc27a2b084..415337622b 100644 --- a/core/src/mindustry/entities/comp/FlyingComp.java +++ b/core/src/mindustry/entities/comp/FlyingComp.java @@ -14,7 +14,7 @@ import static mindustry.Vars.net; abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{ private static final Vec2 tmp1 = new Vec2(), tmp2 = new Vec2(); - @Import float x, y; + @Import float x, y, speedMultiplier; @Import Vec2 vel; @SyncLocal float elevation; @@ -56,7 +56,7 @@ abstract class FlyingComp implements Posc, Velc, Healthc, Hitboxc{ float floorSpeedMultiplier(){ Floor on = isFlying() || hovering ? Blocks.air.asFloor() : floorOn(); - return on.speedMultiplier; + return on.speedMultiplier * speedMultiplier; } @Override diff --git a/core/src/mindustry/input/Binding.java b/core/src/mindustry/input/Binding.java index 517e50ca69..75655412cb 100644 --- a/core/src/mindustry/input/Binding.java +++ b/core/src/mindustry/input/Binding.java @@ -8,7 +8,8 @@ import arc.input.*; public enum Binding implements KeyBind{ move_x(new Axis(KeyCode.a, KeyCode.d), "general"), move_y(new Axis(KeyCode.s, KeyCode.w)), - mouse_move(KeyCode.mouseForward), + mouse_move(KeyCode.mouseBack), + pan(KeyCode.mouseForward), boost(KeyCode.shiftLeft), control(KeyCode.controlLeft), diff --git a/core/src/mindustry/input/DesktopInput.java b/core/src/mindustry/input/DesktopInput.java index 58db9860d5..f194c64fb8 100644 --- a/core/src/mindustry/input/DesktopInput.java +++ b/core/src/mindustry/input/DesktopInput.java @@ -43,6 +43,8 @@ public class DesktopInput extends InputHandler{ /** Whether player is currently deleting removal requests. */ private boolean deleting = false, shouldShoot = false; + private boolean panning = false; + @Override public void buildUI(Group group){ group.fill(t -> { @@ -178,22 +180,35 @@ public class DesktopInput extends InputHandler{ ui.listfrag.toggle(); } - //TODO awful UI state checking code - if((player.dead() || state.isPaused()) && !ui.chatfrag.shown()){ - if(!(scene.getKeyboardFocus() instanceof TextField) && !scene.hasDialog()){ - //move camera around - float camSpeed = !Core.input.keyDown(Binding.boost) ? 3f : 8f; - Core.camera.position.add(Tmp.v1.setZero().add(Core.input.axis(Binding.move_x), Core.input.axis(Binding.move_y)).nor().scl(Time.delta * camSpeed)); + boolean panCam = false; + float camSpeed = !Core.input.keyDown(Binding.boost) ? 3f : 8f; - if(Core.input.keyDown(Binding.mouse_move)){ - Core.camera.position.x += Mathf.clamp((Core.input.mouseX() - Core.graphics.getWidth() / 2f) * 0.005f, -1, 1) * camSpeed; - Core.camera.position.y += Mathf.clamp((Core.input.mouseY() - Core.graphics.getHeight() / 2f) * 0.005f, -1, 1) * camSpeed; - } + if(input.keyDown(Binding.pan)){ + panCam = true; + panning = true; + } + + if(Math.abs(Core.input.axis(Binding.move_x)) > 0 || Math.abs(Core.input.axis(Binding.move_y)) > 0){ + panning = false; + } + + //TODO awful UI state checking code + if(((player.dead() || state.isPaused()) && !ui.chatfrag.shown()) && (!(scene.getKeyboardFocus() instanceof TextField) && !scene.hasDialog())){ + if(input.keyDown(Binding.mouse_move)){ + panCam = true; } - }else if(!player.dead()){ + panning = false; + + Core.camera.position.add(Tmp.v1.setZero().add(Core.input.axis(Binding.move_x), Core.input.axis(Binding.move_y)).nor().scl(Time.delta * camSpeed)); + }else if(!player.dead() && !panning){ Core.camera.position.lerpDelta(player, Core.settings.getBool("smoothcamera") ? 0.08f : 1f); } + if(panCam){ + Core.camera.position.x += Mathf.clamp((Core.input.mouseX() - Core.graphics.getWidth() / 2f) * 0.005f, -1, 1) * camSpeed; + Core.camera.position.y += Mathf.clamp((Core.input.mouseY() - Core.graphics.getHeight() / 2f) * 0.005f, -1, 1) * camSpeed; + } + shouldShoot = !scene.hasMouse(); if(!scene.hasMouse()){ diff --git a/core/src/mindustry/net/Administration.java b/core/src/mindustry/net/Administration.java index 11ed794a4a..1901592263 100644 --- a/core/src/mindustry/net/Administration.java +++ b/core/src/mindustry/net/Administration.java @@ -5,6 +5,7 @@ import arc.func.*; import arc.struct.*; import arc.util.ArcAnnotate.*; import arc.util.*; +import arc.util.Log.*; import arc.util.pooling.Pool.*; import arc.util.pooling.*; import mindustry.*; @@ -576,7 +577,8 @@ public class Administration{ motd("The message displayed to people on connection.", "off"), autosave("Whether the periodically save the map when playing.", false), autosaveAmount("The maximum amount of autosaves. Older ones get replaced.", 10), - autosaveSpacing("Spacing between autosaves in seconds.", 60 * 5); + autosaveSpacing("Spacing between autosaves in seconds.", 60 * 5), + debug("Enable debug logging", false, () -> Log.setLogLevel(debug() ? LogLevel.debug : LogLevel.info)); public static final Config[] all = values(); @@ -635,6 +637,10 @@ public class Administration{ Core.settings.put(key, value); changed.run(); } + + private static boolean debug(){ + return Config.debug.bool(); + } } public static class PlayerInfo{ diff --git a/core/src/mindustry/net/ArcNetProvider.java b/core/src/mindustry/net/ArcNetProvider.java index 5fce1d1373..ea0146312e 100644 --- a/core/src/mindustry/net/ArcNetProvider.java +++ b/core/src/mindustry/net/ArcNetProvider.java @@ -1,10 +1,10 @@ package mindustry.net; import arc.*; -import arc.struct.*; import arc.func.*; import arc.net.*; import arc.net.FrameworkMessage.*; +import arc.struct.*; import arc.util.*; import arc.util.async.*; import arc.util.pooling.*; @@ -28,7 +28,9 @@ public class ArcNetProvider implements NetProvider{ Thread serverThread; public ArcNetProvider(){ - client = new Client(8192, 4096, new PacketSerializer()); + ArcNet.errorHandler = e -> Log.debug(Strings.getStackTrace(e)); + + client = new Client(8192, 8192, new PacketSerializer()); client.setDiscoveryPacket(packetSupplier); client.addListener(new NetListener(){ @Override @@ -66,7 +68,7 @@ public class ArcNetProvider implements NetProvider{ } }); - server = new Server(4096 * 2, 4096, new PacketSerializer()); + server = new Server(8192, 8192, new PacketSerializer()); server.setMulticast(multicastGroup, multicastPort); server.setDiscoveryHandler((address, handler) -> { ByteBuffer buffer = NetworkIO.writeServerData(); diff --git a/core/src/mindustry/world/blocks/logic/LogicBlock.java b/core/src/mindustry/world/blocks/logic/LogicBlock.java index eed8e128c3..9d49935bc5 100644 --- a/core/src/mindustry/world/blocks/logic/LogicBlock.java +++ b/core/src/mindustry/world/blocks/logic/LogicBlock.java @@ -25,7 +25,7 @@ import java.util.zip.*; import static mindustry.Vars.*; public class LogicBlock extends Block{ - public static final int maxInstructions = 2000; + public static final int maxInstructions = 1500; public int maxInstructionScale = 5; public int instructionsPerTick = 1; diff --git a/server/src/mindustry/server/ServerControl.java b/server/src/mindustry/server/ServerControl.java index 2f21c35eeb..29789f52a6 100644 --- a/server/src/mindustry/server/ServerControl.java +++ b/server/src/mindustry/server/ServerControl.java @@ -64,6 +64,9 @@ public class ServerControl implements ApplicationListener{ "globalrules", "{reactorExplosions: false}" ); + //update log level + Config.debug.set(Config.debug.bool()); + Log.setLogger((level, text) -> { String result = "[" + dateTime.format(LocalDateTime.now()) + "] " + format(tags[level.ordinal()] + " " + text + "&fr"); System.out.println(result);