From 2a306d70be3d4e22c0fd7039a50cafa06f10b8e2 Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 8 Mar 2018 21:56:20 -0500 Subject: [PATCH] Fixed invalid web servers, teleporter clearing, desktop input misplace --- core/assets/version.properties | 4 ++-- core/src/io/anuke/mindustry/input/DesktopInput.java | 12 ++++++++---- .../world/blocks/types/distribution/Teleporter.java | 2 ++ .../io/anuke/mindustry/client/WebsocketClient.java | 8 ++++++-- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/core/assets/version.properties b/core/assets/version.properties index d373c22de7..8cb2f67c88 100644 --- a/core/assets/version.properties +++ b/core/assets/version.properties @@ -1,7 +1,7 @@ #Autogenerated file. Do not modify. -#Thu Mar 08 18:52:47 EST 2018 +#Thu Mar 08 20:46:47 EST 2018 version=release -androidBuildCode=356 +androidBuildCode=357 name=Mindustry code=3.4 build=33 diff --git a/core/src/io/anuke/mindustry/input/DesktopInput.java b/core/src/io/anuke/mindustry/input/DesktopInput.java index 859665faa9..4baa52614f 100644 --- a/core/src/io/anuke/mindustry/input/DesktopInput.java +++ b/core/src/io/anuke/mindustry/input/DesktopInput.java @@ -23,10 +23,10 @@ public class DesktopInput extends InputHandler{ private boolean beganBreak; private boolean rotated = false, rotatedAlt, zoomed; - @Override public float getCursorEndX(){ return endx; } - @Override public float getCursorEndY(){ return endy; } - @Override public float getCursorX(){ return (int)(Graphics.screen(mousex, mousey).x + 2); } - @Override public float getCursorY(){ return (int)(Gdx.graphics.getHeight() - 1 - Graphics.screen(mousex, mousey).y); } + @Override public float getCursorEndX(){ return select() ? getCursorX() : endx; } + @Override public float getCursorEndY(){ return select() ? getCursorY() : endy; } + @Override public float getCursorX(){ return (int)(Graphics.screen(mousex, mousey).x); } + @Override public float getCursorY(){ return (int)(Gdx.graphics.getHeight() - Graphics.screen(mousex, mousey).y); } @Override public boolean drawPlace(){ return !beganBreak; } @Override @@ -156,6 +156,10 @@ public class DesktopInput extends InputHandler{ } + boolean select(){ + return !Inputs.keyDown("select") && !Inputs.keyRelease("select"); + } + public int tilex(){ return (recipe != null && recipe.result.isMultiblock() && recipe.result.width % 2 == 0) ? diff --git a/core/src/io/anuke/mindustry/world/blocks/types/distribution/Teleporter.java b/core/src/io/anuke/mindustry/world/blocks/types/distribution/Teleporter.java index 9f90545322..6c185a4d10 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/distribution/Teleporter.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/distribution/Teleporter.java @@ -19,6 +19,7 @@ import io.anuke.ucore.util.Strings; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; +import java.util.Arrays; import static io.anuke.mindustry.Vars.syncBlockState; @@ -55,6 +56,7 @@ public class Teleporter extends PowerBlock{ TeleporterEntity entity = tile.entity(); if(entity != null){ entity.color = data; + Arrays.fill(entity.items, 0); } } diff --git a/html/src/io/anuke/mindustry/client/WebsocketClient.java b/html/src/io/anuke/mindustry/client/WebsocketClient.java index 36bd641128..75bb3339f7 100644 --- a/html/src/io/anuke/mindustry/client/WebsocketClient.java +++ b/html/src/io/anuke/mindustry/client/WebsocketClient.java @@ -114,8 +114,12 @@ public class WebsocketClient implements ClientProvider { @Override public void onMessage(String msg) { - Host host = NetworkIO.readServerData(address, ByteBuffer.wrap(Base64Coder.decode(msg))); - valid.accept(host); + byte[] bytes = Base64Coder.decode(msg); + Host host = NetworkIO.readServerData(address, ByteBuffer.wrap(bytes)); + if(bytes.length != 128) + valid.accept(new Host("Unknown", address, "Unknown", 0, 0, 0)); + else + valid.accept(host); accepted[0] = true; socket.close(); }