diff --git a/contrib/extractor_scripts/ExtractResources.sh b/contrib/extractor_scripts/ExtractResources.sh index f8a4a17690..703bc082f5 100755 --- a/contrib/extractor_scripts/ExtractResources.sh +++ b/contrib/extractor_scripts/ExtractResources.sh @@ -13,7 +13,7 @@ ## Expected param 1 to be 'a' for all, else ask some questions ## optionally param 1 or param 2 is the path to game client -PREFIX="$(dirname $0)" +PREFIX="$(dirname "$0")" ## Normal log file (if not overwritten by second param) LOG_FILE="MaNGOSExtractor.log" @@ -132,7 +132,7 @@ fi if [ "$USE_MMAPS_OFFMESH" = "1" ] then echo "Only extracting offmesh tiles" - $PREFIX/MoveMapGen.sh offmesh "$OUTPUT_PATH" $LOG_FILE $DETAIL_LOG_FILE + "$PREFIX"/MoveMapGen.sh offmesh "$OUTPUT_PATH" "$LOG_FILE" "$DETAIL_LOG_FILE" exit 0 fi @@ -148,7 +148,7 @@ then read line echo # check string is there - if [ ! -z $line ]; then + if [ -n "$line" ]; then # and a number greater 0 if [ "$(expr "$line" : "^[1-9][0-9]*$")" -gt 0 ]; then NUM_THREAD=$line @@ -223,40 +223,40 @@ then read line fi -echo "$(date): Start extracting dataz for MaNGOS" | tee $LOG_FILE +echo "$(date): Start extracting dataz for MaNGOS" | tee "$LOG_FILE" ## Handle log messages if [ "$USE_AD" = "1" ]; then - echo "DBC and map files will be extracted" | tee -a $LOG_FILE + echo "DBC and map files will be extracted" | tee -a "$LOG_FILE" else - echo "DBC and map files won't be extracted!" | tee -a $LOG_FILE + echo "DBC and map files won't be extracted!" | tee -a "$LOG_FILE" fi if [ "$USE_VMAPS" = "1" ] then - echo "Vmaps will be extracted" | tee -a $LOG_FILE + echo "Vmaps will be extracted" | tee -a "$LOG_FILE" else - echo "Vmaps won't be extracted!" | tee -a $LOG_FILE + echo "Vmaps won't be extracted!" | tee -a "$LOG_FILE" fi if [ "$USE_MMAPS" = "1" ] then - echo "Mmaps will be extracted using $NUM_THREAD CPU threads" | tee -a $LOG_FILE + echo "Mmaps will be extracted using $NUM_THREAD CPU threads" | tee -a "$LOG_FILE" else - echo "Mmaps files won't be extracted!" | tee -a $LOG_FILE + echo "Mmaps files won't be extracted!" | tee -a "$LOG_FILE" fi -echo | tee -a $LOG_FILE +echo | tee -a "$LOG_FILE" -echo "$(date): Start extracting MaNGOS data: DBCs/maps $USE_AD, vmaps $USE_VMAPS, mmaps $USE_MMAPS using $NUM_THREAD CPU threads" | tee $DETAIL_LOG_FILE -echo | tee -a $DETAIL_LOG_FILE +echo "$(date): Start extracting MaNGOS data: DBCs/maps $USE_AD, vmaps $USE_VMAPS, mmaps $USE_MMAPS using $NUM_THREAD CPU threads" | tee "$DETAIL_LOG_FILE" +echo | tee -a "$DETAIL_LOG_FILE" ## Extract dbcs and maps if [ "$USE_AD" = "1" ] then - echo "$(date): Start extraction of DBCs and map files..." | tee -a $LOG_FILE - $PREFIX/ad $AD_RES $AD_OPT_RES | tee -a $DETAIL_LOG_FILE - echo "$(date): Extracting of DBCs and map files finished" | tee -a $LOG_FILE - echo | tee -a $LOG_FILE - echo | tee -a $DETAIL_LOG_FILE + echo "$(date): Start extraction of DBCs and map files..." | tee -a "$LOG_FILE" + "$PREFIX"/ad "$AD_RES" "$AD_OPT_RES" | tee -a "$DETAIL_LOG_FILE" + echo "$(date): Extracting of DBCs and map files finished" | tee -a "$LOG_FILE" + echo | tee -a "$LOG_FILE" + echo | tee -a "$DETAIL_LOG_FILE" fi ## Extract vmaps @@ -264,34 +264,34 @@ if [ "$USE_VMAPS" = "1" ] then # 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. file=$(mktemp) - echo "$(date): Start extraction of vmaps..." | tee -a $LOG_FILE + echo "$(date): Start extraction of vmaps..." | tee -a "$LOG_FILE" # We group command and echo to file so we can save the exit code ($?) before execution of tee overwrites it. - { $PREFIX/vmap_extractor $VMAP_RES $VMAP_OPT_RES; echo $? > "$file"; } | tee -a $DETAIL_LOG_FILE - exit_code="$(cat $file)" + { "$PREFIX"/vmap_extractor "$VMAP_RES" "$VMAP_OPT_RES"; echo $? > "$file"; } | tee -a "$DETAIL_LOG_FILE" + exit_code=$(cat "$file") if [ "$exit_code" -ne "0" ]; then echo "$(date): Extraction of vmaps failed with errors. Aborting extraction. See the log file for more details." rm "$file" exit "$exit_code" fi - echo "$(date): Extracting of vmaps finished" | tee -a $LOG_FILE + echo "$(date): Extracting of vmaps finished" | tee -a "$LOG_FILE" if [ ! -d "${OUTPUT_PATH:-.}/vmaps" ] then - mkdir ${OUTPUT_PATH:-.}/vmaps + mkdir "${OUTPUT_PATH:-.}/vmaps" fi - echo "$(date): Start assembling of vmaps..." | tee -a $LOG_FILE + echo "$(date): Start assembling of vmaps..." | tee -a "$LOG_FILE" # We group command and echo to file so we can save the exit code ($?) before execution of tee overwrites it. - { $PREFIX/vmap_assembler ${OUTPUT_PATH:-.}/Buildings ${OUTPUT_PATH:-.}/vmaps; echo $? > "$file"; } | tee -a $DETAIL_LOG_FILE - exit_code="$(cat $file)" + { "$PREFIX"/vmap_assembler "${OUTPUT_PATH:-.}/Buildings" "${OUTPUT_PATH:-.}/vmaps"; echo $? > "$file"; } | tee -a "$DETAIL_LOG_FILE" + exit_code=$(cat "$file") if [ "$exit_code" -ne "0" ]; then echo "$(date): Assembling of vmaps failed with errors. Aborting extraction. See the log file for more details." rm "$file" exit "$exit_code" fi rm "$file" - echo "$(date): Assembling of vmaps finished" | tee -a $LOG_FILE + echo "$(date): Assembling of vmaps finished" | tee -a "$LOG_FILE" - echo | tee -a $LOG_FILE - echo | tee -a $DETAIL_LOG_FILE + echo | tee -a "$LOG_FILE" + echo | tee -a "$DETAIL_LOG_FILE" fi ## Extract mmaps @@ -300,7 +300,7 @@ then if [ "$USE_MMAPS_DELAY" != "" ]; then echo "Extracting of MMaps is set to be started delayed by $USE_MMAPS_DELAY" echo "Current time: $(date)" - sleep $USE_MMAPS_DELAY + sleep "$USE_MMAPS_DELAY" fi - sh MoveMapGen.sh "maps" "$OUTPUT_PATH" $LOG_FILE $DETAIL_LOG_FILE $NUM_THREAD + sh MoveMapGen.sh "maps" "$OUTPUT_PATH" "$LOG_FILE" "$DETAIL_LOG_FILE" "$NUM_THREAD" fi diff --git a/contrib/extractor_scripts/MoveMapGen.sh b/contrib/extractor_scripts/MoveMapGen.sh index 5f343d638f..f889e80334 100644 --- a/contrib/extractor_scripts/MoveMapGen.sh +++ b/contrib/extractor_scripts/MoveMapGen.sh @@ -16,7 +16,7 @@ ## 3rd param may be an addition filename for storing detailed log ## 4th param may be a number of threads to use for maps processing -PREFIX="$(dirname $0)" +PREFIX="$(dirname "$0")" ## Additional Parameters to be forwarded to MoveMapGen, see mmaps/readme for instructions PARAMS="--silent --configInputPath config.json" @@ -43,8 +43,8 @@ badParam() if [ "$#" = "5" ] then OUTPUT_PATH="$2" - LOG_FILE=$3 - DETAIL_LOG_FILE=$4 + LOG_FILE="$3" + DETAIL_LOG_FILE="$4" if [ "$5" != "all" ] then PARAMS="${PARAMS} --threads $5" @@ -52,12 +52,12 @@ then elif [ "$#" = "4" ] then OUTPUT_PATH="$2" - LOG_FILE=$3 - DETAIL_LOG_FILE=$4 + LOG_FILE="$3" + DETAIL_LOG_FILE="$4" elif [ "$#" = "3" ] then OUTPUT_PATH="$2" - LOG_FILE=$3 + LOG_FILE="$3" fi # Offmesh file provided? @@ -77,10 +77,10 @@ fi createHeader() { - echo "`date`: Start creating MoveMaps" | tee -a $LOG_FILE - echo "Used params: $PARAMS $OFFMESH" | tee -a $LOG_FILE - echo "Detailed log can be found in $DETAIL_LOG_FILE" | tee -a $LOG_FILE - echo "Start creating MoveMaps" | tee -a $DETAIL_LOG_FILE + echo "$(date): Start creating MoveMaps" | tee -a "$LOG_FILE" + echo "Used params: $PARAMS $OFFMESH" | tee -a "$LOG_FILE" + echo "Detailed log can be found in $DETAIL_LOG_FILE" | tee -a "$LOG_FILE" + echo "Start creating MoveMaps" | tee -a "$DETAIL_LOG_FILE" echo echo "Be PATIENT - This may take a long time with small number of threads and might also have gaps between visible changes on the console." echo "WAIT until you are informed that 'creating MoveMaps' is 'finished'!" @@ -89,7 +89,7 @@ createHeader() # Create mmaps directory if not exist if [ ! -d mmaps ] then - mkdir ${OUTPUT_PATH:-.}/mmaps + mkdir "${OUTPUT_PATH:-.}/mmaps" fi # Param control @@ -97,15 +97,15 @@ case "$1" in "maps" ) createHeader - $PREFIX/MoveMapGen $PARAMS $OFFMESH $MMG_RES --buildGameObjects | tee -a $DETAIL_LOG_FILE + "$PREFIX"/MoveMapGen "$PARAMS" "$OFFMESH" "$MMG_RES" --buildGameObjects | tee -a "$DETAIL_LOG_FILE" ;; "offmesh" ) - echo "`date`: Recreate offmeshes from file $OFFMESH_FILE" | tee -a $LOG_FILE - echo "Recreate offmeshes from file $OFFMESH_FILE" | tee -a $DETAIL_LOG_FILE + echo "$(date): Recreate offmeshes from file $OFFMESH_FILE" | tee -a "$LOG_FILE" + echo "Recreate offmeshes from file $OFFMESH_FILE" | tee -a "$DETAIL_LOG_FILE" while read map tile line do - $PREFIX/MoveMapGen $PARAMS $OFFMESH $MMG_RES $map --tile $tile | tee -a $DETAIL_LOG_FILE - echo "`date`: Recreated $map $tile from $OFFMESH_FILE" | tee -a $LOG_FILE + "$PREFIX"/MoveMapGen "$PARAMS" "$OFFMESH" "$MMG_RES" "$map" --tile "$tile" | tee -a "$DETAIL_LOG_FILE" + echo "$(date): Recreated $map $tile from $OFFMESH_FILE" | tee -a "$LOG_FILE" done < $OFFMESH_FILE & ;; * ) @@ -116,7 +116,7 @@ esac wait -echo | tee -a $LOG_FILE -echo | tee -a $DETAIL_LOG_FILE -echo "`date`: Finished creating MoveMaps" | tee -a $LOG_FILE -echo "`date`: Finished creating MoveMaps" >> $DETAIL_LOG_FILE +echo | tee -a "$LOG_FILE" +echo | tee -a "$DETAIL_LOG_FILE" +echo "$(date): Finished creating MoveMaps" | tee -a "$LOG_FILE" +echo "$(date): Finished creating MoveMaps" >> "$DETAIL_LOG_FILE"