Changed Argument Parser
This commit is contained in:
parent
d4507655af
commit
9ca7b6ae03
1 changed files with 23 additions and 4 deletions
|
@ -9,7 +9,7 @@ extends Node
|
|||
# 2 -> Errors/Warnings
|
||||
# 3 -> Errors/Warnings/Infos
|
||||
# 4 -> All
|
||||
var logmode: int = 4
|
||||
var logmode: int = 2
|
||||
|
||||
var ip: String = "127.0.0.1"
|
||||
var port: int = 25262
|
||||
|
@ -19,6 +19,8 @@ var roomname: String = "sample"
|
|||
var username: String = "sample"
|
||||
var mapname: String = "Testmap"
|
||||
|
||||
var launchmode: int = 0
|
||||
|
||||
func _ready() -> void:
|
||||
var args: PackedStringArray = OS.get_cmdline_args()
|
||||
var skip: bool = false
|
||||
|
@ -33,13 +35,30 @@ func _ready() -> void:
|
|||
username = args[i+1]
|
||||
skip = true
|
||||
"--server":
|
||||
if Networking.start_server() != OK:
|
||||
Log.error("Failed to start server! Closing application.", "Failed to start server!")
|
||||
launchmode = 2
|
||||
"--client":
|
||||
Networking.join_room()
|
||||
launchmode = 1
|
||||
"res://start.tscn":
|
||||
pass # Catch in order to prevent a warning.
|
||||
_:
|
||||
Log.warning("Unknown argument: %s!" % args[i])
|
||||
else:
|
||||
skip = false
|
||||
|
||||
if DisplayServer.get_name() == "headless":
|
||||
launchmode = 2
|
||||
|
||||
if OS.is_debug_build():
|
||||
logmode = 4
|
||||
|
||||
match launchmode:
|
||||
0:
|
||||
# Will eventually redirect to the main menu
|
||||
pass
|
||||
1:
|
||||
# Client with direct join
|
||||
Networking.join_room()
|
||||
2:
|
||||
# Server
|
||||
if Networking.start_server() != OK:
|
||||
Log.error("Failed to start server! Closing application.", "Failed to start server!")
|
||||
|
|
Loading…
Reference in a new issue