Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatability/bug between MassFarming, ValheimPlus, XPortal/Jotunn #36

Closed
purrdypaws opened this issue Mar 28, 2023 · 14 comments
Closed
Assignees
Labels
bug Something isn't working compatibility Other mods might be involved help wanted Extra attention is needed hotfix A temporary hotfix or debug release was provided for testing purposes

Comments

@purrdypaws
Copy link

purrdypaws commented Mar 28, 2023

Describe the bug
Place portal using hammer, attempt to demolish portal with hammer, portal isn't demolished.

To Reproduce
Place portal using hammer, attempt to demolish portal with hammer, portal isn't demolished.

Expected behaviour
Portal demolished.

LogOutput file(s)
LogOutput.log

Version
v1.2.9

Environment
Dedicated server
Singleplayer

Other mods
MassFarming v1.6 https://www.nexusmods.com/valheim/mods/527
ValheimPlus Fix v0.9.9.12 https://www.nexusmods.com/valheim/mods/2323
Jotunn v2.11.2 https://www.nexusmods.com/valheim/mods/1138

Priority
Medium (XPortal kind of still works, but it's not pleasant to use)

Additional information
XPortal works normally with just ValheimPlus, it also works normally with just MassFarming, but not when using all 3 together. Weirdly enough it lets you demolish after placing a new portal and then zooming out or in with scroll then attempting to demolish with the hammer. Also no error is thrown in server console, portal just doesn't demolish.

@purrdypaws purrdypaws added the bug Something isn't working label Mar 28, 2023
@SpikeHimself
Copy link
Owner

SpikeHimself commented Mar 28, 2023

Hi, thanks for reporting!

Judging by the error that's showing up in your logfile, it looks as if you are trying to destroy a portal that XPortal doesn't know about. So something else has gone wrong earlier, when this portal was created and/or updated.

Did you change the name or destination of the portal before trying to destroy it, and did that cause any errors or weird side effects?

Either way, that is just a "guess at first sight". To properly dive into this I will need a little more information.

Could you peform the following steps for me?

  • Download the latest Debug release of XPortal and replace your (and your server's) XPortal version with this one. You need all 3 files in the debug zipfile to go into the same directory that XPortal.dll is currently in (i.e. [..]\Valheim\BepInEx\plugins\XPortal\)
  • Enable debug logging
  • Join your server
  • Build a new portal. Do not name it and do not change its destination.
  • Destroy that portal
  • Share both your and your server's logfiles here.

Thank you very much in advance!

@SpikeHimself SpikeHimself self-assigned this Mar 28, 2023
@SpikeHimself SpikeHimself added the compatibility Other mods might be involved label Mar 28, 2023
@purrdypaws
Copy link
Author

purrdypaws commented Mar 28, 2023

Sorry, valheim updated while I was away and I didn't have a clean copy of the server files from before, the new update broke the valheim plus fix so just waiting for that to update before I can try this for you.

@SpikeHimself
Copy link
Owner

You can always trust game updates to ruin everything!

But no worries, just give me a shout when you've got things up and running again and I'll look into it.

@purrdypaws
Copy link
Author

purrdypaws commented Mar 31, 2023

Sorry it took a couple days, been dealing with some stuff, here's the logs.

Client:
LogOutput.log

Server:
LogOutput.log

I logged into the server, placed the portal, didn't name it or change destination, attempted to destroy and it didn't demolish, zoomed out and in and it let me demolished it.

@SpikeHimself
Copy link
Owner

SpikeHimself commented Mar 31, 2023

Very curious!

It is precisely what I expected;

XPortal detects when a new piece is being placed (i.e. when you build anything), and if that piece happens to be a portal, XPortal adds that portal to its internal list of "known portals". This did not happen to the portal you built (no error at this stage, just a silent undetected failure). So when the time came to destroy the portal, XPortal searched for it in its internal known portals list, and didn't find it, and that caused an error.

From your server log:

[Debug  :XPortal.RPC.Server.ServerEvents] [RPC_RemoveRequest] -1171665832 wants `-1171665832:14` to be removed, but it doesn't exist

The reason it does work the second time, is because you have hovered over the portal. When you do that, XPortal detects that the portal you are hovering over does not yet exist, and then goes on to add it (client only), assuming it was just a new portal that wasn't added to the list for an unknown reason -- essentially exactly what happened to your portal.

From your client log:

[Debug  :XPortal.XPortal] [OnPrePortalHover] Hovering over new portal `-1171665832:14`

Now, I could just make XPortal ignore the fact that the portal doesn't exist upon destruction. After all, you're destroying it, the portal doesn't matter anymore. And the hover event takes that same approach, as in, it adds a portal if it didn't exist.

This doesn't however address the underlying problem (and the same argument can be made for the hover event taking the wrong approach). You could have chosen not to destroy this portal. You could have just left it there and moved on with your life. In that case, XPortal will not know that this portal exists, until you log out and join the server again (this triggers a full resync), and the portal would not be available in the destination dropdown on other portals (XPortal can only list he portals it knows about).

The root cause of this problem is the fact that the build event is not being triggered. Both VH+ and Mass Farming handle build events, and it's possible that, because of how they work, XPortal never gets a chance to do its part.

I will do two things:

  1. Upon portal destruction, don't error out when a portal that doesn't exist is being destroyed
  2. Try to find alternative ways of detecting portal placement

I'll get back to you on that when I have made some progress.

Sadly I cannot address the root cause. The bug is in either of those other mods.

@SpikeHimself
Copy link
Owner

SpikeHimself commented Mar 31, 2023

Here's a new (debug) release in which:

  1. Portal placement will be detected earlier (not sure if this will work)
  2. When destroying a portal that XPortal does not know, log an error message to console instead of crashing

XPortal-debug-v1.2.10-issue-36.zip

Could you run the same test as before with this new version, and let me know the results? Bear in mind that with this version, the portal will be destroyed, even if that would otherwise have gone wrong, so it's important (for me) to see the client output log.

As a side note, this is a candidate release for v1.2.10 of XPortal and it contains changes that weren't fully tested yet (like UI Keyhints), so you might run into other bugs. I was not able to use the previous version for this test, because of game and bepinex updates.

@purrdypaws
Copy link
Author

The portal destroyed when attempting to demolish. Not sure if you only need client, i'll just send both. Using your debug v1.2.10

Client:
LogOutput.log

Server:
LogOutput.log

@SpikeHimself
Copy link
Owner

Excellent, thank you very much.

Here's the new error message, working as intended:

[Error  :XPortal.Log] Portal `-1650909664:3` is being destroyed, but XPortal does not know it

So now it does that, instead of crashing. That's half the problem fixed. (it's still an error, because it's not supposed to happen, but at least nothing breaks now)

My other point (detection of the portal being placed) clearly did not work so I'll spend a little more time on that. I'll get back to you when my brain has hurt sufficiently ;)

@purrdypaws
Copy link
Author

yea, no worries, it was nice that it broke properly and the error is okay, sometimes i build a workbench portal etc to break then i have the exact materials i need for that thing, instead of going and searching and trying to remember how many of what items i need for it when using vplus build/craft from containers.

@SpikeHimself
Copy link
Owner

I've spent several hours on this issue and I think I have a rough idea of what the root cause is, but I haven't been able to come up with a solution yet.

In case you (or anyone else reading this) are interested in the technicals: it appears that my patch on WearNTear.OnPlaced is not executed when a patch on Player.PlacePiece also exists. I can reproduce your problem with 100% consistency if I create a patch on Player.PlacePiece, even if that patch does not do anything. In your particular case, Mass Farming does indeed patch Player.PlacePiece, and this causes XPortal's WearNTear.OnPlaced patch to not work (for an, as of yet, unknown reason).

I currently have no idea how to debug this, which is why I have opened an issue in the HarmonyX project, here: BepInEx/HarmonyX#71

In the upcoming release of XPortal I will include the change that stops XPortal from crashing when you destroy an unknown portal. The other half of the problem (not detecting portal placement) will have to wait until I have learned more. So I'm leaving this issue open for now.

@SpikeHimself SpikeHimself added the help wanted Extra attention is needed label Apr 2, 2023
SpikeHimself added a commit that referenced this issue Apr 2, 2023
@SpikeHimself
Copy link
Owner

v1.2.10 is now live. As mentioned previously, this version includes the change that stops XPortal from crashing when you destroy an unknown portal.

@SpikeHimself
Copy link
Owner

SpikeHimself commented Apr 4, 2023

Hi @purrdypaws! It seems that the bug I discovered isn't really a bug, but, let's say, a challenging feature of how this programming language works.

If you want to read the technicals (I don't recommend it - it hurts), just click on the HarmonyX issue I linked in an earlier comment.

Anyway, I have a new test file ready. The issue "might" be solved in this (but I'm not sure yet).

Could you please try the same steps again, and share your output logfiles with me?

  • Download XPortal-debug-v1.2.11-issue-36.zip
  • Enable debug logging in case you've turned it off again since last time
  • Join your server
  • Build a new portal. Do not name it and do not change its destination.
  • Destroy that portal
  • Share both your and your server's logfiles here.

Thanks for your patience!

@SpikeHimself SpikeHimself added the hotfix A temporary hotfix or debug release was provided for testing purposes label Apr 7, 2023
@SpikeHimself
Copy link
Owner

Hi @purrdypaws, have you been able to test this yet? Without testing feedback I will not be able to implement this in a new release.

@SpikeHimself
Copy link
Owner

Hi @purrdypaws I have included a work-around in v1.2.11 which has just gone live. If you continue to have this problem please let me know and I will spend more time on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compatibility Other mods might be involved help wanted Extra attention is needed hotfix A temporary hotfix or debug release was provided for testing purposes
Projects
None yet
Development

No branches or pull requests

2 participants