Skip to content

Commit

Permalink
Fix some possible NREs that might stop initialization code running
Browse files Browse the repository at this point in the history
[CI BUILD]
  • Loading branch information
andybak committed Dec 29, 2024
1 parent 176dcf4 commit f110f39
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
12 changes: 6 additions & 6 deletions Assets/Scripts/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ private class UserConfigChange
[NonSerialized] public bool m_QuickLoad = true;

public SecretsConfig.ServiceAuthData GoogleSecrets => Secrets?[SecretsConfig.Service.Google];
public SecretsConfig.ServiceAuthData SketchfabSecrets => Secrets[SecretsConfig.Service.Sketchfab];
public SecretsConfig.ServiceAuthData OculusSecrets => Secrets[SecretsConfig.Service.Oculus];
public SecretsConfig.ServiceAuthData OculusMobileSecrets => Secrets[SecretsConfig.Service.OculusMobile];
public SecretsConfig.ServiceAuthData PimaxSecrets => Secrets[SecretsConfig.Service.Pimax];
public SecretsConfig.ServiceAuthData PhotonFusionSecrets => Secrets[SecretsConfig.Service.PhotonFusion];
public SecretsConfig.ServiceAuthData PhotonVoiceSecrets => Secrets[SecretsConfig.Service.PhotonVoice];
public SecretsConfig.ServiceAuthData SketchfabSecrets => Secrets?[SecretsConfig.Service.Sketchfab];
public SecretsConfig.ServiceAuthData OculusSecrets => Secrets?[SecretsConfig.Service.Oculus];
public SecretsConfig.ServiceAuthData OculusMobileSecrets => Secrets?[SecretsConfig.Service.OculusMobile];
public SecretsConfig.ServiceAuthData PimaxSecrets => Secrets?[SecretsConfig.Service.Pimax];
public SecretsConfig.ServiceAuthData PhotonFusionSecrets => Secrets?[SecretsConfig.Service.PhotonFusion];
public SecretsConfig.ServiceAuthData PhotonVoiceSecrets => Secrets?[SecretsConfig.Service.PhotonVoice];

public bool DisableAccountLogins;

Expand Down
14 changes: 8 additions & 6 deletions Assets/Scripts/Multiplayer/MultiplayerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ void Awake()
void Start()
{
#if OCULUS_SUPPORTED
OVRPlatform.Users.GetLoggedInUser().OnComplete((msg) => {
// GetLoggedInUser can return null
// if Oculus.Platform.Core isn't initialized
OVRPlatform.Users.GetLoggedInUser()?.OnComplete((msg) => {
if (!msg.IsError)
{
myOculusUserId = msg.GetUser().ID;
Expand Down Expand Up @@ -146,7 +148,7 @@ void Start()
m_VoiceManager = new PhotonVoiceManager(this);
if (m_VoiceManager != null) ControllerConsoleScript.m_Instance.AddNewLine("PhotonVoiceManager Loaded");
else ControllerConsoleScript.m_Instance.AddNewLine("PhotonVoiceManager Not Loaded");
#endif
#endif
break;
default:
return;
Expand Down Expand Up @@ -299,7 +301,7 @@ public bool DoesRoomNameExist(string roomName)
// Find the room with the given name
RoomData? room = m_RoomData.FirstOrDefault(r => r.roomName == roomName);

// Room exists
// Room exists
RoomData r = (RoomData)room;
if (r.numPlayers == 0) isUserRoomOwner = true;// and is empty user becomes room owner
else isUserRoomOwner = false; // not empty user is not the room owner
Expand Down Expand Up @@ -399,9 +401,9 @@ void Update()

void OnLocalPlayerJoined(int id, ITransientData<PlayerRigData> playerData)
{
// the user is the room owner if is the firt to get in
// the user is the room owner if is the firt to get in
isUserRoomOwner = m_Manager.GetPlayerCount() == 1 ? true : false;
// if not room owner clear scene
// if not room owner clear scene
if (!isUserRoomOwner) SketchMemoryScript.m_Instance.ClearMemory();

m_LocalPlayer = playerData;
Expand Down Expand Up @@ -445,7 +447,7 @@ void OnPlayerLeft(int id)
}
}

// Reassign Ownership if needed
// Reassign Ownership if needed
// Check if any remaining player is the room owner
bool anyRoomOwner = m_RemotePlayers.Any(player => m_Manager.GetPlayerRoomOwnershipStatus(player.PlayerId))
|| isUserRoomOwner;
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/Sharing/OAuth2Identity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private static void LogOutAll()

public bool IsGoogle => m_Service == SecretsConfig.Service.Google;
public UserCredential UserCredential => m_CredentialRequest?.UserCredential;
private SecretsConfig.ServiceAuthData ServiceAuthData => App.Config.Secrets[m_Service];
private SecretsConfig.ServiceAuthData ServiceAuthData => App.Config.Secrets?[m_Service];
public string ClientId => ServiceAuthData?.ClientId;
private string ClientSecret => ServiceAuthData?.ClientSecret;

Expand Down
6 changes: 3 additions & 3 deletions Assets/Scripts/VrSdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,12 @@ void Awake()
cameraRig.disableEyeAnchorCameras = true;

//Get Oculus ID
var appId = App.Config.OculusSecrets.ClientId;
var appId = App.Config.OculusSecrets?.ClientId;
#if UNITY_ANDROID
appId = App.Config.OculusMobileSecrets.ClientId;
appId = App.Config.OculusMobileSecrets?.ClientId;
#endif

if (Unity.XR.Oculus.Utils.GetSystemHeadsetType() != Unity.XR.Oculus.SystemHeadset.Oculus_Quest)
if (appId != null && Unity.XR.Oculus.Utils.GetSystemHeadsetType() != Unity.XR.Oculus.SystemHeadset.Oculus_Quest)
{
Oculus.Platform.Core.Initialize(appId);
Oculus.Platform.UserAgeCategory.Get().OnComplete((msg) => {
Expand Down

0 comments on commit f110f39

Please sign in to comment.