updates
This commit is contained in:
parent
4298caf5cb
commit
2e6638b744
19 changed files with 484 additions and 185 deletions
|
|
@ -27,6 +27,12 @@ signal failed(text: String)
|
|||
|
||||
const SEARCH_EVERY := 2.0
|
||||
const GAME_PORT := 42400
|
||||
## What a LAN host's computer has to let in (GD-Sync's LocalServer: announcements on
|
||||
## 42354..42373, games on 42400..42419).
|
||||
const LAN_PORTS := "UDP 42354-42373 and 42400-42419"
|
||||
## Seconds to wait for the host to answer a join. A firewall in the way drops the request
|
||||
## without a word, so this is the only way to tell.
|
||||
const JOIN_TIMEOUT := 10.0
|
||||
const GAME_TAG := "harvest-season"
|
||||
|
||||
var gdsync: Node
|
||||
|
|
@ -40,6 +46,7 @@ var status := ""
|
|||
var _after_connect := "" # "host" or "search"
|
||||
var _join_target := ""
|
||||
var _search_left: float = 0.0
|
||||
var _join_left: float = 0.0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
|
@ -96,6 +103,7 @@ func join(lobby: String) -> void:
|
|||
return
|
||||
_join_target = lobby
|
||||
stage = Stage.JOINING
|
||||
_join_left = JOIN_TIMEOUT
|
||||
_say("Joining %s..." % lobby)
|
||||
gdsync.lobby_join(lobby)
|
||||
|
||||
|
|
@ -169,6 +177,21 @@ func _process(delta: float) -> void:
|
|||
if _search_left <= 0.0:
|
||||
_search_left = SEARCH_EVERY
|
||||
gdsync.get_public_lobbies()
|
||||
elif stage == Stage.JOINING:
|
||||
_join_left -= delta
|
||||
if _join_left <= 0.0:
|
||||
_join_timed_out()
|
||||
|
||||
|
||||
## No answer to a join: give up and say why it's most likely.
|
||||
func _join_timed_out() -> void:
|
||||
var target := _join_target
|
||||
var lan := mode == Mode.LAN
|
||||
leave()
|
||||
if lan:
|
||||
failed.emit("No answer from %s. The host's firewall is probably blocking the game (it needs %s open), or the address is wrong. Or both of you pick Online." % [target, LAN_PORTS])
|
||||
else:
|
||||
failed.emit("No answer from %s through GD-Sync. Check your connection and try again." % target)
|
||||
|
||||
|
||||
func _begin(p_mode: Mode, p_name: String) -> bool:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue