@@ -31,44 +31,36 @@ AD_RES=""
3131VMAP_RES=" "
3232NUM_THREAD=" "
3333
34- if [ " $1 " != " a" ] && [ " x$1 " != " x" ]
35- then
34+ if [ " $1 " != " a" ] && [ " x$1 " != " x" ]; then
3635 CLIENT_PATH=" $1 "
3736 OUTPUT_PATH=" $2 "
38- elif [ " x$2 " != " x" ]
39- then
37+ elif [ " x$2 " != " x" ]; then
4038 CLIENT_PATH=" $2 "
4139 OUTPUT_PATH=" $3 "
4240fi
4341
44- if [ " x${CLIENT_PATH} " != " x" ]
45- then
46- if [ ! -d " ${CLIENT_PATH} /Data" ]
47- then
42+ if [ " x${CLIENT_PATH} " != " x" ]; then
43+ if [ ! -d " ${CLIENT_PATH} /Data" ]; then
4844 echo " Data folder not found in provided client path [${CLIENT_PATH} ]. Plese provide a correct client path."
4945 exit 1
5046 fi
5147else
52- if [ ! -d " $( pwd) /Data" ]
53- then
48+ if [ ! -d " $( pwd) /Data" ]; then
5449 echo " Data folder not found. Make sure you have copied the script to the client folder and the 'Data' folder has the correct case."
5550 exit 1
5651 fi
5752fi
5853
59- if [ " x${OUTPUT_PATH} " != " x" ]
60- then
61- if [ ! -d " ${OUTPUT_PATH} " ]
62- then
54+ if [ " x${OUTPUT_PATH} " != " x" ]; then
55+ if [ ! -d " ${OUTPUT_PATH} " ]; then
6356 echo " Provided OUTPUT_PATH=${OUTPUT_PATH} does not exist, please create it before"
6457 exit 1
6558 fi
6659 LOG_FILE=" ${OUTPUT_PATH:- .} /${LOG_FILE} "
6760 DETAIL_LOG_FILE=" ${OUTPUT_PATH:- .} /${DETAIL_LOG_FILE} "
6861fi
6962
70- if [ " $1 " = " a" ]
71- then
63+ if [ " $1 " = " a" ]; then
7264 # # extract all
7365 USE_AD=" 1"
7466 USE_VMAPS=" 1"
8072 echo " Welcome to helper script to extract required dataz for MaNGOS!"
8173 echo " Should all dataz (dbc, maps, vmaps and mmaps) be extracted? (y/n)"
8274 read line
83- if [ " $line " = " y" ]
84- then
75+ if [ " $line " = " y" ]; then
8576 # # extract all
8677 USE_AD=" 1"
8778 USE_VMAPS=" 1"
@@ -101,48 +92,31 @@ else
10192 echo " Should mmaps be extracted? (y/n)"
10293 echo " WARNING! This may take several hours with small number of CPU threads!"
10394 read line
104- if [ " $line " = " y" ]
105- then
106- USE_MMAPS=" 1" ;
95+ if [ " $line " = " y" ]; then
96+ USE_MMAPS=" 1"
10797 else
10898 echo
10999 echo " Only reextract offmesh tiles for mmaps? (y/n)"
110100 read line
111- if [ " $line " = " y" ]
112- then
113- USE_MMAPS_OFFMESH=" 1" ;
101+ if [ " $line " = " y" ]; then
102+ USE_MMAPS_OFFMESH=" 1"
114103 fi
115104 fi
116105 fi
117106fi
118107
119- if [ " x$CLIENT_PATH " != " x" ]
120- then
121- AD_OPT_RES=" -i $CLIENT_PATH "
122- VMAP_OPT_RES=" -d $CLIENT_PATH /Data"
123- fi
124-
125- if [ " x$OUTPUT_PATH " != " x" ] && [ -d " $OUTPUT_PATH " ]
126- then
127- AD_OPT_RES=" $AD_OPT_RES -o $OUTPUT_PATH "
128- VMAP_OPT_RES=" $VMAP_OPT_RES -o $OUTPUT_PATH "
129- fi
130-
131108# # Special case: Only reextract offmesh tiles
132- if [ " $USE_MMAPS_OFFMESH " = " 1" ]
133- then
109+ if [ " $USE_MMAPS_OFFMESH " = " 1" ]; then
134110 echo " Only extracting offmesh tiles"
135111 " $PREFIX " /MoveMapGen.sh offmesh " $OUTPUT_PATH " " $LOG_FILE " " $DETAIL_LOG_FILE "
136112 exit 0
137113fi
138114
139115# # MMap Extraction specific
140- if [ " $1 " = " a" ]
141- then
116+ if [ " $1 " = " a" ]; then
142117 NUM_THREAD=" all"
143118 USE_MMAPS_DELAY=" "
144- elif [ " $USE_MMAPS " = " 1" ]
145- then
119+ elif [ " $USE_MMAPS " = " 1" ]; then
146120 # # Obtain number of processes
147121 echo " How many CPU threads should be used for extracting mmaps? (leave empty to use all available threads)"
148122 read line
174148fi
175149
176150# # Check if user want to do high resolution extraction of maps
177- if [ " $1 " = " a" ]
178- then
151+ if [ " $1 " = " a" ]; then
179152 AD_RES=" "
180153elif [ " $USE_AD " = " 1" ]; then
181154 echo
@@ -189,8 +162,7 @@ elif [ "$USE_AD" = "1" ]; then
189162fi
190163
191164# # Check if user want to do high resolution extraction of vmaps
192- if [ " $1 " = " a" ]
193- then
165+ if [ " $1 " = " a" ]; then
194166 VMAP_RES=" "
195167elif [ " $USE_VMAPS " = " 1" ]; then
196168 echo
@@ -208,38 +180,34 @@ echo
208180echo " Current Settings:"
209181echo " Extract DBCs/maps: $USE_AD , Extract vmaps: $USE_VMAPS , Extract mmaps: $USE_MMAPS , Processes for mmaps: $NUM_THREAD "
210182if [ " $USE_AD " = " 1" ] && [ " $AD_RES " = " -f 0" ]; then
211- echo " maps extraction will be high-resolution" ;
183+ echo " maps extraction will be high-resolution"
212184fi
213185if [ " $USE_VMAPS " = " 1" ] && [ " $VMAP_RES " = " -l" ]; then
214- echo " vmaps extraction will be high-resolution" ;
186+ echo " vmaps extraction will be high-resolution"
215187fi
216188if [ " $USE_MMAPS_DELAY " != " " ]; then
217189 echo " MMap Extraction will be started delayed by $USE_MMAPS_DELAY "
218190fi
219191echo
220- if [ " $1 " != " a" ]
221- then
192+ if [ " $1 " != " a" ]; then
222193 echo " Press (Enter) to continue, or interrupt with (CTRL+C)"
223194 read line
224195fi
225196
226197echo " $( date) : Start extracting dataz for MaNGOS" | tee " $LOG_FILE "
227198
228199# # Handle log messages
229- if [ " $USE_AD " = " 1" ];
230- then
200+ if [ " $USE_AD " = " 1" ]; then
231201 echo " DBC and map files will be extracted" | tee -a " $LOG_FILE "
232202else
233203 echo " DBC and map files won't be extracted!" | tee -a " $LOG_FILE "
234204fi
235- if [ " $USE_VMAPS " = " 1" ]
236- then
205+ if [ " $USE_VMAPS " = " 1" ]; then
237206 echo " Vmaps will be extracted" | tee -a " $LOG_FILE "
238207else
239208 echo " Vmaps won't be extracted!" | tee -a " $LOG_FILE "
240209fi
241- if [ " $USE_MMAPS " = " 1" ]
242- then
210+ if [ " $USE_MMAPS " = " 1" ]; then
243211 echo " Mmaps will be extracted using $NUM_THREAD CPU threads" | tee -a " $LOG_FILE "
244212else
245213 echo " Mmaps files won't be extracted!" | tee -a " $LOG_FILE "
@@ -250,53 +218,80 @@ echo "$(date): Start extracting MaNGOS data: DBCs/maps $USE_AD, vmaps $USE_VMAPS
250218echo | tee -a " $DETAIL_LOG_FILE "
251219
252220# # Extract dbcs and maps
253- if [ " $USE_AD " = " 1" ]
254- then
255- echo " $( date) : Start extraction of DBCs and map files..." | tee -a " $LOG_FILE "
256- " $PREFIX " /ad $AD_RES $AD_OPT_RES | tee -a " $DETAIL_LOG_FILE "
257- echo " $( date) : Extracting of DBCs and map files finished" | tee -a " $LOG_FILE "
258- echo | tee -a " $LOG_FILE "
259- echo | tee -a " $DETAIL_LOG_FILE "
221+ if [ " $USE_AD " = " 1" ]; then
222+ echo " $( date) : Start extraction of DBCs and map files..." | tee -a " $LOG_FILE "
223+ # Prepare ad arguments
224+ set -- $AD_RES
225+ if [ " x$CLIENT_PATH " != " x" ]; then
226+ set -- " $@ " " -i" " $CLIENT_PATH "
227+ fi
228+ if [ " x$OUTPUT_PATH " != " x" ] && [ -d " $OUTPUT_PATH " ]; then
229+ set -- " $@ " " -o" " $OUTPUT_PATH "
230+ fi
231+ file=$( mktemp)
232+ {
233+ " $PREFIX " /ad " $@ "
234+ echo $? > " $file "
235+ } | tee -a " $DETAIL_LOG_FILE "
236+ exit_code=$( cat " $file " )
237+ rm " $file "
238+ if [ " $exit_code " -ne " 0" ]; then
239+ echo " $( date) : Extraction of DBCs and map files failed with errors. Aborting extraction. See the log file for more details."
240+ exit " $exit_code "
241+ fi
242+ echo " $( date) : Extracting of DBCs and map files finished" | tee -a " $LOG_FILE "
243+ echo | tee -a " $LOG_FILE "
244+ echo | tee -a " $DETAIL_LOG_FILE "
260245fi
261246
262247# # Extract vmaps
263- if [ " $USE_VMAPS " = " 1" ]
264- then
248+ if [ " $USE_VMAPS " = " 1" ]; then
265249 # We need to save the exit code for vmap_extractor and vmap_assembler so it doesn't get swallowed by tee. For this we create a temporary file.
266250 file=$( mktemp)
267251 echo " $( date) : Start extraction of vmaps..." | tee -a " $LOG_FILE "
252+ # Prepare vmap_extractor arguments
253+ set -- $VMAP_RES
254+ if [ " x$CLIENT_PATH " != " x" ]; then
255+ set -- " $@ " " -d" " $CLIENT_PATH /Data"
256+ fi
257+ if [ " x$OUTPUT_PATH " != " x" ] && [ -d " $OUTPUT_PATH " ]; then
258+ set -- " $@ " " -o" " $OUTPUT_PATH "
259+ fi
268260 # We group command and echo to file so we can save the exit code ($?) before execution of tee overwrites it.
269- { " $PREFIX " /vmap_extractor $VMAP_RES $VMAP_OPT_RES ; echo $? > " $file " ; } | tee -a " $DETAIL_LOG_FILE "
261+ {
262+ " $PREFIX " /vmap_extractor " $@ "
263+ echo $? > " $file "
264+ } | tee -a " $DETAIL_LOG_FILE "
270265 exit_code=$( cat " $file " )
271266 if [ " $exit_code " -ne " 0" ]; then
272267 echo " $( date) : Extraction of vmaps failed with errors. Aborting extraction. See the log file for more details."
273268 rm " $file "
274269 exit " $exit_code "
275270 fi
276271 echo " $( date) : Extracting of vmaps finished" | tee -a " $LOG_FILE "
277- if [ ! -d " ${OUTPUT_PATH:- .} /vmaps" ]
278- then
272+ if [ ! -d " ${OUTPUT_PATH:- .} /vmaps" ]; then
279273 mkdir " ${OUTPUT_PATH:- .} /vmaps"
280274 fi
281275 echo " $( date) : Start assembling of vmaps..." | tee -a " $LOG_FILE "
282276 # We group command and echo to file so we can save the exit code ($?) before execution of tee overwrites it.
283- { " $PREFIX " /vmap_assembler " ${OUTPUT_PATH:- .} /Buildings" " ${OUTPUT_PATH:- .} /vmaps" ; echo $? > " $file " ; } | tee -a " $DETAIL_LOG_FILE "
277+ {
278+ " $PREFIX " /vmap_assembler " ${OUTPUT_PATH:- .} /Buildings" " ${OUTPUT_PATH:- .} /vmaps"
279+ echo $? > " $file "
280+ } | tee -a " $DETAIL_LOG_FILE "
284281 exit_code=$( cat " $file " )
282+ rm " $file "
285283 if [ " $exit_code " -ne " 0" ]; then
286284 echo " $( date) : Assembling of vmaps failed with errors. Aborting extraction. See the log file for more details."
287- rm " $file "
288285 exit " $exit_code "
289286 fi
290- rm " $file "
291287 echo " $( date) : Assembling of vmaps finished" | tee -a " $LOG_FILE "
292288
293289 echo | tee -a " $LOG_FILE "
294290 echo | tee -a " $DETAIL_LOG_FILE "
295291fi
296292
297293# # Extract mmaps
298- if [ " $USE_MMAPS " = " 1" ]
299- then
294+ if [ " $USE_MMAPS " = " 1" ]; then
300295 if [ " $USE_MMAPS_DELAY " != " " ]; then
301296 echo " Extracting of MMaps is set to be started delayed by $USE_MMAPS_DELAY "
302297 echo " Current time: $( date) "
0 commit comments