Repository navigation
Expand file tree
/
Copy pathgetmap.sh
More file actions
executable file
·204 lines (145 loc) · 5.83 KB
/
Copy pathgetmap.sh
File metadata and controls
executable file
·204 lines (145 loc) · 5.83 KB
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#!/bin/bash
# DayZ ChernarusPlus Map Downloader
# Created by Samg381 | samg381.com
# Usage: ./getmap [Res] [Type] [Version]
# [Res] Map resolution: 1-8
# [Type] Map image type: sat, top
# [Version] Desired DayZ Version (e.g. 1.19.0)
MAP=$1
RES=$2
TYP=$3
VER=$4
if [ $# -eq 4 ]
then
printf "\nDayZ ChernarusPlus Map Downloader by Samg381 | samg381.com\n\n"
else
printf "\nInvalid arguments. Please see below usage:\n\n"
printf "Usage: ./getmap.sh [Map (chernarus, livonia)] [Res (1-8)] [Type (sat/top)] [Version (e.g. 1.19.0)]\n\n"
printf "Note: Version numbers must be exact (e.g. '1.19.0' not '1.19')\n"
printf "Note: Arguments are case sensitive (e.g 'top' not 'Top')\n"
printf "Note: Some maps may not have tiles for the latest DayZ version.\n"
printf " e.g: DayZ game is 1.25, but iZurive only has Livonia version 1.19 available\n\n"
printf "Example: ./getmap.sh chernarus 6 sat 1.25.0\n"
printf "Example: ./getmap.sh livonia 4 sat 1.19.0\n"
printf "\n\n"
exit
fi
printf "Downloading $TYP map at ${RES}x resolution.\n\n\n"
if [ $RES == 1 ]; then
SIZE=1
elif [ $RES == 2 ]; then
SIZE=3
elif [ $RES == 3 ]; then
SIZE=7
elif [ $RES == 4 ]; then
SIZE=15
elif [ $RES == 5 ]; then
SIZE=31
elif [ $RES == 6 ]; then
SIZE=63
elif [ $RES == 7 ]; then
SIZE=127
elif [ $RES == 8 ]; then
SIZE=255
printf "Warning! You have selected 8x resolution- This will create a FOUR GIGAPIXEL (65000x65000px) image. This will take a while!\n"
printf "Processing images of this size is prone to failure. If you encounter errors, please check imagemagick config in /etc/imagemagick/policy.xml.\n"
else
printf "Please specify a valid resolution (1-8) ( ex: ./getmap 4 sat )\n"
exit;
fi
printf "Setting up...\n"
mkdir -p maps
rm -r -f tmp > /dev/null 2>&1
mkdir -p tmp
ulimit -n 2048
touch TilesToDownload.txt
truncate -s 0 TilesToDownload.txt
TOT=$((SIZE+1))
printf "Generating download list...\n"
for (( y=0; y<=$SIZE; y++ ))
do
for (( x=0; x<=$SIZE; x++ ))
do
xFileName=$(printf "%03d" $x)
yFileName=$(printf "%03d" $y)
# echo https://maps.izurvive.com/maps/ChernarusPlus-Top/"$VER"/tiles/"$RES"/"$x"/"$y".jpg | xargs wget -O "${yFileName}_${xFileName}.jpg" > /dev/null 2>&1
# aria2c -x 16 -o "${yFileName}_${xFileName}.jpg" https://maps.izurvive.com/maps/ChernarusPlus-Top/"$VER"/tiles/"$RES"/"$x"/"$y".jpg > /dev/null 2>&1
if [ $TYP == "top" ]; then
if [ $MAP == "chernarus" ]; then
echo https://maps.izurvive.com/maps/ChernarusPlus-Top/"$VER"/tiles/"$RES"/"$x"/"$y".jpg >> TilesToDownload.txt
echo " out=${yFileName}_${xFileName}.jpg" >> TilesToDownload.txt
elif [ $MAP == "livonia" ]; then
echo https://maps.izurvive.com/maps/Livonia-Top/"$VER"/tiles/"$RES"/"$x"/"$y".jpg >> TilesToDownload.txt
echo " out=${yFileName}_${xFileName}.jpg" >> TilesToDownload.txt
else
printf "\nCheck map name parameter (chernarus, livonia) (case sensitive!)\n"
fi
elif [ $TYP == "sat" ]; then
if [ $MAP == "chernarus" ]; then
echo https://maps.izurvive.com/maps/ChernarusPlus-Sat/"$VER"/tiles/"$RES"/"$x"/"$y".jpg >> TilesToDownload.txt
echo " out=${yFileName}_${xFileName}.jpg" >> TilesToDownload.txt
elif [ $MAP == "livonia" ]; then
echo https://maps.izurvive.com/maps/Livonia-Sat/"$VER"/tiles/"$RES"/"$x"/"$y".jpg >> TilesToDownload.txt
echo " out=${yFileName}_${xFileName}.jpg" >> TilesToDownload.txt
else
printf "\nCheck map name parameter (chernarus, livonia) (case sensitive!)\n"
fi
else
printf "\nCheck map type parameter (sat, top) (case sensitive!)\n"
exit;
fi
if [ $RES -ge 5 ]
then
if ! (( $x % 10 )) ; then
if ! (( $y % 10 )) ; then
printf "[${yFileName}_${xFileName}]"
fi
fi
else
printf "[${yFileName}_${xFileName}]"
fi
done
if [ $RES -ge 5 ]
then
if ! (( $y % 10 )) ; then
printf "\n"
fi
else
printf "\n"
fi
done
printf "Done.\nInitiating download (this may take a while)\n"
aria2c --dir=./tmp --input-file=TilesToDownload.txt -c --auto-file-renaming=false --allow-overwrite=false --max-tries=0 --retry-wait=3 --timeout=5 --max-concurrent-downloads=400 --connect-timeout=60 --max-connection-per-server=16 --split=16 --min-split-size=1M --download-result=full
# max-concurrent-downloads (getmap 7 sat) speed tests:
# 300: 1:13
# 500: 1:12
# 600: 1:11
# 800: Errors
printf "Downloads complete!\n"
rm TilesToDownload.txt
cd tmp
# If resolution is 8, saving each tile at 256x256 resolution will cause an error when we concatenate, as the max JPG size is 65500.
# So, we check if the resolution is 8, and if so, resize each tile to 254x254 BEFORE concatenating.
if [ $RES -ge 8 ]
then
printf "Resizing tiles prior to concatenation to avoid .JPG 65500 max overshoot.\n"
mogrify -resize 254x254 -format jpg *.jpg
printf "Resizing complete.\n"
printf "Generating map from tiles- this will take a VERY long time (resolution 8)\n"
else
printf "Generating map from tiles. This may take a while.\n"
fi
# This presupposes the user has at least 10 GB of RAM. If they do not, ImageMagick will throw a "memory allocation failed" error.
montage -verbose -limit area 0 -limit memory 10GB -limit map 10GB -monitor -mode concatenate *_*.jpg -tile "${TOT}x${TOT}" "DayZ_${VER}_${MAP}_map_${TOT}x${TOT}_${TYP}.jpg"
printf "\nMap generation complete! Opening image.\n"
mv "DayZ_${VER}_${MAP}_map_${TOT}x${TOT}_${TYP}.jpg" ../maps
cd ../maps
# Check if explorer (Windows) is available and open newly created image. If not, use eog
explorer "DayZ_${VER}_${MAP}_map_${TOT}x${TOT}_${TYP}.jpg" || eog "DayZ_${VER}_${MAP}_map_${TOT}x${TOT}_${TYP}.jpg" || xdg-open "DayZ_${VER}_${MAP}_map_${TOT}x${TOT}_${TYP}.jpg"
cd ..
if [ $RES -ge 8 ]
then
printf "Since Res [8] was selected, skipping deletion of /tmp directory to avoid re-download if re-run is necessary. Feel free to delete /tmp if you are satisfied with image.\n\n"
else
rm -r -f tmp
fi