xNul / palworld-host-save-fix

Fixes the bug which forces a player to create a new character when they already have a save. Useful for migrating maps from co-op to dedicated servers and from one dedicated server to another.
MIT License
885 stars 69 forks source link

Underlying mechanism for "Windows<>Linux" incompatibility with UID generation #160

Open cheahjs opened 7 months ago

cheahjs commented 7 months ago

The underlying mechanism for UIDs being generated differently on Windows and Linux is actually not OS related, but related to how Palworld handles conversion of a FUniqueNetId (in the case of Steam clients, the client's 64-bit SteamID) to 32-bit PlayerUid.

In the event that the Steam online subsystem is not available, Palworld uses a different algorithm for converting the Steam IDs. The Steam online subsystem could be unavailable if the -nosteam CLI argument was used, or if the Steamworks SDK failed to initialise (for example if no Steam client was installed).

I've built a tool for performing these conversions so that people can check if their existing save is using the standard conversion or the no Steam conversion, and take action accordingly.

xNul commented 7 months ago

You sir are a genius! I've been looking for this information since I first made the script!

I really appreciate you opening the issue and I'll be adding it to my script asap!

cheahjs commented 7 months ago

Automatic conversion is non-trivial, as generation involves a one-way hash. Ideally you would ask the user for the players' Steam IDs. My tool provides the ability to bruteforce convert all 2^32 possible Steam IDs (a 64-bit SteamID consists of a 32-bit account ID and 32-bits of static information for public accounts) to all UIDs to attempt to search for Steam IDs that match a specific UID. However, as it is hashing a number with 32-bits of information into a 32-bit hash, for example the UID 7715B8D6 is generated for 6(!) different Steam IDs.

image
xNul commented 7 months ago

I understand it's not a perfect solution, but it should be able to help a lot. I was thinking about providing two options: an automatic option for bruteforcing the Steam IDs and a manual option for letting the user provide the Steam IDs. In the automatic option, if there are multiple Steam IDs which result in the same hash and each belongs to a valid account, I'd provide the user with the option to choose between the different usernames of those corresponding Steam IDs.

Also, can we reduce the search space by leveraging the fact there is no Steam ID greater than 1.3 billion?

asdf4w3t5 commented 7 months ago

Also, can we reduce the search space by leveraging the fact there is no Steam ID greater than 1.3 billion?

yea the data is almost 1/3rd the size then. No sense in going to ~4.3 bill