1
0
mirror of https://github.com/JohnBreaux/Boat-Battle.git synced 2024-11-14 21:15:58 +00:00

Net: Fix off-by-one in number of players allowed to connect (was 3, now 2; Godot does not include the 'server'.)

This commit is contained in:
John 2021-12-06 12:57:06 -06:00
parent dbd7e0392c
commit d8c5d0548f

View File

@ -62,8 +62,8 @@ func send(id, mail, mail_type = REPLY):
# Host # Host
# start_host: Host the game # start_host: Host the game
# port: TCP port # port: TCP port
# max_players: Largest number of players allowed to connect at a time # max_players: Largest number of players allowed to connect at a time (the host does not count)
func start_host(port = DEFAULT_PORT, max_players = 2): func start_host(port = DEFAULT_PORT, max_players = 1):
get_hostname() get_hostname()
peer_info[1] = local_info peer_info[1] = local_info
# Notify that peer list has updated # Notify that peer list has updated
@ -150,16 +150,10 @@ func _ready():
func _peer_connected(id): func _peer_connected(id):
# Send peer info to remote peer # Send peer info to remote peer
rpc_id(id, "register_peer", local_info) rpc_id(id, "register_peer", local_info)
if hosting and peer_info.size() >= 2:
pass
pass
func _peer_disconnected(id): func _peer_disconnected(id):
# Unregister the peer locally # Unregister the peer locally
unregister_peer(id) unregister_peer(id)
if hosting and peer_info.size() < 2:
pass
pass
func _host_connected(): func _host_connected():