Skip to content

armgit / soju

Public Imported from GitHub
0

Play Windows games on Apple Silicon Macs. Free, open-source app that installs the official Battle.net, Steam, Epic and GOG launchers and lists your games in one library.

Steam with GPTK: Rockstar games start Steam on the launcher engine (#236) (#237)

Mikek165c8b3c6cc6
diff --git a/scripts/play.sh b/scripts/play.sh
index 0f923445111..89380df7922 100755
--- a/scripts/play.sh
+++ b/scripts/play.sh
@@ -390,9 +390,36 @@ case "$MODE" in
# (scripts/steam-gptk-engine.sh). Same wrapper and flags as below; games
# get D3DMetal like Battle.net games, and no Wine 11 steps apply.
ENGINE=$(bash "$(dirname "${BASH_SOURCE[0]}")/steam-gptk-engine.sh") || exit 1
+ # Rockstar games sold on Steam start the Rockstar Games Launcher in this bottle first. With Apple's D3D11
+ # it stops at "The Rockstar Games Launcher failed to initialize!" and Steam then says "Unable to launch
+ # game" (#236); on the launcher engine (DXMT's D3D11, D3D12 still D3DMetal) it opens, as in its own
+ # bottle. So Steam runs on that engine for these games, restarted if it is open on the other one.
+ # .soju-steam-engine says which engine the open Steam runs on (the launcher engine also runs other bottles,
+ # so its wineserver alone does not tell).
+ STEAM_ON=$(cat "$WINEPREFIX/.soju-steam-engine" 2>/dev/null || true); [ -n "$STEAM_ON" ] || STEAM_ON="$ENGINE"
+ STEAM_OPEN=0; pgrep -f 'Steam.steam\.exe' >/dev/null 2>&1 && STEAM_OPEN=1
+ case " 1174180 271590 3240220 12210 204100 2668510 1546970 1546990 1547000 " in
+ *" ${STEAM_APP:-none} "*) ENGINE=$(bash "$(dirname "${BASH_SOURCE[0]}")/launcher-engine.sh") || exit 1 ;;
+ # Opening Steam itself: hand it to Steam on the engine it is open on.
+ *) [ -z "$STEAM_APP" ] && [ "$STEAM_OPEN" = 1 ] && [ -x "$STEAM_ON/bin/wine" ] && ENGINE="$STEAM_ON" ;;
+ esac
+ if [ -n "$STEAM_APP" ] && [ "$STEAM_OPEN" = 1 ] && [ "$STEAM_ON" != "$ENGINE" ]; then
+ echo "Restarting Steam for this game: Rockstar games need another graphics setup for their launcher"
+ bash "${BASH_SOURCE[0]}" steam-kill >/dev/null 2>&1 || true
+ for _ in $(seq 1 30); do pgrep -f 'Steam.steam\.exe' >/dev/null 2>&1 || break; sleep 1; done
+ STEAM_COLD=1
+ STEAM_WATCH=(python3 "$(dirname "${BASH_SOURCE[0]}")/steam_launch.py" watch "$WINEPREFIX/drive_c/Program Files (x86)/Steam" "$STEAM_APP" --seconds 150 --)
+ fi
+ printf '%s\n' "$ENGINE" > "$WINEPREFIX/.soju-steam-engine"
dlss_on
export CX_APPLEGPTK_LIBD3DSHARED_PATH="$ENGINE/lib/external/libd3dshared.dylib"
export DYLD_FALLBACK_LIBRARY_PATH="$ENGINE/lib:/usr/lib"
+ # The Rockstar Games Library Service starts slowly under Rosetta; Wine stops waiting after 10 s by default
+ # (create-launcher-bottle.sh sets the same for the Rockstar bottle).
+ if [ ! -f "$WINEPREFIX/.soju-services-timeout" ]; then
+ "$ENGINE/bin/wine" reg add 'HKLM\System\CurrentControlSet\Control' /v ServicesPipeTimeout /t REG_SZ /d 60000 /f >/dev/null 2>&1 \
+ && : > "$WINEPREFIX/.soju-services-timeout"
+ fi
ST="$WINEPREFIX/drive_c/Program Files (x86)/Steam/steam.exe"
[[ -f "$ST" ]] || { echo "Steam not found in $WINEPREFIX; run: soju steam-gptk on"; exit 1; }
find "$WINEPREFIX/drive_c/users/"*/AppData/Local/Steam/htmlcache -maxdepth 2 \
@@ -575,6 +602,9 @@ case "$MODE" in
WINEPREFIX="$S_BASE/steam-bottle" "$STEAM_WINE_ROOT/bin/wineserver" -k 2>/dev/null || true
[ ! -d "$S_BASE/steam-gptk-bottle" ] || [ ! -x "$S_BASE/cx26-engine-steam/bin/wineserver" ] || \
WINEPREFIX="$S_BASE/steam-gptk-bottle" "$S_BASE/cx26-engine-steam/bin/wineserver" -k 2>/dev/null || true
+ # Steam on the launcher engine for a Rockstar game (see the steam case above).
+ [ ! -d "$S_BASE/steam-gptk-bottle" ] || [ ! -x "$S_BASE/cx26-engine-launchers/bin/wineserver" ] || \
+ WINEPREFIX="$S_BASE/steam-gptk-bottle" "$S_BASE/cx26-engine-launchers/bin/wineserver" -k 2>/dev/null || true
for b in "$S_BASE/steam-bottle" "$S_BASE/steam-gptk-bottle"; do [ ! -d "$b" ] || bottle_kill_leftovers "$b" || true; done
sleep 2; [ ! -x "$SWEEP" ] || "$SWEEP"
;;
diff --git a/scripts/steam-gptk.sh b/scripts/steam-gptk.sh
index a46cc0e022a..a8b4f9b3c8b 100755
--- a/scripts/steam-gptk.sh
+++ b/scripts/steam-gptk.sh
@@ -23,6 +23,13 @@ source "$ROOT/scripts/steam-runtime.sh"
steam_running(){
pgrep -f "$BASE/cx26-engine-steam/(lib/wine/\.\./\.\./)?bin/wineserver" >/dev/null 2>&1 && return 0
+ # For a Rockstar game play.sh starts Steam in the GPTK bottle on the launcher engine (#236) and writes which
+ # engine to .soju-steam-engine. That engine's wineserver also serves the EA, Rockstar and Ubisoft bottles, so
+ # the mark and the Steam client itself tell whether Steam is open there.
+ local on; on=$(cat "$GPTK/.soju-steam-engine" 2>/dev/null || true)
+ if [ -n "$on" ] && [ "$on" != "$BASE/cx26-engine-steam" ] && pgrep -f 'Steam.steam\.exe' >/dev/null 2>&1; then
+ return 0
+ fi
! python3 "$ROOT/scripts/steam-session.py" idle "$STEAM_WINE_ROOT" >/dev/null 2>&1
}
diff --git a/tests/test_steam_gptk.py b/tests/test_steam_gptk.py
index cabfc096f0b..46de024ee18 100644
--- a/tests/test_steam_gptk.py
+++ b/tests/test_steam_gptk.py
@@ -35,6 +35,28 @@ class SteamGPTKTests(unittest.TestCase):
self.put('steam-gptk-bottle/' + CLIENT)
self.assertEqual(self.gptk('status').stdout.strip(), 'on')
+ def test_off_waits_for_steam_open_on_the_launcher_engine(self):
+ # Steam started for a Rockstar game runs on the launcher engine (#236); switching modes must still see it.
+ self.put('steam-bottle/' + CLIENT)
+ self.put('steam-gptk-bottle/' + CLIENT)
+ self.put('steam-gptk')
+ stub = self.base / 'stub-bin'
+ stub.mkdir()
+ (stub / 'pgrep').write_text('#!/bin/sh\ncase "$*" in *steam*exe*) exit 0 ;; esac\nexit 1\n')
+ (stub / 'pgrep').chmod(0o755)
+ env = dict(os.environ, SOJU_BASE=str(self.base), PATH=f'{stub}:{os.environ["PATH"]}')
+ run = lambda: subprocess.run(['bash', str(ROOT / 'scripts/steam-gptk.sh'), 'off'], env=env,
+ capture_output=True, text=True, timeout=60)
+ (self.base / 'steam-gptk-bottle/.soju-steam-engine').write_text(str(self.base / 'cx26-engine-launchers') + '\n')
+ result = run()
+ self.assertNotEqual(result.returncode, 0)
+ self.assertIn('quit Steam first', result.stderr)
+ self.assertTrue((self.base / 'steam-gptk').exists())
+ # Steam on the GPTK engine is found by its wineserver instead; the mark alone does not count.
+ (self.base / 'steam-gptk-bottle/.soju-steam-engine').write_text(str(self.base / 'cx26-engine-steam') + '\n')
+ self.assertEqual(run().returncode, 0)
+ self.assertFalse((self.base / 'steam-gptk').exists())
+
def test_on_needs_steam_installed(self):
result = self.gptk('on')
self.assertNotEqual(result.returncode, 0)