From 5adce756a19db5efa01b8c67a20e41675c429de7 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Tue, 5 Aug 2025 01:44:56 -0400 Subject: [PATCH] Fixed an error in game removal. Fixed an error where it would try to launch an empty file name if escape were pressed to close the menu. --- audiogame-manager.sh | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/audiogame-manager.sh b/audiogame-manager.sh index ce219d3..b66a870 100755 --- a/audiogame-manager.sh +++ b/audiogame-manager.sh @@ -96,13 +96,16 @@ game_removal() { open_url "https://2mb.games/product/2mb-patron/" exit 0 fi + # Parse game info before create_game_array overwrites $game + local selectedGame="$game" local winePath="${game#*|}" export winePath="${winePath%\\*.exe}" local wineExec="${game#*|}" wineExec="${wineExec%|*}" wineExec="${wineExec##*\\}" + # With shared bottles, always remove only the game files, never the entire bottle - create_game_array "$game" + create_game_array "$selectedGame" if [[ ${#game[@]} -gt 0 ]]; then # Set up wine environment for this game source .includes/bottle.sh @@ -126,9 +129,9 @@ game_removal() { fi fi fi - # remove the launcher - gawk -i inplace -vLine="${game//\\/\\\\}" '!index($0,Line)' "$configFile" - echo "The selected item has been deleted." + # remove the launcher using the original selected game info + gawk -i inplace -vLine="${selectedGame//\\/\\\\}" '!index($0,Line)' "$configFile" + agm_msgbox "Game Removal" "" "\"${game[2]}\" has been successfully removed." fi exit 0 } @@ -311,9 +314,15 @@ game_launcher() { if [[ $menuCode -eq 1 ]] || [[ $menuCode -eq 255 ]]; then exit 0 elif [[ $menuCode -eq 3 ]]; then - source .includes/help.sh # Make available in this function - documentation "$game" "$(echo "$game" | cut -d '|' -f2)" + source .includes/help.sh # Make available in this function + documentation "$game" "$(echo "$game" | cut -d '|' -f2)" fi + + # Safety check: don't proceed if game is empty + if [[ -z "$game" ]]; then + exit 0 + fi + create_game_array "$game" else create_game_array "$game"