mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
Fix time as double unity 2019 (#3279)
* NetworkServer - TimeAsDouble compatibility for Unity 2019 * NetworkStatistics - TimeAsDouble compatibility for Unity 2019 * Simplified - rely on defines in NetworkTime
This commit is contained in:
parent
abd1c1689d
commit
a86a115a30
@ -182,16 +182,16 @@ void UpdateServer()
|
||||
// only sync if client has authenticated on the server
|
||||
if (!serverAuthenticated) return;
|
||||
|
||||
// double for long running servers
|
||||
if (Time.timeAsDouble >= lastSendTime + sendInterval)
|
||||
// NetworkTime.localTime has defines for 2019 / 2020 compatibility
|
||||
if (NetworkTime.localTime >= lastSendTime + sendInterval)
|
||||
{
|
||||
lastSendTime = Time.timeAsDouble;
|
||||
lastSendTime = NetworkTime.localTime;
|
||||
|
||||
// target rpc to owner client
|
||||
TargetRpcSync(new Stats(
|
||||
// general
|
||||
NetworkServer.connections.Count,
|
||||
Time.realtimeSinceStartupAsDouble,
|
||||
NetworkTime.time,
|
||||
NetworkServer.tickRate,
|
||||
NetworkServer.actualTickRate,
|
||||
|
||||
@ -209,7 +209,6 @@ void UpdateServer()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateClient()
|
||||
{
|
||||
if (Input.GetKeyDown(hotKey))
|
||||
|
@ -1879,13 +1879,15 @@ internal static void NetworkLateUpdate()
|
||||
if (active)
|
||||
{
|
||||
++actualTickRateCounter;
|
||||
if (Time.timeAsDouble >= actualTickRateStart + 1)
|
||||
|
||||
// NetworkTime.localTime has defines for 2019 / 2020 compatibility
|
||||
if (NetworkTime.localTime >= actualTickRateStart + 1)
|
||||
{
|
||||
// calculate avg by exact elapsed time.
|
||||
// assuming 1s wouldn't be accurate, usually a few more ms passed.
|
||||
float elapsed = (float)(Time.timeAsDouble - actualTickRateStart);
|
||||
float elapsed = (float)(NetworkTime.localTime - actualTickRateStart);
|
||||
actualTickRate = Mathf.RoundToInt(actualTickRateCounter / elapsed);
|
||||
actualTickRateStart = Time.timeAsDouble;
|
||||
actualTickRateStart = NetworkTime.localTime;
|
||||
actualTickRateCounter = 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user