Fixed multiplayer crash bug and properly reset player color on return to menu
This commit is contained in:
parent
10066090b1
commit
62eef907d3
4 changed files with 9 additions and 12 deletions
12
Game.gd
12
Game.gd
|
|
@ -17,19 +17,19 @@ func _ready():
|
|||
# as opposed to someone (3rd) connecting DURING the game
|
||||
# and disconnecting again
|
||||
multiplayer.peer_disconnected.connect(_on_peer_disconnected)
|
||||
multiplayer.server_disconnected.connect(_on_server_disconnected)
|
||||
#multiplayer.server_disconnected.connect(_on_server_disconnected)
|
||||
|
||||
GameEvents.game_started.emit()
|
||||
|
||||
func _on_peer_disconnected(id: int) -> void:
|
||||
GameData.disconnect_reason = "Connection to other peer closed unexpectedly"
|
||||
Networking.disconnect_all()
|
||||
#Networking.disconnect_all()
|
||||
get_tree().change_scene_to_file("res://UI/main_menu.tscn")
|
||||
|
||||
func _on_server_disconnected() -> void:
|
||||
GameData.disconnect_reason = "Connection to other peer closed unexpectedly"
|
||||
Networking.disconnect_all()
|
||||
get_tree().change_scene_to_file("res://UI/main_menu.tscn")
|
||||
#func _on_server_disconnected() -> void:
|
||||
# GameData.disconnect_reason = "Connection to other peer closed unexpectedly"
|
||||
#Networking.disconnect_all()
|
||||
# get_tree().change_scene_to_file("res://UI/main_menu.tscn")
|
||||
|
||||
func advance_turn():
|
||||
GameEvents.turn_ended.emit(current_turn, map)
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ var disconnect_reason: String = ""
|
|||
|
||||
func reset() -> void:
|
||||
is_hot_seat = false
|
||||
is_player_black = false
|
||||
disconnect_reason = ""
|
||||
bees_placed = {}
|
||||
peer_id = 1
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ func close_enet_server() -> void:
|
|||
|
||||
|
||||
func disconnect_all() -> void:
|
||||
close_enet_server()
|
||||
#close_enet_server()
|
||||
close_enet_client()
|
||||
stop_webrtc()
|
||||
|
||||
|
|
@ -62,11 +62,6 @@ func close_enet_client() -> void:
|
|||
if multiplayer.multiplayer_peer is ENetMultiplayerPeer:
|
||||
multiplayer.multiplayer_peer.close()
|
||||
|
||||
func lan_mode() -> void:
|
||||
pass
|
||||
|
||||
func online_mode() -> void:
|
||||
pass
|
||||
|
||||
func offline_mode() -> void:
|
||||
GameData.peer_id = 1
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ func _ready() -> void:
|
|||
lan_button.visible = false
|
||||
|
||||
#WSClient.lobby_joined.connect(_on_lobby_joined)
|
||||
Networking.offline_mode()
|
||||
GameData.reset()
|
||||
|
||||
func _on_lobby_joined(lobby: String) -> void:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue