Skip to content

Commit e75b64a

Browse files
committed
feat: mejorar gestión de DownloadManagers en [IpDrv.TcpNetDriver] al eliminar líneas innecesarias cuando no hay IDs de Workshop
1 parent 93f6205 commit e75b64a

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

server-scripts/KF2-workshop.sh

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ if [ -z "${WORKSHOP_IDS[*]}" ] || [ "${WORKSHOP_IDS[*]}" = "" ]; then
1818
/^\[/ {if(in_section){in_section=0}}
1919
{if(!in_section) print}
2020
' "$WORKSHOP_INI" > "$WORKSHOP_INI.tmp" && mv "$WORKSHOP_INI.tmp" "$WORKSHOP_INI"
21+
# Eliminar cualquier línea DownloadManagers=OnlineSubsystemSteamworks.SteamWorkshopDownload y DownloadManagers= (vacía) de la sección [IpDrv.TcpNetDriver]
22+
tmpfile2=$(mktemp)
23+
awk '
24+
BEGIN {in_section=0}
25+
/^\[IpDrv.TcpNetDriver\]$/ {in_section=1; print; next}
26+
/^\[/ {in_section=0}
27+
in_section && ($0=="DownloadManagers=OnlineSubsystemSteamworks.SteamWorkshopDownload" || $0=="DownloadManagers=") {next}
28+
{print}
29+
' "$WORKSHOP_INI" > "$tmpfile2" && mv "$tmpfile2" "$WORKSHOP_INI"
30+
echo "[KF2-workshop.sh] Se eliminaron líneas DownloadManagers de [IpDrv.TcpNetDriver] porque no hay workshop."
2131
echo "[KF2-workshop.sh] Se eliminó la sección [OnlineSubsystemSteamworks.KFWorkshopSteamworks] de $WORKSHOP_INI porque KF2_WORKSHOP está vacío."
2232
else
2333
echo "[KF2-workshop.sh] No hay IDs de Workshop definidos y no existe $WORKSHOP_INI."
@@ -52,15 +62,15 @@ awk '
5262
# --- Asegurar DownloadManagers=OnlineSubsystemSteamworks.SteamWorkshopDownload en [IpDrv.TcpNetDriver] ---
5363
tmpfile2=$(mktemp)
5464
if [ -z "${WORKSHOP_IDS[*]}" ] || [ "${WORKSHOP_IDS[*]}" = "" ]; then
55-
# Si no hay IDs, eliminar la línea DownloadManagers=OnlineSubsystemSteamworks.SteamWorkshopDownload de la sección [IpDrv.TcpNetDriver]
65+
# Si no hay IDs, eliminar cualquier línea DownloadManagers=OnlineSubsystemSteamworks.SteamWorkshopDownload y DownloadManagers= (vacía) de la sección [IpDrv.TcpNetDriver]
5666
awk '
5767
BEGIN {in_section=0}
5868
/^\[IpDrv.TcpNetDriver\]$/ {in_section=1; print; next}
5969
/^\[/ {in_section=0}
60-
in_section && $0=="DownloadManagers=OnlineSubsystemSteamworks.SteamWorkshopDownload" {next}
70+
in_section && ($0=="DownloadManagers=OnlineSubsystemSteamworks.SteamWorkshopDownload" || $0=="DownloadManagers=") {next}
6171
{print}
6272
' "$WORKSHOP_INI" > "$tmpfile2" && mv "$tmpfile2" "$WORKSHOP_INI"
63-
echo "[KF2-workshop.sh] Se eliminó DownloadManagers=OnlineSubsystemSteamworks.SteamWorkshopDownload de [IpDrv.TcpNetDriver] porque no hay workshop."
73+
echo "[KF2-workshop.sh] Se eliminaron líneas DownloadManagers de [IpDrv.TcpNetDriver] porque no hay workshop."
6474
else
6575
# Si hay IDs, asegurar que la línea esté como la primera DownloadManagers en la sección
6676
awk '
@@ -70,12 +80,10 @@ else
7080
if(in_section && !inserted){print "DownloadManagers=OnlineSubsystemSteamworks.SteamWorkshopDownload"; inserted=1}
7181
in_section=0
7282
}
83+
in_section && $0=="DownloadManagers=OnlineSubsystemSteamworks.SteamWorkshopDownload" {next}
7384
in_section && !inserted && $0 !~ /^DownloadManagers=/ {
7485
print "DownloadManagers=OnlineSubsystemSteamworks.SteamWorkshopDownload"; inserted=1
7586
}
76-
in_section && $0=="DownloadManagers=OnlineSubsystemSteamworks.SteamWorkshopDownload" {
77-
if(!inserted){print; inserted=1} else {next}
78-
}
7987
{print}
8088
END{if(in_section && !inserted){print "DownloadManagers=OnlineSubsystemSteamworks.SteamWorkshopDownload"}}
8189
' "$WORKSHOP_INI" > "$tmpfile2" && mv "$tmpfile2" "$WORKSHOP_INI"

0 commit comments

Comments
 (0)