Skip to content

Commit 693d9d7

Browse files
fix
Convert the string to ushort.
1 parent c90f032 commit 693d9d7

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,13 +1633,20 @@ public override void Initialize(NetworkManager networkManager = null)
16331633
m_NetworkManager = networkManager;
16341634

16351635
//If the port doesn't have a forced value and is set by a command line option, override it.
1636-
if (!m_HasForcedConnectionData && ParseCommandLineOptionsAddress(out var port))
1636+
if (!m_HasForcedConnectionData && ParseCommandLineOptionsAddress(out var portAsString))
16371637
{
16381638
if (m_NetworkManager?.LogLevel <= LogLevel.Developer)
16391639
{
1640-
Debug.Log($"The port is set by a command line option. Using following connection data: {ConnectionData.Address}:{port}");
1640+
Debug.Log($"The port is set by a command line option. Using following connection data: {ConnectionData.Address}:{portAsString}");
1641+
}
1642+
if (UInt16.TryParse(portAsString, out ushort port))
1643+
{
1644+
ConnectionData.Port = port;
1645+
}
1646+
else
1647+
{
1648+
Debug.LogError($"The port ({portAsString}) is not a valid unsigned short value!");
16411649
}
1642-
ConnectionData.Port = port;
16431650
}
16441651

16451652
m_RealTimeProvider = m_NetworkManager ? m_NetworkManager.RealTimeProvider : new RealTimeProvider();

0 commit comments

Comments
 (0)