From 8ca37170e46111314b482e8d97f98746a76a0b8d Mon Sep 17 00:00:00 2001 From: zombieb Date: Thu, 14 Aug 2025 23:12:14 -0400 Subject: [PATCH] AuthenticationValues should only be set when selfhosting/onprem. userid is ignored by photon cloud. --- Patches/PhotonPatch.cs | 48 +++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/Patches/PhotonPatch.cs b/Patches/PhotonPatch.cs index 5e9cb86..b9c5cb2 100644 --- a/Patches/PhotonPatch.cs +++ b/Patches/PhotonPatch.cs @@ -145,33 +145,33 @@ namespace undead_universal_patch_il2cpp.Patches PhotonConfig.ServerPort.Value, PhotonConfig.AppID.Value, ]); - } - Type authValuesType = AccessTools.TypeByName("AuthenticationValues"); - if (authValuesType != null) - { - PropertyInfo networkingPeerProperty = photonNetworkType.GetRuntimeProperty("networkingPeer"); - if (networkingPeerProperty == null) + Type authValuesType = AccessTools.TypeByName("AuthenticationValues"); + if (authValuesType != null) { - UniversalPatchPlugin.Log.LogError("Cannot patch Photon: networkingPeerProperty was null. Is this build supported?"); - return; + PropertyInfo networkingPeerProperty = photonNetworkType.GetRuntimeProperty("networkingPeer"); + if (networkingPeerProperty == null) + { + UniversalPatchPlugin.Log.LogError("Cannot patch Photon: networkingPeerProperty was null. Is this build supported?"); + return; + } + + if (networkingPeerProperty.GetValue(null) == null) + { + UniversalPatchPlugin.Log.LogError("Cannot patch Photon: networkingPeerInstance was null. Is this build supported?"); + return; + } + + string id = Util.LocalInstanceGuid; + Util.ConditionalDebug($"Instance GUID is {id}"); + + PhotonNetwork.AuthValues = new AuthenticationValues + { + UserId = id + }; + + Util.ConditionalDebug($"Set the authValues userId to {id}"); } - - if (networkingPeerProperty.GetValue(null) == null) - { - UniversalPatchPlugin.Log.LogError("Cannot patch Photon: networkingPeerInstance was null. Is this build supported?"); - return; - } - - string id = Core.Util.LocalInstanceGuid; - Util.ConditionalDebug($"Instance GUID is {id}"); - - PhotonNetwork.AuthValues = new AuthenticationValues - { - UserId = id - }; - - Util.ConditionalDebug($"Set the authValues userId to {id}"); } UniversalPatchPlugin.Log.LogInfo($"Photon patch ({(PhotonConfig.SelfHosted.Value ? "self-hosted" : "cloud")}) succeeded.");