Skip to content

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

Play offers a recipe's engine whenever the environment lacks it

Gauthier Piarrette7433e5bf2361
diff --git a/Sources/HighballApp/AppState.swift b/Sources/HighballApp/AppState.swift
index 6a9a98a..402c252 100644
--- a/Sources/HighballApp/AppState.swift
+++ b/Sources/HighballApp/AppState.swift
@@ -251,6 +251,13 @@ final class AppState {
}
if let recipe = fixRecipe(for: item), !bottle.settings.recipes.contains(recipe.id),
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
+ // the game was verified on (Red Dead's and CS:GO's case).
+ if let wanted = recipe.engineToOffer(current: engine.manifest, known: Self.knownManifests) {
+ pendingEngine = (recipe, bottle, wanted)
+ return
+ }
if recipe.isAutoApplicable {
Task { @MainActor in
var runner = RecipeRunner(paths: paths, engine: engine, bottle: bottle)
diff --git a/Sources/HighballApp/EngineAsk.swift b/Sources/HighballApp/EngineAsk.swift
index b0ac373..f54eb0b 100644
--- a/Sources/HighballApp/EngineAsk.swift
+++ b/Sources/HighballApp/EngineAsk.swift
@@ -15,7 +15,7 @@ extension GamePageCopy {
static func engineAsk(recipe: HighballKit.Recipe, manifest: EngineManifest, installed: Bool) -> String {
let download = installed ? "" : String(format: L(", after a download of about %@"), downloadSize(manifest))
- return String(format: L("%@ is verified on the %@ engine, and its installer fails on this environment's Wine build. A new environment keeps your other programs where they are%@. Moving this environment re-runs the Windows setup and keeps everything installed."),
+ return String(format: L("%@ is verified on the %@ engine, and this environment is not on it. Moving this environment switches it there%@ and keeps everything installed; the Windows setup re-runs when needed, a minute or two. A new environment keeps your other programs where they are and starts empty, so the game has to be installed again."),
recipe.title, shortEngineName(manifest), download)
}
}
diff --git a/Sources/HighballApp/HighballApp.swift b/Sources/HighballApp/HighballApp.swift
index 8c2fb9b..7462590 100644
--- a/Sources/HighballApp/HighballApp.swift
+++ b/Sources/HighballApp/HighballApp.swift
@@ -287,8 +287,8 @@ private extension View {
self.alert(state.pendingEngine.map { String(format: L("%@ needs the %@ engine"), $0.recipe.title, GamePageCopy.shortEngineName($0.manifest)) } ?? "",
isPresented: .init(get: { state.pendingEngine != nil }, set: { if !$0 { state.pendingEngine = nil } }),
presenting: state.pendingEngine) { pending in
- Button(String(format: L("New environment for %@"), pending.recipe.title)) { state.createEnvironment(for: pending.recipe, on: pending.manifest) }
Button(L("Move this environment")) { state.moveEnvironment(for: pending.recipe, bottle: pending.bottle, to: pending.manifest) }
+ Button(String(format: L("New environment for %@"), pending.recipe.title)) { state.createEnvironment(for: pending.recipe, on: pending.manifest) }
Button(L("Not now"), role: .cancel) { state.pendingEngine = nil }
} message: { pending in
Text(GamePageCopy.engineAsk(recipe: pending.recipe, manifest: pending.manifest, installed: state.engines.contains { $0.id == pending.manifest.id }))
diff --git a/Sources/HighballApp/L10n.swift b/Sources/HighballApp/L10n.swift
index 357bd77..3ed23c4 100644
--- a/Sources/HighballApp/L10n.swift
+++ b/Sources/HighballApp/L10n.swift
@@ -148,7 +148,7 @@ enum L10n {
"Creating the %@ environment on %@": "Création de l'environnement %@ sur %@",
"a download when the engine is new, then a first boot of about 90 seconds": "un téléchargement si le moteur est nouveau, puis un premier démarrage d'environ 90 secondes",
", after a download of about %@": ", après un téléchargement d'environ %@",
- "%@ is verified on the %@ engine, and its installer fails on this environment's Wine build. A new environment keeps your other programs where they are%@. Moving this environment re-runs the Windows setup and keeps everything installed.": "%@ est vérifié sur le moteur %@, et son installateur échoue avec la version de Wine de cet environnement. Un nouvel environnement laisse vos autres programmes où ils sont%@. Déplacer cet environnement relance la configuration Windows et conserve tout ce qui est installé.",
+ "%@ is verified on the %@ engine, and this environment is not on it. Moving this environment switches it there%@ and keeps everything installed; the Windows setup re-runs when needed, a minute or two. A new environment keeps your other programs where they are and starts empty, so the game has to be installed again.": "%@ est vérifié sur le moteur %@, et cet environnement n'est pas dessus. Déplacer cet environnement le bascule dessus%@ en gardant tout ce qui est installé, la configuration Windows se relance si nécessaire, une minute ou deux. Un nouvel environnement laisse vos autres programmes où ils sont et démarre vide, le jeu devra donc être réinstallé.",
"Epic account connected": "Compte Epic connecté",
"Each release goes to beta a day or two before everyone else, less tested. Turning this off keeps the build you have until the next stable one is newer.": "Chaque version passe en bêta un jour ou deux avant tout le monde, moins testée. Désactiver garde la version actuelle jusqu'à ce qu'une version stable plus récente arrive.",
"vkd3d-proton — D3D12 → Vulkan (experimental)": "vkd3d-proton — D3D12 → Vulkan (expérimental)",
diff --git a/Sources/HighballKit/Manifest.swift b/Sources/HighballKit/Manifest.swift
index 506325f..e602222 100644
--- a/Sources/HighballKit/Manifest.swift
+++ b/Sources/HighballKit/Manifest.swift
@@ -29,6 +29,11 @@ public struct EngineManifest: Codable, Sendable, Identifiable {
/// A component that must land on top of another one's files, like a patched
/// MoltenVK replacing the runtime's, declares a higher order than the one it overrides.
public var order: Int?
+ /// True when installing this component changes what `wineboot` writes into a prefix
+ /// (a new builtin DLL needs its placeholder in system32/syswow64 before a game can load
+ /// it by its system path). A bottle moving to an engine that adds such a component gets
+ /// its Windows setup re-run even when the Wine build is the same.
+ public var refreshesPrefix: Bool?
public var isOptional: Bool { optional ?? false }
}
@@ -74,7 +79,28 @@ public struct EngineManifest: Codable, Sendable, Identifiable {
/// in wineboot's 32-bit step on both engines during the r1 rollout test.
public static func needsPrefixRefresh(from old: EngineManifest, to new: EngineManifest) -> Bool {
guard let a = old.components["wine"]?.sha256, let b = new.components["wine"]?.sha256 else { return true }
- return a != b
+ if a != b { return true }
+ // Same Wine: only a component that asks for it (a new builtin DLL) forces the setup.
+ return new.components.contains { name, c in
+ c.refreshesPrefix == true && old.components[name]?.sha256 != c.sha256
+ }
+ }
+
+ /// The revision number at the end of an engine id (`x64-crossover26.3-r7` is 7), or nil
+ /// for an id without one. Revisions of one Wine build are cumulative: r7 carries everything
+ /// r6 does, so a bottle on r7 already satisfies a recipe that names r6.
+ public static func revision(of id: String) -> Int? {
+ guard let range = id.range(of: #"-r(\d+)$"#, options: .regularExpression) else { return nil }
+ return Int(id[range].dropFirst(2))
+ }
+
+ /// True when a bottle on `current` already has everything `wanted` would bring: the same
+ /// engine, or a later revision of the same Wine build.
+ public static func satisfies(current: EngineManifest, wanted: EngineManifest) -> Bool {
+ if current.id == wanted.id { return true }
+ guard let a = current.components["wine"]?.sha256, let b = wanted.components["wine"]?.sha256, a == b,
+ let c = revision(of: current.id), let w = revision(of: wanted.id) else { return false }
+ return c >= w
}
/// Same rule when the bottle's current engine cannot be resolved (its directory is gone):
diff --git a/Sources/HighballKit/Recipe.swift b/Sources/HighballKit/Recipe.swift
index 218ada5..33b3e07 100644
--- a/Sources/HighballKit/Recipe.swift
+++ b/Sources/HighballKit/Recipe.swift
@@ -405,11 +405,12 @@ public struct RecipeRunner: Sendable {
public extension Recipe {
/// The engine to offer before applying this recipe to an environment on `current`: the
- /// manifest the recipe names when its Wine build differs from `current`'s, nil otherwise
- /// (the environment already runs that Wine, a later build of it included, or the app does
- /// not know the manifest).
+ /// manifest the recipe names unless `current` already satisfies it (the same engine, or a
+ /// later revision of the same Wine build, since revisions are cumulative), or the app does
+ /// not know the manifest. Same Wine is not enough on its own: r7 adds a builtin DLL r6
+ /// lacks, and a bottle on r6 needs the offer.
func engineToOffer(current: EngineManifest, known: [EngineManifest]) -> EngineManifest? {
guard let id = engine, let wanted = known.first(where: { $0.id == id }) else { return nil }
- return EngineManifest.needsPrefixRefresh(from: current, to: wanted) ? wanted : nil
+ return EngineManifest.satisfies(current: current, wanted: wanted) ? nil : wanted
}
}
diff --git a/Tests/HighballKitTests/RecipeEngineTests.swift b/Tests/HighballKitTests/RecipeEngineTests.swift
index 6432c34..e9b15bc 100644
--- a/Tests/HighballKitTests/RecipeEngineTests.swift
+++ b/Tests/HighballKitTests/RecipeEngineTests.swift
@@ -24,18 +24,46 @@ final class RecipeEngineTests: XCTestCase {
XCTAssertNil(try recipe(engine: nil).engine)
}
- func testOfferedOnlyWhenTheWineBuildDiffers() throws {
+ func testOfferedUnlessTheEnvironmentAlreadySatisfiesIt() throws {
let wine10 = try manifest(id: "x64-sikarugir10.0_6-r2", wine: "aaa")
let wine11 = try manifest(id: "x64-crossover26.3-r4", wine: "bbb")
let wine11Later = try manifest(id: "x64-crossover26.3-r5", wine: "bbb")
let r = try recipe(engine: "x64-crossover26.3-r4")
XCTAssertEqual(r.engineToOffer(current: wine10, known: [wine10, wine11])?.id, "x64-crossover26.3-r4")
XCTAssertNil(r.engineToOffer(current: wine11, known: [wine10, wine11]), "already on it")
- XCTAssertNil(r.engineToOffer(current: wine11Later, known: [wine10, wine11]), "a later build of the same Wine counts")
+ XCTAssertNil(r.engineToOffer(current: wine11Later, known: [wine10, wine11]), "a later revision of the same Wine counts")
XCTAssertNil(r.engineToOffer(current: wine10, known: [wine10]), "an engine the app does not know is never offered")
XCTAssertNil(try recipe(engine: nil).engineToOffer(current: wine10, known: [wine10, wine11]))
}
+ /// r6 and r7 are the same Wine as r5, and a bottle on r5 still needs them: r6 changes
+ /// MoltenVK (Red Dead), r7 adds a builtin DLL (CS:GO). Same Wine never meant "has it".
+ func testALaterRevisionOfTheSameWineIsOffered() throws {
+ let r5 = try manifest(id: "x64-crossover26.3-r5", wine: "bbb")
+ let r7 = try manifest(id: "x64-crossover26.3-r7", wine: "bbb")
+ let r = try recipe(engine: "x64-crossover26.3-r7")
+ XCTAssertEqual(r.engineToOffer(current: r5, known: [r5, r7])?.id, "x64-crossover26.3-r7")
+ XCTAssertNil(r.engineToOffer(current: r7, known: [r5, r7]))
+ XCTAssertEqual(EngineManifest.revision(of: "x64-crossover26.3-r7"), 7)
+ XCTAssertNil(EngineManifest.revision(of: "x64-crossover26.3"))
+ XCTAssertFalse(EngineManifest.needsPrefixRefresh(from: r5, to: r7), "same Wine, no component asks: the prefix stays")
+ }
+
+ /// A component that adds a builtin DLL asks for the Windows setup to run again, so the
+ /// bottle gets the DLL's placeholder in syswow64 (a game loading it by system path finds
+ /// nothing otherwise). The same Wine build is no reason to skip that.
+ func testAComponentCanAskForThePrefixRefresh() throws {
+ let json = """
+ {"id": "x64-crossover26.3-r7", "displayName": "Wine 11.0 (test)", "arch": "x86_64", "minMacOS": "14.0",
+ "components": {"wine": {"kind": "engine", "url": "https://example.invalid/bbb.tar.gz", "sha256": "bbb", "size": 1000},
+ "nvapi-stub": {"kind": "runtime", "url": "https://example.invalid/stub.tar.gz", "sha256": "ccc", "size": 10, "refreshesPrefix": true}}}
+ """
+ let r7 = try JSONDecoder().decode(EngineManifest.self, from: Data(json.utf8))
+ let r6 = try manifest(id: "x64-crossover26.3-r6", wine: "bbb")
+ XCTAssertTrue(EngineManifest.needsPrefixRefresh(from: r6, to: r7))
+ XCTAssertFalse(EngineManifest.needsPrefixRefresh(from: r7, to: r7), "the stub is already there")
+ }
+
func testTheShippedWine11ManifestIsOfferedByTheEARecipeOnTheDefaultEngine() throws {
let root = URL(fileURLWithPath: #filePath).deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent()
let def = try EngineManifest.load(from: root.appending(path: "spike/engine-manifest.json"))
diff --git a/spike/engines/x64-crossover26.3-r7.json b/spike/engines/x64-crossover26.3-r7.json
index 5a9238e..ad6b9dd 100644
--- a/spike/engines/x64-crossover26.3-r7.json
+++ b/spike/engines/x64-crossover26.3-r7.json
@@ -93,7 +93,8 @@
"sha256": "cbda8aeee87e84ecf98c06759d2123b073dc99a7aa1c639480fade33383d18a2",
"size": 1759,
"url": "https://github.com/gauthierpiarrette/highball/releases/download/engine-components/nvapi-stub-2-i386.tar.gz",
- "version": "2"
+ "version": "2",
+ "refreshesPrefix": true
}
},
"displayName": "Wine 11.0 (CrossOver 26.3 tree, Highball build) + DXMT (Highball branch) + D3DMetal 3.0 + MoltenVK 1.4.1",