Parcourir la source

fix(fastdl): collect GoldSrc content with the GoldSrc file layout (#5045)

The fastdl command is offered for GoldSrc servers and already copies
files instead of compressing them, but it gathered files using the
Source layout (materials, particles, resource and Source file types).
GoldSrc custom content was therefore left out: wad files in the mod
root, map .res files, sprites, sky and detail textures in gfx, and
overviews.

When the engine is goldsrc, the preview and build steps now use a
GoldSrc directory list and per-directory file types from a single
shared function:

- mod root: *.wad (top level only)
- maps: *.bsp *.res *.txt
- models: *.mdl
- sound: *.wav
- sprites: *.spr *.txt
- gfx: *.tga *.bmp
- overviews: *.bmp *.tga *.txt

Source and Garry's Mod behaviour is unchanged.

Fixes #1778
Daniel Gibbs il y a 3 jours
Parent
commit
80ac7281f8
1 fichiers modifiés avec 35 ajouts et 6 suppressions
  1. 35 6
      lgsm/modules/command_fastdl.sh

+ 35 - 6
lgsm/modules/command_fastdl.sh

@@ -132,6 +132,27 @@ fn_human_readable_file_size() {
 	fi
 	fi
 }
 }
 
 
+# Sets the GoldSrc file types to include for the current directory.
+fn_fastdl_goldsrc_extensions() {
+	fastdl_find_maxdepth=()
+	if [ "${directory}" == "." ]; then
+		allowed_extentions_array=("*.wad")
+		fastdl_find_maxdepth=("-maxdepth" "1")
+	elif [ "${directory}" == "maps" ]; then
+		allowed_extentions_array=("*.bsp" "*.res" "*.txt")
+	elif [ "${directory}" == "models" ]; then
+		allowed_extentions_array=("*.mdl")
+	elif [ "${directory}" == "sound" ]; then
+		allowed_extentions_array=("*.wav")
+	elif [ "${directory}" == "sprites" ]; then
+		allowed_extentions_array=("*.spr" "*.txt")
+	elif [ "${directory}" == "gfx" ]; then
+		allowed_extentions_array=("*.tga" "*.bmp")
+	elif [ "${directory}" == "overviews" ]; then
+		allowed_extentions_array=("*.bmp" "*.tga" "*.txt")
+	fi
+}
+
 # Provides info about the fastdl directory content and prompts for confirmation.
 # Provides info about the fastdl directory content and prompts for confirmation.
 fn_fastdl_preview() {
 fn_fastdl_preview() {
 	# Remove any file list.
 	# Remove any file list.
@@ -160,12 +181,18 @@ fn_fastdl_preview() {
 				fn_print_skip_eol_nl
 				fn_print_skip_eol_nl
 			fi
 			fi
 		done
 		done
-	# Source engine
+	# Source and GoldSrc engines
 	else
 	else
-		fastdl_directories_array=("maps" "materials" "models" "particles" "sound" "resource")
+		if [ "${engine}" == "goldsrc" ]; then
+			fastdl_directories_array=("." "maps" "models" "sound" "sprites" "gfx" "overviews")
+		else
+			fastdl_directories_array=("maps" "materials" "models" "particles" "sound" "resource")
+		fi
 		for directory in "${fastdl_directories_array[@]}"; do
 		for directory in "${fastdl_directories_array[@]}"; do
 			if [ -d "${systemdir}/${directory}" ]; then
 			if [ -d "${systemdir}/${directory}" ]; then
-				if [ "${directory}" == "maps" ]; then
+				if [ "${engine}" == "goldsrc" ]; then
+					fn_fastdl_goldsrc_extensions
+				elif [ "${directory}" == "maps" ]; then
 					local allowed_extentions_array=("*.bsp" "*.ain" "*.nav" "*.jpg" "*.txt")
 					local allowed_extentions_array=("*.bsp" "*.ain" "*.nav" "*.jpg" "*.txt")
 				elif [ "${directory}" == "materials" ]; then
 				elif [ "${directory}" == "materials" ]; then
 					local allowed_extentions_array=("*.vtf" "*.vmt" "*.vbf" "*.png" "*.svg")
 					local allowed_extentions_array=("*.vtf" "*.vmt" "*.vbf" "*.png" "*.svg")
@@ -187,7 +214,7 @@ fn_fastdl_preview() {
 						tput el
 						tput el
 						fn_print "gathering ${directory} ${allowed_extention} : ${fileswc}"
 						fn_print "gathering ${directory} ${allowed_extention} : ${fileswc}"
 						echo -e "${ext}" >> "${tmpdir}/fastdl_files_to_compress.txt"
 						echo -e "${ext}" >> "${tmpdir}/fastdl_files_to_compress.txt"
-					done < <(find "${systemdir}/${directory}" -type f -iname "${allowed_extention}")
+					done < <(find "${systemdir}/${directory}" "${fastdl_find_maxdepth[@]}" -type f -iname "${allowed_extention}")
 					tput rc
 					tput rc
 					tput el
 					tput el
 					fn_print "gathering ${directory} ${allowed_extention} : ${fileswc}"
 					fn_print "gathering ${directory} ${allowed_extention} : ${fileswc}"
@@ -315,7 +342,9 @@ fn_fastdl_gmod() {
 fn_fastdl_source() {
 fn_fastdl_source() {
 	for directory in "${fastdl_directories_array[@]}"; do
 	for directory in "${fastdl_directories_array[@]}"; do
 		if [ -d "${systemdir}/${directory}" ]; then
 		if [ -d "${systemdir}/${directory}" ]; then
-			if [ "${directory}" == "maps" ]; then
+			if [ "${engine}" == "goldsrc" ]; then
+				fn_fastdl_goldsrc_extensions
+			elif [ "${directory}" == "maps" ]; then
 				local allowed_extentions_array=("*.bsp" "*.ain" "*.nav" "*.jpg" "*.txt")
 				local allowed_extentions_array=("*.bsp" "*.ain" "*.nav" "*.jpg" "*.txt")
 			elif [ "${directory}" == "materials" ]; then
 			elif [ "${directory}" == "materials" ]; then
 				local allowed_extentions_array=("*.vtf" "*.vmt" "*.vbf" "*.png" "*.svg")
 				local allowed_extentions_array=("*.vtf" "*.vmt" "*.vbf" "*.png" "*.svg")
@@ -353,7 +382,7 @@ fn_fastdl_source() {
 					else
 					else
 						fn_script_log_pass "Copying ${fastdlfile} > ${fastdldir}/${copytodir}"
 						fn_script_log_pass "Copying ${fastdlfile} > ${fastdldir}/${copytodir}"
 					fi
 					fi
-				done < <(find "${systemdir}/${directory}" -type f -iname "${allowed_extention}")
+				done < <(find "${systemdir}/${directory}" "${fastdl_find_maxdepth[@]}" -type f -iname "${allowed_extention}")
 				if [ ${fileswc} != 0 ]; then
 				if [ ${fileswc} != 0 ]; then
 					fn_print_ok_eol_nl
 					fn_print_ok_eol_nl
 				fi
 				fi