Removed debug menu / Crash fix / Ship speed warp fix / String locale fix

This commit is contained in:
Anuken
2018-09-12 10:07:10 -04:00
parent b19f3ff8cf
commit d65beea179
10 changed files with 33 additions and 134 deletions

View File

@ -27,7 +27,7 @@ allprojects {
appName = 'Mindustry'
gdxVersion = '1.9.8'
roboVMVersion = '2.3.0'
uCoreVersion = '92770a6b462953cb183e7d204f4fc8226b66b2a8'
uCoreVersion = '74dc653bbd66d1e8b10e22efb4f1206195674dd5'
getVersionString = {
String buildVersion = getBuildVersion()

View File

@ -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;

View File

@ -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;

View File

@ -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();

View File

@ -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;

View File

@ -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);
}

View File

@ -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;
}

View File

@ -18,19 +18,25 @@ public class Administration{
private ObjectMap<String, TraceInfo> traceInfo = new ObjectMap<>();
/** Maps packed coordinates to logs for that coordinate*/
private IntMap<Array<EditLog>> editLogs = new IntMap<>();
private Array<String> 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);
}

View File

@ -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));
});
});
}
}

View File

@ -337,8 +337,8 @@ public class ServerControl extends Module{
handler.register("strict", "<on/off>", "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.");