Skip to content

Commit

Permalink
fix createVdfEntry broken BLOCKTABAMOUNT if custom indent is passed
Browse files Browse the repository at this point in the history
If you passed a custom indent amount, BLOCKTABAMOUNT would be offset too much.
  • Loading branch information
sonic2kk committed Jun 4, 2024
1 parent 408dc12 commit 2f63a2b
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions steamtinkerlaunch
Original file line number Diff line number Diff line change
Expand Up @@ -22531,8 +22531,8 @@ function commandline {
# This will create an "Apps" section if it doesn't exist
if [ -z "$FLCVAPPSSECTION" ]; then
echo "Apps Section does not exist - Create it"
# UPDATE 4TH JUNE 2024: ACTUALLY CREATES SUCCESSFULLY!
createVdfEntry "$DEBUG_CONFIG" "UserLocalConfigStore" "Apps" "" "0" ""
# FLCVAPPSSECTION="$( getVdfSection "Apps" "" "1" "$DEBUG_CONFIG" )"
else
echo "Woohoo, we have an apps section! Nothing to do"
fi
Expand All @@ -22541,22 +22541,26 @@ function commandline {
FLCVAPPSHASNOSTAID="$( getNestedVdfSection "Apps/${DEBUGNOSTAID}" "1" "$DEBUG_CONFIG" )"
if ! grep -q -- "$DEBUGNOSTAID" <<< "$FLCVAPPSHASNOSTAID"; then
echo "No AppID section in Apps, we need to create it!"
createVdfEntry "$DEBUG_CONFIG" "Apps" "$DEBUGNOSTAID" "" "2" "" # creates in the wrong place :/
DEBUG_NEWLCVDF_ENTRY=( "OverlayAppEnable!titties" "DisableLaunchInVR!oppai" )
createVdfEntry "$DEBUG_CONFIG" "Apps" "$DEBUGNOSTAID" "" "2" "" "${DEBUG_NEWLCVDF_ENTRY[@]}" # creates in the wrong place :/
else
echo "Win! We have the Non-Steam AppID section in the Apps section! Let's update it"
fi

# Re-fetch FLCVAPPSHASNOSTAID to make sure we have our updated AppID block
# This means if FLCVAPPSHASNOSTAID was blank (block didn't exist) we will have the one we just created
FLCVAPPSHASNOSTAID="$( getNestedVdfSection "Apps/${DEBUGNOSTAID}" "1" "$DEBUG_CONFIG" )"

# echo "$FLCVAPPSHASNOSTAID"
FLCV__SECTIONAID="$( echo "$FLCVAPPSHASNOSTAID" | head -n1 | tr -d '"' | xargs )"
FLCV__OVERLAYAPPENABLE="$( getVdfSectionValue "$FLCVAPPSHASNOSTAID" "OverlayAppEnable" "1" )"
FLCV__DISABLELAUNCHINVR="$( getVdfSectionValue "$FLCVAPPSHASNOSTAID" "DisableLaunchInVR" "1" )"
echo "OverlayAppEnable for ${FLCV__SECTIONAID} is ${FLCV__OVERLAYAPPENABLE}"
echo "DisableLaunchInVR for ${FLCV__SECTIONAID} is ${FLCV__DISABLELAUNCHINVR}"

# Test to see if updating compat tool in config.vdf still works (probably doesn't)
NSGVDFVALS=( "name!boobs" "config!" "priority!250" )
createVdfEntry "$DEBUG_CONFIGVDF" "CompatToolMapping" "4072613992" "" "" "" "${NSGVDFVALS[@]}"

# Test to see if updating compat tool in config.vdf still works (!!!!!4th June 2024: works!!!!!!)
# NSGVDFVALS=( "name!boobs" "config!" "priority!250" )
# createVdfEntry "$DEBUG_CONFIGVDF" "CompatToolMapping" "4072613992" "" "" "" "${NSGVDFVALS[@]}"

echo "Current global compat tool is $( getGlobalSteamCompatToolInternalName )"

Expand Down Expand Up @@ -23807,7 +23811,7 @@ function getVdfSection {
# Allows for parsing top-level VDF section i.e. "UserLocalConfigStore" in localconfig.vdf
INDENTSTR=""
if [ "$INDENT" -gt 0 ]; then
INDENTSTR="$( generateVdfIndentString "$INDENT" "[[:space:]]" )"
INDENTSTR="$( generateVdfIndentString "$INDENT" "[[:space:]]" )"
else
writelog "INFO" "${FUNCNAME[0]} - Indent is 0 ("$INDENT")"
fi
Expand All @@ -23821,7 +23825,10 @@ function getVdfSection {
# It needs the start pattern exact match but other functions can't use this
#
# TODO the '^${INDENTEDSTARTPATTERN}' was added here, make sure this doesn't break other usages
# TODO if this doesn't break anything, check if "STOPAFTERFIRSTMATCH" is still needed
# TODO if this doesn't break anything, check if "STOPAFTERFIRSTMATCH" is still needed
#
# TODO UPDATED 4TH JUNE 2024 -- MAKE EXTRA SURE THIS DOESN'T BREAK ANYTHING!!
# createVdfEntry seems to work fine but absolutely check
if [ -n "$STOPAFTERFIRSTMATCH" ]; then
sed -n "/^${INDENTEDSTARTPATTERN}/I,/^${INDENTEDENDPATTERN}/I { p; /${INDENTEDENDPATTERN}/I q }" "$VDF"
else
Expand Down Expand Up @@ -23906,12 +23913,13 @@ function createVdfEntry {
CHECKDUPLICATES="${6:-1}" # Flag to check for duplicate section names

# If no indent is given, guess the indent, otherwise use the specified one
#
# -------
# BASETABAMOUNT = Indent for the start of the new section, i.e. one indent in from the parent block
# BLOCKTABAMOUNT = Indent for the block inside of the section
#
# Ex: With CompatToolMapping, BASETABAMOUNT represents the indent for the AppID, such as "22300"
# BLOCKTABAMOUNT represents the indent for the contents of the block under this name
# -------
if [ -z "$INDENT" ]; then
## Calculate indents for new block (one more than PARENTBLOCKNAME indent)
BASETABAMOUNT="$(( $( guessVdfIndent "${PARENTBLOCKNAME}" "$VDF" ) + 1 ))"
Expand All @@ -23923,7 +23931,7 @@ function createVdfEntry {
# Has to be +2 if indent is specified because it needs to account for spacing of parent block and new block
# e.g. is INDENT=0, BASETABAMOUNT for new block will be 0 + 1 = 1, then the BLOCKTABAMOUNT needs to be inside that, so it needs to be (0 + 1) + 1 = +2
# When we guess the indent and don't specify one explicitly we don't care about this
BLOCKTABAMOUNT="$(( BASETABAMOUNT + 2 ))"
BLOCKTABAMOUNT="$(( BASETABAMOUNT + 1 ))"
fi

# Indents for PARENTBLOCK
Expand All @@ -23939,8 +23947,8 @@ function createVdfEntry {

## Create array from args, skip first four to get array of key/value pairs for VDF block
NEWBLOCKVALUES=("${@:7}")

writelog "INFO" "${FUNCNAME[0]} - ${NEWBLOCKVALUES[*]}"
writelog "INFO" "${FUNCNAME[0]} - NEWBLOCKVALUES are ${NEWBLOCKVALUES[*]}"

NEWBLOCKVALUESDELIM="!"

Expand Down

0 comments on commit 2f63a2b

Please sign in to comment.