Server launcher and start-up checks for other machines
- server/run_server.sh: checks Godot is 4.7+, imports a fresh copy once (the class cache in .godot/ isn't in git), then starts the server - The dedicated server refuses to start, with a clear reason, on Godot older than 4.7 or when the game's scripts failed to load, instead of claiming to listen - tests/run_all.sh imports a fresh copy first - Setup doc: 4.7+ (not 4.3+), importing a fresh copy, running a server
This commit is contained in:
@@ -144,7 +144,26 @@ func is_server() -> bool:
|
||||
|
||||
# --- server -------------------------------------------------------------------
|
||||
|
||||
## Why this Godot can't run the server ("" = it can): too old, or the game's
|
||||
## scripts failed to load (usually a fresh copy that's never been imported).
|
||||
func startup_problem() -> String:
|
||||
var v := Engine.get_version_info()
|
||||
if v.major < 4 or (v.major == 4 and v.minor < 7):
|
||||
return "This game needs Godot 4.7 or newer, but this is %s. Download 4.7.2 from https://godotengine.org/download" % v.string
|
||||
var root: Window = (Engine.get_main_loop() as SceneTree).root
|
||||
for n in ["ItemDB", "Actions", "Saves"]:
|
||||
var node := root.get_node_or_null(n)
|
||||
if node == null or node.get_script() == null:
|
||||
return "The game's scripts didn't load (see the errors above). If this is a fresh copy of the project, " + \
|
||||
"import it once first: godot --headless --path . --import (server/run_server.sh does this for you)"
|
||||
return ""
|
||||
|
||||
func _start_dedicated() -> void:
|
||||
var bad := startup_problem()
|
||||
if not bad.is_empty():
|
||||
printerr("[server] Not starting: ", bad)
|
||||
get_tree().quit(1)
|
||||
return
|
||||
var err := start_server(String(_args.get("config", ServerConfig.DEFAULT_PATH)), _args)
|
||||
if not err.is_empty():
|
||||
printerr("[server] ", err)
|
||||
|
||||
Reference in New Issue
Block a user