mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
perf: only call localtime once
This commit is contained in:
parent
3aaf6db3cc
commit
6cca04e507
@ -644,7 +644,7 @@ void UpdateServer()
|
||||
}
|
||||
|
||||
// update client ///////////////////////////////////////////////////////
|
||||
void UpdateClientBroadcast()
|
||||
void UpdateClientBroadcast(double localTime)
|
||||
{
|
||||
// send to server each 'sendInterval'
|
||||
// NetworkTime.localTime for double precision until Unity has it too
|
||||
@ -666,7 +666,7 @@ void UpdateClientBroadcast()
|
||||
// DO NOT send nulls if not changed 'since last send' either. we
|
||||
// send unreliable and don't know which 'last send' the other end
|
||||
// received successfully.
|
||||
if (NetworkTime.localTime >= lastClientSendTime + sendInterval) // CUSTOM CHANGE: allow custom sendRate + sendInterval again
|
||||
if (localTime >= lastClientSendTime + sendInterval) // CUSTOM CHANGE: allow custom sendRate + sendInterval again
|
||||
{
|
||||
// send snapshot without timestamp.
|
||||
// receiver gets it from batch timestamp to save bandwidth.
|
||||
@ -679,7 +679,7 @@ void UpdateClientBroadcast()
|
||||
// syncScale ? snapshot.scale : default(Vector3?)
|
||||
);
|
||||
|
||||
lastClientSendTime = NetworkTime.localTime;
|
||||
lastClientSendTime = localTime;
|
||||
}
|
||||
}
|
||||
|
||||
@ -715,7 +715,10 @@ void UpdateClient()
|
||||
// https://github.com/vis2k/Mirror/pull/2992/
|
||||
if (!NetworkClient.ready) return;
|
||||
|
||||
UpdateClientBroadcast();
|
||||
// perf: only grab NetworkTime.localTime property once.
|
||||
double localTime = NetworkTime.localTime;
|
||||
|
||||
UpdateClientBroadcast(localTime);
|
||||
}
|
||||
// for all other clients (and for local player if !authority),
|
||||
// we need to apply snapshots from the buffer
|
||||
|
Loading…
Reference in New Issue
Block a user