From a854a1862a30632e49520f6e1e11333d5c8ff241 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Wed, 27 Nov 2024 14:36:20 +0100 Subject: next commit --- Game/Network.gd | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'Game/Network.gd') diff --git a/Game/Network.gd b/Game/Network.gd index 23542e2..2858d98 100644 --- a/Game/Network.gd +++ b/Game/Network.gd @@ -16,17 +16,25 @@ func _ready(): multiplayer.allow_object_decoding = true -func host_game(port): +func host_game(port) -> Error: var peer = ENetMultiplayerPeer.new() - peer.create_server(int(port)) + var error = peer.create_server(int(port)) + + if error != OK: + return error multiplayer.multiplayer_peer = peer Client.player.id = multiplayer.get_unique_id() + + return error func join_game(ip, port): var peer = ENetMultiplayerPeer.new() - peer.create_client(ip, int(port)) + var error = peer.create_client(ip, int(port)) + + if error != OK: + return error multiplayer.multiplayer_peer = peer @@ -37,8 +45,9 @@ func close_game(): multiplayer.multiplayer_peer = OfflineMultiplayerPeer.new() reset_players() - await Client.request(Client.game_lobby_url, [], HTTPClient.METHOD_POST, JSON.stringify({"close": Client.current_game_id})) - Client.current_game_id = "" + await GameLobby.request_post("/close") + GameLobby.current_game_id = "" + GameLobby.current_secret = "" func _on_connected_to_server(): -- cgit v1.2.3