From 2b52d9923dfcb4d84cd9436697a1e36206db5b43 Mon Sep 17 00:00:00 2001 From: Eamonn Rea Date: Tue, 4 Jun 2024 18:53:45 +0100 Subject: [PATCH] fix createVdfEntry broken BLOCKTABAMOUNT if custom indent is passed If you passed a custom indent amount, BLOCKTABAMOUNT would be offset too much. --- steamtinkerlaunch | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/steamtinkerlaunch b/steamtinkerlaunch index c6c55bf5..327e3fc5 100755 --- a/steamtinkerlaunch +++ b/steamtinkerlaunch @@ -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 @@ -22541,11 +22541,16 @@ 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!1" "DisableLaunchInVR!2" ) + 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" )" @@ -22553,10 +22558,9 @@ function commandline { 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 )" @@ -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 @@ -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 @@ -23906,27 +23913,23 @@ 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 ))" - BLOCKTABAMOUNT="$(( BASETABAMOUNT + 1 ))" - writelog "INFO" "${FUNCNAME[0]} - Guessed BASETABAMOUNT='${BASETABAMOUNT}'" else BASETABAMOUNT="$INDENT" - # 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 ))" fi # Indents for PARENTBLOCK + BLOCKTABAMOUNT="$(( BASETABAMOUNT + 1 ))" PARENTBLOCKTABAMOUNT="$(( BASETABAMOUNT - 1 ))" ## Ensure no duplicates are written out (duplicate names can exist at different indent levels) @@ -23939,8 +23942,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="!"