Skip to content

Commit c81d339

Browse files
committed
Cleanup and styleup
1 parent 2c3b9db commit c81d339

File tree

3 files changed

+27
-26
lines changed

3 files changed

+27
-26
lines changed

lgsm/functions/command_workshop_install.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ for modid in "${workshoplist[@]}"; do
3838
echo -e ""
3939
echo -e "Installing $(fn_workshop_get_mod_name ${modid})."
4040
echo -e "================================="
41-
fn_workshop_download $modid
42-
fn_workshop_copy_destination $modid
41+
fn_workshop_download "${modid}"
42+
fn_workshop_copy_destination "${modid}"s
4343
done
4444

4545
fn_workshop_lowercase

lgsm/functions/command_workshop_update.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ echo -e "================================="
2222
fn_workshop_installed_list
2323

2424
for modid in "${workshoplist[@]}"; do
25-
modname="$(fn_workshop_get_mod_name $modid)"
26-
if fn_workshop_check_mod_update $modid; then
25+
modname="$(fn_workshop_get_mod_name ${modid})"
26+
if [ fn_workshop_check_mod_update "${modid}" ]; then
2727
echo "Mod ${modname} (${modid}) is not up to date."
28-
fn_workshop_download $modid
29-
fn_workshop_copy_destination $modid
28+
fn_workshop_download "${modid}"
29+
fn_workshop_copy_destination "${modid}"
3030
else
31-
echo "Mod $modname is up to date."
31+
echo "Mod ${modname} is up to date."
3232
fi
3333
done
3434

lgsm/functions/workshop_core.sh

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -104,35 +104,35 @@ fn_workshop_download() {
104104
}
105105

106106
fn_workshop_get_list() {
107-
workshoplist=($(echo $workshopmods | tr ";" "\n"))
107+
workshoplist=($(echo "${workshopmods}" | tr ";" "\n"))
108108
}
109109

110110
fn_workshop_get_latest_mod_version() {
111111
local modid="$1"
112112
local serverresp="$(curl -s -d "itemcount=1&publishedfileids[0]=${modid}" "http://api.steampowered.com/ISteamRemoteStorage/GetPublishedFileDetails/v1")"
113113
local remupd=
114-
if [[ "$serverresp" =~ \"hcontent_file\":[[:space:]]*([^,]*) ]]; then
114+
if [[ "${serverresp}" =~ \"hcontent_file\":[[:space:]]*([^,]*) ]]; then
115115
remupd="${BASH_REMATCH[1]}"
116116
fi
117-
echo "$remupd" | tr -d '"'
117+
echo "${remupd}" | tr -d '"'
118118
}
119119

120120
fn_workshop_get_name_from_steam() {
121121
local modid="$1"
122122
local serverresp="$(curl -s -d "itemcount=1&publishedfileids[0]=${modid}" "http://api.steampowered.com/ISteamRemoteStorage/GetPublishedFileDetails/v1")"
123123
local title=
124-
if [[ "$serverresp" =~ \"title\":[[:space:]]*([^,]*) ]]; then
124+
if [[ "${serverresp}" =~ \"title\":[[:space:]]*([^,]*) ]]; then
125125
title="${BASH_REMATCH[1]}"
126126
fi
127-
echo "$title" | tr -d '"'
127+
echo "${title}" | tr -d '"'
128128
}
129129

130130
fn_workshop_check_mod_update() {
131131
local modid="$1"
132132
if [ ! -f "${workshopmodsdldir}/steamapps/workshop/appworkshop_${gameappid}.acf" ]; then return 0; fi
133133
local instmft="$(sed -n '/^\t"WorkshopItemsInstalled"$/,/^\t[}]$/{/^\t\t"'"${modid}"'"$/,/^\t\t[}]$/{s|^\t\t\t"manifest"\t\t"\(.*\)"$|\1|p}}' <"${workshopmodsdldir}/steamapps/workshop/appworkshop_${gameappid}.acf")"
134-
if [ -z "$instmft" ]; then return 0; fi
135-
local remmft="$(fn_workshop_get_latest_mod_version "$modid")"
134+
if [ -z "${instmft}" ]; then return 0; fi
135+
local remmft="$(fn_workshop_get_latest_mod_version "${modid}")"
136136
if [[ -n "${remmft}" && "${instmft}" != "${remmft}" ]]; then
137137
return 0 # true
138138
fi
@@ -144,8 +144,8 @@ fn_workshop_is_mod_copy_needed(){
144144
local modsrc="${workshopmodsdldir}/steamapps/workshop/content/${gameappid}/${modid}"
145145
if [ ! -f "${workshopmodsdir}/${modid}/meta.cpp" ]; then return 0; fi
146146
local instmft="$(grep "timestamp" ${workshopmodsdir}/${modid}/meta.cpp)"
147-
if [ -z "$instmft" ]; then return 0; fi
148-
local remmft="$(grep "timestamp" $modsrc/meta.cpp)"
147+
if [ -z "${instmft}" ]; then return 0; fi
148+
local remmft="$(grep "timestamp" ${modsrc}/meta.cpp)"
149149
if [[ -n "${remmft}" && "${instmft}" != "${remmft}" ]]; then
150150
return 0 # true
151151
fi
@@ -225,31 +225,31 @@ fn_workshop_lowercase() {
225225
# # Copy the mod into serverfiles.
226226
fn_workshop_copy_destination() {
227227
local modid="$1"
228-
local modname="$(fn_workshop_get_mod_name $modid)"
229-
if fn_workshop_is_mod_copy_needed $modid; then
228+
local modname="$(fn_workshop_get_mod_name ${modid})"
229+
if fn_workshop_is_mod_copy_needed ${modid}; then
230230
echo "Copying mod ${modname} (${modid})"
231231
# If workshop mod exists in installation folder, delete it for clean install
232232
if [ -d "${workshopmodsdir}/${modid}" ]; then
233233
rm -rf "${workshopmodsdir}/${modid}"
234234
fi
235-
modsrc="${workshopmodsdldir}/steamapps/workshop/content/${gameappid}/$modid"
235+
modsrc="${workshopmodsdldir}/steamapps/workshop/content/${gameappid}/${modid}"
236236
cp -fa ${modsrc} ${workshopmodsdir}
237237
if [ "${engine}" == "realvirtuality" ]; then
238-
modkey="${workshopmodsdldir}/steamapps/workshop/content/${gameappid}/$modid/keys"
238+
modkey="${workshopmodsdldir}/steamapps/workshop/content/${gameappid}/${modid}/keys"
239239
if ! [ -d "${modkey}" ]; then
240-
modkey="$steamcmd/steamapps/workshop/content/${gameappid}/$modid/Keys"
240+
modkey="$steamcmd/steamapps/workshop/content/${gameappid}/${modid}/Keys"
241241
fi
242242
if ! [ -d "${modkey}" ]; then
243-
modkey="$steamcmd/steamapps/workshop/content/${gameappid}/$modid/key"
243+
modkey="$steamcmd/steamapps/workshop/content/${gameappid}/${modid}/key"
244244
fi
245245
if ! [ -d "${modkey}" ]; then
246-
modkey="$steamcmd/steamapps/workshop/content/${gameappid}/$modid/Key"
246+
modkey="$steamcmd/steamapps/workshop/content/${gameappid}/${modid}/Key"
247247
fi
248248
if ! [ -d "${modkey}" ]; then
249249
echo "Mod ${modname} seems to be missing key folder. Tring to copy key from the main folder."
250250
cp -fa "${workshopmodsdir}/${modid}/*.bikey" ${keysdir}
251251
else
252-
cp -fa $modkey/*.bikey ${keysdir}
252+
cp -fa ${modkey}/*.bikey ${keysdir}
253253
fi
254254
fi
255255
else
@@ -328,8 +328,9 @@ fn_workshop_check_installed() {
328328
# Builds list of installed Steam Workshop mods.
329329
fn_workshop_installed_list() {
330330
fn_workshop_count_installed
331-
for f in ${workshopmodsdir}/*; do
332-
if [ -d "$f" ]; then
331+
for folder in ${workshopmodsdir}/*; do
332+
# If it is a folder, then use it's name as Steam Workshop Mod Id
333+
if [ -d "${folder}" ]; then
333334
echo -e "$(fn_workshop_get_mod_name $(basename ${f})) ($(basename ${f}))"
334335
fi
335336
done

0 commit comments

Comments
 (0)