-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.rkt
56 lines (51 loc) · 1.56 KB
/
main.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#lang racket/base
(require racket/cmdline
"defs.rkt"
"server.rkt"
"client.rkt")
(define show-help #f)
(define port PORT)
(define address #f)
(define run-server? #f)
(define g #f)
(define combined? #f)
(define name "player")
(command-line
#:program "warp"
#:usage-help "Runs the warp game client (or server with -s)"
#:once-each
[("-c" "--combined")
"Run combined server and client for testing"
(set! combined? #t)]
[("-a" "--address") a
"Specify ip address to use for tcp"
(set! address a)]
[("-p" "--port") p
"Specify port to use for tcp"
(set! port p)]
[("-g" "--nogui") ng
"Run # of headless clients for testing"
(set! g (string->number ng))]
[("-n" "--name") n
"Set client base name for -g"
(set! name n)]
[("-s" "--server") "Run server"
(set! run-server? #t)])
(cond
[combined?
; note that start-client immediately changes the server? parameter to #f
; so start the server thread first (need to fix it at some point)
(thread (lambda () (start-server)))
(start-client port #:ip address)]
[run-server?
(start-server port)]
[g
(for ((i g))
(start-client port
#:ip address
#:name (string-append name "-" (number->string i))
#:gui? #f
#:new-eventspace? #t))
(sync never-evt)]
[else
(start-client port #:ip address)])