Skip to content

Commit

Permalink
Fixed all occurrences of 'SC2086 - Double quote to prevent globbing a…
Browse files Browse the repository at this point in the history
…nd word splitting' in the extraction scripts

Also fixed some SC2006 style warnings.
  • Loading branch information
Muehe committed Sep 22, 2023
1 parent b085931 commit 2f61c81
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 51 deletions.
62 changes: 31 additions & 31 deletions contrib/extractor_scripts/ExtractResources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -223,75 +223,75 @@ 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
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
Expand All @@ -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
40 changes: 20 additions & 20 deletions contrib/extractor_scripts/MoveMapGen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -43,21 +43,21 @@ 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"
fi
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?
Expand All @@ -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'!"
Expand All @@ -89,23 +89,23 @@ createHeader()
# Create mmaps directory if not exist
if [ ! -d mmaps ]
then
mkdir ${OUTPUT_PATH:-.}/mmaps
mkdir "${OUTPUT_PATH:-.}/mmaps"
fi

# Param control
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 &
;;
* )
Expand All @@ -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"

0 comments on commit 2f61c81

Please sign in to comment.