Skip to content

Commit 83b321a

Browse files
authored
Add a fallback method of determining the I:R version (#2921) #patch
Sentry event ID: 228662d8a98549e2affc17b77fad05a2
1 parent 0377a04 commit 83b321a

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

ImperatorToCK3/Configuration.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@ private void SetOutputName() {
296296
private void VerifyImperatorVersion(ConverterVersion converterVersion) {
297297
var path = Path.Combine(ImperatorPath, "launcher/launcher-settings.json");
298298
IRVersion = GameVersion.ExtractVersionFromLauncher(path) ??
299-
throw new ConverterException("Imperator version could not be determined.");
299+
GetImperatorVersionFromSullaBranchFile() ??
300+
throw new ConverterException("Imperator version could not be determined.");
300301

301302
Logger.Info($"Imperator version: {IRVersion.ToShortString()}");
302303

@@ -310,6 +311,21 @@ private void VerifyImperatorVersion(ConverterVersion converterVersion) {
310311
}
311312
}
312313

314+
private GameVersion? GetImperatorVersionFromSullaBranchFile() {
315+
const string sullaBranchFileName = "sulla_branch.txt";
316+
var path = Path.Combine(ImperatorPath, sullaBranchFileName);
317+
318+
if (!File.Exists(path)) {
319+
Logger.Warn($"{sullaBranchFileName} not found");
320+
return null;
321+
}
322+
323+
// The file contains the game version in the following format: release/X.Y.Z.
324+
var versionStr = File.ReadAllText(path).Trim().Replace("release/", "");
325+
var version = new GameVersion(versionStr);
326+
return version;
327+
}
328+
313329
private void VerifyCK3Version(ConverterVersion converterVersion) {
314330
var path = Path.Combine(CK3Path, "launcher/launcher-settings.json");
315331
CK3Version = GameVersion.ExtractVersionFromLauncher(path) ??
@@ -329,10 +345,11 @@ private void VerifyCK3Version(ConverterVersion converterVersion) {
329345
}
330346

331347
private GameVersion? GetCK3VersionFromTitusBranchFile() {
332-
var path = Path.Combine(CK3Path, "titus_branch.txt");
348+
const string titusBranchFileName = "titus_branch.txt";
349+
var path = Path.Combine(CK3Path, titusBranchFileName);
333350

334351
if (!File.Exists(path)) {
335-
Logger.Warn("titus_branch.txt not found");
352+
Logger.Warn($"{titusBranchFileName} not found");
336353
return null;
337354
}
338355

0 commit comments

Comments
 (0)