fix server

This commit is contained in:
Spencer Killen 2024-05-31 16:47:56 -06:00
parent b54c7d72fa
commit 4ff3ed3e7c
Signed by: sjkillen
GPG Key ID: 3AF3117BA6FBB75B
4 changed files with 11 additions and 6 deletions

View File

@ -71,7 +71,6 @@ func server_add_player(id: int):
%PlayerSpawner.spawn(id)
static func find_level(node: Node) -> Level:
var parent := node
while not (node is Level):
node = node.get_parent()
return node

View File

@ -27,6 +27,7 @@ func is_on_ground() -> bool:
func _physics_process(delta):
print(is_on_ground())
if not is_on_floor():
velocity.y -= gravity * delta
@ -58,7 +59,7 @@ func get_first_bumper() -> Player:
func _on_tag_detection_area_entered(area):
if not (area.get_parent() is Player):
return
var other_player: Player = area.get_parent()
var _other_player: Player = area.get_parent()
if is_bumping.is_connected(_bump_check):
return
is_bumping.connect(_bump_check)
@ -66,7 +67,7 @@ func _on_tag_detection_area_entered(area):
func _on_tag_detection_area_exited(area):
if not (area.get_parent() is Player):
return
var other_player: Player = area.get_parent()
var _other_player: Player = area.get_parent()
if not is_bumping.is_connected(_bump_check):
return
is_bumping.disconnect(_bump_check)
@ -74,6 +75,7 @@ func _on_tag_detection_area_exited(area):
func _on_tag_detection_body_entered(body):
if body.is_in_group("ground"):
print("fuck")
if not is_grounded.is_connected(body.grounded):
is_grounded.connect(body.grounded)

View File

@ -3,8 +3,12 @@ extends Control
signal join_lobby(addr: String, port: int)
@rpc("reliable", "authority", "call_local")
func add(addr: String, port: int):
func add(port: int):
var lobby_button := preload("res://server/lobby_list_entry.tscn").instantiate()
var addr := "127.0.0.1"
var peer := (multiplayer.multiplayer_peer as ENetMultiplayerPeer).get_peer(1)
if peer != null:
addr = peer.get_remote_address()
lobby_button.address = addr
lobby_button.port = port
$Lobbies.add_child(lobby_button, true)

View File

@ -19,14 +19,14 @@ func _ready():
func peer_connected(id: int):
print("Client " + str(id) + " connected to master server")
for lobby in %LobbyList.lobbies():
%LobbyList.add.rpc_id(id, lobby.address, lobby.port)
%LobbyList.add.rpc_id(id, lobby.port)
func create_lobby():
var lobby := preload("res://server/lobby.tscn").instantiate()
lobby.port = next_port_num
next_port_num += 1
%Lobbies.add_child(lobby)
%LobbyList.add.rpc(external_address, lobby.port)
%LobbyList.add.rpc(lobby.port)
func _on_create_lobby_pressed():
create_lobby()