Many fixes
This commit is contained in:
parent
f234ca974e
commit
e758c9f042
11 changed files with 8784 additions and 8739 deletions
|
|
@ -8,6 +8,7 @@ signal lobby_created
|
|||
signal lobby_joined
|
||||
signal lobby_closed
|
||||
signal update_teams_state
|
||||
signal client_data_updated(id)
|
||||
|
||||
var in_lobby: bool = false
|
||||
|
||||
|
|
@ -36,6 +37,7 @@ func player_left(id: int) -> void:
|
|||
client_nicknames.erase(id)
|
||||
|
||||
update_teams_state.emit()
|
||||
client_data_updated.emit(-id)
|
||||
|
||||
func server_disconnected() -> void:
|
||||
leave()
|
||||
|
|
@ -84,6 +86,7 @@ func recieve_client_data(data: Dictionary):
|
|||
client_nicknames[id] = nickname
|
||||
|
||||
sync_client_data.rpc(client_nicknames)
|
||||
client_data_updated.emit(id)
|
||||
|
||||
@rpc("authority","call_remote")
|
||||
func sync_client_data(new_client_nicknames: Dictionary[int,StringName]):
|
||||
|
|
|
|||
|
|
@ -87,6 +87,8 @@ func send_session_data(peer_id: int = -1):
|
|||
if multiplayer.is_server() == false or session_started_flag == false:
|
||||
return
|
||||
|
||||
init_player_data(peer_id)
|
||||
|
||||
var data: PackedByteArray
|
||||
data.resize(5)
|
||||
data.encode_u8(0,current_round)
|
||||
|
|
@ -95,11 +97,29 @@ func send_session_data(peer_id: int = -1):
|
|||
data.encode_u8(3,round_state)
|
||||
data.encode_u8(4,session_started_flag)
|
||||
|
||||
|
||||
|
||||
if peer_id == -1:
|
||||
recieve_session_data.rpc(data,player_data)
|
||||
else:
|
||||
recieve_session_data.rpc_id(peer_id,data,player_data)
|
||||
|
||||
func init_player_data(id: int) -> void:
|
||||
if Lobby.client_nicknames.has(id) == false:
|
||||
while true:
|
||||
var wait_id = await Lobby.client_data_updated
|
||||
if wait_id == id:
|
||||
break
|
||||
elif wait_id == -id:
|
||||
return
|
||||
player_data[id] = {
|
||||
"money" : START_MONEY,
|
||||
"nickname" : Lobby.client_nicknames[id],
|
||||
"saved_slots" : {},
|
||||
"kills" : 0,
|
||||
"deaths" : 0,
|
||||
}
|
||||
|
||||
@rpc("authority","call_remote","unreliable")
|
||||
func recieve_session_data(data: PackedByteArray,players_data_sent: Dictionary[int,Dictionary]):
|
||||
if not is_server_request():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue