From 2dfa238ff39dfe66696767551da33aeeb33c6969 Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 21 Dec 2021 10:33:09 -0500 Subject: [PATCH] More debug stats --- core/src/mindustry/core/NetServer.java | 23 ++++++++++++++--------- core/src/mindustry/net/NetConnection.java | 2 ++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/core/src/mindustry/core/NetServer.java b/core/src/mindustry/core/NetServer.java index 6c39803bf1..2a5e73b1a3 100644 --- a/core/src/mindustry/core/NetServer.java +++ b/core/src/mindustry/core/NetServer.java @@ -578,21 +578,25 @@ public class NetServer implements ApplicationListener{ (player.isAdded() ? 4 : 0) | (player.con.hasBegunConnecting ? 8 : 0); - Call.debugStatusClient(player.con, flags); - Call.debugStatusClientUnreliable(player.con, flags); + Call.debugStatusClient(player.con, flags, player.con.lastReceivedClientSnapshot, player.con.snapshotsSent); + Call.debugStatusClientUnreliable(player.con, flags, player.con.lastReceivedClientSnapshot, player.con.snapshotsSent); } @Remote(variants = Variant.both, priority = PacketPriority.high) - public static void debugStatusClient(int value){ - Log.info("[RELIABLE] Debug status received. disconnected = @, connected = @, added = @, begunConnecting = @", - (value & 1) != 0, (value & 2) != 0, (value & 4) != 0, (value & 8) != 0 - ); + public static void debugStatusClient(int value, int lastClientSnapshot, int snapshotsSent){ + logClientStatus(true, value, lastClientSnapshot, snapshotsSent); } @Remote(variants = Variant.both, priority = PacketPriority.high, unreliable = true) - public static void debugStatusClientUnreliable(int value){ - Log.info("[UNRELIABLE] Debug status received. disconnected = @, connected = @, added = @, begunConnecting = @", - (value & 1) != 0, (value & 2) != 0, (value & 4) != 0, (value & 8) != 0 + public static void debugStatusClientUnreliable(int value, int lastClientSnapshot, int snapshotsSent){ + logClientStatus(false, value, lastClientSnapshot, snapshotsSent); + } + + static void logClientStatus(boolean reliable, int value, int lastClientSnapshot, int snapshotsSent){ + Log.info("@ Debug status received. disconnected = @, connected = @, added = @, begunConnecting = @ lastClientSnapshot = @, snapshotsSent = @", + reliable ? "[RELIABLE]" : "[UNRELIABLE]", + (value & 1) != 0, (value & 2) != 0, (value & 4) != 0, (value & 8) != 0, + lastClientSnapshot, snapshotsSent ); } @@ -959,6 +963,7 @@ public class NetServer implements ApplicationListener{ Call.entitySnapshot(player.con, (short)sent, syncStream.toByteArray()); } + player.con.snapshotsSent ++; } String fixName(String name){ diff --git a/core/src/mindustry/net/NetConnection.java b/core/src/mindustry/net/NetConnection.java index 3d9ac3e5ee..09929ec27f 100644 --- a/core/src/mindustry/net/NetConnection.java +++ b/core/src/mindustry/net/NetConnection.java @@ -22,6 +22,8 @@ public abstract class NetConnection{ public long connectTime = Time.millis(); /** ID of last received client snapshot. */ public int lastReceivedClientSnapshot = -1; + /** Count of snapshots sent from server. */ + public int snapshotsSent; /** Timestamp of last received snapshot. */ public long lastReceivedClientTime; /** Build requests that have been recently rejected. This is cleared every snapshot. */