Skip to content

question about ForceSavingPosition / crashing sending players back to their bed/spawn on dedicated servers? #101

Description

@dreamwraith

hey! ran into something recently on our dedicated server and was digging through the code to see what happened, but wanted to ask here in case i'm misunderstanding how this works.

sometimes when a player's game crashes, they log back in and find themselves teleported all the way back to their bed or world spawn instead of near where they were when they crashed (even though their inventory and skills saved fine from the auto-save).

i was looking at ClientSide.cs and saw the ForceSavingPosition patch on Game.SavePlayerProfile:

if (ZNet.m_world == null || __instance.m_playerProfile.HaveLogoutPoint())
{
    originalValue = true;
    return;
}

i might be mistaken, but isn't ZNet.m_world always null on clients when connected to a dedicated server?

if that's the case, wouldn't this check always return early on clients during periodic auto-saves, meaning setLogoutPoint = true never actually happens? and then if the client crashes (so normal clean logout never runs), the server never gets their field position and valheim just defaults to sending them back to their bed?

would changing ZNet.m_world == null to something like Player.m_localPlayer == null make it so auto-saves actually save their position in case of a crash? or was ZNet.m_world == null checking for something specific here that i'm missing?

thanks a bunch for the mod!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions