update holiday
This commit is contained in:
@@ -309,13 +309,24 @@ func _on_match_joined(match_id: String) -> void:
|
||||
# Client will request room info when peer connection is established
|
||||
|
||||
@rpc("any_peer", "reliable")
|
||||
func request_room_info(requester_id: int) -> void:
|
||||
"""Client requests room info from host."""
|
||||
func request_room_info(requester_id: int, requester_name: String, requester_character: String) -> void:
|
||||
"""Client requests room info from host, sending their name and character."""
|
||||
if not multiplayer.is_server():
|
||||
return
|
||||
|
||||
# Update the player's name and character in the list
|
||||
for player in players_in_room:
|
||||
if player["id"] == requester_id:
|
||||
player["name"] = requester_name
|
||||
player["character"] = requester_character
|
||||
break
|
||||
|
||||
# Send room data to requester
|
||||
rpc_id(requester_id, "receive_room_info", current_room, players_in_room)
|
||||
|
||||
# Also sync updated player list to all other clients
|
||||
rpc("sync_player_list", players_in_room)
|
||||
emit_signal("player_list_changed")
|
||||
|
||||
@rpc("reliable")
|
||||
func receive_room_info(room_data: Dictionary, player_list: Array) -> void:
|
||||
@@ -346,7 +357,8 @@ func _on_peer_connected(peer_id: int) -> void:
|
||||
if peer_id == 1 and not is_host:
|
||||
# Wait a frame to ensure connection is stable
|
||||
await get_tree().process_frame
|
||||
rpc_id(1, "request_room_info", multiplayer.get_unique_id())
|
||||
# Send our actual name and character to the host
|
||||
rpc_id(1, "request_room_info", multiplayer.get_unique_id(), local_player_name, available_characters[local_character_index])
|
||||
|
||||
func _on_peer_disconnected(peer_id: int) -> void:
|
||||
"""Called when peer disconnects."""
|
||||
|
||||
Reference in New Issue
Block a user