From 428dfbe99a96422dc64ad76454f701cc014ff687 Mon Sep 17 00:00:00 2001 From: Chase Cichorz Date: Tue, 24 Nov 2026 11:36:30 -0500 Subject: [PATCH] Add Ambush installer and Wine timer compatibility Install the current lowercase archive layout, preserve the game speech client, and load a game-local winmm proxy for Wine timer compatibility. Stop on installation or DLL setup failures and initialize the launcher title for CLI installation. Validation: Bash syntax checks and ShellCheck; 13 isolated Ambush checks including failure handling, repeat installation, ZIP extraction, and CLI title; RS Games and action menu tests. Live Wine gameplay and speech remain unverified. --- .install/Ambush.sh | 39 ++++++ audiogame-manager.sh | 3 + game-scripts/ambush-winmm/README.md | 45 +++++++ game-scripts/ambush-winmm/winmm.c | 10 ++ game-scripts/ambush-winmm/winmm.def | 188 ++++++++++++++++++++++++++++ game-scripts/ambush-winmm/winmm.dll | Bin 0 -> 25466 bytes tests/ambush_installer_tests.sh | 136 ++++++++++++++++++++ 7 files changed, 421 insertions(+) create mode 100644 .install/Ambush.sh create mode 100644 game-scripts/ambush-winmm/README.md create mode 100644 game-scripts/ambush-winmm/winmm.c create mode 100644 game-scripts/ambush-winmm/winmm.def create mode 100755 game-scripts/ambush-winmm/winmm.dll create mode 100644 tests/ambush_installer_tests.sh diff --git a/.install/Ambush.sh b/.install/Ambush.sh new file mode 100644 index 0000000..b3dedbb --- /dev/null +++ b/.install/Ambush.sh @@ -0,0 +1,39 @@ +# shellcheck shell=bash disable=SC2154 # installer is sourced by audiogame-manager with shared globals +export WINEARCH=win64 +export winVer="win10" +install_wine_bottle || exit 1 +download "https://altaistudiogames.com/ambush.zip" || exit 1 +# Preserve extraction failures through the progress dialog's pipeline. +if ! ( + set -o pipefail + install_with_progress unzip "Extracting game files..." -d "$WINEPREFIX/drive_c/Program Files" "${cache}/ambush.zip" +); then + agm_msgbox "Ambush" "Ambush" "Could not extract Ambush. No launcher was added." + exit 1 +fi +ambushDir="$WINEPREFIX/drive_c/Program Files/ambush" +if [[ ! -f "${ambushDir}/Ambush.exe" ]]; then + agm_msgbox "Ambush" "Ambush" "Ambush did not install to the expected location: ${ambushDir}" + exit 1 +fi +# Wine's timeGetTime trips Ambush's speed hack detection. See game-scripts/ambush-winmm/README.md. +if [[ ! -f "${WINEPREFIX}/drive_c/windows/system32/winmm.dll" ]] || + ! cp -f "${scriptDir}/game-scripts/ambush-winmm/winmm.dll" "${ambushDir}/winmm.dll" || + ! ln -sfn "../../windows/system32/winmm.dll" "${ambushDir}/winmm_wine.dll"; then + agm_msgbox "Ambush" "Ambush" "Could not install Ambush's Wine timer support. No launcher was added." + exit 1 +fi +# Audiogame Manager replaces regular nvdaControllerClient*.dll files at launch, and the +# replacement makes Ambush's login() throw. Keep the game's own client behind a symlink, +# which the replacement skips. +if [[ -f "${ambushDir}/nvdaControllerClient64.dll" && ! -L "${ambushDir}/nvdaControllerClient64.dll" ]]; then + if ! mv -f "${ambushDir}/nvdaControllerClient64.dll" "${ambushDir}/ambush-nvda-client64.orig"; then + agm_msgbox "Ambush" "Ambush" "Could not preserve Ambush's speech DLL. No launcher was added." + exit 1 + fi + if ! ln -sfn "ambush-nvda-client64.orig" "${ambushDir}/nvdaControllerClient64.dll"; then + agm_msgbox "Ambush" "Ambush" "Could not link Ambush's speech DLL. The original is saved as ambush-nvda-client64.orig. No launcher was added." + exit 1 + fi +fi +add_launcher 'c:\Program Files\ambush\Ambush.exe' 'export WINEDLLOVERRIDES=winmm=n,b' diff --git a/audiogame-manager.sh b/audiogame-manager.sh index 954852f..d3046d1 100755 --- a/audiogame-manager.sh +++ b/audiogame-manager.sh @@ -1145,6 +1145,9 @@ if [[ "$noninteractiveInstall" == "true" ]]; then # Install the specified game noninteractively if [[ -f "${scriptDir}/.install/${selectedGameName}.sh" ]]; then export LANG="en_US.UTF-8" + # Installers and add_launcher use game as the launcher title. + # shellcheck disable=SC2178 # In this install path, game is a scalar title, not a parsed launcher record. + game="${selectedGameName}" # shellcheck disable=SC1090 . "${scriptDir}/.install/${selectedGameName}.sh" # Show success message diff --git a/game-scripts/ambush-winmm/README.md b/game-scripts/ambush-winmm/README.md new file mode 100644 index 0000000..4fb86ce --- /dev/null +++ b/game-scripts/ambush-winmm/README.md @@ -0,0 +1,45 @@ +# Ambush winmm proxy + +Ambush's anti-cheat checks whether `timeGetTime`, `QueryPerformanceCounter`, +`GetTickCount` and `GetTickCount64` start with a jump instruction, which is how +speed hack tools hook them. Wine's `winmm.timeGetTime` is a one-instruction +`jmp` thunk, so under Wine the game reports "Security Alert. Tamper Reason: +Speed Hack" about 20 to 35 seconds after starting. + +`winmm.dll` here implements `timeGetTime` with real code and forwards every +other export to `winmm_wine.dll`. The installer makes `winmm_wine.dll` a +symlink to the bottle's own `system32/winmm.dll`, so it stays in step with +the installed Wine. The launcher sets `WINEDLLOVERRIDES=winmm=n,b`, so only +Ambush loads the proxy. The game executable is not modified. + +Rebuild with mingw-w64: + + x86_64-w64-mingw32-gcc -O2 -shared -nostartfiles -e DllMain -o winmm.dll winmm.c winmm.def -lkernel32 + +`winmm.def` lists the exports of Wine's x86_64 `winmm.dll`; regenerate it if +Wine adds exports. + +## Speech DLL + +Audiogame Manager's `update_nvda_dlls` replaces every regular +`nvdaControllerClient*.dll` file in the bottle at launch. With the replacement, +Ambush's `login()` fails with "Caught an exception from the application" +about 40 seconds after start. The installer moves the game's own client to +`ambush-nvda-client64.orig` and links `nvdaControllerClient64.dll` to it; the +replacement uses `find -type f`, so it skips the symlink. If an Ambush update +puts back a regular file, run the installer again. + +## Installer checks + +The upstream archive extracts into lowercase `ambush/`, installed under the +bottle's `Program Files` directory. The installer stops without adding a +launcher if bottle setup, downloading, extraction, or DLL setup fails. If the +speech DLL cannot be linked after backup, its original remains in +`ambush-nvda-client64.orig`. + +Run `bash tests/ambush_installer_tests.sh` from the repository root for isolated +failure, repeat-installation, archive-layout and CLI launcher-title checks. +These checks do not run Wine or prove game speech. For live acceptance, install +and launch Ambush from both console and graphical menus, check login and speech, +play beyond the reported security-alert interval, then quit and relaunch. +Also confirm another game in the shared bottle still launches and speaks. diff --git a/game-scripts/ambush-winmm/winmm.c b/game-scripts/ambush-winmm/winmm.c new file mode 100644 index 0000000..597983b --- /dev/null +++ b/game-scripts/ambush-winmm/winmm.c @@ -0,0 +1,10 @@ +/* Proxy winmm for Ambush under Wine: real-code timeGetTime (no jmp thunk), everything else forwarded. */ +#include +static volatile LONGLONG freq; +DWORD WINAPI my_timeGetTime(void){ + LARGE_INTEGER c; LONGLONG f=freq; + if(!f){LARGE_INTEGER q; QueryPerformanceFrequency(&q); f=freq=q.QuadPart;} + QueryPerformanceCounter(&c); + return (DWORD)(c.QuadPart/(f/1000)); +} +BOOL WINAPI DllMain(HINSTANCE h, DWORD r, LPVOID p){ if(r==DLL_PROCESS_ATTACH) DisableThreadLibraryCalls(h); return TRUE; } diff --git a/game-scripts/ambush-winmm/winmm.def b/game-scripts/ambush-winmm/winmm.def new file mode 100644 index 0000000..b4edbf8 --- /dev/null +++ b/game-scripts/ambush-winmm/winmm.def @@ -0,0 +1,188 @@ +LIBRARY winmm.dll +EXPORTS + CloseDriver=winmm_wine.CloseDriver @5 + DefDriverProc=winmm_wine.DefDriverProc @6 + DriverCallback=winmm_wine.DriverCallback @7 + DrvClose=winmm_wine.DrvClose @8 + DrvDefDriverProc=winmm_wine.DrvDefDriverProc @9 + DrvGetModuleHandle=winmm_wine.DrvGetModuleHandle @10 + DrvOpen=winmm_wine.DrvOpen @11 + DrvOpenA=winmm_wine.DrvOpenA @12 + DrvSendMessage=winmm_wine.DrvSendMessage @13 + GetDriverFlags=winmm_wine.GetDriverFlags @14 + GetDriverModuleHandle=winmm_wine.GetDriverModuleHandle @15 + OpenDriver=winmm_wine.OpenDriver @16 + OpenDriverA=winmm_wine.OpenDriverA @17 + PlaySound=winmm_wine.PlaySound @18 + PlaySoundA=winmm_wine.PlaySoundA @19 + PlaySoundW=winmm_wine.PlaySoundW @20 + SendDriverMessage=winmm_wine.SendDriverMessage @21 + auxGetDevCapsA=winmm_wine.auxGetDevCapsA @22 + auxGetDevCapsW=winmm_wine.auxGetDevCapsW @23 + auxGetNumDevs=winmm_wine.auxGetNumDevs @24 + auxGetVolume=winmm_wine.auxGetVolume @25 + auxOutMessage=winmm_wine.auxOutMessage @26 + auxSetVolume=winmm_wine.auxSetVolume @27 + joyConfigChanged=winmm_wine.joyConfigChanged @28 + joyGetDevCapsA=winmm_wine.joyGetDevCapsA @29 + joyGetDevCapsW=winmm_wine.joyGetDevCapsW @30 + joyGetNumDevs=winmm_wine.joyGetNumDevs @31 + joyGetPos=winmm_wine.joyGetPos @32 + joyGetPosEx=winmm_wine.joyGetPosEx @33 + joyGetThreshold=winmm_wine.joyGetThreshold @34 + joyReleaseCapture=winmm_wine.joyReleaseCapture @35 + joySetCapture=winmm_wine.joySetCapture @36 + joySetThreshold=winmm_wine.joySetThreshold @37 + mciDriverNotify=winmm_wine.mciDriverNotify @38 + mciDriverYield=winmm_wine.mciDriverYield @39 + mciExecute=winmm_wine.mciExecute @40 + mciFreeCommandResource=winmm_wine.mciFreeCommandResource @41 + mciGetCreatorTask=winmm_wine.mciGetCreatorTask @42 + mciGetDeviceIDA=winmm_wine.mciGetDeviceIDA @43 + mciGetDeviceIDFromElementIDA=winmm_wine.mciGetDeviceIDFromElementIDA @44 + mciGetDeviceIDFromElementIDW=winmm_wine.mciGetDeviceIDFromElementIDW @45 + mciGetDeviceIDW=winmm_wine.mciGetDeviceIDW @46 + mciGetDriverData=winmm_wine.mciGetDriverData @47 + mciGetErrorStringA=winmm_wine.mciGetErrorStringA @48 + mciGetErrorStringW=winmm_wine.mciGetErrorStringW @49 + mciGetYieldProc=winmm_wine.mciGetYieldProc @50 + mciLoadCommandResource=winmm_wine.mciLoadCommandResource @51 + mciSendCommandA=winmm_wine.mciSendCommandA @52 + mciSendCommandW=winmm_wine.mciSendCommandW @53 + mciSendStringA=winmm_wine.mciSendStringA @54 + mciSendStringW=winmm_wine.mciSendStringW @55 + mciSetDriverData=winmm_wine.mciSetDriverData @56 + mciSetYieldProc=winmm_wine.mciSetYieldProc @57 + midiConnect=winmm_wine.midiConnect @58 + midiDisconnect=winmm_wine.midiDisconnect @59 + midiInAddBuffer=winmm_wine.midiInAddBuffer @60 + midiInClose=winmm_wine.midiInClose @61 + midiInGetDevCapsA=winmm_wine.midiInGetDevCapsA @62 + midiInGetDevCapsW=winmm_wine.midiInGetDevCapsW @63 + midiInGetErrorTextA=winmm_wine.midiInGetErrorTextA @64 + midiInGetErrorTextW=winmm_wine.midiInGetErrorTextW @65 + midiInGetID=winmm_wine.midiInGetID @66 + midiInGetNumDevs=winmm_wine.midiInGetNumDevs @67 + midiInMessage=winmm_wine.midiInMessage @68 + midiInOpen=winmm_wine.midiInOpen @69 + midiInPrepareHeader=winmm_wine.midiInPrepareHeader @70 + midiInReset=winmm_wine.midiInReset @71 + midiInStart=winmm_wine.midiInStart @72 + midiInStop=winmm_wine.midiInStop @73 + midiInUnprepareHeader=winmm_wine.midiInUnprepareHeader @74 + midiOutCacheDrumPatches=winmm_wine.midiOutCacheDrumPatches @75 + midiOutCachePatches=winmm_wine.midiOutCachePatches @76 + midiOutClose=winmm_wine.midiOutClose @77 + midiOutGetDevCapsA=winmm_wine.midiOutGetDevCapsA @78 + midiOutGetDevCapsW=winmm_wine.midiOutGetDevCapsW @79 + midiOutGetErrorTextA=winmm_wine.midiOutGetErrorTextA @80 + midiOutGetErrorTextW=winmm_wine.midiOutGetErrorTextW @81 + midiOutGetID=winmm_wine.midiOutGetID @82 + midiOutGetNumDevs=winmm_wine.midiOutGetNumDevs @83 + midiOutGetVolume=winmm_wine.midiOutGetVolume @84 + midiOutLongMsg=winmm_wine.midiOutLongMsg @85 + midiOutMessage=winmm_wine.midiOutMessage @86 + midiOutOpen=winmm_wine.midiOutOpen @87 + midiOutPrepareHeader=winmm_wine.midiOutPrepareHeader @88 + midiOutReset=winmm_wine.midiOutReset @89 + midiOutSetVolume=winmm_wine.midiOutSetVolume @90 + midiOutShortMsg=winmm_wine.midiOutShortMsg @91 + midiOutUnprepareHeader=winmm_wine.midiOutUnprepareHeader @92 + midiStreamClose=winmm_wine.midiStreamClose @93 + midiStreamOpen=winmm_wine.midiStreamOpen @94 + midiStreamOut=winmm_wine.midiStreamOut @95 + midiStreamPause=winmm_wine.midiStreamPause @96 + midiStreamPosition=winmm_wine.midiStreamPosition @97 + midiStreamProperty=winmm_wine.midiStreamProperty @98 + midiStreamRestart=winmm_wine.midiStreamRestart @99 + midiStreamStop=winmm_wine.midiStreamStop @100 + mixerClose=winmm_wine.mixerClose @101 + mixerGetControlDetailsA=winmm_wine.mixerGetControlDetailsA @102 + mixerGetControlDetailsW=winmm_wine.mixerGetControlDetailsW @103 + mixerGetDevCapsA=winmm_wine.mixerGetDevCapsA @104 + mixerGetDevCapsW=winmm_wine.mixerGetDevCapsW @105 + mixerGetID=winmm_wine.mixerGetID @106 + mixerGetLineControlsA=winmm_wine.mixerGetLineControlsA @107 + mixerGetLineControlsW=winmm_wine.mixerGetLineControlsW @108 + mixerGetLineInfoA=winmm_wine.mixerGetLineInfoA @109 + mixerGetLineInfoW=winmm_wine.mixerGetLineInfoW @110 + mixerGetNumDevs=winmm_wine.mixerGetNumDevs @111 + mixerMessage=winmm_wine.mixerMessage @112 + mixerOpen=winmm_wine.mixerOpen @113 + mixerSetControlDetails=winmm_wine.mixerSetControlDetails @114 + mmGetCurrentTask=winmm_wine.mmGetCurrentTask @115 + mmTaskBlock=winmm_wine.mmTaskBlock @116 + mmTaskCreate=winmm_wine.mmTaskCreate @117 + mmTaskSignal=winmm_wine.mmTaskSignal @118 + mmTaskYield=winmm_wine.mmTaskYield @119 + mmioAdvance=winmm_wine.mmioAdvance @120 + mmioAscend=winmm_wine.mmioAscend @121 + mmioClose=winmm_wine.mmioClose @122 + mmioCreateChunk=winmm_wine.mmioCreateChunk @123 + mmioDescend=winmm_wine.mmioDescend @124 + mmioFlush=winmm_wine.mmioFlush @125 + mmioGetInfo=winmm_wine.mmioGetInfo @126 + mmioInstallIOProc16=winmm_wine.mmioInstallIOProc16 @127 + mmioInstallIOProcA=winmm_wine.mmioInstallIOProcA @128 + mmioInstallIOProcW=winmm_wine.mmioInstallIOProcW @129 + mmioOpenA=winmm_wine.mmioOpenA @130 + mmioOpenW=winmm_wine.mmioOpenW @131 + mmioRead=winmm_wine.mmioRead @132 + mmioRenameA=winmm_wine.mmioRenameA @133 + mmioRenameW=winmm_wine.mmioRenameW @134 + mmioSeek=winmm_wine.mmioSeek @135 + mmioSendMessage=winmm_wine.mmioSendMessage @136 + mmioSetBuffer=winmm_wine.mmioSetBuffer @137 + mmioSetInfo=winmm_wine.mmioSetInfo @138 + mmioStringToFOURCCA=winmm_wine.mmioStringToFOURCCA @139 + mmioStringToFOURCCW=winmm_wine.mmioStringToFOURCCW @140 + mmioWrite=winmm_wine.mmioWrite @141 + mmsystemGetVersion=winmm_wine.mmsystemGetVersion @142 + sndPlaySoundA=winmm_wine.sndPlaySoundA @143 + sndPlaySoundW=winmm_wine.sndPlaySoundW @144 + timeBeginPeriod=winmm_wine.timeBeginPeriod @145 + timeEndPeriod=winmm_wine.timeEndPeriod @146 + timeGetDevCaps=winmm_wine.timeGetDevCaps @147 + timeGetSystemTime=winmm_wine.timeGetSystemTime @148 + timeGetTime=my_timeGetTime @149 + timeKillEvent=winmm_wine.timeKillEvent @150 + timeSetEvent=winmm_wine.timeSetEvent @151 + waveInAddBuffer=winmm_wine.waveInAddBuffer @152 + waveInClose=winmm_wine.waveInClose @153 + waveInGetDevCapsA=winmm_wine.waveInGetDevCapsA @154 + waveInGetDevCapsW=winmm_wine.waveInGetDevCapsW @155 + waveInGetErrorTextA=winmm_wine.waveInGetErrorTextA @156 + waveInGetErrorTextW=winmm_wine.waveInGetErrorTextW @157 + waveInGetID=winmm_wine.waveInGetID @158 + waveInGetNumDevs=winmm_wine.waveInGetNumDevs @159 + waveInGetPosition=winmm_wine.waveInGetPosition @160 + waveInMessage=winmm_wine.waveInMessage @161 + waveInOpen=winmm_wine.waveInOpen @162 + waveInPrepareHeader=winmm_wine.waveInPrepareHeader @163 + waveInReset=winmm_wine.waveInReset @164 + waveInStart=winmm_wine.waveInStart @165 + waveInStop=winmm_wine.waveInStop @166 + waveInUnprepareHeader=winmm_wine.waveInUnprepareHeader @167 + waveOutBreakLoop=winmm_wine.waveOutBreakLoop @168 + waveOutClose=winmm_wine.waveOutClose @169 + waveOutGetDevCapsA=winmm_wine.waveOutGetDevCapsA @170 + waveOutGetDevCapsW=winmm_wine.waveOutGetDevCapsW @171 + waveOutGetErrorTextA=winmm_wine.waveOutGetErrorTextA @172 + waveOutGetErrorTextW=winmm_wine.waveOutGetErrorTextW @173 + waveOutGetID=winmm_wine.waveOutGetID @174 + waveOutGetNumDevs=winmm_wine.waveOutGetNumDevs @175 + waveOutGetPitch=winmm_wine.waveOutGetPitch @176 + waveOutGetPlaybackRate=winmm_wine.waveOutGetPlaybackRate @177 + waveOutGetPosition=winmm_wine.waveOutGetPosition @178 + waveOutGetVolume=winmm_wine.waveOutGetVolume @179 + waveOutMessage=winmm_wine.waveOutMessage @180 + waveOutOpen=winmm_wine.waveOutOpen @181 + waveOutPause=winmm_wine.waveOutPause @182 + waveOutPrepareHeader=winmm_wine.waveOutPrepareHeader @183 + waveOutReset=winmm_wine.waveOutReset @184 + waveOutRestart=winmm_wine.waveOutRestart @185 + waveOutSetPitch=winmm_wine.waveOutSetPitch @186 + waveOutSetPlaybackRate=winmm_wine.waveOutSetPlaybackRate @187 + waveOutSetVolume=winmm_wine.waveOutSetVolume @188 + waveOutUnprepareHeader=winmm_wine.waveOutUnprepareHeader @189 + waveOutWrite=winmm_wine.waveOutWrite @190 diff --git a/game-scripts/ambush-winmm/winmm.dll b/game-scripts/ambush-winmm/winmm.dll new file mode 100755 index 0000000000000000000000000000000000000000..a6155806830e6312a90d8b2c628a72f83dd32b43 GIT binary patch literal 25466 zcmeZ`n!v!!z`(%5z`*eTKLf)K1_*F~PBLl++1~nyaCMJCbCI$uu0|o{VT_C`~zyQJwzLyw5dO>U^h`T{tR*)hPV*$i7 z8~Yd-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!DXt%#Il z;^X5%qcadAh$w5o6|Z}039MOxl9-T_1BwKsR|DPV2+OaTxryni*js&24 /dev/null; } + # shellcheck disable=SC1090 # Extract only the helper, avoiding AGM startup. + source <(sed -n '/^install_with_progress() {/,/^}/p' "$scriptDir/.includes/functions.sh") + cp() { + [[ "$caseName" != copy-failure ]] || return 1 + command cp "$@" + } + mv() { + [[ "$caseName" != backup-failure ]] || return 1 + command mv "$@" + } + ln() { + if [[ "$caseName" == timer-link-failure && "${*: -1}" == */winmm_wine.dll ]] || + [[ "$caseName" == speech-link-failure && "${*: -1}" == */nvdaControllerClient64.dll ]]; then + return 1 + fi + command ln "$@" + } + agm_msgbox() { echo "$*" >> "${caseRoot}/messages"; } + add_launcher() { + [[ "$WINEARCH" == win64 && "$winVer" == win10 && "$game" == Ambush ]] || return 2 + [[ "$1" == 'c:\Program Files\ambush\Ambush.exe' && "$2" == 'export WINEDLLOVERRIDES=winmm=n,b' ]] || return 2 + echo launcher >> "${caseRoot}/launchers" + } + # shellcheck source=.install/Ambush.sh + source "$scriptDir/.install/Ambush.sh" +) + +check_case() { + local caseName="$1" expectedStatus="$2" expectedLaunchers="$3" + local caseRoot ambushDir actualStatus=0 actualLaunchers=0 + caseRoot="$(mktemp -d "${testRoot}/case.XXXXXX")" + ambushDir="${caseRoot}/prefix/drive_c/Program Files/ambush" + mkdir -p "$ambushDir" "${caseRoot}/prefix/drive_c/windows/system32" + # An existing executable must not hide a failed reinstallation. + if [[ "$caseName" == archive-extraction ]]; then + mkdir -p "${caseRoot}/cache" + # Match the paths in the current upstream ZIP, including lowercase ambush/. + python3 - "${caseRoot}/cache/ambush.zip" <<'PY' +import sys +import zipfile +with zipfile.ZipFile(sys.argv[1], 'w') as archive: + archive.writestr('ambush/Ambush.exe', 'executable') + archive.writestr('ambush/nvdaControllerClient64.dll', 'original-client\n') +PY + else + echo executable > "$ambushDir/Ambush.exe" + echo original-client > "$ambushDir/nvdaControllerClient64.dll" + fi + echo wine-timer > "${caseRoot}/prefix/drive_c/windows/system32/winmm.dll" + case "$caseName" in + missing-executable) rm "$ambushDir/Ambush.exe" ;; + missing-wine-timer) rm "${caseRoot}/prefix/drive_c/windows/system32/winmm.dll" ;; + esac + + run_installer || actualStatus=$? + if [[ "$caseName" == repeat-installation && "$actualStatus" == 0 ]]; then + run_installer || actualStatus=$? + fi + if [[ -f "${caseRoot}/launchers" ]]; then + actualLaunchers="$(wc -l < "${caseRoot}/launchers")" + fi + [[ "$actualStatus" == "$expectedStatus" && "$actualLaunchers" == "$expectedLaunchers" ]] || { + echo "FAIL: $caseName (status $actualStatus, launchers $actualLaunchers)" >&2 + exit 1 + } + if [[ "$expectedStatus" == 0 ]]; then + cmp "$ambushDir/winmm.dll" "$scriptDir/game-scripts/ambush-winmm/winmm.dll" + [[ -L "$ambushDir/winmm_wine.dll" && -f "$ambushDir/winmm_wine.dll" ]] + [[ -L "$ambushDir/nvdaControllerClient64.dll" ]] + [[ "$(cat "$ambushDir/nvdaControllerClient64.dll")" == original-client ]] + elif [[ "$caseName" == speech-link-failure ]]; then + [[ "$(cat "$ambushDir/ambush-nvda-client64.orig")" == original-client ]] + else + [[ ! -L "$ambushDir/nvdaControllerClient64.dll" ]] + [[ "$(cat "$ambushDir/nvdaControllerClient64.dll")" == original-client ]] + fi + echo "PASS: $caseName" +} + +for caseName in bottle-failure download-failure extraction-failure missing-executable \ + missing-wine-timer copy-failure timer-link-failure backup-failure speech-link-failure; do + check_case "$caseName" 1 0 +done +check_case successful-installation 0 1 +check_case repeat-installation 0 2 +check_case archive-extraction 0 1 + +# Exercise only the CLI install dispatch, without running startup or Wine. +dispatchFile="${testRoot}/install-dispatch.sh" +sed -n '/^if \[\[ "$noninteractiveInstall" == "true" \]\]; then/,$p' \ + "$scriptDir/audiogame-manager.sh" > "$dispatchFile" +mkdir -p "${testRoot}/dispatch/.install" +cat > "${testRoot}/dispatch/.install/Example Game.sh" <<'EOF' +[[ "$game" == 'Example Game' ]] || exit 1 +echo "$game" > "$dispatchResult" +EOF +( + scriptDir="${testRoot}/dispatch" + export noninteractiveInstall=true + export selectedGameName='Example Game' + export dispatchResult="${testRoot}/title" + # shellcheck disable=SC2329 # Invoked by the extracted CLI dispatch. + agm_msgbox() { :; } + # shellcheck disable=SC1090 # Only the production CLI dispatch, extracted above. + source "$dispatchFile" +) +[[ "$(cat "${testRoot}/title")" == 'Example Game' ]] +echo 'PASS: CLI installer receives the launcher title'