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
A program added by hand carries its game's fix variables. The library matches such a program to its database game, and the game's page lists the variables the fix scoped to it as applied to its launches, but launching a pin passed only the pin's own environment. Forza Horizon 6 run from its exe in ~/Games then started on D3DMetal's default graphics card and crashed at startup (highball#486). A pin launch now starts from the matched game's variables, with the program's own settings winning. 590 tests pass on the M4.
Gauthier Piarrette234c9888e621
diff --git a/Sources/HighballApp/AppState.swift b/Sources/HighballApp/AppState.swiftindex f66b7eb..04ba43c 100644--- a/Sources/HighballApp/AppState.swift+++ b/Sources/HighballApp/AppState.swift@@ -2559,13 +2559,17 @@ final class AppState {let steamFirstBoot = isSteamUI(pin) && !FileManager.default.fileExists(atPath: bottle.driveC.appending(path: "Program Files (x86)/Steam/bin/cef").path)let cef = bottle.driveC.appending(path: "Program Files (x86)/Steam/bin/cef")+ // The database game the library matches this program to keeps its fix's variables, as its+ // page says, with the program's own winning (highball#486).+ let gameID = libraryItems.first(where: { $0.pinID == pin.id }).flatMap { gameDB.entry(for: $0)?.id }+ let gameEnvironment = pin.environment(withGame: bottle.settings.environment(forGame: gameID))runBusy(steamFirstBoot ? L("Starting Steam for the first time — it downloads and unpacks its own client") : "Starting \(pin.name)",expected: steamFirstBoot ? L("usually 15–25 minutes; long quiet stretches are normal") : nil,done: .handedOff,stop: .killBottle(bottle, label: L("Stop")),cleanup: { [weak self] in self?.launchingPins.remove(pin.id) }) { [self] inlet runner = WineRunner(paths: paths, engine: engine, bottle: bottle)- var extraEnvironment = [String: String]()+ var extraEnvironment = gameEnvironment// A Steam client left running by a game launch answers a new steam.exe by swallowing// it (issue #33). Ask it to show its window instead, and leave the wineserver alone:// a game may still be running under it.diff --git a/Sources/HighballKit/Bottle.swift b/Sources/HighballKit/Bottle.swiftindex 9604ec5..36a8944 100644--- a/Sources/HighballKit/Bottle.swift+++ b/Sources/HighballKit/Bottle.swift@@ -282,6 +282,15 @@ public struct Pin: Codable, Sendable, Identifiable, Hashable {return pin}+ /// What a launch of this program carries: the variables the database game it is matched to got+ /// from its fix, then the program's own, which win. A program added by hand ran with its own+ /// variables only, so its game's page listed the fix's variables as applied while the launch+ /// dropped them, and Forza Horizon 6 started that way crashed on D3DMetal's default graphics card+ /// (highball#486).+ public func environment(withGame gameVariables: [String: String]) -> [String: String] {+ gameVariables.merging(environment) { $1 }+ }+/// Where the pin's executable actually lives for a given bottle.public func executableURL(driveC: URL) -> URL {let named = launchURL(driveC: driveC)diff --git a/Tests/HighballKitTests/LaunchChecksTests.swift b/Tests/HighballKitTests/LaunchChecksTests.swiftindex 73561ba..1321633 100644--- a/Tests/HighballKitTests/LaunchChecksTests.swift+++ b/Tests/HighballKitTests/LaunchChecksTests.swift@@ -71,6 +71,18 @@ final class LaunchChecksTests: XCTestCase {XCTAssertNil(Pin(name: "x", path: "x.exe").launching(with: nil).renderer, "and with none, the environment decides")}+ /// Forza Horizon 6 added by hand ran without its fix's graphics card variables and crashed (highball#486).+ func testAProgramCarriesItsGamesVariables() {+ let fix = ["D3DM_VENDOR_ID": "0x10de", "D3DM_DEVICE_ID": "0x2786"]+ let pin = Pin(name: "Forza Horizon 6", path: "/Users/x/Games/Forza Horizon 6/forzahorizon6.exe",+ environment: ["D3DM_DEVICE_ID": "0x56a1", "MY_SETTING": "1"])+ let env = pin.environment(withGame: fix)+ XCTAssertEqual(env["D3DM_VENDOR_ID"], "0x10de", "the fix's variable reaches the launch")+ XCTAssertEqual(env["D3DM_DEVICE_ID"], "0x56a1", "the program's own setting wins over the fix")+ XCTAssertEqual(env["MY_SETTING"], "1")+ XCTAssertEqual(Pin(name: "x", path: "x.exe").environment(withGame: [:]), [:], "no game, nothing added")+ }+/// A DualSense player had "Controllers through SDL" installed and no way back but regedit.func testRegistryOnlyTweaksCanBeRemoved() throws {let sdl = try JSONDecoder.highball.decode(Recipe.self, from: Data("""