Fixed player data synchronisation

remotes/1705377932733043820/tmp_refs/heads/unbroken
Jan Heemstra 2021-09-11 21:30:10 +02:00
parent aa29738472
commit 1294136800
1 changed files with 2 additions and 8 deletions

View File

@ -199,7 +199,7 @@ func update_hud():
else:
hud.get_node("ScoreRank").text += str(rank) + "\nGAP: " + str(-lead)
@rpc func player_list_update(info, pid = get_tree().get_rpc_sender_id()):
@rpc(any) func player_list_update(info, pid = get_tree().get_rpc_sender_id()):
var new_info = PlayerInfo.new()
new_info.deserialize(info)
print("Recieved player info: ", info)
@ -219,13 +219,7 @@ func update_hud():
# if i != pid:
chat.rpc_id(i, &'chat_notification', "Player [b]" + new_info.name + "[/b] joined")
if get_tree().multiplayer.get_network_unique_id() == 1: # if we're server, we should store this
pid = get_tree().get_rpc_sender_id() #disallow clients setting player_info for other players than themselves
player_list.set(pid, new_info)
rpc(&'player_list_update', info, pid) # broadcast the new entry to clients
else: #we are client, so we're getting data relayed from the server
player_list.set(pid, new_info) # server relays other PID's data
player_list.set(pid, new_info) # server relays other PID's data
# update locla HUD
update_hud()