SpikeHimself / XPortal

XPortal is a Valheim mod that lets you select a portal's destination from a list. XPortal is a complete rewrite of AnyPortal.
GNU General Public License v3.0
19 stars 6 forks source link

Portal connections are not restored #57

Closed Quentin-ctrL closed 1 year ago

Quentin-ctrL commented 1 year ago

Describe the bug Portal destinations are not stored between sessions

To Reproduce

Expected behaviour Remeber portal destination

LogOutput file(s)

[Info   :XPortal.Log] Received XPortal Config from server
[Info   :XPortal.Log] Received sync request from `3354732442` because: Gunnmjak (3354732442) has joined the game
[Info   :XPortal.Log] Setting portal tag `01` and target `0:0` on behalf of `3354732442`
[Info   :XPortal.Log] Setting portal tag `00_Autels` and target `0:0` on behalf of `3354732442`
[Info   :XPortal.Log] Setting portal tag `Marchand` and target `0:0` on behalf of `3354732442`
[Info   :XPortal.Log] Known portals updated. Current total: 12
[Info   : Unity Log] 06/17/2023 15:58:46: Activating default element Texts
[Info   :XPortal.Log] Received XPortal Config from server
[Info   :XPortal.Log] Received sync request from `2446572062` because: Gunnmjak (2446572062) has joined the game
[Info   :XPortal.Log] Known portals updated. Current total: 12
[Info   :XPortal.Log] Setting portal tag `00_Autels` and target `1:538063` on behalf of `2446572062`
[Info   :XPortal.Log] Setting portal tag `Marchand` and target `1:382972` on behalf of `2446572062`
[Info   :XPortal.Log] Received XPortal Config from server
[Info   :XPortal.Log] Received sync request from `2446572062` because: Gunnmjak (2446572062) has joined the game
[Info   :XPortal.Log] Known portals updated. Current total: 12
[Info   :XPortal.Log] Setting portal tag `00_Autels` and target `1:538063` on behalf of `2446572062`
[Info   :XPortal.Log] Setting portal tag `Marchand` and target `1:382972` on behalf of `2446572062`
[Info   :XPortal.Log] Received XPortal Config from server
[Info   :XPortal.Log] Received sync request from `3372468183` because: Gunnmjak (3372468183) has joined the game
[Info   :XPortal.Log] Setting portal tag `00_Autels` and target `0:0` on behalf of `3372468183`
[Info   :XPortal.Log] Setting portal tag `10` and target `0:0` on behalf of `3372468183`
[Info   :XPortal.Log] Known portals updated. Current total: 12
[Info   :XPortal.Log] Setting portal tag `00_Autels` and target `1:622260` on behalf of `3372468183`
[Info   :XPortal.Log] Setting portal tag `` and target `0:0` on behalf of `3372468183`
[Info   :XPortal.Log] Setting portal tag `test01` and target `1:622260` on behalf of `3372468183`
[Info   :XPortal.Log] Setting portal tag `01` and target `3372468183:601049` on behalf of `3372468183`

No error in BepInEx/LogOutput.log

Version Which version of XPortal are you experiencing your problem with? Loading [XPortal 1.2.13]

Environment

Other mods Jötunn v2.12.1 loaded successfully

Priority

Additional information I had unamed portal and renamed them all but it's not the issue. For me the situation is the same as described in Xportal not saving destinations between logins

SpikeHimself commented 1 year ago

I think this could be a backwards-compatibility issue, and the connections should be saved "from now on".

Could you set up a new portal connection, and then save/restart your game, and see if it is remembered?

Quentin-ctrL commented 1 year ago

I created 2 portals with 2 different names never used. I tried to teleport with other portals but in a new session it's all messed up and some portal are disconnected.

I extracted log between 2 sessions

grep XPortal.Log '/data/Games/Steam/steamapps/common/Valheim/BepInEx/LogOutput.log' 
[Info   :XPortal.Log] Received XPortal Config from server
[Info   :XPortal.Log] Received sync request from `3260367284` because: Gunnmjak (3260367284) has joined the game
[Info   :XPortal.Log] Setting portal tag `qwerty` and target `0:0` on behalf of `3260367284`
[Info   :XPortal.Log] Known portals updated. Current total: 14
[Info   :XPortal.Log] Setting portal tag `qwerty` and target `1:384132` on behalf of `3260367284`

grep XPortal.Log '/data/Games/Steam/steamapps/common/Valheim/BepInEx/LogOutput.log' 
[Info   :XPortal.Log] Received XPortal Config from server
[Info   :XPortal.Log] Received sync request from `3260367284` because: Gunnmjak (3260367284) has joined the game
[Info   :XPortal.Log] Setting portal tag `qwerty` and target `0:0` on behalf of `3260367284`
[Info   :XPortal.Log] Known portals updated. Current total: 14
[Info   :XPortal.Log] Setting portal tag `qwerty` and target `1:384132` on behalf of `3260367284`
[Info   :XPortal.Log] Received XPortal Config from server
[Info   :XPortal.Log] Received sync request from `2268114920` because: Gunnmjak (2268114920) has joined the game
[Info   :XPortal.Log] Setting portal tag `00_Autels` and target `0:0` on behalf of `2268114920`
[Info   :XPortal.Log] Setting portal tag `azerty` and target `0:0` on behalf of `2268114920`
[Info   :XPortal.Log] Setting portal tag `Marchand` and target `0:0` on behalf of `2268114920`
[Info   :XPortal.Log] Known portals updated. Current total: 14
[Info   :XPortal.Log] Setting portal tag `azerty` and target `1:1139086` on behalf of `2268114920`

It's seems some connections are correctly stored and other not. With new portal, the problem persist.

I tested on my second world. On a new world maybe it's fixed. What can I do to solve the issue ?

SpikeHimself commented 1 year ago

Could you send me the full logfiles of both the server and the client, with BepInEx debugging enabled and using the XPortal Debug release?

Quentin-ctrL commented 1 year ago

I don't find something for BepInEx debugging enabled I just installed debug release to give full logs

First time I delete 2 portals and keep 2 old portals. Connect old portals '00_Autels' to 'Marchand' and teleport I create 2 new portals close to the previous I connect 'xportal' to 'yportal' and teleport Now I can travel without issue during the session

I close Valheim and restart. I was close to 'yportal' and 'Marchand' and both are correctly connected. I teleport to 'xportal' Now I can see 'xportal' is not connected nor '00_Autels' Something is really weird after, I checked '00_Autels' when I open the UI it seems to be linked to ''Marchand' but not connected On the contrary 'xportal' was linked to none so not connected to the other portal.

LogOutput_1.log LogOutput_2.log

I'll check on windows later

Quentin-ctrL commented 1 year ago

Hi, I updated Valheim and Xportal. The issue remains, some portals keep the destination, some dont. I tried to test with new portal only. the destination are not kept between session, like the others. It seems random, I see some portals with a destination set. I had the idea to recreate all the portals but I will have no effect.

when reconnecting to the world some portals are reset without doing anything !

[Info   :XPortal.Log] Received XPortal Config from server
[Info   :XPortal.Log] Received sync request from `3890066118` because: Gunnmjak (3890066118) has joined the game
[Info   :XPortal.Log] Setting portal tag `bug` and target `0:0` on behalf of `3890066118`
[Info   :XPortal.Log] Setting portal tag `new` and target `0:0` on behalf of `3890066118`
[Info   :XPortal.Log] Known portals updated. Current total: 19

Is it possible to clear all data from the mod ? Where is it stored ?

[Info   :   BepInEx] Loading [XPortal 1.2.14]
[Info   :XPortal.Log] Received XPortal Config from server
[Info   :XPortal.Log] Received sync request from `2527332158` because: Gunnmjak (2527332158) has joined the game
[Info   :XPortal.Log] Known portals updated. Current total: 19
[Info   :XPortal.Log] Setting portal tag `00_Autels` and target `1:685311` on behalf of `2527332158`
[Info   : Unity Log] 08/29/2023 03:56:39: Button pressed XPortal_DestinationDropdown  frame:7483
[Info   : Unity Log] 08/29/2023 03:56:42: Button pressed XPortal_OkayButton  frame:7682
[Info   :XPortal.Log] Setting portal tag `new02` and target `1:501094` on behalf of `2527332158`
[Info   :XPortal.Log] Received XPortal Config from server
[Info   :XPortal.Log] Received sync request from `3890066118` because: Gunnmjak (3890066118) has joined the game
[Info   :XPortal.Log] Setting portal tag `bug` and target `0:0` on behalf of `3890066118`
[Info   :XPortal.Log] Setting portal tag `new` and target `0:0` on behalf of `3890066118`
[Info   :XPortal.Log] Known portals updated. Current total: 19
SpikeHimself commented 1 year ago

This issue is finally fixed, in v1.2.15! Please let me know if you find any persisting problems relating to this. You do need to set new portal connections first - old ones made prior to this version will not be restored.

Quentin-ctrL commented 1 year ago

I'll check that next week. As a workaround I installed better portal. I don't know if that could affect the results.

No problem to set new portal connections. Can you explain the issue and why it seems I'm the only affected ?

Thanks :+1:

SpikeHimself commented 1 year ago

As a workaround I installed better portal. I don't know if that could affect the results.

I'm not familiar with this mod, so I can't say.

Can you explain the issue and why it seems I'm the only affected ?

You're not the only one affected. In v1.2.12 I added a quick work-around that sort of half-fixed the issue, and people haven't complained since, but there was very much still an issue, where portal connections weren't remembered after logging out.

The reason this started is because Valheim released an update (0.216.9) that completely changed how portal connections are created and saved.

Before 0.216.9, each portal had its own "target" property. When you connect a portal in vanilla (without XPortal), the game just sets that property to the other portal when connecting two portals by their tag/name.

Since 0.216.9, that "target" property has been abandoned, and portals are now connected through a more generic connection system that stores a hash per portal, and this hash must match that of the portal on the other side. In this new system, one portal is specifically marked as "portal" while the other end is specifically marked as "target". This completely breaks the functionality that XPortal relied on, and means you can no longer target one portal from multiple others.

In v1.2.15 which I released today, I have replaced that new functionality entirely by creating my own implementation of the old method. Each portal now has a "target" property again (called "XPortal_TargetId") and you can once more connect multiple portals to one and the same exit.

There is one more caveat that was introduced either by that same Valheim patch, or perhaps a later one (I'm not sure), that meant that after logging out of your game, and then logging back in (so without closing the game inbetween), portal ZDOs are given freshly generated IDs. This breaks my method again, and is half the reason why it took so long to come up with this solution. I had to add another new property to portals which I called XPortal_PreviousId - this is saved along with the rest of the game data, and can be used to find previously linked portals which have changed ID.

Long story short I need a lot of coffee to recover from this 😄

Quentin-ctrL commented 1 year ago

Hi,

Sadly, the issue is still there but it's better than before the fix. When I play, I see that some connections are lost. I don't know if it's related that I switch between worlds.

SpikeHimself commented 1 year ago

Hi @Quentin-ctrL, you're right, I discovered the same bug today by accident. It was addressed in https://github.com/SpikeHimself/XPortal/commit/86cc586b40087105aa64c95bead8672455b51634 and I'll push a new version tomorrow (most likely).

SpikeHimself commented 1 year ago

To elaborate on the above, in a previous comment I wrote this, regarding the recycling of ZDOIDs.

There is one more caveat that was introduced either by that same Valheim patch, or perhaps a later one (I'm not sure), that meant that after logging out of your game, and then logging back in (so without closing the game inbetween), portal ZDOs are given freshly generated IDs. This breaks my method again, and is half the reason why it took so long to come up with this solution. I had to add another new property to portals which I called XPortal_PreviousId - this is saved along with the rest of the game data, and can be used to find previously linked portals which have changed ID.

A bug that occurred here is that when I determined that a ZDO existed, I also assumed it was a portal. This turned out to be incorrect, as the ZDOIDs of what previously were portals can become other objects in the next session. To fix this I do a second check that looks if the ZDO it finds has the XPortal_PreviousId set: https://github.com/SpikeHimself/XPortal/blob/86cc586b40087105aa64c95bead8672455b51634/XPortal/Patches/ZDOMan.cs#L71-L74

This works, because every single portal that is created or interacted with while XPortal is active, will have this field set (as of v1.2.15).

SpikeHimself commented 1 year ago

@Quentin-ctrL v1.2.16 just went live in which this should finally be fixed. Please let me know if you still run into any problems!