From d65beea17954f81aabd541d7c9d8a0b1a11d3194 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 12 Sep 2018 10:07:10 -0400 Subject: [PATCH] Removed debug menu / Crash fix / Ship speed warp fix / String locale fix --- build.gradle | 2 +- core/src/io/anuke/mindustry/Vars.java | 1 - .../src/io/anuke/mindustry/content/Mechs.java | 8 +- core/src/io/anuke/mindustry/core/Control.java | 4 - .../io/anuke/mindustry/core/NetServer.java | 29 +++--- core/src/io/anuke/mindustry/core/UI.java | 2 - core/src/io/anuke/mindustry/io/TypeIO.java | 5 +- .../anuke/mindustry/net/Administration.java | 14 ++- .../mindustry/ui/fragments/DebugFragment.java | 96 ------------------- .../anuke/mindustry/server/ServerControl.java | 6 +- 10 files changed, 33 insertions(+), 134 deletions(-) delete mode 100644 core/src/io/anuke/mindustry/ui/fragments/DebugFragment.java diff --git a/build.gradle b/build.gradle index 5e896dbdf5..6fd627a388 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,7 @@ allprojects { appName = 'Mindustry' gdxVersion = '1.9.8' roboVMVersion = '2.3.0' - uCoreVersion = '92770a6b462953cb183e7d204f4fc8226b66b2a8' + uCoreVersion = '74dc653bbd66d1e8b10e22efb4f1206195674dd5' getVersionString = { String buildVersion = getBuildVersion() diff --git a/core/src/io/anuke/mindustry/Vars.java b/core/src/io/anuke/mindustry/Vars.java index 895f7680b1..e5798b39f6 100644 --- a/core/src/io/anuke/mindustry/Vars.java +++ b/core/src/io/anuke/mindustry/Vars.java @@ -89,7 +89,6 @@ public class Vars{ public static float fontScale; //camera zoom displayed on startup public static int baseCameraScale; - public static boolean console = false; public static boolean showBlockDebug = false; public static boolean showFog = true; public static boolean headless = false; diff --git a/core/src/io/anuke/mindustry/content/Mechs.java b/core/src/io/anuke/mindustry/content/Mechs.java index 36b9d1f29e..d100b5af2b 100644 --- a/core/src/io/anuke/mindustry/content/Mechs.java +++ b/core/src/io/anuke/mindustry/content/Mechs.java @@ -245,7 +245,7 @@ public class Mechs implements ContentList{ drillPower = 1; mineSpeed = 0.9f; speed = 0.4f; - maxSpeed = 3f; + maxSpeed = 10f; drag = 0.1f; armor = 10f; weapon = Weapons.blasterSmall; @@ -262,7 +262,7 @@ public class Mechs implements ContentList{ { drillPower = -1; speed = 0.11f; - maxSpeed = 3.4f; + maxSpeed = 10f; drag = 0.01f; armor = 5f; weapon = Weapons.missiles; @@ -316,7 +316,7 @@ public class Mechs implements ContentList{ { drillPower = 2; speed = 0.12f; - maxSpeed = 3.4f; + maxSpeed = 10f; drag = 0.035f; turnCursor = false; armor = 20f; @@ -338,7 +338,7 @@ public class Mechs implements ContentList{ drillPower = 4; mineSpeed = 1.3f; speed = 0.32f; - maxSpeed = 3f; + maxSpeed = 10f; drag = 0.06f; armor = 30f; itemCapacity = 60; diff --git a/core/src/io/anuke/mindustry/core/Control.java b/core/src/io/anuke/mindustry/core/Control.java index d31a95d310..61246c4245 100644 --- a/core/src/io/anuke/mindustry/core/Control.java +++ b/core/src/io/anuke/mindustry/core/Control.java @@ -356,10 +356,6 @@ public class Control extends Module{ throw new RuntimeException(error); } - if(Inputs.keyTap(io.anuke.ucore.input.Input.GRAVE)){ - console = !console; - } - saves.update(); triggerUpdateInput(); diff --git a/core/src/io/anuke/mindustry/core/NetServer.java b/core/src/io/anuke/mindustry/core/NetServer.java index a068d85ded..6dc339e43a 100644 --- a/core/src/io/anuke/mindustry/core/NetServer.java +++ b/core/src/io/anuke/mindustry/core/NetServer.java @@ -23,7 +23,6 @@ import io.anuke.mindustry.net.*; import io.anuke.mindustry.net.Administration.PlayerInfo; import io.anuke.mindustry.net.Packets.*; import io.anuke.mindustry.world.Tile; -import io.anuke.ucore.core.Settings; import io.anuke.ucore.core.Timers; import io.anuke.ucore.entities.Entities; import io.anuke.ucore.entities.EntityGroup; @@ -126,7 +125,7 @@ public class NetServer extends Module{ return; } - boolean preventDuplicates = headless && isStrict(); + boolean preventDuplicates = headless && netServer.admins.getStrict(); if(preventDuplicates){ for(Player player : playerGroup.all()){ @@ -219,15 +218,6 @@ public class NetServer extends Module{ }); } - private static float compound(float speed, float drag){ - float total = 0f; - for(int i = 0; i < 20; i++){ - total *= (1f - drag); - total += speed; - } - return total; - } - /** Sends a raw byte[] snapshot to a client, splitting up into chunks when needed.*/ private static void sendSplitSnapshot(int userid, byte[] bytes, int snapshotID, int uncompressedLength){ if(bytes.length < maxSnapshotSize){ @@ -267,10 +257,6 @@ public class NetServer extends Module{ } } - public static boolean isStrict(){ - return Settings.getBool("strict", true); - } - public void sendWorldData(Player player, int clientID){ ByteArrayOutputStream stream = new ByteArrayOutputStream(); DeflaterOutputStream def = new DeflaterOutputStream(stream); @@ -291,6 +277,15 @@ public class NetServer extends Module{ netServer.connections.remove(player.con.id); } + private static float compound(float speed, float drag){ + float total = 0f; + for(int i = 0; i < 50; i++){ + total *= (1f - drag); + total += speed; + } + return total; + } + @Remote(targets = Loc.client, unreliable = true) public static void onClientShapshot( Player player, @@ -307,7 +302,7 @@ public class NetServer extends Module{ NetConnection connection = player.con; if(connection == null || snapshotID < connection.lastRecievedClientSnapshot) return; - boolean verifyPosition = !player.isDead() && isStrict() && headless && player.getCarrier() == null; + boolean verifyPosition = !player.isDead() && netServer.admins.getStrict() && headless && player.getCarrier() == null; if(connection.lastRecievedClientTime == 0) connection.lastRecievedClientTime = TimeUtils.millis() - 16; @@ -319,7 +314,7 @@ public class NetServer extends Module{ long elapsed = TimeUtils.timeSinceMillis(connection.lastRecievedClientTime); float maxSpeed = boosting && !player.mech.flying ? player.mech.boostSpeed : player.mech.speed; - float maxMove = elapsed / 1000f * 60f * Math.min(compound(maxSpeed, player.mech.drag) * 1.2f, player.mech.maxSpeed * 1.05f); + float maxMove = elapsed / 1000f * 60f * Math.min(compound(maxSpeed, player.mech.drag) * 1.25f, player.mech.maxSpeed * 1.1f); player.pointerX = pointerX; player.pointerY = pointerY; diff --git a/core/src/io/anuke/mindustry/core/UI.java b/core/src/io/anuke/mindustry/core/UI.java index 198c109618..2eae60336f 100644 --- a/core/src/io/anuke/mindustry/core/UI.java +++ b/core/src/io/anuke/mindustry/core/UI.java @@ -39,7 +39,6 @@ public class UI extends SceneModule{ public final PlayerListFragment listfrag = new PlayerListFragment(); public final BackgroundFragment backfrag = new BackgroundFragment(); public final LoadingFragment loadfrag = new LoadingFragment(); - public final DebugFragment debugfrag = new DebugFragment(); public AboutDialog about; public RestartDialog restart; @@ -177,7 +176,6 @@ public class UI extends SceneModule{ menufrag.build(group); chatfrag.container().build(group); listfrag.build(group); - debugfrag.build(group); loadfrag.build(group); } diff --git a/core/src/io/anuke/mindustry/io/TypeIO.java b/core/src/io/anuke/mindustry/io/TypeIO.java index 9cac976ee0..a6d653598e 100644 --- a/core/src/io/anuke/mindustry/io/TypeIO.java +++ b/core/src/io/anuke/mindustry/io/TypeIO.java @@ -26,6 +26,7 @@ import io.anuke.ucore.core.Effects.Effect; import io.anuke.ucore.entities.Entities; import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; import static io.anuke.mindustry.Vars.*; @@ -329,7 +330,7 @@ public class TypeIO{ @WriteClass(String.class) public static void writeString(ByteBuffer buffer, String string){ if(string != null){ - byte[] bytes = string.getBytes(); + byte[] bytes = string.getBytes(StandardCharsets.UTF_8); buffer.putShort((short) bytes.length); buffer.put(bytes); }else{ @@ -343,7 +344,7 @@ public class TypeIO{ if(length != -1){ byte[] bytes = new byte[length]; buffer.get(bytes); - return new String(bytes); + return new String(bytes, StandardCharsets.UTF_8); }else{ return null; } diff --git a/core/src/io/anuke/mindustry/net/Administration.java b/core/src/io/anuke/mindustry/net/Administration.java index 4c0a50469c..b303bf4d2a 100644 --- a/core/src/io/anuke/mindustry/net/Administration.java +++ b/core/src/io/anuke/mindustry/net/Administration.java @@ -18,19 +18,25 @@ public class Administration{ private ObjectMap traceInfo = new ObjectMap<>(); /** Maps packed coordinates to logs for that coordinate*/ private IntMap> editLogs = new IntMap<>(); - private Array bannedIPs = new Array<>(); public Administration(){ Settings.defaultList( - "antigrief", false, - "antigrief-max", defaultMaxBrokenBlocks, - "antigrief-cooldown", defaultBreakCooldown + "strict", true ); load(); } + public void setStrict(boolean on){ + Settings.putBool("strict", on); + Settings.save(); + } + + public boolean getStrict(){ + return Settings.getBool("strict"); + } + public boolean allowsCustomClients(){ return Settings.getBool("allow-custom", !headless); } diff --git a/core/src/io/anuke/mindustry/ui/fragments/DebugFragment.java b/core/src/io/anuke/mindustry/ui/fragments/DebugFragment.java deleted file mode 100644 index 321eb3cfc3..0000000000 --- a/core/src/io/anuke/mindustry/ui/fragments/DebugFragment.java +++ /dev/null @@ -1,96 +0,0 @@ -package io.anuke.mindustry.ui.fragments; - -import io.anuke.mindustry.entities.Player; -import io.anuke.mindustry.entities.TileEntity; -import io.anuke.mindustry.net.Net; -import io.anuke.ucore.core.Timers; -import io.anuke.ucore.entities.EntityGroup; -import io.anuke.ucore.scene.Group; -import io.anuke.ucore.scene.ui.Label; - -import static io.anuke.mindustry.Vars.*; - -public class DebugFragment extends Fragment{ - - public static String debugInfo(){ - int totalUnits = 0; - for(EntityGroup group : unitGroups){ - totalUnits += group.size(); - } - - totalUnits += playerGroup.size(); - - StringBuilder result = join( - "net.active: " + Net.active(), - "net.server: " + Net.server(), - "net.client: " + Net.client(), - "state: " + state.getState(), - "units: " + totalUnits, - "bullets: " + bulletGroup.size(), - Net.client() ? - "chat.open: " + ui.chatfrag.chatOpen() + "\n" + - "chat.messages: " + ui.chatfrag.getMessagesSize() + "\n" + - "client.connecting: " + netClient.isConnecting() + "\n" : "", - "players: " + playerGroup.size(), - "tiles: " + tileGroup.size(), - "tiles.sleeping: " + TileEntity.sleepingEntities, - "time: " + Timers.time(), - "state.gameover: " + state.gameOver, - "state: " + state.getState() - ); - - result.append("players: "); - - for(Player player : playerGroup.all()){ - result.append(" name: "); - result.append(player.name); - result.append("\n"); - result.append(" id: "); - result.append(player.id); - result.append("\n"); - result.append(" cid: "); - result.append(player.con == null ? -1 : player.con.id); - result.append("\n"); - result.append(" dead: "); - result.append(player.isDead()); - result.append("\n"); - result.append(" pos: "); - result.append(player.x); - result.append(", "); - result.append(player.y); - result.append("\n"); - result.append(" mech: "); - result.append(player.mech); - result.append("\n"); - result.append(" local: "); - result.append(player.isLocal); - result.append("\n"); - - result.append("\n"); - } - - return result.toString(); - } - - private static StringBuilder join(String... strings){ - StringBuilder builder = new StringBuilder(); - for(String string : strings){ - builder.append(string); - builder.append("\n"); - } - return builder; - } - - @Override - public void build(Group parent){ - parent.fill(t -> { - t.top().left().visible(() -> console); - - t.table("pane", p -> { - p.defaults().fillX(); - - p.pane("clear", new Label(DebugFragment::debugInfo)); - }); - }); - } -} diff --git a/server/src/io/anuke/mindustry/server/ServerControl.java b/server/src/io/anuke/mindustry/server/ServerControl.java index 002357dab0..8fa9796d1c 100644 --- a/server/src/io/anuke/mindustry/server/ServerControl.java +++ b/server/src/io/anuke/mindustry/server/ServerControl.java @@ -337,8 +337,8 @@ public class ServerControl extends Module{ handler.register("strict", "", "Disables or enables strict mode", arg -> { boolean value = arg[0].equalsIgnoreCase("on"); - Settings.putBool("strict", value); - info("Debug mode is now {0}.", Settings.getBool("strict", true) ? "on" : "off"); + netServer.admins.setStrict(value); + info("Strict mode is now {0}.", netServer.admins.getStrict() ? "on" : "off"); }); handler.register("allow-custom-clients", "[on/off]", "Allow or disallow custom clients.", arg -> { @@ -903,7 +903,7 @@ public class ServerControl extends Module{ checkPvPGameOver(); } - if(state.is(State.playing) && world.getSector() != null && !inExtraRound){ + if(state.is(State.playing) && world.getSector() != null && !inExtraRound && netServer.admins.getStrict()){ //all assigned missions are complete if(world.getSector().completedMissions >= world.getSector().missions.size){ Log.info("Mission complete.");