Skip to content

Commit

Permalink
More debug stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Anuken committed Dec 21, 2021
1 parent a093ba5 commit 2dfa238
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
23 changes: 14 additions & 9 deletions core/src/mindustry/core/NetServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -578,21 +578,25 @@ public static void requestDebugStatus(Player player){
(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
);
}

Expand Down Expand Up @@ -959,6 +963,7 @@ public void writeEntitySnapshot(Player player) throws IOException{
Call.entitySnapshot(player.con, (short)sent, syncStream.toByteArray());
}

player.con.snapshotsSent ++;
}

String fixName(String name){
Expand Down
2 changes: 2 additions & 0 deletions core/src/mindustry/net/NetConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down

0 comments on commit 2dfa238

Please sign in to comment.