William758 / ZetTweaks

0 stars 0 forks source link

Exception on RoR2.UI.LogBook.LogBookController.Init (ZetTweaksPlugin.OnLogBookControllerReady) #16

Open oorzkws opened 2 months ago

oorzkws commented 2 months ago

Seems like SotS changed the return type for Init() if I'm reading this correctly.

[Debug  :RoR2BepInExPack] OnHook TPDespair.ZetTweaks.ZetTweaksPlugin+<>c.<OnLogBookControllerReady>b__28_0 added by assembly: ZetTweaks.dll for: RoR2.UI.LogBook.LogBookController.Init
[Error  : Unity Log] InvalidOperationException: Return type of hook for System.Collections.IEnumerator Init() doesn't match, must be System.Collections.IEnumerator
Stack trace:
MonoMod.RuntimeDetour.Hook..ctor (System.Reflection.MethodBase from, System.Reflection.MethodInfo to, System.Object target, MonoMod.RuntimeDetour.HookConfig& config) (at <4e2760c7517c4ea79c633d67e84b319f>:IL_008B)
MonoMod.RuntimeDetour.Hook..ctor (System.Reflection.MethodBase from, System.Reflection.MethodInfo to, System.Object target, MonoMod.RuntimeDetour.HookConfig config) (at <4e2760c7517c4ea79c633d67e84b319f>:IL_0000)
MonoMod.RuntimeDetour.Hook..ctor (System.Reflection.MethodBase from, System.Reflection.MethodInfo to, System.Object target) (at <4e2760c7517c4ea79c633d67e84b319f>:IL_001D)
MonoMod.RuntimeDetour.Hook..ctor (System.Reflection.MethodBase method, System.Delegate to) (at <4e2760c7517c4ea79c633d67e84b319f>:IL_000E)
MonoMod.RuntimeDetour.HookGen.HookEndpoint._NewHook (System.Reflection.MethodBase from, System.Delegate to) (at <4e2760c7517c4ea79c633d67e84b319f>:IL_0000)
MonoMod.RuntimeDetour.HookGen.HookEndpoint._Add[TDelegate] (System.Func`3[T1,T2,TResult] gen, TDelegate hookDelegate) (at <4e2760c7517c4ea79c633d67e84b319f>:IL_003C)
MonoMod.RuntimeDetour.HookGen.HookEndpoint.Add (System.Delegate hookDelegate) (at <4e2760c7517c4ea79c633d67e84b319f>:IL_0000)
MonoMod.RuntimeDetour.HookGen.HookEndpointManager.Add (System.Reflection.MethodBase method, System.Delegate hookDelegate) (at <4e2760c7517c4ea79c633d67e84b319f>:IL_0028)
MonoMod.RuntimeDetour.HookGen.HookEndpointManager.Add[T] (System.Reflection.MethodBase method, System.Delegate hookDelegate) (at <4e2760c7517c4ea79c633d67e84b319f>:IL_0000)
On.RoR2.UI.LogBook.LogBookController.add_Init (On.RoR2.UI.LogBook.LogBookController+hook_Init ) (at <5e656fcb1fed4cfc8c3cd90ea3cdea9c>:IL_000A)
TPDespair.ZetTweaks.ZetTweaksPlugin.OnLogBookControllerReady () (at <2765c1503af74327b3cb78e5b161b13f>:IL_000A)
TPDespair.ZetTweaks.ZetTweaksPlugin.Awake () (at <2765c1503af74327b3cb78e5b161b13f>:IL_0039)
UnityEngine.GameObject:AddComponent(Type)
BepInEx.Bootstrap.Chainloader:Start()
RoR2.Console:.cctor()

ROR2.dll

// RoR2.UI.LogBook.LogBookController
// Token: 0x06006774 RID: 26484 RVA: 0x001AC8D5 File Offset: 0x001AAAD5
public static IEnumerator Init()
{
    if (LocalUserManager.isAnyUserSignedIn)
    {
        LogBookController.BuildStaticData();
    }
    yield return null;
    LocalUserManager.onUserSignIn += LogBookController.OnUserSignIn;
    BaseUserEntitlementTracker<LocalUser>.OnUserEntitlementsUpdated = (Action)Delegate.Combine(BaseUserEntitlementTracker<LocalUser>.OnUserEntitlementsUpdated, new Action(LogBookController.BuildStaticData));
    LogBookController.IsInitialized = true;
    yield break;
}

https://github.com/William758/ZetTweaks/blob/a86fafd9e985ddea404e67612669208c48325377/ZetTweaksPlugin.cs#L126-L147

William758 commented 2 months ago

Just updated the mod for SotS.