From d1e53f5811d8474bd626d015241b63fd07fe258e Mon Sep 17 00:00:00 2001 From: vis2k Date: Sun, 10 Jun 2018 15:01:22 +0200 Subject: [PATCH] NetworkLobbyManager.OnValidate simplified by using Mathf.Clamp --- .../Runtime/NetworkManager.cs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Unity-Technologies-networking/Runtime/NetworkManager.cs b/Unity-Technologies-networking/Runtime/NetworkManager.cs index d2cd6bda3..8441f714d 100644 --- a/Unity-Technologies-networking/Runtime/NetworkManager.cs +++ b/Unity-Technologies-networking/Runtime/NetworkManager.cs @@ -214,14 +214,9 @@ void InitializeSingleton() void OnValidate() { - if (m_SimulatedLatency < 1) m_SimulatedLatency = 1; - if (m_SimulatedLatency > 500) m_SimulatedLatency = 500; - - if (m_PacketLossPercentage < 0) m_PacketLossPercentage = 0; - if (m_PacketLossPercentage > 99) m_PacketLossPercentage = 99; - - if (m_MaxConnections <= 0) m_MaxConnections = 1; - if (m_MaxConnections > 32000) m_MaxConnections = 32000; + m_SimulatedLatency = Mathf.Clamp(m_SimulatedLatency, 1, 500); // [1, 500] + m_PacketLossPercentage = Mathf.Clamp(m_PacketLossPercentage, 0, 99); // [0, 99] + m_MaxConnections = Mathf.Clamp(m_MaxConnections, 1, 32000); // [1, 32000] if (m_MaxBufferedPackets <= 0) m_MaxBufferedPackets = 0; if (m_MaxBufferedPackets > ChannelBuffer.MaxBufferedPackets)