From f45410c917c4e0e69f0e769e83b5b7df7cd5853c Mon Sep 17 00:00:00 2001 From: qwint Date: Tue, 15 Jul 2025 00:10:40 -0500 Subject: [PATCH] Core: Update UUID handling to be more easily sharable between libraries (#5088) moves uuid caching to appdata and uuid generation to be a random uuid instead of getnode's hardware address driven identifier and updates docs to point to the shared cache --- Utils.py | 18 ++++++++++++++---- docs/network protocol.md | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Utils.py b/Utils.py index 5697bb16..d1c1dd5b 100644 --- a/Utils.py +++ b/Utils.py @@ -413,13 +413,23 @@ def get_adjuster_settings(game_name: str) -> Namespace: @cache_argsless def get_unique_identifier(): - uuid = persistent_load().get("client", {}).get("uuid", None) + common_path = cache_path("common.json") + if os.path.exists(common_path): + with open(common_path) as f: + common_file = json.load(f) + uuid = common_file.get("uuid", None) + else: + common_file = {} + uuid = None + if uuid: return uuid - import uuid - uuid = uuid.getnode() - persistent_store("client", "uuid", uuid) + from uuid import uuid4 + uuid = str(uuid4()) + common_file["uuid"] = uuid + with open(common_path, "w") as f: + json.dump(common_file, f, separators=(",", ":")) return uuid diff --git a/docs/network protocol.md b/docs/network protocol.md index 8c07ff10..27238e6b 100644 --- a/docs/network protocol.md +++ b/docs/network protocol.md @@ -294,7 +294,7 @@ Sent by the client to initiate a connection to an Archipelago game session. | password | str | If the game session requires a password, it should be passed here. | | game | str | The name of the game the client is playing. Example: `A Link to the Past` | | name | str | The player name for this client. | -| uuid | str | Unique identifier for player client. | +| uuid | str | Unique identifier for player. Cached in the user cache \Archipelago\Cache\common.json | | version | [NetworkVersion](#NetworkVersion) | An object representing the Archipelago version this client supports. | | items_handling | int | Flags configuring which items should be sent by the server. Read below for individual flags. | | tags | list\[str\] | Denotes special features or capabilities that the sender is capable of. [Tags](#Tags) |