From 171f12903902f81fd9d4c772777ef30c81824c77 Mon Sep 17 00:00:00 2001 From: SDraw Date: Tue, 30 Jan 2024 23:32:51 +0300 Subject: [PATCH] Offset in VR fix Fix of illogical bug of null player descriptor --- ml_pin/Main.cs | 74 ++++++++++++++++++++----------------- ml_prm/RagdollController.cs | 2 +- 2 files changed, 41 insertions(+), 35 deletions(-) diff --git a/ml_pin/Main.cs b/ml_pin/Main.cs index f89d611..59f5c03 100644 --- a/ml_pin/Main.cs +++ b/ml_pin/Main.cs @@ -41,25 +41,28 @@ namespace ml_pin { try { - bool l_isFriend = Friends.FriendsWith(p_player.ownerId); - bool l_notify = false; - - switch(Settings.NotifyType) + if(p_player != null) // This happens sometimes, no idea why { - case Settings.NotificationType.None: - l_notify = false; - break; - case Settings.NotificationType.Friends: - l_notify = (l_isFriend && ShouldNotifyInCurrentInstance()); - break; - case Settings.NotificationType.All: - l_notify = ShouldNotifyInCurrentInstance(); - break; - } - l_notify |= (l_isFriend && Settings.FriendsAlways); + bool l_isFriend = Friends.FriendsWith(p_player.ownerId); + bool l_notify = false; - if(l_notify) - m_soundManager?.PlaySound(l_isFriend ? SoundManager.SoundType.FriendJoin : SoundManager.SoundType.PlayerJoin); + switch(Settings.NotifyType) + { + case Settings.NotificationType.None: + l_notify = false; + break; + case Settings.NotificationType.Friends: + l_notify = (l_isFriend && ShouldNotifyInCurrentInstance()); + break; + case Settings.NotificationType.All: + l_notify = ShouldNotifyInCurrentInstance(); + break; + } + l_notify |= (l_isFriend && Settings.FriendsAlways); + + if(l_notify) + m_soundManager?.PlaySound(l_isFriend ? SoundManager.SoundType.FriendJoin : SoundManager.SoundType.PlayerJoin); + } } catch(Exception e) { @@ -70,25 +73,28 @@ namespace ml_pin { try { - bool l_isFriend = Friends.FriendsWith(p_player.ownerId); - bool l_notify = false; - - switch(Settings.NotifyType) + if(p_player != null) // This happens sometimes, no idea why { - case Settings.NotificationType.None: - l_notify = false; - break; - case Settings.NotificationType.Friends: - l_notify = (l_isFriend && ShouldNotifyInCurrentInstance()); - break; - case Settings.NotificationType.All: - l_notify = ShouldNotifyInCurrentInstance(); - break; - } - l_notify |= (l_isFriend && Settings.FriendsAlways); + bool l_isFriend = Friends.FriendsWith(p_player.ownerId); + bool l_notify = false; - if(l_notify) - m_soundManager?.PlaySound(l_isFriend ? SoundManager.SoundType.FriendLeave : SoundManager.SoundType.PlayerLeave); + switch(Settings.NotifyType) + { + case Settings.NotificationType.None: + l_notify = false; + break; + case Settings.NotificationType.Friends: + l_notify = (l_isFriend && ShouldNotifyInCurrentInstance()); + break; + case Settings.NotificationType.All: + l_notify = ShouldNotifyInCurrentInstance(); + break; + } + l_notify |= (l_isFriend && Settings.FriendsAlways); + + if(l_notify) + m_soundManager?.PlaySound(l_isFriend ? SoundManager.SoundType.FriendLeave : SoundManager.SoundType.PlayerLeave); + } } catch(Exception e) { diff --git a/ml_prm/RagdollController.cs b/ml_prm/RagdollController.cs index 8b23f0a..64a4171 100644 --- a/ml_prm/RagdollController.cs +++ b/ml_prm/RagdollController.cs @@ -763,7 +763,7 @@ namespace ml_prm internal bool ShoudlDisableHeadOffset() { - return (!m_inVR && m_enabled && (m_vrIK != null)); + return (m_enabled && (m_vrIK != null)); } static void TryRestoreMovement()