Skip to content

Commit b88183e

Browse files
committed
Fixed SyncOnSend logic
1 parent bd081fd commit b88183e

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

MLAPI/Data/NetworkedCollections/NetworkedDictionary.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ public bool CanClientRead(uint clientId)
221221
public bool IsDirty()
222222
{
223223
if (dirtyEvents.Count == 0) return false;
224-
if (NetworkingManager.singleton.NetworkTime - LastSyncedTime >= Settings.SendTickrate) return true;
224+
if (Settings.SendTickrate <= 0) return true;
225+
if (NetworkingManager.singleton.NetworkTime - LastSyncedTime >= (1f / Settings.SendTickrate)) return true;
225226
return false;
226227
}
227228

MLAPI/Data/NetworkedCollections/NetworkedList.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ public void ResetDirty()
5151
public bool IsDirty()
5252
{
5353
if (dirtyEvents.Count == 0) return false;
54-
if (NetworkingManager.singleton.NetworkTime - LastSyncedTime >= Settings.SendTickrate) return true;
54+
if (Settings.SendTickrate <= 0) return true;
55+
if (NetworkingManager.singleton.NetworkTime - LastSyncedTime >= (1f / Settings.SendTickrate)) return true;
5556
return false;
5657
}
5758

MLAPI/Data/NetworkedVar.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ public void ResetDirty()
7070
public bool IsDirty()
7171
{
7272
if (!isDirty) return false;
73-
if (NetworkingManager.singleton.NetworkTime - LastSyncedTime >= Settings.SendTickrate) return true;
73+
if (Settings.SendTickrate <= 0) return true;
74+
if (NetworkingManager.singleton.NetworkTime - LastSyncedTime >= (1f / Settings.SendTickrate)) return true;
7475
return false;
7576
}
7677

MLAPI/Data/NetworkedVarMeta.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public class NetworkedVarSettings
2525
/// </summary>
2626
public NetworkedVarPermissionsDelegate ReadPermissionCallback = null;
2727
/// <summary>
28-
/// The minimum amount of delay in seconds between sends
28+
/// The maximum times per second this var will be synced.
29+
/// Less than or equal to 0 will cause the variable to sync as soon as possible after being changed.
2930
/// </summary>
3031
public float SendTickrate = NetworkingManager.singleton.NetworkConfig.SendTickrate;
3132
/// <summary>

0 commit comments

Comments
 (0)