Try-catch statements for Harmony patches

This commit is contained in:
SDraw 2022-09-13 08:09:33 +03:00
parent bee29e7771
commit 4e3d5dd6d4
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
6 changed files with 93 additions and 37 deletions

View file

@ -3,9 +3,9 @@ Merged set of MelonLoader mods for ChilloutVR.
**State table for game build 2022r168:**
| Full name | Short name | Latest version | Available in [CVRMA](https://github.com/knah/CVRMelonAssistant) | Current Status | Notes |
|-----------|------------|----------------|-----------------------------------------------------------------|----------------|-------|
| Avatar Change Info | ml_aci | 1.0.2 | Pending | Working |
| Avatar Motion Tweaker | ml_amt | 1.0.6 | Pending | Working |
| Avatar Change Info | ml_aci | 1.0.2 | Yes | Working |
| Avatar Motion Tweaker | ml_amt | 1.0.6 | Yes | Working |
| Desktop Reticle Switch | ml_drs | 1.0.0 | Yes | Working |
| Four Point Tracking | ml_fpt | 1.0.4 | Pending | Working |
| Leap Motion Extension | ml_lme | 1.1.8 | Pending | Working |
| Four Point Tracking | ml_fpt | 1.0.4 | Yes | Working |
| Leap Motion Extension | ml_lme | 1.1.8 | Yes | Working |
| Server Connection Info | ml_sci | 1.0.1 | Yes | Working |

View file

@ -24,12 +24,21 @@ namespace ml_aci
}
static void OnLocalAvatarLoad()
{
try
{
if(ViewManager.Instance != null)
ViewManager.Instance.TriggerPushNotification("Avatar changed", 1f);
}
catch(System.Exception e)
{
MelonLoader.MelonLogger.Error(e);
}
}
static void OnPropSpawned()
{
try
{
if(ViewManager.Instance != null)
{
@ -39,5 +48,10 @@ namespace ml_aci
ViewManager.Instance.TriggerAlert("Prop Error", "Not connected to live instance", -1, true);
}
}
catch(System.Exception e)
{
MelonLoader.MelonLogger.Error(e);
}
}
}
}

View file

@ -45,16 +45,30 @@ namespace ml_amt
static void OnAvatarClear_Postfix() => ms_instance?.OnAvatarClear();
void OnAvatarClear()
{
try
{
if(m_localTweaker != null)
m_localTweaker.OnAvatarClear();
}
catch(System.Exception l_exception)
{
MelonLoader.MelonLogger.Error(l_exception);
}
}
static void OnSetupAvatarGeneral_Postfix() => ms_instance?.OnSetupAvatarGeneral();
void OnSetupAvatarGeneral()
{
try
{
if(m_localTweaker != null)
m_localTweaker.OnSetupAvatarGeneral();
}
catch(System.Exception l_exception)
{
MelonLoader.MelonLogger.Error(l_exception);
}
}
}
}

View file

@ -169,6 +169,8 @@ namespace ml_fpt
static void OnAvatarClear_Postfix() => ms_instance?.OnAvatarClear();
void OnAvatarClear()
{
try
{
if(m_inCalibration)
{
@ -190,6 +192,11 @@ namespace ml_fpt
ShowHudNotification("Calibration canceled");
}
}
catch(System.Exception e)
{
MelonLoader.MelonLogger.Error(e);
}
}
static void ShowHudNotification(string p_message)
{

View file

@ -316,20 +316,34 @@ namespace ml_lme
// Patches
static void OnAvatarClear_Postfix() => ms_instance?.OnAvatarClear();
void OnAvatarClear()
{
try
{
if(m_leapTracked != null)
m_leapTracked.OnAvatarClear();
}
catch(System.Exception e)
{
MelonLoader.MelonLogger.Error(e);
}
}
// Sneaky forced IndexIK calibration
static void OnSetupAvatarGeneral_Postfix() => ms_instance?.OnSetupAvatarGeneral();
void OnSetupAvatarGeneral()
{
try
{
if(m_leapTracked != null)
m_leapTracked.OnSetupAvatarGeneral();
OnSettingsHeadAttachChange(Settings.HeadAttach);
}
catch(System.Exception e)
{
MelonLoader.MelonLogger.Error(e);
}
}
// Utilities
static void ReorientateLeapToUnity(ref Vector3 p_pos, ref Quaternion p_rot, Settings.LeapTrackingMode p_mode)

View file

@ -15,9 +15,16 @@ namespace ml_sci
}
static void OnGameNetworkConnectionClosed(object __0, DisconnectedEventArgs __1)
{
try
{
if((CohtmlHud.Instance != null) && (__1 != null) && (!__1.LocalDisconnect))
CohtmlHud.Instance.ViewDropTextImmediate("(Local) Client", "Connection lost", (__1.Error != System.Net.Sockets.SocketError.Success) ? ("Reason: " + __1.Error.ToString()) : "");
}
catch(System.Exception e)
{
MelonLoader.MelonLogger.Error(e);
}
}
}
}