Integrate per-save identity and interaction UI
This commit is contained in:
parent
ac82a28f3b
commit
4fda6e97f6
58 changed files with 3471 additions and 461 deletions
|
|
@ -67,6 +67,7 @@ signal host_openness_changed(is_open: bool)
|
|||
signal session_display_name_changed(display_name: String)
|
||||
signal peer_count_changed(player_count: int, max_players: int)
|
||||
signal peer_display_name_changed(peer_id: int, display_name: String)
|
||||
signal peer_title_changed(peer_id: int, title: String)
|
||||
signal peer_profile_changed(
|
||||
peer_id: int,
|
||||
display_name: String,
|
||||
|
|
@ -354,6 +355,7 @@ func _register_player_host() -> void:
|
|||
NetworkProtocol.HOME_CAPABILITY,
|
||||
NetworkProtocol.HOME_UPGRADE_CAPABILITY,
|
||||
]),
|
||||
_profile.title,
|
||||
)
|
||||
_registry.update_appearance(1, _local_appearance_snapshot)
|
||||
var host_profile_hello := NetworkProtocol.make_client_hello(
|
||||
|
|
@ -362,6 +364,8 @@ func _register_player_host() -> void:
|
|||
NetworkIdentityCrypto.secure_id(32),
|
||||
_local_appearance_snapshot,
|
||||
_player_identity.fingerprint,
|
||||
PackedByteArray(),
|
||||
_profile.title,
|
||||
)
|
||||
host_profile_hello["identity_signature"] = _player_identity.sign(
|
||||
"handshake_client_profile",
|
||||
|
|
@ -931,13 +935,16 @@ func apply_canonical_profile(
|
|||
peer_id: int,
|
||||
display_name: String,
|
||||
appearance: Dictionary,
|
||||
player_title: String = NetworkProfilePreferences.DEFAULT_TITLE,
|
||||
) -> bool:
|
||||
if (
|
||||
not NetworkProfilePreferences.is_valid_display_name(display_name)
|
||||
or not NetworkProfilePreferences.is_valid_title(player_title)
|
||||
or not CharacterCustomizationCatalog.validate_snapshot(appearance)
|
||||
):
|
||||
return false
|
||||
var name_changed := _registry.update_display_name(peer_id, display_name)
|
||||
var title_changed: bool = _registry.update_title(peer_id, player_title)
|
||||
var appearance_changed := _registry.update_appearance(peer_id, appearance)
|
||||
if name_changed:
|
||||
peer_display_name_changed.emit(peer_id, display_name)
|
||||
|
|
@ -945,9 +952,11 @@ func apply_canonical_profile(
|
|||
var avatar: Player = _spawn_service.get_avatar(peer_id)
|
||||
if avatar != null:
|
||||
avatar.apply_appearance_snapshot(appearance)
|
||||
if title_changed:
|
||||
peer_title_changed.emit(peer_id, player_title)
|
||||
if name_changed or appearance_changed:
|
||||
peer_profile_changed.emit(peer_id, display_name, appearance.duplicate(true))
|
||||
return name_changed or appearance_changed
|
||||
return name_changed or title_changed or appearance_changed
|
||||
|
||||
|
||||
@rpc("any_peer", "call_remote", "reliable", 0)
|
||||
|
|
@ -1376,6 +1385,8 @@ func request_client_profile() -> void:
|
|||
_client_nonce,
|
||||
_local_appearance_snapshot,
|
||||
_player_identity.fingerprint,
|
||||
PackedByteArray(),
|
||||
_profile.title,
|
||||
)
|
||||
hello["identity_signature"] = _player_identity.sign(
|
||||
"handshake_client_profile",
|
||||
|
|
@ -1459,6 +1470,7 @@ func submit_client_hello(data: Dictionary) -> void:
|
|||
return
|
||||
var profile_id: String = data["local_profile_id"]
|
||||
var display_name: String = data["display_name"]
|
||||
var player_title: String = data["player_title"]
|
||||
if not NetworkProfilePreferences.is_valid_display_name(display_name):
|
||||
_reject_peer(
|
||||
sender_id,
|
||||
|
|
@ -1473,6 +1485,7 @@ func submit_client_hello(data: Dictionary) -> void:
|
|||
identity["fingerprint"],
|
||||
identity["public_key"],
|
||||
client_capabilities,
|
||||
player_title,
|
||||
):
|
||||
_reject_peer(
|
||||
sender_id,
|
||||
|
|
@ -1515,6 +1528,7 @@ func submit_client_hello(data: Dictionary) -> void:
|
|||
display_name,
|
||||
submitted_appearance.duplicate(true),
|
||||
)
|
||||
peer_title_changed.emit(sender_id, player_title)
|
||||
receive_server_hello.rpc_id(
|
||||
sender_id,
|
||||
NetworkProtocol.make_server_hello(
|
||||
|
|
@ -1691,6 +1705,7 @@ func receive_server_hello(data: Dictionary) -> void:
|
|||
NetworkProtocol.HOME_CAPABILITY,
|
||||
NetworkProtocol.HOME_UPGRADE_CAPABILITY,
|
||||
]),
|
||||
_profile.title,
|
||||
)
|
||||
_registry.update_appearance(local_peer_id, _local_appearance_snapshot)
|
||||
var local_record := _registry.get_peer(local_peer_id)
|
||||
|
|
@ -1777,6 +1792,10 @@ func _apply_spawn_entry(entry: Dictionary) -> void:
|
|||
typeof(entry.get("peer_id")) != TYPE_INT
|
||||
or typeof(entry.get("profile_id")) != TYPE_STRING
|
||||
or typeof(entry.get("display_name")) != TYPE_STRING
|
||||
or typeof(entry.get("player_title")) != TYPE_STRING
|
||||
or not NetworkProfilePreferences.is_valid_title(
|
||||
str(entry["player_title"])
|
||||
)
|
||||
or typeof(entry.get("position")) != TYPE_ARRAY
|
||||
or typeof(entry.get("yaw")) not in [TYPE_FLOAT, TYPE_INT]
|
||||
or typeof(entry.get("sitting")) != TYPE_BOOL
|
||||
|
|
@ -1811,6 +1830,7 @@ func _apply_spawn_entry(entry: Dictionary) -> void:
|
|||
str(entry.get("identity_fingerprint", "")),
|
||||
str(entry.get("identity_public_key", "")),
|
||||
_sanitized_capabilities(entry.get("capability_flags", [])),
|
||||
str(entry["player_title"]),
|
||||
):
|
||||
return
|
||||
peer_was_added = true
|
||||
|
|
@ -1894,6 +1914,10 @@ func _make_spawn_entry(
|
|||
"peer_id": peer_id,
|
||||
"profile_id": record.profile_id if record != null else "",
|
||||
"display_name": display_name,
|
||||
"player_title": (
|
||||
record.title
|
||||
if record != null else NetworkProfilePreferences.DEFAULT_TITLE
|
||||
),
|
||||
"position": [
|
||||
transform.origin.x,
|
||||
transform.origin.y,
|
||||
|
|
@ -1978,6 +2002,7 @@ func verify_profile_authorization(
|
|||
display_name: String,
|
||||
appearance: Dictionary,
|
||||
authorization: Dictionary,
|
||||
player_title: String = NetworkProfilePreferences.DEFAULT_TITLE,
|
||||
) -> bool:
|
||||
var record := _registry.get_peer(peer_id)
|
||||
if record == null:
|
||||
|
|
@ -1986,6 +2011,7 @@ func verify_profile_authorization(
|
|||
peer_id,
|
||||
record.profile_id,
|
||||
display_name,
|
||||
player_title,
|
||||
appearance,
|
||||
record.identity_fingerprint,
|
||||
record.identity_public_key,
|
||||
|
|
@ -2000,6 +2026,7 @@ func _verify_spawn_identity(entry: Dictionary) -> bool:
|
|||
int(entry.get("peer_id", 0)),
|
||||
str(entry.get("profile_id", "")),
|
||||
str(entry.get("display_name", "")),
|
||||
str(entry.get("player_title", NetworkProfilePreferences.DEFAULT_TITLE)),
|
||||
Dictionary(entry.get("appearance", {})),
|
||||
str(entry.get("identity_fingerprint", "")),
|
||||
str(entry.get("identity_public_key", "")),
|
||||
|
|
@ -2011,6 +2038,7 @@ func _verify_profile_authorization_fields(
|
|||
peer_id: int,
|
||||
profile_id: String,
|
||||
display_name: String,
|
||||
player_title: String,
|
||||
appearance: Dictionary,
|
||||
fingerprint: String,
|
||||
identity_public_key: String,
|
||||
|
|
@ -2021,6 +2049,8 @@ func _verify_profile_authorization_fields(
|
|||
)
|
||||
if NetworkIdentityCrypto.fingerprint_public_pem(public_pem) != fingerprint:
|
||||
return false
|
||||
if not NetworkProfilePreferences.is_valid_title(player_title):
|
||||
return false
|
||||
if authorization.is_empty():
|
||||
return peer_id == 1
|
||||
if authorization.get("domain") == "handshake_client_profile":
|
||||
|
|
@ -2031,6 +2061,7 @@ func _verify_profile_authorization_fields(
|
|||
appearance,
|
||||
fingerprint,
|
||||
authorization.get("signature", PackedByteArray()),
|
||||
player_title,
|
||||
)
|
||||
return NetworkIdentityCrypto.verify_fields(
|
||||
NetworkIdentityCrypto.load_public_key(public_pem),
|
||||
|
|
@ -2054,6 +2085,7 @@ func _verify_profile_authorization_fields(
|
|||
return false
|
||||
var signed := authorization.duplicate(true)
|
||||
signed["display_name"] = display_name
|
||||
signed["player_title"] = player_title
|
||||
signed["appearance"] = appearance
|
||||
return NetworkIdentityCrypto.verify_fields(
|
||||
NetworkIdentityCrypto.load_public_key(public_pem),
|
||||
|
|
@ -2182,7 +2214,6 @@ func _maybe_send_local_animation_action() -> void:
|
|||
str(action["id"]),
|
||||
int(action["sequence"]),
|
||||
bool(action.get("paused", false)),
|
||||
avatar.get_network_sitting_intent(),
|
||||
]
|
||||
if signature == _last_local_animation_action_signature:
|
||||
return
|
||||
|
|
@ -2237,9 +2268,9 @@ func submit_movement_animation_action(encoded: Array) -> void:
|
|||
avatar.apply_authoritative_network_animation_action(
|
||||
animation_state["action"]
|
||||
)
|
||||
avatar.apply_authoritative_network_sitting_state(
|
||||
bool(animation_state["sitting"])
|
||||
)
|
||||
# Sitting is authoritative only on sequenced movement input. The legacy bit
|
||||
# remains in this packet's wire shape for protocol compatibility, but acting
|
||||
# on it here would race jump input across two independent ENet channels.
|
||||
|
||||
|
||||
static func _encode_movement_input(data: Dictionary) -> Array:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue