breaking: NetworkServer.tickRate and .tickInterval, set from exposed NetworkManager.serverTickInterval.

prepares for NetworkClient time interpolation
This commit is contained in:
vis2k 2022-10-06 13:50:48 +02:00
parent 47bd10f237
commit c940963779
2 changed files with 18 additions and 2 deletions

View File

@ -45,8 +45,8 @@ public class NetworkManager : MonoBehaviour
// send interval is 1 / sendRate.
// but for tests we need a way to set it to exactly 0.
// 1 / int.max would not be exactly 0, so handel that manually.
public float serverTickInterval =>
serverTickRate < int.MaxValue ? 1f / serverTickRate : 0; // for 30 Hz, that's 33ms
[Obsolete("NetworkManager.serverTickInterval was moved to NetworkServer.tickInterval for consistency.")]
public float serverTickInterval => NetworkServer.tickInterval;
/// <summary>Automatically switch to this scene upon going offline (on start / on disconnect / on shutdown).</summary>
[Header("Scene Management")]
@ -244,6 +244,9 @@ void SetupServer()
authenticator.OnServerAuthenticated.AddListener(OnServerAuthenticated);
}
// copy exposed settings to static NetworkServer
NetworkServer.tickRate = serverTickRate;
ConfigureHeadlessFrameRate();
// start listening to network connections

View File

@ -12,6 +12,19 @@ public static partial class NetworkServer
static bool initialized;
public static int maxConnections;
/// <summary>Server Update frequency, per second. Use around 60Hz for fast paced games like Counter-Strike to minimize latency. Use around 30Hz for games like WoW to minimize computations. Use around 1-10Hz for slow paced games like EVE.</summary>
// overwritten by NetworkManager (if any)
public static int tickRate = 30;
// tick rate is in Hz.
// convert to interval in seconds for convenience where needed.
//
// send interval is 1 / sendRate.
// but for tests we need a way to set it to exactly 0.
// 1 / int.max would not be exactly 0, so handel that manually.
public static float tickInterval =>
tickRate < int.MaxValue ? 1f / tickRate : 0; // for 30 Hz, that's 33ms
/// <summary>Connection to host mode client (if any)</summary>
public static NetworkConnectionToClient localConnection { get; private set; }