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
This commit is contained in:
bastimeyer 2022-04-10 01:23:32 +02:00
parent ea731b7669
commit 94b7c5a5a4

View file

@ -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})"