Update check: version feed from the git server's releases, title-screen banner, clearer version refusals
This commit is contained in:
@@ -167,6 +167,18 @@ func _start_dedicated() -> void:
|
||||
if not err.is_empty():
|
||||
printerr("[server] ", err)
|
||||
get_tree().quit(1)
|
||||
return
|
||||
# A real dedicated server (not one a test or Host Game started) says in
|
||||
# its log when there's a newer version; server.json "check_updates".
|
||||
if not _args.has("exit-with") and bool(config.v("check_updates")):
|
||||
Updates.checked.connect(_on_update_checked, CONNECT_ONE_SHOT)
|
||||
Updates.check(true)
|
||||
|
||||
func _on_update_checked(s: String) -> void:
|
||||
if s == "available":
|
||||
print("[server] Emberwild %s is out (protocol %d); this server runs %s (protocol %d). %s" % [
|
||||
Updates.latest_version(), Updates.latest_protocol(), Updates.version, PROTOCOL,
|
||||
"Players with the new version can't join until it's updated." if Updates.latest_protocol() != PROTOCOL else ""])
|
||||
|
||||
## Opens the server. Returns "" on success, otherwise what went wrong.
|
||||
func start_server(config_path: String, overrides: Dictionary = {}) -> String:
|
||||
@@ -577,7 +589,9 @@ func _c2s_hello(d: Dictionary) -> void:
|
||||
if not is_server() or not _pending.has(peer) or _pending[peer].has("hello"):
|
||||
return
|
||||
if int(d.get("protocol", 0)) != PROTOCOL:
|
||||
_reject(peer, "Different game version (server %d, you %d): update the game" % [PROTOCOL, int(d.get("protocol", 0))])
|
||||
var theirs := int(d.get("protocol", 0))
|
||||
_reject(peer, "Different game version: this server runs Emberwild %s (protocol %d), you have protocol %d. %s" % [
|
||||
Updates.version, PROTOCOL, theirs, "Update the game to join." if theirs < PROTOCOL else "The server needs updating."])
|
||||
return
|
||||
var pw := String(config.v("password"))
|
||||
if not pw.is_empty() and String(d.get("password", "")) != pw:
|
||||
|
||||
@@ -27,6 +27,7 @@ const DEFAULTS := {
|
||||
"autosave_minutes": 2,
|
||||
"backups_kept": 10,
|
||||
"backup_hours": 6,
|
||||
"check_updates": true,
|
||||
"admins": [],
|
||||
"allowlist": [],
|
||||
"banned": [],
|
||||
|
||||
Reference in New Issue
Block a user