Skip to content

Commit

Permalink
fixes for parsing the CSV to remove trailing quotes, other misc edge …
Browse files Browse the repository at this point in the history
…case catches
  • Loading branch information
sonic2kk committed Jul 25, 2024
1 parent 57f9410 commit 1cb35e3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions steamtinkerlaunch
Original file line number Diff line number Diff line change
Expand Up @@ -650,15 +650,20 @@ function setSteamPaths {
if [ -f "$STLDEFGLOBALCFG" ] && grep -q "^STEAMUSERID=" "$STLDEFGLOBALCFG" ; then
STEAMUSERID="$(grep "^STEAMUSERID=" "$STLDEFGLOBALCFG" | grep -o "[[:digit:]]*")"
STUIDPATH="$SUSDA/$STEAMUSERID"

writelog "INFO" "${FUNCNAME[0]} - Parsing Steam UserID from global config as '$STEAMUSERID' -- STUIDPATH is now '$STUIDPATH'"
else
if [ -d "$SUSDA" ]; then
writelog "INFO" "${FUNCNAME[0]} - Trying to determine Steam UserID and userdata path"

STEAMUSERID=""
STUIDPATH=""

# Try to set the path to the userdata folder (this contains grids, shortcuts.vdf, etc)
# fillLoginUsersCSV will fall back to taking the first userdata folder in the Steam userdata dir and will set it to MostRecent=1
# if it doesn't get any matches in loginusers.vdf, so we don't have to do the fallback here
if [ ! -f "$LOGINUSERSCSV" ]; then
writelog "INFO" "${FUNCNAME[0]} - Filling Users CSV"
fillLoginUsersCSV
fi

Expand Down Expand Up @@ -694,6 +699,11 @@ function setSteamPaths {
# Hopefully this never happens under normal usage... We should always be able to find the Steam User
if [ -z "${STEAMUSERID}" ] || [ -z "${STUIDPATH}" ]; then
writelog "WARN" "${FUNCNAME[0]} - Could not find any logged in Steam users in '$LOGINUSERSCSV' (are any users logged in?) - other variables depend on it, expect problems!" "E"
elif [ ! -d "${STUIDPATH}" ]; then
# If we were able to get the Most Recent Steam user but the userdata path for this user with this UserID does not actually exist, something has gone horribly wrong!
# One possible but unlikely scenario is that the MostRecent user in LognUsersCSV file was removed from the Steam Client, so the userdata path would no longer exist
# Users should remove /dev/shm/steamtinkerlaunch if the accounts or Steam Client config changes in any way so this would only be a temporary issue
writelog "WARN" "${FUNCNAME[0]} - Built Steam userdata path for User ID '${STEAMUSERID}' at path '${STUIDPATH}', but this path does not exist! This will probably cause problems!" "E"
fi
else
writelog "WARN" "${FUNCNAME[0]} - Steam '$USDA' directory not found, other variables depend on it - Expect problems" "E"
Expand Down Expand Up @@ -24350,7 +24360,7 @@ function fillLoginUsersCSV {
fi

# NOTE: For testing only
LOGUVDF="$HOME/.local/share/Steam/config/test_loginusers.vdf"
# LOGUVDF="$HOME/.local/share/Steam/config/test_loginusers.vdf"

# Toplevel block in loginusers.vdf is "users", get all block names ("[0-9]+" with one hardcoded indent, because we know we only have 1 indent)
#
Expand Down Expand Up @@ -24403,7 +24413,7 @@ function fillLoginUsersCSV {
# This value should really only ever be 0 or 1
LOGINUSERBLOCK="$( getVdfSection "${LOGINUSERLONGID}" "" "1" "${LOGUVDF}" )"
if [ -n "${LOGINUSERBLOCK}" ]; then
LOGINUSERMOSTRECENTVAL="$( getVdfSectionValue "${LOGINUSERBLOCK}" "MostRecent" "1" )"
LOGINUSERMOSTRECENTVAL="$( getVdfSectionValue "${LOGINUSERBLOCK}" "MostRecent" "1" | tr -d '"' )"

if [ -n "$LOGINUSERMOSTRECENTVAL" ]; then
LOGINUSERMOSTRECENT="$LOGINUSERMOSTRECENTVAL"
Expand Down

0 comments on commit 1cb35e3

Please sign in to comment.