|
1 | 1 | namespace QModManager.Patching
|
2 | 2 | {
|
3 | 3 | using System;
|
| 4 | + using System.Collections.Generic; |
4 | 5 | using System.IO;
|
| 6 | + using System.Reflection; |
5 | 7 | using QModManager.API;
|
6 | 8 | using QModManager.Utility;
|
7 | 9 |
|
8 | 10 | internal class GameDetector
|
9 | 11 | {
|
10 | 12 | internal readonly QModGame CurrentlyRunningGame;
|
| 13 | + internal readonly int CurrentGameVersion = -1; |
11 | 14 |
|
12 |
| - internal bool IsValidGameRunning => CurrentlyRunningGame == QModGame.Subnautica || CurrentlyRunningGame == QModGame.BelowZero; |
| 15 | + /// <summary> |
| 16 | + /// Game -> game version. |
| 17 | + /// 0 = no minimum version required. |
| 18 | + /// </summary> |
| 19 | + private static readonly Dictionary<QModGame, int> SupportedGameVersions = new Dictionary<QModGame, int> |
| 20 | + { |
| 21 | + { QModGame.Subnautica, 0 }, |
| 22 | + { QModGame.BelowZero, 0 } |
| 23 | + }; |
| 24 | + |
| 25 | + internal bool IsValidGameRunning => SupportedGameVersions.ContainsKey(CurrentlyRunningGame); |
| 26 | + internal int MinimumBuildVersion => IsValidGameVersion ? SupportedGameVersions[CurrentlyRunningGame] : -1; |
| 27 | + internal bool IsValidGameVersion => IsValidGameRunning && MinimumBuildVersion == 0 || (CurrentGameVersion > -1 && CurrentGameVersion >= MinimumBuildVersion); |
13 | 28 |
|
14 | 29 | internal GameDetector()
|
15 | 30 | {
|
@@ -38,6 +53,17 @@ internal GameDetector()
|
38 | 53 | Logger.Fatal("A fatal error has occurred. No game executable was found!");
|
39 | 54 | throw new FatalPatchingException("No game executable was found!");
|
40 | 55 | }
|
| 56 | + |
| 57 | + Logger.Info($"Game Version: {SNUtils.GetPlasticChangeSetOfBuild()} Build Date: {SNUtils.GetDateTimeOfBuild():dd-MMMM-yyyy}"); |
| 58 | + Logger.Info($"Loading QModManager v{Assembly.GetExecutingAssembly().GetName().Version.ToStringParsed()}{(IsValidGameRunning && MinimumBuildVersion != 0 ? $" built for {CurrentlyRunningGame} v{MinimumBuildVersion}" : string.Empty)}..."); |
| 59 | + Logger.Info($"Today is {DateTime.Today:dd-MMMM-yyyy}"); |
| 60 | + |
| 61 | + CurrentGameVersion = SNUtils.GetPlasticChangeSetOfBuild(-1); |
| 62 | + if (!IsValidGameVersion) |
| 63 | + { |
| 64 | + Logger.Fatal("A fatal error has occurred. An invalid game version was detected!"); |
| 65 | + throw new FatalPatchingException("An invalid game version was detected!"); |
| 66 | + } |
41 | 67 | }
|
42 | 68 | }
|
43 | 69 | }
|
0 commit comments