void StartUpSafeErrorTrapAdded() { if (NSC_ETRAP.IsDone) { return; } if (AssemblyCheckByNiec.IsInstalled("NRaasErrorTrap") || ShouldACoreScipt2020()) { NiecTask.Perform(delegate { if (!NFinalizeDeath.GameIs64Bit(true) && ShouldACoreScipt2020() && !NiecHelperSituation.isdgmods) { if (!NFinalizeDeath.DoneSafePreventGetAssembliesPro && NFinalizeDeath.func_address_GetAssemblies != 0) { NFinalizeDeath.RemovePreventGetAssemblies(); } Type.GetType("NRaas.Common, NRaasErrorTrap").GetMethod("OnPreLoad", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).Invoke(null, new object[0]); var p = Type.GetType("NRaas.ErrorTrap, NRaasErrorTrap"); if (p == null) { NFinalizeDeath.Assert("Type.GetType(\"NRaas.ErrorTrap, NRaasErrorTrap\"); == null"); goto faled; } else { var m = p.GetMethod("OnScriptError", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (m != null) { var myM = typeof(SCOSR).GetMethod("OnScriptError", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); dontcall = true; OnScriptError(null, null); dontcall = false; // Required if no create method pointer. Delegate.CreateDelegate(typeof(SCOSR._SafeScriptError), m); if (!niec_script_func.niecmod_script_copy_ptr_func_to_func(myM, m, false, false, true, false)) { goto faled; } } else { goto faled; } } _SafeOnScriptError = null; DoneSafeErrorTrap = true; ShouldInjectedMethodOnScriptError = true; if (NiecHelperSituation.___bOpenDGSIsInstalled_) { SetBoolScriptCore2020(false, false, false); } else { SetBoolScriptCore2020(AssemblyCheckByNiec.IsInstalled("AweCore"), true, true); } return; } faled: for (int i = 0; i < 100; i++) { Simulator.Sleep(0); } if (!DoneSafeErrorTrap && AssemblyCheckByNiec.IsInstalled("NRaasErrorTrap")) { Type.GetType("NRaas.Common, NRaasErrorTrap").GetMethod("OnPreLoad", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).Invoke(null, new object[0]); } if (AssemblyCheckByNiec.IsInstalled("NRaasErrorTrap")) { Type type = Type.GetType("ScriptCore.ExceptionTrap, ScriptCore", true); if (type != null) { FieldInfo mField = type.GetField("OnScriptError", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (mField != null) { MethodInfo mf = (mField.GetValue(null) as MulticastDelegate).method_info; if (mf != null) { NFinalizeDeath.sIs_m_OnScriptError = typeof(SCOSR).GetMethod("OnScriptError"); if (mf == typeof(SCOSR).GetMethod("OnScriptError") || mf.DeclaringType == typeof(SCOSR)) { DoneSafeErrorTrap = true; } else { SCOSR._SafeOnScriptError = (SCOSR._SafeScriptError)Delegate.CreateDelegate(typeof(SCOSR._SafeScriptError), mf); type = Type.GetType("ScriptCore.ExceptionTrap+ScriptError, ScriptCore", true); if (type != null) { mf = typeof(SCOSR).GetMethod("OnScriptError"); if (mf != null) { mField.SetValue(null, Delegate.CreateDelegate(type, mf)); DoneSafeErrorTrap = true; if (NiecHelperSituation.___bOpenDGSIsInstalled_) { SetBoolScriptCore2020(false, false, false); } else { SetBoolScriptCore2020(AssemblyCheckByNiec.IsInstalled("AweCore"), true, mField.GetValue(null) != null); } if (mField.GetValue(null) == null) { NiecException.WriteLog("StartUpSafeErrorTrapAdded() Found mField.GetValue(null) == null"); } } else { throw new NotSupportedException("OnScriptError not find"); } } } } else { NiecException.WriteLog("if (mf == null)"); } } else { throw new NotSupportedException("OnScriptError not find"); } } } }); } }