codefaux / persistence

Add some Lite to your Rogue
MIT License
1 stars 0 forks source link

[BUG] UI vanishes when there are modded spells in inventory #10

Open Tmktahu opened 3 months ago

Tmktahu commented 3 months ago

It seems that if there are any modded spells in the inventory when trying to research spells or wands, the UI vanishes. At one point I think I saw it go flying off the screen for some reason, as if the position of the UI got messed up.

My expectation would be for the UI to function as expected and only allow interactions with vanilla spells, ignoring the existence of any modded ones.

This is the mod list I was using at the time of seeing the bug: image

Jophire commented 3 months ago

Aah, I was running into this issue as well, but had not made the connection with modded spells. So long as I remove all modded spells from my inventory first, I should be fine to research? Good to know.

Tmktahu commented 3 months ago

So long as I remove all modded spells from my inventory first, I should be fine to research?

Yes that does seem to be the case. The UI works as expected if I drop all modded spells from my inventory and then open the UI. Though, if the UI gets bugged once then it's perma-bugged until you restart the client.

In addition, this applies to the wand stuff as well. If wands have any modded spells on them, the UI will freak out in the same way.

codefaux commented 3 months ago

Okay big TLDR here; known issue, might be fixed by upcoming release, I don't want to start working on supporting other mods until I've got this one under control. Soonish(tm)

I'll likely begin directly addressing cross-mod support within the next few major releases, but this coming release makes a first attempt to mitigate the issue. As a failsafe, if it has issues, try putting it last in the mod order.

And for the behind-the-scenes; Basically, this happens because Persistence stores all available spells into a pool organized by their action_id instead of using the numerically indexed array provided by the game. I do this so I can return a spell with a single lookup instead of iterating through every single spell until I find a match, which is the only other option. This iteration takes a lot of time, and adds a significant amount of extra processing time, which amounts to low framerates with the window open, or stuttering when in a Persistence area.

The failing is, if the spell isn't in my handy little array, the lookup fails, and much of the UI doesn't handle failure well.

If it's a failure which is recoverable or inside the UI draw routines themselves, the UI will shoot off to the bottom right because it's repeatedly starting a container, but never closing it.

If it's a failure someplace before the UI is initiated, the Lua engine simply doesn't run any of the code up to that point, anymore.

In the next release, I've put first-step mitigations in place to attempt to fix it; we watch for the number of existing spells to change, and iterate the spell array again, looking for anything we missed.

Code execution failures will still behave similarly, but Persistence -might- support other mods' spells now. If not, let me know and I'll put it on the todo list.

Let me know if I should close this as solved, AFTER the next release. (Kinda want it out tomorrow for my anniversary but it's 10pm so no promises. This week, for sure.)

codefaux commented 2 months ago

V3 is out.

Spell tooltips are only partially working, but the mod MIGHT work with other mods' spells.

I'm still not ready to directly address this issue if it persists, but please provide fresh feedback here so I know what I'm dealing with in advance.

Thanks everyone!

Gigachad694200 commented 2 months ago

I had this bug too (before V3) but i think the problem is with me is with the mod " bags of many". Like it works perfectly but when picking up modded spells (ui vanishes) or restarting with mods, the research spells only shows no spells even when there are only vanilla spells in the spell inventory. I have around over 30 mods including the screenshot above lol. Also I did not download the V3 patch yet so I will test it later. Thanks for continuing updating this mod <3

Gigachad694200 commented 2 months ago

I had this bug too (before V3) but i think the problem is with me is with the mod " bags of many". Like it works perfectly but when picking up modded spells (ui vanishes) or restarting with mods, the research spells only shows no spells even when there are only vanilla spells in the spell inventory. I have around over 30 mods including the screenshot above lol. Also I did not download the V3 patch yet so I will test it later. Thanks for continuing updating this mod <3

Yep, except for the bugs mentioned in the workshop mod page this incompatibility still exists with bags of many. Maybe not this mods fault, but they are incompatible. The spell research doesn't have any spells when you restart with mods

Gigachad694200 commented 2 months ago

I had this bug too (before V3) but i think the problem is with me is with the mod " bags of many". Like it works perfectly but when picking up modded spells (ui vanishes) or restarting with mods, the research spells only shows no spells even when there are only vanilla spells in the spell inventory. I have around over 30 mods including the screenshot above lol. Also I did not download the V3 patch yet so I will test it later. Thanks for continuing updating this mod <3

Yep, except for the bugs mentioned in the workshop mod page this incompatibility still exists with bags of many. Maybe not this mods fault, but they are incompatible. The spell research doesn't have any spells when you restart with mods

Seems like this is fixed with the new bags of many update

Tmktahu commented 2 months ago

I've been using Persistence for the last couple days and haven't encountered any bugs thus far.

Question though, I have noticed that I seem to be able to research modded spells, which is cool and all. But what would happen if I were to load up a game with only Persistence and without the other mods after I had researched modded spells?

codefaux commented 2 months ago

haven't encountered any bugs thus far.

Really glad to hear it.

what would happen if I were to load up a game with only Persistence and without the other mods after I had researched modded spells?

Well, I don't directly support other mods presently, but to speculate a bit --

When profiles are loaded, I have to scan for the existence or absence of every spell currently known to the game to indicate if it's been researched, and I cannot find a tag for anything not known to the game. So, no negative effect on loading/using a Persistence profile with absent mods.

When a profile is deleted however, I have to scan for the existence of and remove every spell currently known to the game.

So, the first potential bug is, if you research a modded spell, then unload the mod and delete the Persistence profile, I have no way (literally, no way beyond a brute force scan of every combination of letters and numbers of every possible length) to find and erase the marker for that spell, for that profile, due to how limited access to "persistent data" is within the Noita engine. The files would remain until cleaned up by the user, or a new Persistence profile was made using the absent mod. (Simply creating a profile causes Persistence to scan for and delete any detectable remains of a profile before creating a new one, but again it can only act using spells currently known to Noita.)

Spell Loadouts using absent spells might cause a crash, which I can work around easily enough, I just need to see a log (from the console visible when running noita_dev.exe -- noita_dev.exe uses a different save than your Steam slot, don't be scared when you start it and it's a blank slate! It won't overwrite your Steam save slot unless you ask it to with extra steps.) where it happens. I may even be able to induce that error and fix it proactively, I'll see about that today.

So, "It should be fine(tm)" so long as absent spells are not present in saved Loadouts, but if it isn't, show me a console log of where it broke and I'll figure it out if I can.