From 94b7c5a5a45de02c2f709f736a837c6b8dc4ac07 Mon Sep 17 00:00:00 2001 From: bastimeyer Date: Sun, 10 Apr 2022 01:23:32 +0200 Subject: [PATCH] feat: shorten mod link names as much as possible Resolves #9 Resolves #8 See ValveSoftware/steam-for-linux#5753 Steam seems to have issues with long launch arguments when calling it via `steam -applaunch GAMEID ARGUMENTS`. This results in the client not responding to any `-applaunch` attempts anymore, and it needs to be restarted. When trying to join servers with lots of mods, the `-mod=...` argument can become too long for Steam to handle, so mod directories should not be named by their mod ID and mod name and they should instead be kept as short as possible. This comes at the cost of not being able to identify mod directories easily anymore, but it's better than not being able to join certain servers at all and having to restart Steam. - Remove mod names from mod directory links - Turn decimal mod IDs into ASCII char strings and convert to base64 --- dayz-launcher.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/dayz-launcher.sh b/dayz-launcher.sh index 021695f..b3cab95 100755 --- a/dayz-launcher.sh +++ b/dayz-launcher.sh @@ -186,6 +186,20 @@ check_flatpak() { && { flatpak ps | grep "${FLATPAK_STEAM}"; } >/dev/null 2>&1 } +dec2base64() { + echo "$1" \ + | LC_ALL=C gawk ' + { + do { + printf "%c", and($1, 255) + $1 = rshift($1, 8) + } while ($1 > 0) + } + ' \ + | base64 \ + | sed 's|/|-|g; s|=||g' +} + # ---- @@ -242,7 +256,7 @@ setup_mods() { local modname="$(gawk 'match($0,/name\s*=\s*"(.+)"/,m){print m[1];exit}' "${modmeta}")" [[ -n "${modname}" ]] || err "Missing mod name for: ${modid}" debug "Mod ${modid} found: ${modname}" - modlink="@${modid}-$(echo "${modname}" | sed -E 's/[^[:alpha:]0-9]+/_/g; s/^_|_$//g')" + local modlink="@$(dec2base64 "${modid}")" if ! [[ -L "${dir_dayz}/${modlink}" ]]; then msg "Creating mod symlink for: ${modname} (${modlink})"