fix server
This commit is contained in:
		
							parent
							
								
									b54c7d72fa
								
							
						
					
					
						commit
						4ff3ed3e7c
					
				
					 4 changed files with 11 additions and 6 deletions
				
			
		| 
						 | 
					@ -71,7 +71,6 @@ func server_add_player(id: int):
 | 
				
			||||||
	%PlayerSpawner.spawn(id)
 | 
						%PlayerSpawner.spawn(id)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static func find_level(node: Node) -> Level:
 | 
					static func find_level(node: Node) -> Level:
 | 
				
			||||||
	var parent := node
 | 
					 | 
				
			||||||
	while not (node is Level):
 | 
						while not (node is Level):
 | 
				
			||||||
		node = node.get_parent()
 | 
							node = node.get_parent()
 | 
				
			||||||
	return node
 | 
						return node
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,6 +27,7 @@ func is_on_ground() -> bool:
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func _physics_process(delta):
 | 
					func _physics_process(delta):
 | 
				
			||||||
 | 
						print(is_on_ground())
 | 
				
			||||||
	if not is_on_floor():
 | 
						if not is_on_floor():
 | 
				
			||||||
		velocity.y -= gravity * delta
 | 
							velocity.y -= gravity * delta
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -58,7 +59,7 @@ func get_first_bumper() -> Player:
 | 
				
			||||||
func _on_tag_detection_area_entered(area):
 | 
					func _on_tag_detection_area_entered(area):
 | 
				
			||||||
	if not (area.get_parent() is Player):
 | 
						if not (area.get_parent() is Player):
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	var other_player: Player = area.get_parent()
 | 
						var _other_player: Player = area.get_parent()
 | 
				
			||||||
	if is_bumping.is_connected(_bump_check):
 | 
						if is_bumping.is_connected(_bump_check):
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	is_bumping.connect(_bump_check)
 | 
						is_bumping.connect(_bump_check)
 | 
				
			||||||
| 
						 | 
					@ -66,7 +67,7 @@ func _on_tag_detection_area_entered(area):
 | 
				
			||||||
func _on_tag_detection_area_exited(area):
 | 
					func _on_tag_detection_area_exited(area):
 | 
				
			||||||
	if not (area.get_parent() is Player):
 | 
						if not (area.get_parent() is Player):
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	var other_player: Player = area.get_parent()
 | 
						var _other_player: Player = area.get_parent()
 | 
				
			||||||
	if not is_bumping.is_connected(_bump_check):
 | 
						if not is_bumping.is_connected(_bump_check):
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	is_bumping.disconnect(_bump_check)
 | 
						is_bumping.disconnect(_bump_check)
 | 
				
			||||||
| 
						 | 
					@ -74,6 +75,7 @@ func _on_tag_detection_area_exited(area):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func _on_tag_detection_body_entered(body):
 | 
					func _on_tag_detection_body_entered(body):
 | 
				
			||||||
	if body.is_in_group("ground"):
 | 
						if body.is_in_group("ground"):
 | 
				
			||||||
 | 
							print("fuck")
 | 
				
			||||||
		if not is_grounded.is_connected(body.grounded):
 | 
							if not is_grounded.is_connected(body.grounded):
 | 
				
			||||||
			is_grounded.connect(body.grounded)
 | 
								is_grounded.connect(body.grounded)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,8 +3,12 @@ extends Control
 | 
				
			||||||
signal join_lobby(addr: String, port: int)
 | 
					signal join_lobby(addr: String, port: int)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@rpc("reliable", "authority", "call_local")
 | 
					@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 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.address = addr
 | 
				
			||||||
	lobby_button.port = port
 | 
						lobby_button.port = port
 | 
				
			||||||
	$Lobbies.add_child(lobby_button, true)
 | 
						$Lobbies.add_child(lobby_button, true)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,14 +19,14 @@ func _ready():
 | 
				
			||||||
func peer_connected(id: int):
 | 
					func peer_connected(id: int):
 | 
				
			||||||
	print("Client " + str(id) + " connected to master server")
 | 
						print("Client " + str(id) + " connected to master server")
 | 
				
			||||||
	for lobby in %LobbyList.lobbies():
 | 
						for lobby in %LobbyList.lobbies():
 | 
				
			||||||
		%LobbyList.add.rpc_id(id, lobby.address, lobby.port)
 | 
							%LobbyList.add.rpc_id(id, lobby.port)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func create_lobby():
 | 
					func create_lobby():
 | 
				
			||||||
	var lobby := preload("res://server/lobby.tscn").instantiate()
 | 
						var lobby := preload("res://server/lobby.tscn").instantiate()
 | 
				
			||||||
	lobby.port = next_port_num
 | 
						lobby.port = next_port_num
 | 
				
			||||||
	next_port_num += 1
 | 
						next_port_num += 1
 | 
				
			||||||
	%Lobbies.add_child(lobby)
 | 
						%Lobbies.add_child(lobby)
 | 
				
			||||||
	%LobbyList.add.rpc(external_address, lobby.port)
 | 
						%LobbyList.add.rpc(lobby.port)
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
func _on_create_lobby_pressed():
 | 
					func _on_create_lobby_pressed():
 | 
				
			||||||
	create_lobby()
 | 
						create_lobby()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue