Tickrate is now a ushort

Fixes #5592

This allows net.tickrate to be set to a max of 65535 instead of 255.

I didn't raise it fully to a uint because there are many places it's cast to an int, so uint would cause various compiler errors and compat issues I don't wanna deal with.
This commit is contained in:
PJB3005
2025-01-16 01:13:50 +01:00
parent bcc4cd77cf
commit a314c5f797
5 changed files with 11 additions and 11 deletions

View File

@@ -88,10 +88,10 @@ namespace Robust.Client
{
if (GameInfo != null)
{
GameInfo.TickRate = (byte) tickrate;
GameInfo.TickRate = (ushort) tickrate;
}
_timing.SetTickRateAt((byte) tickrate, info.TickChanged);
_timing.SetTickRateAt((ushort) tickrate, info.TickChanged);
_logger.Info($"Tickrate changed to: {tickrate} on tick {_timing.CurTick}");
}
@@ -395,6 +395,6 @@ namespace Robust.Client
/// </summary>
public int ServerMaxPlayers { get; set; }
public byte TickRate { get; internal set; }
public uint TickRate { get; internal set; }
}
}

View File

@@ -586,7 +586,7 @@ namespace Robust.Server
{
_config.OnValueChanged(CVars.NetTickrate, i =>
{
var b = (byte) i;
var b = (ushort) i;
_time.TickRate = b;
_logger.Info($"Tickrate changed to: {b} on tick {_time.CurTick}");
@@ -594,7 +594,7 @@ namespace Robust.Server
var startOffset = TimeSpan.FromSeconds(_config.GetCVar(CVars.NetTimeStartOffset));
_time.TimeBase = (startOffset, GameTick.First);
_time.TickRate = (byte) _config.GetCVar(CVars.NetTickrate);
_time.TickRate = (ushort) _config.GetCVar(CVars.NetTickrate);
_logger.Info($"Name: {ServerName}");
_logger.Info($"TickRate: {_time.TickRate}({_time.TickPeriod.TotalMilliseconds:0.00}ms)");

View File

@@ -22,7 +22,7 @@ public sealed class CommandBuffer
_commandBuffer.AddFirst(command);
}
public void Tick(byte tickRate)
public void Tick(ushort tickRate)
{
_tickrate = tickRate;

View File

@@ -123,13 +123,13 @@ namespace Robust.Shared.Timing
/// </summary>
public TimeSpan LastTick { get; set; }
private byte _tickRate;
private ushort _tickRate;
private TimeSpan _tickRemainder;
/// <summary>
/// The target ticks/second of the simulation.
/// </summary>
public byte TickRate
public ushort TickRate
{
get => _tickRate;
set => SetTickRateAt(value, CurTick);
@@ -230,7 +230,7 @@ namespace Robust.Shared.Timing
Paused = true;
}
public void SetTickRateAt(byte tickRate, GameTick atTick)
public void SetTickRateAt(ushort tickRate, GameTick atTick)
{
// Check this, because TickRate is a divisor in the cache calculation
// The first time TickRate is set, no time will have passed anyways

View File

@@ -86,7 +86,7 @@ namespace Robust.Shared.Timing
/// <summary>
/// The target ticks/second of the simulation.
/// </summary>
byte TickRate { get; set; }
ushort TickRate { get; set; }
/// <summary>
/// The baseline time value that CurTime is calculated relatively to.
@@ -167,7 +167,7 @@ namespace Robust.Shared.Timing
void ResetSimTime();
void ResetSimTime((TimeSpan, GameTick) timeBase);
void SetTickRateAt( byte tickRate, GameTick atTick);
void SetTickRateAt(ushort tickRate, GameTick atTick);
TimeSpan RealLocalToServer(TimeSpan local);
TimeSpan RealServerToLocal(TimeSpan server);