diff options
Diffstat (limited to 'racing/multiplayer.gd')
-rw-r--r-- | racing/multiplayer.gd | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/racing/multiplayer.gd b/racing/multiplayer.gd index 52d76bf..0dfebf2 100644 --- a/racing/multiplayer.gd +++ b/racing/multiplayer.gd | |||
@@ -143,8 +143,10 @@ func _on_lobby_joined(lobby_id: int, _permissions: int, _locked: bool, result: i | |||
143 | 143 | ||
144 | 144 | ||
145 | func _on_lobby_chat_update( | 145 | func _on_lobby_chat_update( |
146 | _lobby_id: int, _member_id: int, _making_change_id: int, _chat_state: int | 146 | _lobby_id: int, member_id: int, _making_change_id: int, chat_state: int |
147 | ) -> void: | 147 | ) -> void: |
148 | if chat_state == Steam.CHAT_MEMBER_STATE_CHANGE_LEFT: | ||
149 | messages.showMessage("%s has left the room" % Steam.getFriendPersonaName(member_id)) | ||
148 | _update_lobby_members() | 150 | _update_lobby_members() |
149 | 151 | ||
150 | 152 | ||
@@ -231,7 +233,8 @@ func _handle_packet(packet): | |||
231 | if "timeout" in data: | 233 | if "timeout" in data: |
232 | _update_lobby_members() | 234 | _update_lobby_members() |
233 | if "victory" in data: | 235 | if "victory" in data: |
234 | _someone_victory(Steam.getFriendPersonaName(remote_id)) | 236 | _someone_victory(Steam.getFriendPersonaName(remote_id), data["victory"]) |
237 | messages.showMessage("%s reached the goal" % Steam.getFriendPersonaName(remote_id)) | ||
235 | if "ack" in data: | 238 | if "ack" in data: |
236 | messages_needing_ack.erase(data["ack"]) | 239 | messages_needing_ack.erase(data["ack"]) |
237 | _update_lobby_members() | 240 | _update_lobby_members() |
@@ -294,6 +297,7 @@ func time_to_start(): | |||
294 | get_node("/root/Spatial/label").text = ( | 297 | get_node("/root/Spatial/label").text = ( |
295 | "Destination: %s" % global.get_node("RaceManager").end_pos[0] | 298 | "Destination: %s" % global.get_node("RaceManager").end_pos[0] |
296 | ) | 299 | ) |
300 | global.get_node("RaceManager").start_timer() | ||
297 | get_node("/root/Spatial").ingame_achieve("Go!") | 301 | get_node("/root/Spatial").ingame_achieve("Go!") |
298 | 302 | ||
299 | 303 | ||
@@ -302,15 +306,20 @@ func player_victory(): | |||
302 | global._print("(MP) Victory!") | 306 | global._print("(MP) Victory!") |
303 | is_victory = true | 307 | is_victory = true |
304 | _send_p2p_packet( | 308 | _send_p2p_packet( |
305 | {"victory": "true"}, RECIPIENT_BROADCAST_ALL, Steam.P2P_SEND_RELIABLE, true | 309 | {"victory": get_node("/root/Spatial/timer_label").text}, |
310 | RECIPIENT_BROADCAST_ALL, | ||
311 | Steam.P2P_SEND_RELIABLE, | ||
312 | true | ||
313 | ) | ||
314 | _someone_victory( | ||
315 | Steam.getFriendPersonaName(player_steam_id), get_node("/root/Spatial/timer_label").text | ||
306 | ) | 316 | ) |
307 | _someone_victory(Steam.getFriendPersonaName(player_steam_id)) | ||
308 | 317 | ||
309 | 318 | ||
310 | func _someone_victory(name): | 319 | func _someone_victory(name, time): |
311 | if !victorious_players.has(name): | 320 | if !victorious_players.has(name): |
312 | global._print("(MP) Someone's victory") | 321 | global._print("(MP) Someone's victory") |
313 | victorious_players.append(name) | 322 | victorious_players.append(name) |
314 | 323 | ||
315 | var label = get_node("/root/Spatial/label") | 324 | var label = get_node("/root/Spatial/label") |
316 | label.text = "%s\n%s is #%d" % [label.text, name, victorious_players.size()] | 325 | label.text = "%s\n#%d: %s (%s)" % [label.text, victorious_players.size(), name, time] |