Skip to content

Run Windows games on Apple Silicon — free, open source, with an open compatibility database that tells you what actually works.

play: a recipe whose copied file is gone counts as not applied, so a reinstalled game gets it back

Gauthier Piarrette6c49b5fa30ab
diff --git a/Sources/HighballApp/AppState.swift b/Sources/HighballApp/AppState.swift
index f485efb..450aa33 100644
--- a/Sources/HighballApp/AppState.swift
+++ b/Sources/HighballApp/AppState.swift
@@ -249,7 +249,8 @@ final class AppState {
renderer = instead
}
}
- if let recipe = fixRecipe(for: item), !bottle.settings.recipes.contains(recipe.id),
+ if let recipe = fixRecipe(for: item),
+ !bottle.settings.recipes.contains(recipe.id) || !recipe.artifactsPresent(driveC: bottle.driveC),
let engine = engine(for: bottle) {
// The engine comes first, whatever the steps: a recipe of plain notes that names r7
// used to auto-apply on r5 and launch there, so nobody was ever offered the engine
diff --git a/Sources/HighballApp/GameDetailView.swift b/Sources/HighballApp/GameDetailView.swift
index 600a941..fb8218c 100644
--- a/Sources/HighballApp/GameDetailView.swift
+++ b/Sources/HighballApp/GameDetailView.swift
@@ -18,7 +18,7 @@ struct GameDetailView: View {
private var fixRecipe: HighballKit.Recipe? { state.fixRecipe(for: item) }
private var fixApplied: Bool {
guard let fixRecipe, let bottle else { return false }
- return bottle.settings.recipes.contains(fixRecipe.id)
+ return bottle.settings.recipes.contains(fixRecipe.id) && fixRecipe.artifactsPresent(driveC: bottle.driveC)
}
private var running: GameSession? {
if let appid = item.steamAppID, let s = state.session(forAppID: appid) { return s }
diff --git a/Sources/HighballKit/Recipe.swift b/Sources/HighballKit/Recipe.swift
index 40ff2e7..2d30beb 100644
--- a/Sources/HighballKit/Recipe.swift
+++ b/Sources/HighballKit/Recipe.swift
@@ -167,6 +167,17 @@ public struct Recipe: Codable, Sendable, Identifiable {
/// Recipes with heavy or wine-touching steps get an honest prompt instead.
public var isAutoApplicable: Bool { steps.allSatisfy(\.isAutoApplicable) }
+ /// False when a file a `copy` step placed is gone: the game was reinstalled or Steam put its
+ /// files back, and the environment still records the recipe as applied. Play then treats the
+ /// recipe as not applied, so the copy comes back before the launch (2026-09-11: CS:GO Legacy
+ /// reinstalled without its d3d9.dll would have launched on the wrong Direct3D).
+ public func artifactsPresent(driveC: URL) -> Bool {
+ steps.allSatisfy { step in
+ if case let .copy(_, to, _) = step { return FileManager.default.fileExists(atPath: driveC.appending(path: to).path) }
+ return true
+ }
+ }
+
/// True when applying the recipe changes what a launch inherits: the renderer, the sync
/// mode or an environment variable. A Steam client that is already running keeps the
/// environment it started with (issues #22/#25), so a Play that auto-applied such a recipe
diff --git a/Tests/HighballKitTests/RecipeCopyStepTests.swift b/Tests/HighballKitTests/RecipeCopyStepTests.swift
index 75cc087..83a58f5 100644
--- a/Tests/HighballKitTests/RecipeCopyStepTests.swift
+++ b/Tests/HighballKitTests/RecipeCopyStepTests.swift
@@ -21,6 +21,31 @@ final class RecipeCopyStepTests: XCTestCase {
guard case let .copy(_, _, nativeAgain) = again.steps[0], nativeAgain else { return XCTFail("round trip lost the step or the flag") }
}
+ /// A reinstalled game loses the copied file while the environment still lists the recipe as
+ /// applied. The recipe knows its file is gone, so Play applies it again instead of launching
+ /// the game on the wrong Direct3D (2026-09-11, CS:GO Legacy reinstalled).
+ func testArtifactsPresentFollowsTheCopiedFile() throws {
+ let json = """
+ {"id": "csgo-legacy", "kind": "game", "title": "CS:GO", "steps": [
+ {"type": "note", "text": "notes carry no file"},
+ {"type": "copy", "from": "engine/lib/wine/i386-windows/d3d9.dll", "to": "Program Files (x86)/Steam/steamapps/common/csgo legacy/bin/d3d9.dll", "asNative": true}]}
+ """
+ let r = try JSONDecoder().decode(Recipe.self, from: Data(json.utf8))
+ let driveC = FileManager.default.temporaryDirectory.appending(path: "hb-artifacts-\(UUID().uuidString)")
+ defer { try? FileManager.default.removeItem(at: driveC) }
+ XCTAssertFalse(r.artifactsPresent(driveC: driveC), "the file was never placed")
+ let dest = driveC.appending(path: "Program Files (x86)/Steam/steamapps/common/csgo legacy/bin/d3d9.dll")
+ try FileManager.default.createDirectory(at: dest.deletingLastPathComponent(), withIntermediateDirectories: true)
+ try Data("x".utf8).write(to: dest)
+ XCTAssertTrue(r.artifactsPresent(driveC: driveC))
+ try FileManager.default.removeItem(at: dest)
+ XCTAssertFalse(r.artifactsPresent(driveC: driveC), "the game was reinstalled: the copy is gone")
+ let notesOnly = try JSONDecoder().decode(Recipe.self, from: Data("""
+ {"id": "x", "kind": "game", "title": "X", "steps": [{"type": "note", "text": "n"}]}
+ """.utf8))
+ XCTAssertTrue(notesOnly.artifactsPresent(driveC: driveC), "a recipe without copies has nothing to lose")
+ }
+
func testAsNativeBlanksTheBuiltinMarkerAndLeavesOtherFilesAlone() {
var pe = Data(count: 0x80); pe[0] = 0x4D; pe[1] = 0x5A
pe.replaceSubrange(0x40..<0x51, with: Data("Wine builtin DLL\0".utf8))