diff --git a/Core/Init.cs b/Core/Init.cs index d5d1d45..e009217 100644 --- a/Core/Init.cs +++ b/Core/Init.cs @@ -84,9 +84,9 @@ public class Initialization "Always present patch. Never get kicked to dorm."); ServerPatchesConfig.CustomEmotes = UniversalPatchPlugin.Instance.Config.Bind("ServerPatches", "CustomEmotes", ServerPatchesConfigDefaults.CustomEmotes, - "Modify the game's emote text with a configuration from the server. Requires a custom server."); + "Modify the game's emote text with a configuration from the server."); ServerPatchesConfig.CustomPhoton = UniversalPatchPlugin.Instance.Config.Bind("ServerPatches", "CustomPhoton", ServerPatchesConfigDefaults.CustomPhoton, - "Patch ServerSettings values with a configuration from the server." + + "Patch Photon ServerSettings values with a configuration from the server." + "\nWhen the server fails to provide a valid configuration, values from the local config will be used." + "\nPhoton.PatchPhotonIds must be enabled for this fallback to work."); @@ -98,25 +98,25 @@ public class Initialization PhotonConfig.PatchPhotonIds = UniversalPatchPlugin.Instance.Config.Bind("Photon", "PatchPhotonIds", PhotonConfigDefaults.PatchPhotonIds, "Patch Photon configuration."); PhotonConfig.PunLogging = UniversalPatchPlugin.Instance.Config.Bind("Photon", "PunLogging", PhotonConfigDefaults.PunLogging, - "Enable all logging sent by Photon/PUN/Voice (useful for server debugging)"); + "Enable all PUN/Voice logging (useful for server debugging)"); PhotonConfig.SelfHosted = UniversalPatchPlugin.Instance.Config.Bind("Photon", "IsSelfHosted", PhotonConfigDefaults.SelfHosted, - "When enabled, use a self-hosted 'OnPremises' PhotonSocketServer. (EXPERIMENTAL)" + + "When enabled, use a self-hosted ('OnPremises' or 'PhotonSocketServer') Photon server." + "\nWhen disabled, AppID and VoiceAppID are sent to Photon Cloud and a cloud masterserver is used."); PhotonConfig.AppID = UniversalPatchPlugin.Instance.Config.Bind("Photon", "AppID", PhotonConfigDefaults.AppID, "The new target (PUN) App ID from the Photon dashboard." + - "\nWhen self-hosting, this should be the name of your application (either 'Master' or 'Game')"); + "\nWhen self-hosting, this should be the name of your Photon application (usually 'Master' without quotes)"); PhotonConfig.VoiceAppID = UniversalPatchPlugin.Instance.Config.Bind("Photon", "VoiceAppID", PhotonConfigDefaults.VoiceAppID, "The new target Voice App ID from the Photon dashboard." + - "\nWhen self-hosting, this value is ignored, since Photon voice in Rec Room is based on PUN."); + "\nWhen self-hosting, this should be the same as AppID."); PhotonConfig.ServerAddress = UniversalPatchPlugin.Instance.Config.Bind("Photon", "ServerAddress", PhotonConfigDefaults.ServerAddress, - "Address of the Photon target server (ignored if not using self-hosted)"); + "Address of the Photon Master server (ignored if using cloud)"); PhotonConfig.ServerPort = UniversalPatchPlugin.Instance.Config.Bind("Photon", "ServerPort", PhotonConfigDefaults.ServerPort, - "Photon target server port (ignored if not using self-hosted)." + + "Photon Master server port (ignored if using cloud)." + "\nYou can set this port to the matching protocol port from the server, e.g. 5055 for UDP, 9091 for WebSockets"); PhotonConfig.ConnectionProtocol = UniversalPatchPlugin.Instance.Config.Bind("Photon", "ConnectionProtocol", PhotonConfigDefaults.ConnectionProtocol, - "Connection protocol to use when connecting to the target port (ignored if not using self-hosted)." + + "Connection protocol to use when connecting to the Photon servers (ignored if using cloud)." + "\n0: UDP, 1: TCP;" + - "\nWebSockets are not supported by Photon in this build."); + "\nWebSockets are not supported by Photon in this build. TCP is experimental and may cause instability/crashes."); NameserverConfig.Rewrite = UniversalPatchPlugin.Instance.Config.Bind("Nameserver", "Rewrite", NameserverConfigDefaults.Rewrite, "Enable/disable rewriting the URL for nameserver requests."); diff --git a/Patches/Photon/PUNNetworkManager.cs b/Patches/Photon/PUNNetworkManager.cs index 512fc22..ac92121 100644 --- a/Patches/Photon/PUNNetworkManager.cs +++ b/Patches/Photon/PUNNetworkManager.cs @@ -1,5 +1,7 @@ +using System.Linq; using System.Reflection; using HarmonyLib; +using Mapster; using undead_universal_patch_il2cpp.Core; using undead_universal_patch_il2cpp.Core.Config; using undead_universal_patch_il2cpp.Core.Content.CustomRecNet.CustomPhoton; @@ -101,7 +103,12 @@ public class PhotonThrottlingPatch "UpdatePhotonThrottling" ); - static bool Prepare() => patchTypesResult.Success; + static bool Prepare() + { + if (PhotonConfig.ConnectionProtocol.Value == 1) return patchTypesResult.Success; + else return false; + } + static MethodBase TargetMethod() => patchTypesResult.Method; static bool Prefix() => PhotonConfig.ConnectionProtocol.Value != 1; diff --git a/Plugin.cs b/Plugin.cs index 4a7c9e8..6bb4550 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -6,7 +6,7 @@ using undead_universal_patch_il2cpp.Core; namespace undead_universal_patch_il2cpp; -[BepInPlugin("dev.proxnet.recroom.universalpatch.noneac.il2cpp", "Undead Universal Patch", "2.1.0")] +[BepInPlugin("dev.proxnet.recroom.universalpatch.noneac.il2cpp", "Undead Universal Patch", "2.1.1")] public class UniversalPatchPlugin : BasePlugin { public static new readonly ManualLogSource Log = Logger.CreateLogSource("UUPatch"); diff --git a/SERVERS.md b/SERVERS.md index 8cbfd02..55253a4 100644 --- a/SERVERS.md +++ b/SERVERS.md @@ -5,15 +5,31 @@ Requests are sent after the game client authenticates with the server. ## Endpoints -### `API: GET "/api/undead/v1/emotes"` -Expects: `List` -[EmoteConfigDTO](#emoteconfigdto) +### `API: GET "/api/undead/v1/emotes"` +Expects: `List` [(to DTO)](#emoteconfigdto) Replace existing emotes in the game with these, keyed by `UniqueName`. -See [the source](./Core/CustomRecNet/CustomEmotes/RecNetEmotes.cs) for more information. + +See [the source](.\Core\CustomRecNet\CustomEmotes\RecNetEmotes.cs) for more information. + +### `API: GET "/api/undead/v1/photon"` +Expects: `PhotonConfigDTO` [(to DTO)](#photonconfigdto) + +The patch uses a Photon configuration given by the server.
+When this fails, the patch will fall back to the local config, if enabled. + +`ConnectionProtocol` is 0 for UDP, or 1 for TCP. Use UDP if you don't know what to use.
+`ServerAddress`, `ServerPort`, and `ConnectionProtocol` are ignored when `SelfHosted` is enabled. + +When using a self-hosted server, ideally, you should set the `AppID` *and* `VoiceAppID` to the name
+of your application, e.g. Master when using the port for a default Masterserver.
+Voice will go over the same gameserver port as PUN does when selfhosting. + +See [the source](.\Core\Content\CustomRecNet\CustomPhoton\CustomPhoton.cs) for more information. ## DTOs + ### `EmoteConfigDTO` ```c# public class EmoteConfigDTO @@ -25,4 +41,18 @@ public class EmoteConfigDTO public bool ForceEmoteBubble { get; set; } public bool OnlyBroadcastToTeam { get; set; } } +``` + +### `PhotonConfigDTO` +```c# +public class PhotonConfigDTO +{ + public bool Logging { get; set; } + public string AppID { get; set; } + public string VoiceAppID { get; set; } + public bool SelfHosted { get; set; } + public string ServerAddress { get; set; } + public int ServerPort { get; set; } + public byte ConnectionProtocol { get; set; } +} ``` \ No newline at end of file diff --git a/undead-universal-patch-il2cpp.csproj b/undead-universal-patch-il2cpp.csproj index 8416f84..2887ba1 100644 --- a/undead-universal-patch-il2cpp.csproj +++ b/undead-universal-patch-il2cpp.csproj @@ -4,7 +4,7 @@ net6.0 undead_universal_patch_il2cpp Non-EAC, IL2CPP build patcher for Rec Room (Late 2018*-*April 2020) - 2.1.0 + 2.1.1 true latest