-
Notifications
You must be signed in to change notification settings - Fork 1
/
genWorlds.sh
executable file
·77 lines (66 loc) · 1.66 KB
/
genWorlds.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
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\t\n'
: "${F7D2D:?Please export F7D2D with 7D2D install folder}"
usage() {
cat >&2 <<-USAGE
$0 [options] <count> [{<size>}]
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
}
declare -a ARGS
ARGS=( )
while [[ $# -gt 0 && $1 == -* ]]; do
case "$1" in
--towns | --wilderness | --rivers | --craters | --cracks | --lakes | --plains | --hills | --mountains | --random)
ARGS=( "${ARGS[@]}" "$1" "$2" )
shift 2
;;
*)
usage
;;
esac
done
if [[ $# -lt 1 ]]; then
usage
fi
ellapsed() {
echo -n "$(date -u -d @${SECONDS} +"%T")"
}
BIN="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SECONDS=0
TOTAL="$1"
shift
SIZES=("$@")
if [[ ${#SIZES[@]} -eq 0 ]]; then
SIZES=( 6144 8192 10240 )
fi
for size in "${SIZES[@]}"; do
[[ -f stop ]] && break
COUNT=0
while [[ $COUNT -lt $TOTAL ]]; do
[[ -f stop ]] && break
SEED="$("${BIN}"/seed.sh)"
"${BIN}"/genSeed.sh "${ARGS[@]}" "$size" "${SEED}"
COUNT=$((COUNT + 1))
echo "*** World #${COUNT} for size ${size} done (time elapsed: $(ellapsed))"
echo
done
done
if [[ -f stop ]]; then
echo >&2 "'stop' file found. Aborting."
rm stop
exit 1
fi
echo "Finished generating ${TOTAL} worlds for sizes ${SIZES[*]} in $(ellapsed)."