mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Fix ICommonSession.Ping (#5453)
This commit is contained in:
@@ -43,7 +43,7 @@ END TEMPLATE-->
|
||||
|
||||
### Bugfixes
|
||||
|
||||
*None yet*
|
||||
* Fixed `ICommonSession.Ping` always returning zero instead of the ping. Note that this will still return zero for client-side code when trying to get the ping of other players.
|
||||
|
||||
### Other
|
||||
|
||||
|
||||
@@ -261,7 +261,6 @@ namespace Robust.Client.Player
|
||||
// This is a new userid, so we create a new session.
|
||||
DebugTools.Assert(state.UserId != LocalPlayer?.UserId);
|
||||
var newSession = (ICommonSessionInternal)CreateAndAddSession(state.UserId, state.Name);
|
||||
newSession.SetPing(state.Ping);
|
||||
SetStatus(newSession, state.Status);
|
||||
SetAttachedEntity(newSession, controlled, out _, true);
|
||||
dirty = true;
|
||||
@@ -271,7 +270,6 @@ namespace Robust.Client.Player
|
||||
// Check if the data is actually different
|
||||
if (session.Name == state.Name
|
||||
&& session.Status == state.Status
|
||||
&& session.Ping == state.Ping
|
||||
&& session.AttachedEntity == controlled)
|
||||
{
|
||||
continue;
|
||||
@@ -280,7 +278,6 @@ namespace Robust.Client.Player
|
||||
dirty = true;
|
||||
var local = (ICommonSessionInternal)session;
|
||||
local.SetName(state.Name);
|
||||
local.SetPing(state.Ping);
|
||||
SetStatus(local, state.Status);
|
||||
SetAttachedEntity(local, controlled, out _, true);
|
||||
}
|
||||
|
||||
@@ -137,8 +137,7 @@ namespace Robust.Server.Player
|
||||
{
|
||||
UserId = client.UserId,
|
||||
Name = client.Name,
|
||||
Status = client.Status,
|
||||
Ping = client.Channel!.Ping
|
||||
Status = client.Status
|
||||
};
|
||||
list.Add(info);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,10 @@ namespace Robust.Shared.GameStates
|
||||
[ViewVariables]
|
||||
public SessionStatus Status { get; set; }
|
||||
|
||||
// TODO PlayerManager
|
||||
// Network ping information, though probably do it outside of SessionState to avoid re-sending the name and such
|
||||
// for all players every few seconds.
|
||||
[Obsolete("Ping data is not currently networked")]
|
||||
[ViewVariables]
|
||||
public short Ping { get; set; }
|
||||
|
||||
@@ -34,7 +38,6 @@ namespace Robust.Shared.GameStates
|
||||
UserId = UserId,
|
||||
Name = Name,
|
||||
Status = Status,
|
||||
Ping = Ping,
|
||||
ControlledEntity = ControlledEntity
|
||||
};
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ namespace Robust.Shared.Network.Messages
|
||||
UserId = new NetUserId(buffer.ReadGuid()),
|
||||
Name = buffer.ReadString(),
|
||||
Status = (SessionStatus)buffer.ReadByte(),
|
||||
Ping = buffer.ReadInt16()
|
||||
};
|
||||
Plyrs.Add(plyNfo);
|
||||
}
|
||||
@@ -40,7 +39,6 @@ namespace Robust.Shared.Network.Messages
|
||||
buffer.Write(ply.UserId.UserId);
|
||||
buffer.Write(ply.Name);
|
||||
buffer.Write((byte) ply.Status);
|
||||
buffer.Write(ply.Ping);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,12 @@ internal sealed class CommonSession : ICommonSessionInternal
|
||||
public string Name { get; set; } = "<Unknown>";
|
||||
|
||||
[ViewVariables]
|
||||
public short Ping { get; set; }
|
||||
public short Ping
|
||||
{
|
||||
get => Channel?.Ping ?? _ping;
|
||||
set => _ping = value;
|
||||
}
|
||||
private short _ping;
|
||||
|
||||
[ViewVariables]
|
||||
public DateTime ConnectedTime { get; set; }
|
||||
|
||||
@@ -33,9 +33,12 @@ public interface ICommonSession
|
||||
string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Current connection latency of this session from the server to their client.
|
||||
/// Current connection latency of this session. If <see cref="Channel"/> is not null this simply returns
|
||||
/// <see cref="INetChannel.Ping"/>. This is not currently usable by client-side code that wants to try access ping
|
||||
/// information of other players.
|
||||
/// </summary>
|
||||
short Ping { get; }
|
||||
// TODO PlayerManager ping networking.
|
||||
|
||||
/// <summary>
|
||||
/// The current network channel for this session.
|
||||
|
||||
@@ -18,6 +18,9 @@ internal abstract partial class SharedPlayerManager
|
||||
if (LastStateUpdate < fromTick)
|
||||
return;
|
||||
|
||||
// TODO PlayerManager delta states
|
||||
// Track last update tick/time per session, and only send sessions that actually changed.
|
||||
|
||||
states.EnsureCapacity(InternalSessions.Count);
|
||||
foreach (var player in InternalSessions.Values)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user