Skip to content

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

A GOG Mac build keeps its DLC ids, as a Windows install does

Gabe02c51660e9b8
diff --git a/Sources/HighballKit/GOGMac.swift b/Sources/HighballKit/GOGMac.swift
index 97ce8d9..6b6d94e 100644
--- a/Sources/HighballKit/GOGMac.swift
+++ b/Sources/HighballKit/GOGMac.swift
@@ -63,12 +63,15 @@ extension GOGStore {
public var clientID: String? = nil
/// The info file's play tasks, what Galaxy's Play button runs.
public var tasks: [PlayTask] = []
+ /// The DLC installed with it: the other info files beside the game's own whose root game is
+ /// this one.
+ public var dlcIDs: [String] = []
/// The same game as the installed-game record the Windows paths take, so the save sync,
/// comet's achievement lookup and the rest run unchanged. Its folder keeps the Mac build's
/// sync history apart from a Windows copy's.
public var asInstalledGame: InstalledGame {
- InstalledGame(id: id, title: title, folder: folder, buildID: buildID, clientID: clientID, dlcIDs: [], tasks: tasks)
+ InstalledGame(id: id, title: title, folder: folder, buildID: buildID, clientID: clientID, dlcIDs: dlcIDs, tasks: tasks)
}
}
@@ -150,9 +153,12 @@ extension GOGStore {
// opens), not the first by name; none named, the first.
let app = home ?? taskApp(tasks, in: own, among: apps) ?? apps.first
let named = home.map { $0.deletingPathExtension().lastPathComponent } ?? folder.lastPathComponent
+ // DLC sits beside the game's own info and names it as its root. Only the same place's: a
+ // folder of apps holds other games' infos, each its own root.
+ let dlcs = infos.filter { $0.1 == home && $0.0.gameId != base.gameId && $0.0.rootGameId == base.gameId }.map { $0.0.gameId }.sorted()
return MacInstalledGame(id: base.gameId, title: base.name ?? named, folder: own,
app: app, buildID: base.buildId, arch: app.map(MacBinaryArch.ofApp(at:)) ?? .unknown,
- clientID: base.clientId, tasks: tasks)
+ clientID: base.clientId, tasks: tasks, dlcIDs: dlcs)
}
/// The app among `apps` that the primary play task (else the first file task) points at or
diff --git a/Tests/HighballKitTests/StoreMacVersionTests.swift b/Tests/HighballKitTests/StoreMacVersionTests.swift
index ee85c99..1135de6 100644
--- a/Tests/HighballKitTests/StoreMacVersionTests.swift
+++ b/Tests/HighballKitTests/StoreMacVersionTests.swift
@@ -96,6 +96,26 @@ final class GOGMacBuildTests: XCTestCase {
XCTAssertEqual(games.first?.app?.lastPathComponent, "Samorost 1.app")
XCTAssertEqual(games.first?.folder.lastPathComponent, "Samorost 1.app", "the info sits in the app, so the app is the game's folder")
XCTAssertEqual(games.first?.buildID, "55")
+ XCTAssertEqual(games.first?.dlcIDs, ["99"])
+ XCTAssertEqual(games.first?.asInstalledGame.dlcIDs, ["99"], "the record the Windows paths take keeps the DLC")
+ }
+
+ /// DLC is the info beside the game's own that names it as root: never another app's info in
+ /// the same folder of apps, whether that app is another game or names this one.
+ func testDLCIsOnlyTheInfoBesideTheGamesOwn() throws {
+ let applications = FileManager.default.temporaryDirectory.appending(path: "apps-\(UUID().uuidString)")
+ defer { try? FileManager.default.removeItem(at: applications) }
+ let games = applications.appending(path: "Games")
+ let foo = games.appending(path: "Foo.app/Contents/Resources"), zed = games.appending(path: "Zed.app/Contents/Resources")
+ for folder in [foo, zed] { try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true) }
+ try #"{"gameId":"1","rootGameId":"1","name":"Foo"}"#.write(to: foo.appending(path: "goggame-1.info"), atomically: true, encoding: .utf8)
+ try #"{"gameId":"2","rootGameId":"1","name":"Foo DLC"}"#.write(to: foo.appending(path: "goggame-2.info"), atomically: true, encoding: .utf8)
+ try #"{"gameId":"5","name":"Zed"}"#.write(to: zed.appending(path: "goggame-5.info"), atomically: true, encoding: .utf8)
+ try #"{"gameId":"6","rootGameId":"1","name":"Stray"}"#.write(to: zed.appending(path: "goggame-6.info"), atomically: true, encoding: .utf8)
+
+ let game = try XCTUnwrap(GOGStore.macInstalledGames(in: applications).first)
+ XCTAssertEqual(game.id, "1")
+ XCTAssertEqual(game.dlcIDs, ["2"])
}
/// An app among others in a folder of /Applications (/Applications/Games/Foo.app): the game,
@@ -151,6 +171,7 @@ final class GOGMacBuildTests: XCTestCase {
XCTAssertEqual(games.map(\.id), ["1423049311"])
XCTAssertEqual(games.first?.app?.lastPathComponent, "Cyberpunk2077.app")
XCTAssertEqual(games.first?.folder.lastPathComponent, "Cyberpunk 2077")
+ XCTAssertEqual(games.first?.dlcIDs, ["1256837418"])
}
/// A folder with several apps beside its info opens the one the primary play task names, not