-
Notifications
You must be signed in to change notification settings - Fork 1
/
startClient.sh
executable file
·132 lines (115 loc) · 2.43 KB
/
startClient.sh
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\t\n'
: "${F7D2D:?Please export F7D2D with 7D2D install folder}"
if [[ -L "$F7D2D" ]]; then
F7D2D="$(readlink "$F7D2D")"
fi
: "${LOG:=${F7D2D}/log.txt}"
: "${AHK:=/mnt/c/Program Files/AutoHotkey/AutoHotkey.exe}"
usage() {
cat >&2 <<-USAGE
$0 [options] <size> <seed>
Options:
--towns None | Few | Default | Many
--wilderness None | Few | Default | Many
--rivers None | Few | Default | Many
--craters None | Few | Default | Many
--cracks None | Few | Default | Many
--lakes None | Few | Default | Many
--plains 0 .. 10
--hills 0 .. 10
--mountains 0 .. 10
--random 0 .. 10
USAGE
exit 1
}
while [[ $# -gt 0 && $1 == -* ]]; do
case "$1" in
--towns)
shift
RWGTowns="$1"
;;
--wilderness)
shift
RWGWilderness="$1"
;;
--rivers)
shift
RWGRivers="$1"
;;
--craters)
shift
RWGCraters="$1"
;;
--cracks)
shift
RWGCracks="$1"
;;
--lakes)
shift
RWGLakes="$1"
;;
--plains)
shift
RWGPlains="$1"
;;
--hills)
shift
RWGHills="$1"
;;
--mountains)
shift
RWGMountains="$1"
;;
--random)
shift
RWGRandom="$1"
;;
*)
usage
;;
esac
shift
done
if [[ $# -ne 2 ]]; then
usage
fi
BIN="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SIZE="${1}"
SEED="${2}"
cd "${F7D2D}"
rm -f "${LOG}" || { sleep 30; rm -f "${LOG}"; }
rm -fr UserData/
touch "${LOG}"
# Start game
./7DaysToDie.exe -logfile "$(wslpath -w "${LOG}")" \
-configfile=serverconfig.xml \
-UserDataFolder=UserData \
-popupwindow \
-verbose &
# Wait for log file to be available
until [ -f "${LOG}" ]
do
sleep 1
done
# Wait for game ready
grep -E -m 1 "WorldStaticData.Init" <(tail ---disable-inotify --max-unchanged-stats=5 --sleep-interval=5 -F "${LOG}") | tee /dev/stderr
# Generate seed
"${AHK}" "$(wslpath -w "${BIN}/previewSeed.ahk")" "${SIZE}" "${SEED}" \
"${RWGTowns:-Default}" \
"${RWGWilderness:-Default}" \
"${RWGRivers:-Default}" \
"${RWGCraters:-Default}" \
"${RWGCracks:-Default}" \
"${RWGLakes:-Default}" \
"${RWGPlains:-Default}" \
"${RWGHills:-Default}" \
"${RWGMountains:-Default}" \
"${RWGRandom:-Default}"
# Wait for generation to finish
grep -E -m 1 "Generation Complete|Opening OnScreen keyboard failed|aborting generation|Crash!!!" <(tail ---disable-inotify --max-unchanged-stats=5 --sleep-interval=5 -F "${LOG}")
sleep 5
# Exit game
"${AHK}" "$(wslpath -w "${BIN}/exitGame.ahk")" || echo >& 2 "Unable to stop 7 Days to Die"
sleep 1