From 741082f2379358cb109fef07cb45757d045923b1 Mon Sep 17 00:00:00 2001 From: MrMaho Date: Sat, 26 Sep 2026 22:45:21 +0200 Subject: [PATCH] Ping measurement and display (console: ping) Co-Authored-By: Claude Opus 5.5 --- GameServer.cs | 2 ++ Protocol.cs | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/GameServer.cs b/GameServer.cs index 16f08c0..f8aea44 100644 --- a/GameServer.cs +++ b/GameServer.cs @@ -263,6 +263,8 @@ public sealed class GameServer return; case MsgType.Ping: + // Mit Zeitstempel: sofort zurückschicken, damit der Spieler seinen Ping sieht + if (m.Payload.Length > 0 && m.Payload.Length <= 16) c.Conn.Send(MsgType.Pong, m.Payload); return; case MsgType.AdminListRequest: diff --git a/Protocol.cs b/Protocol.cs index d0802ed..451963e 100644 --- a/Protocol.cs +++ b/Protocol.cs @@ -34,7 +34,8 @@ public enum MsgType : byte AdminResult = 27, // Server -> Client: string Meldung Chat = 28, // Chatnachricht (string) VarSync = 29, // Fahrzeugzustand: int n, je [int key, byte typ, wert] - Teleport = 30 // Admin holt einen Spieler zu sich: 3 float Position + Teleport = 30, // Admin holt einen Spieler zu sich: 3 float Position + Pong = 31 // Antwort auf Ping mit demselben Zeitstempel (Laufzeit messen) } public readonly record struct Message(MsgType Type, byte[] Payload)