FujiAPI / Fuji

Celeste 64 Mod Loader
30 stars 10 forks source link

hooks don't reapply after disabling and re-enabling a mod #59

Closed bananaturtlesandwich closed 6 months ago

bananaturtlesandwich commented 6 months ago

Please confirm the following

What were you doing?

i was testing my discord rich presence mod and everything seems to be working well but after disabling and re-enabling the presence doesn't change when entering a new level which is set by a hook to LevelInfo.Enter

Your logs

no logs :p
jasminegamedev commented 6 months ago

I tried reproducing this with my own test mod, and could not reproduce it on the latest version of the dev stream. It seemed like after getting re-enabled, the hook worked as expected. Any chance you could send me your mod's source code so I can troubleshoot it better? Feel free free to send it privately on discord if you'd prefer.

Edit: Disregard this and see my below message. I figured out how to look at it through some visual studio disassembling stuff.

jasminegamedev commented 6 months ago

Ok, nevermind. I'm pretty sure I figured it out. I don't think the problem was a hooks thing. I think the problem was that we weren't calling OnModUnloaded properly, which was leading to your discord rich present client not getting disposed correctly. I think I have a fix for this here: https://github.com/FujiAPI/Fuji/commit/6e68cace8df7a270f1ef891e00f990ea4801e832 I think you may have a secondary problem though that might also be effecting it. I noticed you were calling Dispose twice, in both OnModLoaded, and the Destructor.

    public override void OnModUnloaded()
    {
        client.Dispose();
    }

    ~DiscordPlugin()
    {
        client.Dispose();
    }

I think this might fail if it gets called multiple times like that, because it becomes null after the first one from what I was seeing. So you may want to wrap these in a null check, and I don't know if you actually need the destructor one. Also might not hurt to try to dispose it if it's not null at the beginning of OnModLoaded as well, just to be safe. I'm closing this for now, but let me know if this is still an issue after the next release, and we can reopen this.

bananaturtlesandwich commented 6 months ago

since the client is reinitialised on mod load i don't think this is the issue

bananaturtlesandwich commented 6 months ago

oh wait i'll check on new branch

jasminegamedev commented 6 months ago

No, the issue was that your old client wasn't getting disposed properly I think, which I think was causing issues. I believe this should be fixed now, although it's only on the dev stream at the moment.

bananaturtlesandwich commented 6 months ago

dunno how to build for new branch since it needs hookgen