Skip to content

Commit

Permalink
Merge pull request #123 from BUTR/v1.0.32
Browse files Browse the repository at this point in the history
v1.0.36
  • Loading branch information
Aragas authored Jan 26, 2022
2 parents 855c2fe + 332d1fe commit db5159d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<!--Development Variables-->
<PropertyGroup>
<!--Module Version-->
<Version>1.0.35</Version>
<Version>1.0.36</Version>
<!--Harmony Version-->
<HarmonyVersion>2.1.1</HarmonyVersion>
<!--Microsoft Extension Libraries Version-->
Expand Down
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---------------------------------------------------------------------------------------------------
Version: 1.0.36
Game Versions: e1.4.3,e1.5.0,e1.5.1,e1.5.2,e1.5.3,e1.5.4,e1.5.5,e1.5.6,e1.5.7,e1.5.8,e1.5.9,e1.5.10,e1.6.0,e1.6.1,e1.6.2,e1.6.3,e1.6.4,e1.6.5,e1.7.0,e1.7.1
* Involved mods fix
---------------------------------------------------------------------------------------------------
Version: 1.0.35
Game Versions: e1.4.3,e1.5.0,e1.5.1,e1.5.2,e1.5.3,e1.5.4,e1.5.5,e1.5.6,e1.5.7,e1.5.8,e1.5.9,e1.5.10,e1.6.0,e1.6.1,e1.6.2,e1.6.3,e1.6.4,e1.6.5,e1.7.0,e1.7.1
* Build fix
Expand Down
2 changes: 1 addition & 1 deletion src/Bannerlord.ButterLib/ExceptionHandler/BEWPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal sealed class BEWPatch
private static readonly MethodInfo? ScreenManagerTickMethod = AccessTools2.Method(typeof(ScreenManager), "Tick");
private static readonly MethodInfo? ManagedScriptHolderTickComponentsMethod = AccessTools2.Method(typeof(ManagedScriptHolder), "TickComponents");
private static readonly MethodInfo? MissionTickMethod = AccessTools2.Method(typeof(Mission), "Tick");
private static readonly MethodInfo? FinalizerMethod = AccessTools2.Method(typeof(BEWPatch), nameof(Finalizer));
public static readonly MethodInfo? FinalizerMethod = AccessTools2.Method(typeof(BEWPatch), nameof(Finalizer));

private static void Finalizer(Exception? __exception)
{
Expand Down
31 changes: 23 additions & 8 deletions src/Bannerlord.ButterLib/ExceptionHandler/CrashReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@

namespace Bannerlord.ButterLib.ExceptionHandler
{
internal record InvolvedModule(MethodBase Method, ExtendedModuleInfo ModuleInfo, string StackFrameDescription);

internal class CrashReport
{
public Guid Id { get; } = Guid.NewGuid();
public Exception Exception { get; }
public List<(MethodBase Method, ExtendedModuleInfo ModuleInfo, string StackFrameDescription)> InvolvedModules { get; }
public List<InvolvedModule> InvolvedModules { get; }
public List<ExtendedModuleInfo> LoadedModules { get; } = ModuleInfoHelper.GetLoadedModules().ToList();
public List<Assembly> ModuleLoadedAssemblies { get; } = new();
public List<Assembly> ExternalLoadedAssemblies { get; } = new();
Expand All @@ -27,7 +29,7 @@ public CrashReport(Exception exception)
{
Exception = exception;

InvolvedModules = GetAllInvolvedModules(exception, 0).ToList();
InvolvedModules = GetAllInvolvedModules(exception, 0).Where(FilterButterLib).ToList();

var moduleAssemblies = new List<string>();
foreach (var subModule in LoadedModules.SelectMany(module => module.ExtendedSubModules))
Expand All @@ -47,7 +49,20 @@ public CrashReport(Exception exception)
}
}

private static IEnumerable<(MethodBase, ExtendedModuleInfo, string)> GetAllInvolvedModules(Exception ex, int level)
private static bool FilterButterLib(InvolvedModule involvedModule)
{
if (involvedModule.ModuleInfo.Id == "Bannerlord.ButterLib")
{
if (involvedModule.Method == BEWPatch.FinalizerMethod)
{
return false;
}
}

return true;
}

private static IEnumerable<InvolvedModule> GetAllInvolvedModules(Exception ex, int level)
{
static Patches? FindPatches(MethodBase method) => method is MethodInfo replacement
? Harmony.GetOriginalMethod(replacement) is { } original ? Harmony.GetPatchInfo(original) : null
Expand Down Expand Up @@ -102,24 +117,24 @@ public CrashReport(Exception exception)

foreach (var (methodBase, extendedModuleInfo) in GetFinalizers(patches))
{
yield return (methodBase, extendedModuleInfo, frame.ToString() ?? string.Empty);
yield return new(methodBase, extendedModuleInfo, frame.ToString() ?? string.Empty);
}
foreach (var (methodBase, extendedModuleInfo) in GetPostfixes(patches))
{
yield return (methodBase, extendedModuleInfo, frame.ToString() ?? string.Empty);
yield return new(methodBase, extendedModuleInfo, frame.ToString() ?? string.Empty);
}
foreach (var (methodBase, extendedModuleInfo) in GetPrefixes(patches))
{
yield return (methodBase, extendedModuleInfo, frame.ToString() ?? string.Empty);
yield return new(methodBase, extendedModuleInfo, frame.ToString() ?? string.Empty);
}
foreach (var (methodBase, extendedModuleInfo) in GetTranspilers(patches))
{
yield return (methodBase, extendedModuleInfo, frame.ToString() ?? string.Empty);
yield return new(methodBase, extendedModuleInfo, frame.ToString() ?? string.Empty);
}

var moduleInfo = GetModuleInfoIfMod(method);
if (moduleInfo is not null)
yield return (method, moduleInfo, frame.ToString() ?? string.Empty);
yield return new(method, moduleInfo, frame.ToString() ?? string.Empty);
}
}
}
Expand Down

0 comments on commit db5159d

Please sign in to comment.