online multiplayer chess game (note server currently down)
Diffstat (limited to 'Credentials.gd')
| -rw-r--r-- | Credentials.gd | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Credentials.gd b/Credentials.gd index 34eef5f..facbd37 100644 --- a/Credentials.gd +++ b/Credentials.gd @@ -10,11 +10,19 @@ var data := default_id_data func _ready(): var lod = SaveLoad.load(file) data = lod if Utils.dict_cmp(lod, default_id_data) else default_id_data + if len(data.uuid) == 0: + create_temporary_uuid() + + +func create_temporary_uuid(): + randomize() + data.uuid = "A-%02x%02x%02x%02x-N" % [randi() % 256, randi() % 256, randi() % 256, randi() % 256] + save() func reset(): data = default_id_data - save() + create_temporary_uuid() func save() -> void: @@ -25,5 +33,5 @@ func get(property: String) -> String: return data[property] -func get_public() -> Dictionary: # obviously the uuid is public. This actually just means ok for server: must not be used to send to other clients, directly. the id will be filtered out +func get_public() -> Dictionary: # obviously the uuid isnt public. This actually just means ok for server: must not be used to send to other clients, directly. the id will be filtered out return {id = data.uuid, name = data.name, country = data.country} |