Kinda start work on uid saveload

This commit is contained in:
Loki Rautio
2026-03-05 10:55:59 -06:00
parent 66b9e61925
commit 90318307e2
6 changed files with 54 additions and 29 deletions

View File

@@ -40,6 +40,25 @@ namespace Win64NameXuid
return (PlayerUID)hash;
}
/**
* Creates a completely random PlayerUID while also keeping itself away from the legacy values
*
* @return Random PlayerUID within valid ranges
*/
inline PlayerUID GenerateRandomPlayerUID()
{
unsigned __int64 hash = ((unsigned __int64)rand() << 32) | (unsigned __int64)rand();
// Namespace the hash away from legacy smallId-based values.
hash ^= 0x9E3779B97F4A7C15ULL;
hash |= 0x8000000000000000ULL;
if (hash == (unsigned __int64)INVALID_XUID)
{
hash ^= 0x0100000000000001ULL;
}
return (PlayerUID)hash;
}
}
#endif