From a08bbdcb3d25d7f04cb3d67df567834b7f37c58f Mon Sep 17 00:00:00 2001 From: cxxpxr <60411087+cxxpxr@users.noreply.github.com> Date: Wed, 5 May 2021 21:22:52 -0400 Subject: [PATCH] minor cleanup and player count --- .../RelayHandler/RelayHandlerRoomMethods.cs | 2 +- .../LRM/Room.cs | 3 + UnityProject/Assets/LRMTestScene.unity | 115 +++++++++--------- .../LightReflectiveMirrorTransport.cs | 7 +- .../ProjectSettings/ProjectSettings.asset | 3 +- 5 files changed, 64 insertions(+), 66 deletions(-) diff --git a/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/RelayHandler/RelayHandlerRoomMethods.cs b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/RelayHandler/RelayHandlerRoomMethods.cs index f37f277..31cd082 100644 --- a/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/RelayHandler/RelayHandlerRoomMethods.cs +++ b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/RelayHandler/RelayHandlerRoomMethods.cs @@ -119,7 +119,7 @@ namespace LightReflectiveMirror serverId = GetRandomServerID(), hostIP = hostIP, hostLocalIP = hostLocalIP, - supportsDirectConnect = hostIP == null ? false : useDirectConnect, + supportsDirectConnect = hostIP != null && useDirectConnect, port = port, useNATPunch = useNatPunch }; diff --git a/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Room.cs b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Room.cs index aff389e..6d85aba 100644 --- a/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Room.cs +++ b/ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Room.cs @@ -14,6 +14,9 @@ namespace LightReflectiveMirror public string serverData; public bool isPublic; public int maxPlayers; + public int currentPlayers { get => clients.Count + 1; } // player count + + [JsonIgnore] public List clients; public RelayAddress relayInfo; diff --git a/UnityProject/Assets/LRMTestScene.unity b/UnityProject/Assets/LRMTestScene.unity index f198b08..3c8b635 100644 --- a/UnityProject/Assets/LRMTestScene.unity +++ b/UnityProject/Assets/LRMTestScene.unity @@ -195,64 +195,6 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 45, y: 180, z: 0} ---- !u!1 &126344731 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 126344733} - - component: {fileID: 126344732} - m_Layer: 0 - m_Name: LRM - Connector - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &126344732 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 126344731} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 0110f245bfcfc7d459681f7bd9ebc590, type: 3} - m_Name: - m_EditorClassIdentifier: - port: 7778 - maxMessageSize: 16384 - handshakeMaxSize: 3000 - noDelay: 1 - sendTimeout: 5000 - receiveTimeout: 20000 - serverMaxMessagesPerTick: 10000 - clientMaxMessagesPerTick: 1000 - batchSend: 1 - waitBeforeSend: 0 - clientUseWss: 0 - sslEnabled: 0 - sslCertJson: ./cert.json - sslProtocols: 3072 - _logLevels: 0 ---- !u!4 &126344733 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 126344731} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 1282001518} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &171810013 GameObject: m_ObjectHideFlags: 0 @@ -1217,7 +1159,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 1226094909} - - {fileID: 126344733} + - {fileID: 1521806212} m_Father: {fileID: 0} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -1295,7 +1237,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 7064b1b1d0671194baf55fa8d5f564d6, type: 3} m_Name: m_EditorClassIdentifier: - clientToServerTransport: {fileID: 126344732} + clientToServerTransport: {fileID: 1521806211} serverIP: 127.0.0.1 serverPort: 7777 endpointServerPort: 8080 @@ -1406,6 +1348,59 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 41f84591ce72545258ea98cb7518d8b9, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!1 &1521806210 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1521806212} + - component: {fileID: 1521806211} + m_Layer: 0 + m_Name: LRM - Connector + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1521806211 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1521806210} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 6b0fecffa3f624585964b0d0eb21b18e, type: 3} + m_Name: + m_EditorClassIdentifier: + Port: 7777 + NoDelay: 1 + Interval: 10 + FastResend: 2 + CongestionWindow: 0 + SendWindowSize: 4096 + ReceiveWindowSize: 4096 + debugLog: 0 + statisticsGUI: 0 + statisticsLog: 0 +--- !u!4 &1521806212 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1521806210} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1282001518} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1600541100 GameObject: m_ObjectHideFlags: 0 diff --git a/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMTransport/LightReflectiveMirrorTransport.cs b/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMTransport/LightReflectiveMirrorTransport.cs index cd7df86..5ec8bca 100644 --- a/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMTransport/LightReflectiveMirrorTransport.cs +++ b/UnityProject/Assets/Mirror/Runtime/Transport/LRM/LRMTransport/LightReflectiveMirrorTransport.cs @@ -288,9 +288,8 @@ namespace LightReflectiveMirror } } - IPAddress serverAddr; - if (!IPAddress.TryParse(serverIP, out serverAddr)) + if (!IPAddress.TryParse(serverIP, out IPAddress serverAddr)) serverAddr = Dns.GetHostEntry(serverIP).AddressList[0]; _relayPuncherIP = new IPEndPoint(serverAddr, NATPunchtroughPort); @@ -437,13 +436,13 @@ namespace LightReflectiveMirror public string serverData; public int hostId; public List clients; - + public int currentPlayers; public RelayAddress relayInfo; /// /// This variable is only available on the client /// - public int currentPlayers { get => clients.Count + 1; } + //public int currentPlayers { get => clients.Count + 1; } } [Serializable] diff --git a/UnityProject/ProjectSettings/ProjectSettings.asset b/UnityProject/ProjectSettings/ProjectSettings.asset index 702997d..a043db6 100644 --- a/UnityProject/ProjectSettings/ProjectSettings.asset +++ b/UnityProject/ProjectSettings/ProjectSettings.asset @@ -516,7 +516,8 @@ PlayerSettings: 1: MIRROR;MIRROR_17_0_OR_NEWER;MIRROR_18_0_OR_NEWER;MIRROR_24_0_OR_NEWER;MIRROR_26_0_OR_NEWER;MIRROR_27_0_OR_NEWER;MIRROR_28_0_OR_NEWER;MIRROR_29_0_OR_NEWER;MIRROR_30_0_OR_NEWER;MIRROR_30_5_2_OR_NEWER;MIRROR_32_1_2_OR_NEWER;MIRROR_32_1_4_OR_NEWER;MIRROR_35_0_OR_NEWER;MIRROR_35_1_OR_NEWER 13: MIRROR;MIRROR_17_0_OR_NEWER;MIRROR_18_0_OR_NEWER;MIRROR_24_0_OR_NEWER;MIRROR_26_0_OR_NEWER;MIRROR_27_0_OR_NEWER;MIRROR_28_0_OR_NEWER;MIRROR_29_0_OR_NEWER;MIRROR_30_0_OR_NEWER;MIRROR_30_5_2_OR_NEWER;MIRROR_32_1_2_OR_NEWER;MIRROR_32_1_4_OR_NEWER;MIRROR_35_0_OR_NEWER;MIRROR_35_1_OR_NEWER platformArchitecture: {} - scriptingBackend: {} + scriptingBackend: + Standalone: 1 il2cppCompilerConfiguration: {} managedStrippingLevel: {} incrementalIl2cppBuild: {}