kyechou / leagueoflegends

League of Legends install and launch wrapper for Linux
https://www.leagueoflegends.com
GNU General Public License v3.0
289 stars 23 forks source link

Cannot launch client with Garena #33

Closed drshapeless closed 1 year ago

drshapeless commented 2 years ago

!! Before creating an issue, please take a look at the troubleshooting section.

System information

If your issue is related to graphics display, please attach the output of vulkaninfo.

Describe the issue

Is the garena version ready to use? I saw a todo tag.

Cannot launch the client by following all the steps.

I cannot start the garena client and install the game. But when I click the play button, it says fail to launch the game.

I did change the game location according to the README.

LoL will by default be installed at Z:\Garena\Games\, which is in most cases not desirable. Please change it to C:\Program Files\Garena\Games\, or any other location you desire as long as it is consistent with the script variables.

2022-02-03_004610

Steps to reproduce

Note: Use the -v option and attach the verbose log outputs for all relevant commands. For long texts/logs, consider sharing them via services like Gist. Do not attach screenshots for text/log outputs.

Here is the verbose log.

leagueoflegends -v start-garena
+ export WINEDEBUG=fixme-all
+ WINEDEBUG=fixme-all
+ shift
+ :
+ case "${1-}" in
+ break
+ case "${1-}" in
+ start_garena
+ export_env_variables_garena
+ export_env_variables
+ export PATH=/opt/wine-lol/bin:/opt/wine-lol/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/jacky/src/swift-language/swift/swift-nightly-install/usr/bin:/home/jacky/.local/bin:/home/jacky/src/swift-language/swift/swift-nightly-install/usr/bin:/home/jacky/.local/bin
+ PATH=/opt/wine-lol/bin:/opt/wine-lol/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/jacky/src/swift-language/swift/swift-nightly-install/usr/bin:/home/jacky/.local/bin:/home/jacky/src/swift-language/swift/swift-nightly-install/usr/bin:/home/jacky/.local/bin
+ export REGFILE=/usr/share/doc/leagueoflegends/leagueoflegends.reg
+ REGFILE=/usr/share/doc/leagueoflegends/leagueoflegends.reg
+ export ICON=/usr/share/icons/hicolor/256x256/apps/leagueoflegends.png
+ ICON=/usr/share/icons/hicolor/256x256/apps/leagueoflegends.png
+ export CACHE_DIR=/home/jacky/.cache/leagueoflegends
+ CACHE_DIR=/home/jacky/.cache/leagueoflegends
+ export WINEARCH=win32
+ WINEARCH=win32
+ export WINEDEBUG=-all
+ WINEDEBUG=-all
+ export 'WINEDLLOVERRIDES=mscoree,mshtml,winemenubuilder.exe=;d3d10,d3d11=n,b'
+ WINEDLLOVERRIDES='mscoree,mshtml,winemenubuilder.exe=;d3d10,d3d11=n,b'
+ WINE_REQ_MOD=('d3dx9' 'vcrun2019')
+ export WINE_REQ_MOD
+ export WINEPREFIX=/home/jacky/.local/share/leagueoflegends
+ WINEPREFIX=/home/jacky/.local/share/leagueoflegends
+ export 'INSTALL_DIR=/home/jacky/.local/share/leagueoflegends/drive_c/Riot Games'
+ INSTALL_DIR='/home/jacky/.local/share/leagueoflegends/drive_c/Riot Games'
+ export 'CLIENT_EXE=/home/jacky/.local/share/leagueoflegends/drive_c/Riot Games/Riot Client/RiotClientServices.exe'
+ CLIENT_EXE='/home/jacky/.local/share/leagueoflegends/drive_c/Riot Games/Riot Client/RiotClientServices.exe'
+ export MESA_GLTHREAD=true
+ MESA_GLTHREAD=true
+ export STAGING_SHARED_MEMORY=1
+ STAGING_SHARED_MEMORY=1
+ export WINE_LARGE_ADDRESS_AWARE=1
+ WINE_LARGE_ADDRESS_AWARE=1
+ export __GL_SHADER_DISK_CACHE=1
+ __GL_SHADER_DISK_CACHE=1
+ export __GL_SHADER_DISK_CACHE_PATH=/home/jacky/.local/share/leagueoflegends
+ __GL_SHADER_DISK_CACHE_PATH=/home/jacky/.local/share/leagueoflegends
+ export __GL_THREADED_OPTIMIZATIONS=1
+ __GL_THREADED_OPTIMIZATIONS=1
+ export DXVK_LOG_LEVEL=none
+ DXVK_LOG_LEVEL=none
+ export DXVK_STATE_CACHE_PATH=/home/jacky/.cache/leagueoflegends
+ DXVK_STATE_CACHE_PATH=/home/jacky/.cache/leagueoflegends
+ export WINEPREFIX=/home/jacky/.local/share/garena
+ WINEPREFIX=/home/jacky/.local/share/garena
+ WINE_REQ_MOD+=(vcrun2013)
+ export WINE_REQ_MOD
+ export 'INSTALL_DIR=/home/jacky/.local/share/garena/drive_c/Program Files/Garena'
+ INSTALL_DIR='/home/jacky/.local/share/garena/drive_c/Program Files/Garena'
+ export 'GARENA_EXE=/home/jacky/.local/share/garena/drive_c/Program Files/Garena/Garena/Garena.exe'
+ GARENA_EXE='/home/jacky/.local/share/garena/drive_c/Program Files/Garena/Garena/Garena.exe'
+ ls '/home/jacky/.local/share/garena/drive_c/Program Files/Garena/Games/32775/lol.version'
+++ ls '/home/jacky/.local/share/garena/drive_c/Program Files/Garena/Games/32775/lol.version'
+++ head -n1
++ dirname '/home/jacky/.local/share/garena/drive_c/Program Files/Garena/Games/32775/lol.version'
+ export 'GAME_DIR=/home/jacky/.local/share/garena/drive_c/Program Files/Garena/Games/32775'
+ GAME_DIR='/home/jacky/.local/share/garena/drive_c/Program Files/Garena/Games/32775'
+ export 'CLIENT_EXE=/home/jacky/.local/share/garena/drive_c/Program Files/Garena/Games/32775/Riot Client/RiotClientServices.exe'
+ CLIENT_EXE='/home/jacky/.local/share/garena/drive_c/Program Files/Garena/Games/32775/Riot Client/RiotClientServices.exe'
+ '[' '!' -f '/home/jacky/.local/share/garena/drive_c/Program Files/Garena/Games/32775/Riot Client/RiotClientServices.exe' ']'
+ name=RiotClientServices.exe
++ ps -C RiotClientServices.exe -o cmd=,
++ winepath -w '/home/jacky/.local/share/garena/drive_c/Program Files/Garena/Garena/Garena.exe'
++ sleep 1
++ ps -C RiotClientServices.exe -o cmd=,

Afterwards, it is just a 1 second sleep loop of the last line.

Screenshots

kyechou commented 2 years ago

Hi @drshapeless, thanks for the issue! I'm aware that it's not working with Garena yet since some of my previous updates, because Garena requires certain versions of wine. Though making the script work with Garena is quite simple, lately I haven't had enough time to get around to do it and test it. I'll take a look whenever possible. But any PR is also welcomed in the mean time. :)

kyechou commented 2 years ago

Hi @drshapeless, please check out the latest commit for the fix. Closing for now, please feel free to reopen the issue if needed. Thanks!

drshapeless commented 2 years ago

Sorry for my late response. I just tested it out. I successfully installed garena client and the game.

It did not work. Even worse, when I run league-of-legends start-garena, nothing happened. When I turned on verbose, it showed that the script stuck in a weird loop just as before. But this time, I could not even have the garena client shown up.

+ export WINEDEBUG=fixme-all
+ WINEDEBUG=fixme-all
+ shift
+ :
+ case "${1-}" in
+ break
+ case "${1-}" in
+ start_garena
+ export_env_variables_garena
+ export_env_variables
+ export PATH=/opt/wine-lol/bin:/opt/wine-lol/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/jacky/src/swift-language/swift/swift-nightly-install/usr/bin:/home/jacky/.local/bin:/home/jacky/bin:/home/jacky/src/swift-language/swift/swift-nightly-install/usr/bin:/home/jacky/.local/bin:/home/jacky/bin
+ PATH=/opt/wine-lol/bin:/opt/wine-lol/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/jacky/src/swift-language/swift/swift-nightly-install/usr/bin:/home/jacky/.local/bin:/home/jacky/bin:/home/jacky/src/swift-language/swift/swift-nightly-install/usr/bin:/home/jacky/.local/bin:/home/jacky/bin
+ export REGFILE=/usr/share/doc/leagueoflegends/leagueoflegends.reg
+ REGFILE=/usr/share/doc/leagueoflegends/leagueoflegends.reg
+ export ICON=/usr/share/icons/hicolor/256x256/apps/leagueoflegends.png
+ ICON=/usr/share/icons/hicolor/256x256/apps/leagueoflegends.png
+ export CACHE_DIR=/home/jacky/.cache/leagueoflegends
+ CACHE_DIR=/home/jacky/.cache/leagueoflegends
+ export WINEARCH=win32
+ WINEARCH=win32
+ export WINEDEBUG=-all
+ WINEDEBUG=-all
+ export 'WINEDLLOVERRIDES=mscoree,mshtml,winemenubuilder.exe=;d3d10,d3d11=n,b'
+ WINEDLLOVERRIDES='mscoree,mshtml,winemenubuilder.exe=;d3d10,d3d11=n,b'
+ WINE_REQ_MOD=('vcrun2019')
+ export WINE_REQ_MOD
+ export WINEPREFIX=/home/jacky/.local/share/leagueoflegends
+ WINEPREFIX=/home/jacky/.local/share/leagueoflegends
+ export 'INSTALL_DIR=/home/jacky/.local/share/leagueoflegends/drive_c/Riot Games'
+ INSTALL_DIR='/home/jacky/.local/share/leagueoflegends/drive_c/Riot Games'
+ export 'CLIENT_EXE=/home/jacky/.local/share/leagueoflegends/drive_c/Riot Games/Riot Client/RiotClientServices.exe'
+ CLIENT_EXE='/home/jacky/.local/share/leagueoflegends/drive_c/Riot Games/Riot Client/RiotClientServices.exe'
+ export MESA_GLTHREAD=true
+ MESA_GLTHREAD=true
+ export STAGING_SHARED_MEMORY=1
+ STAGING_SHARED_MEMORY=1
+ export WINE_LARGE_ADDRESS_AWARE=1
+ WINE_LARGE_ADDRESS_AWARE=1
+ export __GL_SHADER_DISK_CACHE=1
+ __GL_SHADER_DISK_CACHE=1
+ export __GL_SHADER_DISK_CACHE_PATH=/home/jacky/.local/share/leagueoflegends
+ __GL_SHADER_DISK_CACHE_PATH=/home/jacky/.local/share/leagueoflegends
+ export __GL_THREADED_OPTIMIZATIONS=1
+ __GL_THREADED_OPTIMIZATIONS=1
+ export DXVK_LOG_LEVEL=none
+ DXVK_LOG_LEVEL=none
+ export DXVK_STATE_CACHE=0
+ DXVK_STATE_CACHE=0
+ export WINEPREFIX=/home/jacky/.local/share/garena
+ WINEPREFIX=/home/jacky/.local/share/garena
+ WINE_REQ_MOD+=(vcrun2013)
+ export WINE_REQ_MOD
+ export 'INSTALL_DIR=/home/jacky/.local/share/garena/drive_c/Program Files/Garena'
+ INSTALL_DIR='/home/jacky/.local/share/garena/drive_c/Program Files/Garena'
+ export 'GARENA_EXE=/home/jacky/.local/share/garena/drive_c/Program Files/Garena/Garena/Garena.exe'
+ GARENA_EXE='/home/jacky/.local/share/garena/drive_c/Program Files/Garena/Garena/Garena.exe'
+ ls '/home/jacky/.local/share/garena/drive_c/Program Files/Garena/Games/32775/lol.version'
+++ ls '/home/jacky/.local/share/garena/drive_c/Program Files/Garena/Games/32775/lol.version'
+++ head -n1
++ dirname '/home/jacky/.local/share/garena/drive_c/Program Files/Garena/Games/32775/lol.version'
+ export 'GAME_DIR=/home/jacky/.local/share/garena/drive_c/Program Files/Garena/Games/32775'
+ GAME_DIR='/home/jacky/.local/share/garena/drive_c/Program Files/Garena/Games/32775'
+ export 'CLIENT_EXE=/home/jacky/.local/share/garena/drive_c/Program Files/Garena/Games/32775/Riot Client/RiotClientServices.exe'
+ CLIENT_EXE='/home/jacky/.local/share/garena/drive_c/Program Files/Garena/Games/32775/Riot Client/RiotClientServices.exe'
++ wine --version
++ sed s/wine-//
++ cut -d ' ' -f 1
+ WINE_VERSION=5.18
+ version_le 6.0 5.18
++ echo -e '6.0\n5.18'
++ sort -V
++ head -n1
+ lesser_version=5.18
+ '[' 6.0 = 5.18 ']'
++ echo /opt/wine-lol/bin:/opt/wine-lol/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/jacky/src/swift-language/swift/swift-nightly-install/usr/bin:/home/jacky/.local/bin:/home/jacky/bin:/home/jacky/src/swift-language/swift/swift-nightly-install/usr/bin:/home/jacky/.local/bin:/home/jacky/bin
++ sed s,/opt/wine-lol/bin:,,g
+ local PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/jacky/src/swift-language/swift/swift-nightly-install/usr/bin:/home/jacky/.local/bin:/home/jacky/bin:/home/jacky/src/swift-language/swift/swift-nightly-install/usr/bin:/home/jacky/.local/bin:/home/jacky/bin
+ export PATH_GARENA=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/jacky/src/swift-language/swift/swift-nightly-install/usr/bin:/home/jacky/.local/bin:/home/jacky/bin:/home/jacky/src/swift-language/swift/swift-nightly-install/usr/bin:/home/jacky/.local/bin:/home/jacky/bin
+ PATH_GARENA=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/jacky/src/swift-language/swift/swift-nightly-install/usr/bin:/home/jacky/.local/bin:/home/jacky/bin:/home/jacky/src/swift-language/swift/swift-nightly-install/usr/bin:/home/jacky/.local/bin:/home/jacky/bin
++ wine --version
++ cut -d ' ' -f 1
++ sed s/wine-//
+ WINE_GARENA_VERSION=7.2
+ version_le 6.0 7.2
++ echo -e '6.0\n7.2'
++ sort -V
++ head -n1
+ lesser_version=6.0
+ '[' 6.0 = 6.0 ']'
+ '[' '!' -f '/home/jacky/.local/share/garena/drive_c/Program Files/Garena/Games/32775/Riot Client/RiotClientServices.exe' ']'
+ find '/home/jacky/.local/share/garena/drive_c/Program Files/Garena' -type f -name '*libEGL.dll' -exec rm '{}' +
+ OLD_PATH=/opt/wine-lol/bin:/opt/wine-lol/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/jacky/src/swift-language/swift/swift-nightly-install/usr/bin:/home/jacky/.local/bin:/home/jacky/bin:/home/jacky/src/swift-language/swift/swift-nightly-install/usr/bin:/home/jacky/.local/bin:/home/jacky/bin
+ export PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/jacky/src/swift-language/swift/swift-nightly-install/usr/bin:/home/jacky/.local/bin:/home/jacky/bin:/home/jacky/src/swift-language/swift/swift-nightly-install/usr/bin:/home/jacky/.local/bin:/home/jacky/bin
+ PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/jacky/src/swift-language/swift/swift-nightly-install/usr/bin:/home/jacky/.local/bin:/home/jacky/bin:/home/jacky/src/swift-language/swift/swift-nightly-install/usr/bin:/home/jacky/.local/bin:/home/jacky/bin
+ name=RiotClientServices.exe
++ ps -C RiotClientServices.exe -o cmd=,
++ winepath -w '/home/jacky/.local/share/garena/drive_c/Program Files/Garena/Garena/Garena.exe'
++ sleep 1
++ ps -C RiotClientServices.exe -o cmd=,
++ sleep 1
kyechou commented 2 years ago

@drshapeless, Could you please share the content of /usr/bin/leagueoflegends? It's strange there's no line indicating the garena client was executed by wine from your log. Please put the log text in monospace format.

How long had you waited for the loop? The loop is supposed to happen when the garena client is running. So I suspect that it might be because of some display/graphics issue(?) Can you share the output of vulkaninfo --summary? Please also provide the output of pacman -Qi leagueoflegends-git.

I just tested it from scratch, and things seem to work just fine. I'm able to launch the garena client and open the league client, but because of my Internet geographical location, I won't be able to login within the league client. Here's the full log.

drshapeless commented 2 years ago

I had been waiting for at least 5 minutes. But from the log, I don't think Garena client has ever been launched. This is weird.

This is the script in my /usr/bin/leagueoflegends.

jacky ~ % cat /usr/bin/leagueoflegends  
#!/bin/bash

set -euo pipefail

msg() {
    echo -e "[+] ${1-}" >&2
}

die() {
    echo -e "[!] ${1-}" >&2
    exit 1
}

version_le() {
    lesser_version="$(echo -e "$1\n$2" | sort -V | head -n1)"
    [ "$1" = "$lesser_version" ]
}

askQ() {
    count=1
    first_arg="$2"
    echo
    echo "    $1"
    for var in "${@:2}"; do
        echo "    #$count - $2"
        ((count++))
        shift
    done
    echo
}

check_depends() {
    depends=(wine wineboot winetricks winecfg wineserver winepath curl)
    for dep in ${depends[@]}; do
        if ! command -v "$dep" >/dev/null 2>&1; then
            die "Missing $dep"
        fi
    done

    optdepends=(zenity)
    for dep in ${optdepends[@]}; do
        if command -v "$dep" >/dev/null 2>&1; then
            export "HAS_$(echo $dep | awk '{ print toupper($0) }')"=1
        fi
    done
}

check_syscall() {
    if [ "$(command -v wine)" = "/opt/wine-ge-lol/bin/wine" ]; then
        if [ "$(cat /proc/sys/abi/vsyscall32)" -ne 0 ]; then
            message=$(cat <<EOF
Your system is not configured to work with League's anticheat.
Please make sure the kernel parameter abi.vsyscall32 is set to 0.
For more detail, see https://github.com/kyechou/leagueoflegends
EOF
            )
            if [ ${HAS_ZENITY-0} -eq 1 ]; then
                zenity --warning --width=500 --title="League of Legends" \
                    --window-icon="$ICON" --text="$message"
            fi
            die "$message"
        fi
    fi
}

export_env_variables() {
    export PATH="/opt/wine-lol/bin:$PATH"
    export REGFILE="/usr/share/doc/leagueoflegends/leagueoflegends.reg"
    export ICON="/usr/share/icons/hicolor/256x256/apps/leagueoflegends.png"
    export CACHE_DIR="$HOME/.cache/leagueoflegends"

    export WINEARCH=win32
    export WINEDEBUG=-all
    export WINEDLLOVERRIDES="mscoree,mshtml,winemenubuilder.exe=;d3d10,d3d11=n,b"
    export WINE_REQ_MOD=(vcrun2019)
    export WINEPREFIX="$HOME/.local/share/leagueoflegends"
    export INSTALL_DIR="$WINEPREFIX/drive_c/Riot Games"
    export CLIENT_EXE="$INSTALL_DIR/Riot Client/RiotClientServices.exe"

    export MESA_GLTHREAD=true
    export STAGING_SHARED_MEMORY=1
    export WINE_LARGE_ADDRESS_AWARE=1
    export __GL_SHADER_DISK_CACHE=1
    export __GL_SHADER_DISK_CACHE_PATH="$WINEPREFIX"
    export __GL_THREADED_OPTIMIZATIONS=1
    export DXVK_LOG_LEVEL=none
    export DXVK_STATE_CACHE=0
}

export_env_variables_garena() {
    export_env_variables
    export WINEPREFIX="$HOME/.local/share/garena"
    WINE_REQ_MOD+=(vcrun2013)   # https://bugs.winehq.org/show_bug.cgi?id=47375
    export WINE_REQ_MOD
    export INSTALL_DIR="$WINEPREFIX/drive_c/Program Files/Garena"
    export GARENA_EXE="$INSTALL_DIR/Garena/Garena.exe"
    if ls "$INSTALL_DIR"/Games/*/lol.version &>/dev/null; then
        export GAME_DIR="$(dirname "$(ls "$INSTALL_DIR"/Games/*/lol.version | head -n1)")"
        export CLIENT_EXE="$GAME_DIR/Riot Client/RiotClientServices.exe"
    else
        export GAME_DIR=""
        export CLIENT_EXE=""
    fi

    WINE_VERSION="$(wine --version | cut -d ' ' -f 1 | sed 's/wine-//')"
    if version_le "6.0" "$WINE_VERSION"; then
        export PATH_GARENA="$PATH"
    else
        local PATH="$(echo "$PATH" | sed 's,/opt/wine-lol/bin:,,g')"
        export PATH_GARENA="$PATH"
        WINE_GARENA_VERSION="$(wine --version | cut -d ' ' -f 1 | sed 's/wine-//')"
        if ! version_le "6.0" "$WINE_GARENA_VERSION"; then
            die "The wine version $WINE_GARENA_VERSION is too old for running Garena client"
        fi
    fi
}

create_wineprefix() {
    if [ -e "$WINEPREFIX" ]; then
        die "Wineprefix $WINEPREFIX already exists"
    fi

    msg "Creating wineprefix: $WINEPREFIX"
    mkdir -p "$WINEPREFIX"
    wineboot --init
    msg "Installing winetricks verbs: ${WINE_REQ_MOD[*]}"
    winetricks -q --optout --force "${WINE_REQ_MOD[@]}"
    for link in "$WINEPREFIX/dosdevices"/*; do
        [[ "$link" =~ 'c:' ]] && continue # for drive_c
        [[ "$link" =~ 'z:' ]] && continue # for /
        msg "Removing unnecessary device $(basename $link)"
        unlink "$link"
    done
    msg "Modifying WINE registry with $REGFILE"
    regedit "$REGFILE"
    msg "Waiting for wine processes..."
    wineserver --wait
    add_dxvk
    msg "Wineprefix created: $WINEPREFIX"
}

install_LoL() {
    if [ ! -d "$WINEPREFIX" ]; then
        create_wineprefix
    elif [ -f "$CLIENT_EXE" ]; then
        while :; do
            echo -n "[!] The game has been installed. Install anyway? [Y/n] "
            read force
            force="$(echo "$force" | tr '[:upper:]' '[:lower:]')"
            if [ -z "${force##y*}" ]; then
                break
            elif [ -z "${force##n*}" ]; then
                exit 1
            fi
        done
    fi

    askQ "Select your region" \
        "North America" "EU West" "EU Nordic & East" "Latin America North" \
        "Latin America South" "Brazil" "Turkey" "Russia" "Japan" "Oceania" \
        "Republic of Korea"
    read -p "    #: " answer

    case "${answer}" in
        1) # North America
            export LANG_CODE="na" ;;
        2) # EU West
            export LANG_CODE="euw" ;;
        3) # EU Nordic & East
            export LANG_CODE="eune" ;;
        4) # Latin America North
            export LANG_CODE="la1" ;;
        5) # Latin America South
            export LANG_CODE="la2" ;;
        6) # Brazil
            export LANG_CODE="br" ;;
        7) # Turkey
            export LANG_CODE="tr" ;;
        8) # Russia
            export LANG_CODE="ru" ;;
        9) # Japan
            export LANG_CODE="jp" ;;
        10) # Oceania
            export LANG_CODE="oc1" ;;
        11) # Republic of Korea
            export LANG_CODE="kr" ;;
        *)
            die "Unknown region number: $answer" ;;
    esac

    INSTALLER="$CACHE_DIR/installer.$LANG_CODE.exe"
    INSTALLER_URL="https://lol.secure.dyn.riotcdn.net/channels/public/x/installer/current/live.$LANG_CODE.exe"

    if [ ! -e "$INSTALLER" ]; then
        msg "Downloading installer..."
        mkdir -p "$CACHE_DIR"
        curl --silent --show-error -Lo "$INSTALLER" "$INSTALLER_URL"
    fi
    msg "Installing League of Legends..."
    wine "$(winepath -w "$INSTALLER")"
    msg "Waiting for wine processes..."
    wineserver --wait
    msg "The game is installed at $INSTALL_DIR"
}

install_garena() {
    # Create the wine environment from which we launch the game
    if [ ! -d "$WINEPREFIX" ]; then
        create_wineprefix
    fi

    export_env_variables_garena

    # Create the wine environment in which the game is installed
    if [ ! -d "$WINEPREFIX" ]; then
        create_wineprefix
    elif [ -f "$CLIENT_EXE" ]; then
        while :; do
            echo -n "[!] The game has been installed. Remove it and reinstall? [Y/n] "
            read remove
            remove="$(echo "$remove" | tr '[:upper:]' '[:lower:]')"
            if [ -z "${remove##y*}" ]; then
                rm -rf "$INSTALL_DIR"
                break
            elif [ -z "${remove##n*}" ]; then
                exit 1
            fi
        done
    fi

    askQ "Select your region" \
        "Taiwan, Hong Kong, Macau" \
        "Singapore, Malaysia, Indonesia, Philippines" \
        "Vietnam" \
        "Thailand"
    read -p "    #: " answer

    case "${answer}" in
        1) # Taiwan, Hong Kong, Macau
            export LANG_CODE="tw"
            export URL="https://cdn.gxx.garenanow.com/gxx/pc/installer/Garena-v2.0-TW.exe"
            ;;
        2) # Singapore, Malaysia, Indonesia, Philippines
            export LANG_CODE="sg"
            export URL="https://cdn.gxx.garenanow.com/gxx/pc/installer/Garena-v2.0.exe"
            ;;
        3) # Vietnam
            export LANG_CODE="vn"
            export URL="https://cdn.gxx.garenanow.com/gxx/pc/installer/Garena-v2.0-VN.exe"
            ;;
        4) # Thailand
            export LANG_CODE="th"
            export URL="https://cdn.gxx.garenanow.com/gxx/pc/gameinst/Garena-v2.0-LOLTH.exe"
            ;;
        *)
            die "Unknown region number: $answer" ;;
    esac

    INSTALLER="$CACHE_DIR/garena-installer.$LANG_CODE.exe"
    if [ ! -e "$INSTALLER" ]; then
        msg "Downloading Garena..."
        mkdir -p "$CACHE_DIR"
        curl --silent --show-error -Lo "$INSTALLER" "$URL"
    fi
    msg "Installing Garena..."
    wine "$(winepath -w "$INSTALLER")" &
    pid=$!
    until ! ps -p $pid >/dev/null; do sleep 1; done
    wineserver --kill
    wineserver --wait
    msg "Garena is installed at $INSTALL_DIR/Garena"

    msg "Installing LoL from Garena..."
    wine "$(winepath -w "$GARENA_EXE")" &
    pid=$!
    until ! ps -p $pid >/dev/null; do sleep 1; done
    wineserver --kill
    wineserver --wait
    export_env_variables_garena
    msg "The game is installed at $GAME_DIR"
}

uninstall_LoL() {
    msg "Uninstalling league of legends..."
    set +e
    rm -rf "$CACHE_DIR" "$WINEPREFIX"

    # clean up menu entries
    rm -rf \
        ~/.config/menus/applications-merged/*-League\ of\ Legends* \
        ~/.local/share/applications/wine/Programs/Riot\ Games \
        ~/.local/share/desktop-directories/*-League\ of\ Legends.directory \
        ~/.local/share/desktop-directories/*-Riot\ Games.directory
    find -H ~/.config/menus/applications-merged -empty -delete
    find -H ~/.config/menus -empty -delete
    find -H ~/.local/share/applications/wine/Programs -empty -delete
    find -H ~/.local/share/applications/wine -empty -delete
    find -H ~/.local/share/applications -empty -delete
    set -e
}

uninstall_garena() {
    export_env_variables_garena

    msg "Uninstalling Garena..."
    rm -rf "$WINEPREFIX"
}

#
# https://www.reddit.com/r/leagueoflinux/comments/j07yrg/starting_the_client_script/
#
port_waiting_daemon() {
    # Find PID
    process=LeagueClientUx.exe
    uxpid=$(timeout 2m sh -c "until ps -C $process -o pid=; do sleep 1; done | sed 's/[[:space:]]*//g'")
    if [ -z "$uxpid" ]; then
        die "Could not find process ${process}"
    fi

    # Get the app-port parameter
    port=$(xargs -0 <"/proc/${uxpid}/cmdline" | sed -n 's/.*--app-port=\([[:digit:]]*\).*/\1/p')
    if [ -z "$port" ]; then
        die "Could not find --app-port of LeagueClientUx.exe"
    fi

    # Suspend the league client until app-port gets available
    kill -STOP ${uxpid}
    timeout 5m bash -c "
    until openssl s_client -connect :${port} <<< Q >/dev/null 2>&1; do
        sleep 1
    done"
    kill -CONT ${uxpid}
}

loading_screen() {
    if [ ${HAS_ZENITY-0} -eq 1 ]; then
        zenity --progress --pulsate --auto-close --no-cancel \
            --title="League of Legends" --window-icon="$ICON" \
            --text="Waiting for the League client port to open..."
    fi
}

start_LoL() {
    if [ ! -f "$CLIENT_EXE" ]; then
        while :; do
            echo -n "[!] The game is not installed. Install it? [Y/n] "
            read install
            install="$(echo "$install" | tr '[:upper:]' '[:lower:]')"
            if [ -z "${install##y*}" ]; then
                install_LoL
                break
            elif [ -z "${install##n*}" ]; then
                exit 1
            fi
        done
    fi

    # prelaunch helper
    ( port_waiting_daemon ) | loading_screen &

    msg "Starting..."
    wine "$(winepath -w "$CLIENT_EXE")" \
        --launch-product=league_of_legends \
        --launch-patchline=live
    wineserver --wait
    wait
}

start_garena() {
    export_env_variables_garena

    if [ ! -f "$CLIENT_EXE" ]; then
        while :; do
            echo -n "[!] The game is not installed. Install it? [Y/n] "
            read install
            install="$(echo "$install" | tr '[:upper:]' '[:lower:]')"
            if [ -z "${install##y*}" ]; then
                install_garena
                break
            elif [ -z "${install##n*}" ]; then
                exit 1
            fi
        done
    fi

    # Remove libEGL.dll files for Garena client having blank screen
    find "$INSTALL_DIR" -type f -name '*libEGL.dll' -exec rm {} +

    # Start Garena in the background with wine >= 6.0
    # Note that Garena is unsupported if wine-lol=5.18 is used.
    # https://github.com/nhubaotruong/league-of-legends-linux-garena-script
    # https://www.reddit.com/r/leagueoflinux/comments/jzbfzb/
    # https://www.reddit.com/r/leagueoflinux/comments/jzbfzb/comment/gt7td4k/
    OLD_PATH=$PATH
    export PATH=$PATH_GARENA
    wine "$(winepath -w "$GARENA_EXE")" &

    # Get the Riot Client pid and command-line argument
    name=RiotClientServices.exe
    process="$(until ps -C $name -o cmd=,; do sleep 1; done)"
    riot_argument="$(echo "$process" | awk -F '.exe ' '{print $2}')"

    # Kill the Garena process
    wineserver --kill
    wineserver --wait

    # prelaunch helper
    ( port_waiting_daemon ) | loading_screen &

    # Launch the game directly with the riot argument (garena tokens)
    msg "Starting..."
    export PATH=$OLD_PATH
    wine "$(winepath -w "$CLIENT_EXE")" $riot_argument
    wineserver --wait
    wait
}

download_dxvk() {
    DXVK_VERSION="$(curl -s https://api.github.com/repos/doitsujin/dxvk/releases/latest | grep 'tag_name' | cut -d\" -f4 | tr -d v)"
    DXVK_URL="https://github.com/doitsujin/dxvk/releases/download/v$DXVK_VERSION/dxvk-$DXVK_VERSION.tar.gz"
    DXVK_TARBALL="$CACHE_DIR/dxvk-$DXVK_VERSION.tar.gz"

    if [ ! -e "$DXVK_TARBALL" ]; then
        msg "Downloading DXVK tarball"
        mkdir -p "$CACHE_DIR"
        curl --silent --show-error -Lo "$DXVK_TARBALL" "$DXVK_URL"
    fi
    msg "Extracting DXVK tarball..."
    tar xzf "$DXVK_TARBALL" -C "$CACHE_DIR"
}

rm_dxvk_cache() {
    if [ -d "$CACHE_DIR" ]; then
        find "$CACHE_DIR" -type f -name '*.dxvk-cache' -exec rm {} +
    fi
}

add_dxvk() {
    if [ ! -d "$WINEPREFIX" ]; then
        die "The game is not installed. Please install it first"
    fi

    download_dxvk
    msg "Installing DXVK to $WINEPREFIX"
    "$CACHE_DIR/dxvk-$DXVK_VERSION/setup_dxvk.sh" install --with-d3d10
    msg "DXVK is installed"
}

del_dxvk() {
    if [ ! -d "$WINEPREFIX" ]; then
        die "The game is not installed. Please install it first"
    fi

    download_dxvk
    msg "Uninstalling DXVK from $WINEPREFIX"
    "$CACHE_DIR/dxvk-$DXVK_VERSION/setup_dxvk.sh" uninstall
    msg "DXVK is removed"
}

cleanup_logs() {
    msg "Cleaning up log files..."
    if [ -d "$INSTALL_DIR" ]; then
        find -H "$INSTALL_DIR" -name "*.log" -delete -print
        if [ -d "$INSTALL_DIR/League of Legends/Logs" ]; then
            find -H "$INSTALL_DIR/League of Legends/Logs" -type f -delete -print
            find -H "$INSTALL_DIR/League of Legends/Logs" -empty -delete -print
        fi
    fi
}

usage() {
    cat <<EOF
[!] Usage: $(basename "${BASH_SOURCE[0]}") [options] <command>

    League of Legends - helper program

    Options:
        -h, --help          Print this message and exit
        -v, --verbose       Enable verbose output

    Commands:
        start               Start LoL
        install             Install LoL
        uninstall           Uninstall LoL
        reinstall           Reinstall LoL
        start-garena        Start Garena
        install-garena      Install Garena
        uninstall-garena    Uninstall Garena
        reinstall-garena    Reinstall Garena
        add-dxvk            Install DXVK to the LoL wineprefix
        del-dxvk            Remove DXVK from the LoL wineprefix
        rm-dxvk-cache       Remove DXVK cache
        cleanup-logs        Remove log files
        kill                Kill the wine processes of the wineprefix
        kill-garena         Kill the Garena wine processes
        run <cmd>           Run shell command with environment variables
        run-garena <cmd>    Run shell command with environment variables
EOF
}

main() {
    check_depends
    export_env_variables
    check_syscall

    while :; do
        case "${1-}" in
        -h | --help) usage; exit ;;
        -v | --verbose) set -x; export WINEDEBUG=fixme-all ;;
        --) shift; break ;;
        -?*) die "Unknown option: ${1-}\n$(usage)" ;;
        *) break ;;
        esac
        shift
    done

    case "${1-}" in
        start) start_LoL ;;
        install) install_LoL ;;
        uninstall) uninstall_LoL ;;
        reinstall) uninstall_LoL && install_LoL ;;
        start-garena) start_garena ;;
        install-garena) install_garena ;;
        uninstall-garena) uninstall_garena ;;
        reinstall-garena) uninstall_garena && install_garena ;;
        add-dxvk) add_dxvk ;;
        del-dxvk) del_dxvk ;;
        rm-dxvk-cache) rm_dxvk_cache ;;
        cleanup-logs) cleanup_logs ;;
        kill)
            wineserver --kill
            pkill -f -- '--title=League of Legends' # kill the zenity dialog
            ;;
        kill-garena)
            export_env_variables_garena
            wineserver --kill
            pkill -f -- '--title=League of Legends' # kill the zenity dialog
            ;;
        run) shift; $@ ;;
        run-garena) shift; export_env_variables_garena; $@ ;;
        *) die "Unknown command: ${1-}\n$(usage)" ;;
    esac
}

main $@

# vim: set ts=4 sw=4 et:

This is the vulkaninfo --summary, but sorry for this, I am now at work and using ssh to my home machine to show the info, something is missing. But I don't think vulkan is the problem, because I am able to use lutris to play league without issues.


jacky ~ % vulkaninfo --summary
'DISPLAY' environment variable not set... skipping surface info
==========
VULKANINFO
==========

Vulkan Instance Version: 1.2.203

Instance Extensions: count = 18
-------------------------------
VK_EXT_acquire_xlib_display            : extension revision 1
VK_EXT_debug_report                    : extension revision 10
VK_EXT_debug_utils                     : extension revision 2
VK_EXT_direct_mode_display             : extension revision 1
VK_EXT_display_surface_counter         : extension revision 1
VK_KHR_device_group_creation           : extension revision 1
VK_KHR_display                         : extension revision 23
VK_KHR_external_fence_capabilities     : extension revision 1
VK_KHR_external_memory_capabilities    : extension revision 1
VK_KHR_external_semaphore_capabilities : extension revision 1
VK_KHR_get_display_properties2         : extension revision 1
VK_KHR_get_physical_device_properties2 : extension revision 2
VK_KHR_get_surface_capabilities2       : extension revision 1
VK_KHR_surface                         : extension revision 25
VK_KHR_surface_protected_capabilities  : extension revision 1
VK_KHR_wayland_surface                 : extension revision 6
VK_KHR_xcb_surface                     : extension revision 6
VK_KHR_xlib_surface                    : extension revision 6

Instance Layers: count = 10
---------------------------
VK_LAYER_KHRONOS_validation       Khronos Validation Layer       1.2.203  version 1
VK_LAYER_LUNARG_api_dump          LunarG API dump layer          1.2.189  version 2
VK_LAYER_LUNARG_device_simulation LunarG device simulation layer 1.2.189  version 1
VK_LAYER_LUNARG_monitor           Execution Monitoring Layer     1.2.189  version 1
VK_LAYER_LUNARG_screenshot        LunarG image capture layer     1.2.189  version 1
VK_LAYER_NV_optimus               NVIDIA Optimus layer           1.3.194  version 1
VK_LAYER_VALVE_steam_fossilize_32 Steam Pipeline Caching Layer   1.2.136  version 1
VK_LAYER_VALVE_steam_fossilize_64 Steam Pipeline Caching Layer   1.2.136  version 1
VK_LAYER_VALVE_steam_overlay_32   Steam Overlay Layer            1.2.136  version 1
VK_LAYER_VALVE_steam_overlay_64   Steam Overlay Layer            1.2.136  version 1

Devices:
========
GPU0:
        apiVersion         = 4206786 (1.3.194)
        driverVersion      = 2139979776 (0x7f8d8000)
        vendorID           = 0x10de
        deviceID           = 0x1e89
        deviceType         = PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
        deviceName         = NVIDIA GeForce RTX 2060
        driverID           = DRIVER_ID_NVIDIA_PROPRIETARY
        driverName         = NVIDIA
        driverInfo         = 510.54
        conformanceVersion = 1.3.0.0

jacky ~ % pacman -Qi leagueoflegends-git
Name            : leagueoflegends-git
Version         : 0.12.3.r1.g040b76b-1
Description     : League of Legends helper script
Architecture    : any
URL             : https://github.com/kyechou/leagueoflegends
Licenses        : GPL3
Groups          : None
Provides        : leagueoflegends
Depends On      : winetricks-git  bash  curl  openssl  samba  lib32-gnutls
                  lib32-libldap  lib32-openal  lib32-libpulse  lib32-alsa-lib
                  lib32-mpg123  lib32-unixodbc  lib32-vkd3d  vulkan-icd-loader
                  lib32-vulkan-icd-loader  vulkan-driver  lib32-vulkan-driver  wine-lol
Optional Deps   : lib32-amdvlk: AMD Vulkan driver
                  lib32-nvidia-utils: NVIDIA Vulkan driver [installed]
                  lib32-vulkan-intel: Intel's Vulkan mesa driver
                  lib32-vulkan-radeon: Radeon's Vulkan mesa driver
                  zenity: Loading screen indication [installed]
Required By     : None
Optional For    : None
Conflicts With  : leagueoflegends  leagueoflegends-ge-git
Replaces        : None
Installed Size  : 133.13 KiB
Packager        : Unknown Packager
Build Date      : Tue 22 Feb 2022 01:43:56 PM HKT
Install Date    : Tue 22 Feb 2022 01:43:59 PM HKT
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : None

Something worth mention is that, I discovered that using wine version > 7.1 will not be able to launch the Garena client, it will result in a blank white screen in the middle with no response. Using a lower version of wine to launch Garena is a much more reliable approach, e.g. wine6.14 is quite stable. Afterwards, we can use a higher version of wine to launch the league client. I doubt that if the issue is caused by the wine-lol-glibc, because I have not been successfully launch league client with that for at least two months. Switching to wine-ge may have solved the issue, I may test it tonight.

Last, sorry for a dumb question, is setting abi.vsyscall32=0 necessary to use wine-ge? Since I was able to use lutris and run league with wine-ge without setting it. I am not sure what black magic lutris did to make it run.

kyechou commented 2 years ago

Hi @drshapeless , thanks for the details!

Something worth mention is that, I discovered that using wine version > 7.1 will not be able to launch the Garena client, it will result in a blank white screen in the middle with no response. Using a lower version of wine to launch Garena is a much more reliable approach, e.g. wine6.14 is quite stable.

You're right, the more recent versions of wine may render the Garena client blank, but removing the libEGL.dll files solves the problem for me, which has already been added in the script (i.e., the find command in the start_garena function). I agree that maybe having a slightly lower version of wine (>=6.0 but <=7.1) may work better for the Garena client.

I doubt that if the issue is caused by the wine-lol-glibc, because I have not been successfully launch league client with that for at least two months.

The current script uses the "wine" in the default path locations (possibly /usr/bin/wine) to run the Garena client, instead of wine-lol or wine-ge-lol, so the issue most likely isn't caused by wine-lol-glibc. However, you could install some other package that provides "wine" (maybe from https://archive.archlinux.org/packages/w/wine/?), which would still satisfy the dependencies as long as the version is at least 6.0.

Switching to wine-ge may have solved the issue, I may test it tonight.

Switching to wine-ge (or wine-lol) would only have effect on the league client and game, but not on the Garena client.

As for the league client, either wine-lol or wine-ge-lol should work. (Note that they're only used for launching the league client rather than the Garena client.) wine-lol is based on 5.18, and both of them are working fine with at least the Riot-based league client of the NA region that I tested.

is setting abi.vsyscall32=0 necessary to use wine-ge? Since I was able to use lutris and run league with wine-ge without setting it. I am not sure what black magic lutris did to make it run.

Yes, setting abi.vsyscall32=0 is necessary for wine-ge-lol, which is exactly the same as what Lutris did. Here's their script for checking the variable. You can check the current setting by running sysctl abi.vsyscall32. On the first time you ran wine-ge through Lutris, if your system has abi.vsyscall32=1, it should've asked you something about League's anti-cheat mechanism and whether you want to change the setting now. It then basically set the variable for you if you agree.

kyechou commented 1 year ago

After the recent update of wine-lol (7.14), some things mentioned above do not apply anymore. Please try again with the new version and reinstall the game. I haven't had much time testing and making sure Garena works, so any PR is appreciated. Closing for now. Please open up a new issue if things don't work.

drshapeless commented 1 year ago

I can install Garena successfully. But it only shows a blank window, buttons are clickable. This is a known visual bug when we enable DXVK to launch garena client. I know how to set it in Lutris, but have no idea how to set it here.

Is there any way to disable DXVK when launching garena but not the game?

drshapeless commented 1 year ago

The game was downloaded. However, the client launched is not the desired one. It is the english client instead of my localized one. Maybe there is something wrong in the path to launch the different client for different regions?

kyechou commented 1 year ago

Is there any way to disable DXVK when launching garena but not the game?

Yes, please check out the README document, or run leagueoflegends --help.

The game was downloaded. However, the client launched is not the desired one. It is the english client instead of my localized one. Maybe there is something wrong in the path to launch the different client for different regions?

I won't be able to look into the issue until at least October. As mentioned, please open up a new issue, and pull requests would be also helpful!