add addr flag
This commit is contained in:
parent
e8d062c4b7
commit
d6d0f36cee
12
main.go
12
main.go
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"gitea.boner.be/bdnugget/goonscape/game"
|
||||
"gitea.boner.be/bdnugget/goonscape/network"
|
||||
@ -11,10 +12,21 @@ import (
|
||||
|
||||
func main() {
|
||||
local := flag.Bool("local", false, "Use local server instead of remote")
|
||||
addr := flag.String("addr", "boner.be:6969", "Server address (hostname:port or hostname)")
|
||||
flag.Parse()
|
||||
|
||||
if *local && *addr != "boner.be:6969" {
|
||||
log.Fatal("Cannot use both -local and -addr flags")
|
||||
}
|
||||
|
||||
if *local {
|
||||
network.SetServerAddr("localhost:6969")
|
||||
} else if *addr != "" {
|
||||
// If only hostname is provided, append default port
|
||||
if !strings.Contains(*addr, ":") {
|
||||
*addr = *addr + ":6969"
|
||||
}
|
||||
network.SetServerAddr(*addr)
|
||||
}
|
||||
|
||||
rl.InitWindow(1024, 768, "GoonScape")
|
||||
|
Loading…
x
Reference in New Issue
Block a user