فهرست منبع

feat(workshop): add Steam Workshop downloads for Hurtworld (#5019)

Daniel Gibbs 1 هفته پیش
والد
کامیت
c0a5ced6ad

+ 8 - 1
lgsm/config-default/config-lgsm/hwserver/_default.cfg

@@ -27,7 +27,14 @@ loadsave=""
 
 ## Server Parameters | https://docs.linuxgsm.com/configuration/start-parameters#additional-parameters
 # http://hurtworld.wikia.com/wiki/Hosting_A_Server
-startparameters="-batchmode -nographics -logfile ${gamelog} -exec \"host ${port} ${defaultmap} ${loadsave};queryport ${queryport};maxplayers ${maxplayers};servername ${servername};creativemode ${creativemode};addadmin ${admins}\""
+startparameters="-batchmode -nographics -logfile ${gamelog} -exec \"host ${port} ${defaultmap} ${loadsave};queryport ${queryport};maxplayers ${maxplayers};servername ${servername};creativemode ${creativemode}${workshoploadmods};addadmin ${admins}\""
+
+## Steam Workshop Mods | https://docs.linuxgsm.com/steamcmd/workshop
+# Workshop item or collection IDs, separated by spaces. Collections are expanded.
+# Downloaded with SteamCMD and loaded with loadmod on start. If you set your own startparameters, keep ${workshoploadmods} in -exec.
+# Run ./hwserver workshop-update after changing, or let update apply it.
+# workshopmods="2015422570"
+workshopmods=""
 
 #### LinuxGSM Settings ####
 

+ 1 - 1
lgsm/modules/check.sh

@@ -107,7 +107,7 @@ for allowed_command in "${allowed_commands_array[@]}"; do
 	fi
 done
 
-if [ "${shortname}" == "arma3" ] || [ "${shortname}" == "dayz" ]; then
+if [ "${shortname}" == "arma3" ] || [ "${shortname}" == "dayz" ] || [ "${shortname}" == "hw" ]; then
 	allowed_commands_array=(DEBUG DETAILS POST-DETAILS RESTART START)
 	for allowed_command in "${allowed_commands_array[@]}"; do
 		if [ "${allowed_command}" == "${commandname}" ] && { [ -n "${workshopmods}" ] || [ -f "${datadir}/${selfname}-workshop.txt" ]; }; then

+ 1 - 1
lgsm/modules/command_check_update.sh

@@ -44,7 +44,7 @@ else
 	update_steamcmd.sh
 fi
 
-if { [ "${shortname}" == "arma3" ] || [ "${shortname}" == "dayz" ] || [ "${shortname}" == "bt" ] || [ "${shortname}" == "col" ] || [ "${shortname}" == "l4d2" ] || [ "${shortname}" == "ohd" ] || [ "${shortname}" == "sb" ] || [ "${shortname}" == "squad" ] || [ "${shortname}" == "squad44" ] || [ "${shortname}" == "st" ]; } && { [ -n "${workshopmods}" ] || [ -f "${datadir}/${selfname}-workshop.txt" ]; }; then
+if { [ "${shortname}" == "arma3" ] || [ "${shortname}" == "dayz" ] || [ "${shortname}" == "bt" ] || [ "${shortname}" == "col" ] || [ "${shortname}" == "hw" ] || [ "${shortname}" == "l4d2" ] || [ "${shortname}" == "ohd" ] || [ "${shortname}" == "sb" ] || [ "${shortname}" == "squad" ] || [ "${shortname}" == "squad44" ] || [ "${shortname}" == "st" ]; } && { [ -n "${workshopmods}" ] || [ -f "${datadir}/${selfname}-workshop.txt" ]; }; then
 	workshop_core.sh
 	fn_workshop_update
 fi

+ 1 - 1
lgsm/modules/command_update.sh

@@ -45,7 +45,7 @@ else
 	update_steamcmd.sh
 fi
 
-if { [ "${shortname}" == "arma3" ] || [ "${shortname}" == "dayz" ] || [ "${shortname}" == "bt" ] || [ "${shortname}" == "col" ] || [ "${shortname}" == "l4d2" ] || [ "${shortname}" == "ohd" ] || [ "${shortname}" == "sb" ] || [ "${shortname}" == "squad" ] || [ "${shortname}" == "squad44" ] || [ "${shortname}" == "st" ]; } && { [ -n "${workshopmods}" ] || [ -f "${datadir}/${selfname}-workshop.txt" ]; }; then
+if { [ "${shortname}" == "arma3" ] || [ "${shortname}" == "dayz" ] || [ "${shortname}" == "bt" ] || [ "${shortname}" == "col" ] || [ "${shortname}" == "hw" ] || [ "${shortname}" == "l4d2" ] || [ "${shortname}" == "ohd" ] || [ "${shortname}" == "sb" ] || [ "${shortname}" == "squad" ] || [ "${shortname}" == "squad44" ] || [ "${shortname}" == "st" ]; } && { [ -n "${workshopmods}" ] || [ -f "${datadir}/${selfname}-workshop.txt" ]; }; then
 	workshop_core.sh
 	fn_workshop_update
 fi

+ 1 - 1
lgsm/modules/core_getopt.sh

@@ -144,7 +144,7 @@ if [ "${engine}" == "source" ] || [ "${shortname}" == "cs2" ] || [ "${shortname}
 fi
 
 ## Workshop commands.
-if [ "${shortname}" == "arma3" ] || [ "${shortname}" == "dayz" ] || [ "${shortname}" == "bt" ] || [ "${shortname}" == "col" ] || [ "${shortname}" == "l4d2" ] || [ "${shortname}" == "ohd" ] || [ "${shortname}" == "sb" ] || [ "${shortname}" == "squad" ] || [ "${shortname}" == "squad44" ] || [ "${shortname}" == "st" ]; then
+if [ "${shortname}" == "arma3" ] || [ "${shortname}" == "dayz" ] || [ "${shortname}" == "bt" ] || [ "${shortname}" == "col" ] || [ "${shortname}" == "hw" ] || [ "${shortname}" == "l4d2" ] || [ "${shortname}" == "ohd" ] || [ "${shortname}" == "sb" ] || [ "${shortname}" == "squad" ] || [ "${shortname}" == "squad44" ] || [ "${shortname}" == "st" ]; then
 	currentopt+=("${cmd_workshop_update[@]}")
 fi
 

+ 33 - 18
lgsm/modules/workshop_core.sh

@@ -18,6 +18,10 @@ elif [ "${shortname}" == "ohd" ]; then
 elif [ "${shortname}" == "bt" ]; then
 	workshopdir="${serverfiles}/LocalMods"
 	workshopprefix=""
+elif [ "${shortname}" == "hw" ]; then
+	workshopdir="${serverfiles}/steamapps/workshop/content/393420"
+	workshopprefix=""
+	workshopinplace=1
 elif [ "${shortname}" == "col" ]; then
 	workshopdir="${serverfiles}/gamedata/mods"
 	workshopprefix=""
@@ -244,8 +248,13 @@ fn_workshop_download() {
 	local attempt=0
 	local item params
 	steamcmdlog="${lgsmlogdir}/${selfname}-steamcmd.log"
-	rm -rf "${workshopdldir:?}"
-	mkdir -p "${workshopdldir}"
+	if [ -n "${workshopinplace}" ]; then
+		workshopdlroot="${serverfiles}"
+	else
+		workshopdlroot="${workshopdldir}"
+		rm -rf "${workshopdldir:?}"
+		mkdir -p "${workshopdldir}"
+	fi
 	if [ -d "${steamcmddir}" ]; then
 		cd "${steamcmddir}" || exit
 	fi
@@ -255,7 +264,7 @@ fn_workshop_download() {
 	fi
 	while [ "${#pending[@]}" -gt 0 ] && [ "${attempt}" -lt "${workshopretries}" ]; do
 		attempt=$((attempt + 1))
-		params=(+force_install_dir "${workshopdldir}" +login "${steamuser}" "${steampass}")
+		params=(+force_install_dir "${workshopdlroot}" +login "${steamuser}" "${steampass}")
 		for item in "${pending[@]}"; do
 			params+=(+workshop_download_item "${workshopappid[${item}]}" "${item}")
 		done
@@ -272,7 +281,7 @@ fn_workshop_download() {
 
 		local failed=()
 		for item in "${pending[@]}"; do
-			if [ -z "$(find "${workshopdldir}/steamapps/workshop/content/${workshopappid[${item}]}/${item}" -mindepth 1 -print -quit 2> /dev/null)" ]; then
+			if [ -z "$(find "${workshopdlroot}/steamapps/workshop/content/${workshopappid[${item}]}/${item}" -mindepth 1 -print -quit 2> /dev/null)" ]; then
 				failed+=("${item}")
 			fi
 		done
@@ -336,7 +345,7 @@ fn_workshop_remove_links() {
 # Moves a downloaded item into the game's mod directory and prepares it for the game.
 fn_workshop_install() {
 	local item="$1"
-	local src="${workshopdldir}/steamapps/workshop/content/${workshopappid[${item}]}/${item}"
+	local src="${workshopdlroot}/steamapps/workshop/content/${workshopappid[${item}]}/${item}"
 	local dst="${workshopdir}/${workshopprefix}${item}"
 	local installed
 	local keys=()
@@ -347,7 +356,9 @@ fn_workshop_install() {
 	if [ -n "${installed}" ]; then
 		fn_workshop_remove_keys "${item}"
 		fn_workshop_remove_links "${item}"
-		rm -rf "${installed:?}"
+		if [ "${installed}" != "${src}" ]; then
+			rm -rf "${installed:?}"
+		fi
 	fi
 	# A mod that is a single plugin folder is installed as that folder, for games that load mods by folder name.
 	if [ -n "${workshopflatten}" ]; then
@@ -358,16 +369,18 @@ fn_workshop_install() {
 			src="${subdirs[0]}"
 		fi
 	fi
-	if [ -e "${dst}" ]; then
-		fn_print_fail_nl "Installing ${workshoptitle[${item}]} (${item}): ${dst} already exists"
-		fn_script_log_fail "Installing ${workshoptitle[${item}]} (${item}): ${dst} already exists"
-		return
-	fi
-	mkdir -p "${workshopdir}"
-	if ! mv "${src}" "${dst}"; then
-		fn_print_fail_nl "Installing ${workshoptitle[${item}]} (${item})"
-		fn_script_log_fail "Installing ${workshoptitle[${item}]} (${item})"
-		core_exit.sh
+	if [ "${src}" != "${dst}" ]; then
+		if [ -e "${dst}" ]; then
+			fn_print_fail_nl "Installing ${workshoptitle[${item}]} (${item}): ${dst} already exists"
+			fn_script_log_fail "Installing ${workshoptitle[${item}]} (${item}): ${dst} already exists"
+			return
+		fi
+		mkdir -p "${workshopdir}"
+		if ! mv "${src}" "${dst}"; then
+			fn_print_fail_nl "Installing ${workshoptitle[${item}]} (${item})"
+			fn_script_log_fail "Installing ${workshoptitle[${item}]} (${item})"
+			core_exit.sh
+		fi
 	fi
 	if [ "${shortname}" == "arma3" ] || [ "${shortname}" == "dayz" ]; then
 		fn_workshop_lowercase "${dst}"
@@ -590,7 +603,7 @@ fn_workshop_update() {
 	unset exitbypass
 }
 
-# Adds installed Workshop mods to the mods start parameter, in workshopmods order.
+# Adds installed Workshop mods to the start parameters, in workshopmods order: -mod= for Arma 3 and DayZ, loadmod for Hurtworld.
 fn_workshop_mods_startparameters() {
 	if [ -n "${workshopmodsadded}" ]; then
 		return
@@ -611,7 +624,9 @@ fn_workshop_mods_startparameters() {
 	local missing=0
 	local item
 	for item in "${items[@]}"; do
-		if [ -d "${workshopdir}/${workshopprefix}${item}" ]; then
+		if [ -d "${workshopdir}/${workshopprefix}${item}" ] && [ "${shortname}" == "hw" ]; then
+			workshoploadmods+=";loadmod ${item}"
+		elif [ -d "${workshopdir}/${workshopprefix}${item}" ]; then
 			workshopmodsparam+="${workshopmodsparam:+\\;}workshop/${workshopprefix}${item}"
 		else
 			missing=$((missing + 1))