Run Windows games on Apple Silicon — free, open source, with an open compatibility database that tells you what actually works.
Swift apple-silicond3dmetaldxmtdxvkfexgame-porting-toolkitgamingmac-gamingmacosmetalmoltenvksteamswiftuivkd3d-protonwhisky-alternativewindows-gameswinewine-wrapper
Play: stop the bottle before launching when the auto-applied recipe changed the environment
Gauthier Piarrette48e89d9c3ff5
diff --git a/Sources/HighballApp/AppState.swift b/Sources/HighballApp/AppState.swiftindex d48a5c5..823a323 100644--- a/Sources/HighballApp/AppState.swift+++ b/Sources/HighballApp/AppState.swift@@ -103,6 +103,13 @@ final class AppState {logLines.append("applied the \(recipe.title) fix")for n in notes { logLines.append("note: \(n)") }}+ if recipe.changesLaunchEnvironment {+ // A running Steam keeps the environment it started with; the game we are+ // about to launch through it would never see the recipe's settings.+ try? WineRunner(paths: paths, engine: engine, bottle: bottle).kill()+ try? await Task.sleep(for: .seconds(2))+ logLines.append("stopped the bottle so the new settings apply to this launch")+ }refresh()let fresh = bottles.first { $0.name == bottleName } ?? runner.bottlelaunch(item, in: fresh)diff --git a/Sources/HighballKit/Recipe.swift b/Sources/HighballKit/Recipe.swiftindex a4966e4..13c431b 100644--- a/Sources/HighballKit/Recipe.swift+++ b/Sources/HighballKit/Recipe.swift@@ -145,6 +145,20 @@ 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) }+ /// 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+ /// must stop the bottle first or the game it launches never sees the change. The Sims+ /// recipe's MVK_SHADOW_IMPORT=1 is the case that made this visible.+ public var changesLaunchEnvironment: Bool {+ steps.contains { step in+ switch step {+ case .renderer, .sync, .environment: return true+ default: return false+ }+ }+ }+public struct KnownIssue: Codable, Sendable {public var symptom: Stringpublic var cause: String?diff --git a/Tests/HighballKitTests/RegressionTests.swift b/Tests/HighballKitTests/RegressionTests.swiftindex e12516a..6002626 100644--- a/Tests/HighballKitTests/RegressionTests.swift+++ b/Tests/HighballKitTests/RegressionTests.swift@@ -714,6 +714,19 @@ extension RegressionTests {XCTAssertTrue(EngineManifest.needsPrefixRefresh(from: try manifest(nil, id: "x"), to: r1), "unknown: be safe, boot")}+ // A Play that auto-applies a recipe with environment or renderer steps must restart the+ // bottle: a running Steam keeps its old environment and the game would launch without the+ // fix (the Sims recipe's MVK_SHADOW_IMPORT=1 would silently do nothing).+ func testRecipeKnowsWhenItChangesTheLaunchEnvironment() throws {+ func recipe(_ steps: String) throws -> HighballKit.Recipe {+ try JSONDecoder().decode(HighballKit.Recipe.self, from: Data(#"{"id":"r","kind":"game","title":"r","steps":[\#(steps)]}"#.utf8))+ }+ XCTAssertTrue(try recipe(#"{"type":"environment","name":"MVK_SHADOW_IMPORT","value":"1"}"#).changesLaunchEnvironment)+ XCTAssertTrue(try recipe(#"{"type":"renderer","renderer":"dxvk"}"#).changesLaunchEnvironment)+ XCTAssertFalse(try recipe(#"{"type":"file","path":"a/b.txt","contents":"x"},{"type":"note","text":"n"}"#).changesLaunchEnvironment,+ "config files alone do not need a restart")+ }+// extract() with a single-file `into` replaces that file and nothing else in the directory.// The old code treated every target as a directory, so a file target would have removed// the whole frameworks tree on the way in.