From 2a5d745c68f11131fb1b27ec42a30ecd6dc5da1d Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Mon, 25 Dec 2023 20:43:51 +0100 Subject: fix networking --- Network/Network.gd | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'Network/Network.gd') diff --git a/Network/Network.gd b/Network/Network.gd index ff076a4..1222b92 100644 --- a/Network/Network.gd +++ b/Network/Network.gd @@ -40,10 +40,10 @@ func _ready(): @rpc("any_peer") func register_player(player_name): - var id = get_tree().get_remote_sender_id() + var id = multiplayer.get_remote_sender_id() self.players[id] = { name = player_name, - ip = self.peer.get_peer_address(id), + ip = self.peer.get_peer(id).get_remote_address(), } emit_signal("player_list_changed") @@ -73,7 +73,7 @@ func leave_game(): @rpc("any_peer") func _leave_game(): - var id = get_tree().get_remote_sender_id() + var id = multiplayer.get_remote_sender_id() self.peer.disconnect_peer(id) @@ -86,15 +86,16 @@ func _on_Global_game_started(): var idx = 1 for id in self.players: self.players[id].idx = idx - rpc_id(id, "_preconfigure_game", idx) + rpc_id(id, "_preconfigure_game", idx, Global.Level_Map) idx += 1 # start game for everyone rpc("_start_game") -@rpc("any_peer") func _preconfigure_game(idx): +@rpc("any_peer") func _preconfigure_game(idx, level_map): self.player.idx = idx + Global.Level_Map = level_map @rpc("any_peer", "call_local") func _start_game(): @@ -132,7 +133,7 @@ func _connection_succeeded(): func _connection_failed(): - get_tree().set_multiplayer_peer(null) # remove peer + multiplayer.multiplayer_peer = null # remove peer emit_signal("connection_failed") -- cgit v1.2.3