Skip to content

Commit 6565bd1

Browse files
authored
Handle launcher-settings.json not being found in CK3 files (#2800) #patch
Sentry event ID: 72fdb08741464fb18c5435bb1f1d7caa
1 parent 34ef549 commit 6565bd1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

ImperatorToCK3/Configuration.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ private void VerifyImperatorVersion(ConverterVersion converterVersion) {
311311
private void VerifyCK3Version(ConverterVersion converterVersion) {
312312
var path = Path.Combine(CK3Path, "launcher/launcher-settings.json");
313313
CK3Version = GameVersion.ExtractVersionFromLauncher(path) ??
314+
GetCK3VersionFromTitusBranchFile() ??
314315
throw new ConverterException("CK3 version could not be determined.");
315316

316317
Logger.Info($"CK3 version: {CK3Version.ToShortString()}");
@@ -325,6 +326,20 @@ private void VerifyCK3Version(ConverterVersion converterVersion) {
325326
}
326327
}
327328

329+
private GameVersion? GetCK3VersionFromTitusBranchFile() {
330+
var path = Path.Combine(CK3Path, "titus_branch.txt");
331+
332+
if (!File.Exists(path)) {
333+
Logger.Warn("titus_branch.txt not found");
334+
return null;
335+
}
336+
337+
// The file contains the game version in the following format: release/X.Y.Z.
338+
var versionStr = File.ReadAllText(path).Trim().Replace("release/", "");
339+
var version = new GameVersion(versionStr);
340+
return version;
341+
}
342+
328343
public void DetectSpecificCK3Mods(ICollection<Mod> loadedMods) {
329344
var tfeMod = loadedMods.FirstOrDefault(m => m.Name.StartsWith("The Fallen Eagle", StringComparison.Ordinal));
330345
if (tfeMod is not null) {

0 commit comments

Comments
 (0)