Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions TLM/TLM/Lifecycle/TMPELifecycle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,25 @@ internal static bool PlayMode {
}
}

/// <summary>
/// Inhibits the "Resume" (auto-load last city on launch) feature of
/// the Paradox Launcher (and associated app launch option).
/// </summary>
public static void HaltLauncherAutoContinue() {
Log.Info("Halting game 'Resume' feature due to incompatibility issue.");
LauncherLoginData.instance.m_continue = false;
}

private static void CompatibilityCheck() {
bool problems = false;

ModsCompatibilityChecker mcc = new ModsCompatibilityChecker();
mcc.PerformModCheck();
VersionUtil.CheckGameVersion();
problems |= mcc.PerformModCheck();
problems |= VersionUtil.CheckGameVersion();

if (problems) {
HaltLauncherAutoContinue();
}
}

internal void Preload() {
Expand Down
8 changes: 6 additions & 2 deletions TLM/TLM/Util/ModsCompatibilityChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ public ModsCompatibilityChecker() {
}

/// <summary>
/// Initiates scan for incompatible mods. If any found, and the user has enabled the mod checker, it creates and initialises the modal dialog panel.
/// Initiates scan for incompatible mods. If any found, and the user has enabled the mod checker,
/// it creates and initialises the modal dialog panel.
/// </summary>
public void PerformModCheck() {
/// <returns>Returns <c>false</c> if incompatible mods found (ie. mcc dialog shown).</returns>
public bool PerformModCheck() {
try {
Dictionary<PluginInfo, string> detected = ScanForIncompatibleMods();

Expand All @@ -46,13 +48,15 @@ public void PerformModCheck() {
panel.Initialize();
UIView.PushModal(panel);
UIView.SetFocus(panel);
return false;
}
}
catch (Exception e) {
Log.Info(
"Something went wrong while checking incompatible mods - see main game log for details.");
Debug.LogException(e);
}
return true;
}

/// <summary>
Expand Down
47 changes: 22 additions & 25 deletions TLM/TLM/Util/VersionUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public static class VersionUtil {
// we could alternatively use BuildConfig.APPLICATION_VERSION because const values are evaluated at compile time.
// but I have decided not to do this because I don't want this to happen automatically with a rebuild if
// CS updates. these values should be changed manaually so as to force us to acknowledge that they have changed.
public const uint EXPECTED_GAME_VERSION_U = 189262096U;
public const uint EXPECTED_GAME_VERSION_U = 193061904u;

// see comments for EXPECTED_GAME_VERSION_U.
public static Version ExpectedGameVersion => new Version(1, 13, 3, 9);
public static Version ExpectedGameVersion => new Version(1, 14, 0, 4);

public static string ExpectedGameVersionString => BuildConfig.VersionToString(EXPECTED_GAME_VERSION_U, false);

Expand Down Expand Up @@ -116,41 +116,38 @@ public static void LogMonoVersion() {
}
}

/// <summary>
/// Checks to see if game version is what TMPE expects, and if not warns users.
///
/// This will be replaced as part of #699.
/// </summary>
public static void CheckGameVersion() {
/// <summary>Checks to see if game version is what TMPE expects, and if not warns users.</summary>
/// <returns>Returns <c>false</c> if there is a game/mod version problem.</returns>
public static bool CheckGameVersion() {
if (CurrentGameVersionU != EXPECTED_GAME_VERSION_U) {
Log.Info($"Detected game version v{BuildConfig.applicationVersion}. TMPE built for {ExpectedGameVersionString}");
Log._Debug($"CurrentGameVersion={CurrentGameVersion} ExpectedGameVersion={ExpectedGameVersion}");
Version current = CurrentGameVersion.Take(VERSION_COMPONENTS_COUNT);
Version expected = ExpectedGameVersion.Take(VERSION_COMPONENTS_COUNT);

if (current < expected) {
// game too old
string msg = string.Format(
"Traffic Manager: President Edition detected that you are running " +
"a newer game version ({0}) than TM:PE has been built for ({1}). " +
"Please be aware that TM:PE has not been updated for the newest game " +
"version yet and thus it is very likely it will not work as expected.",
BuildConfig.applicationVersion,
ExpectedGameVersionString);
Log.Error(msg);
Shortcuts.ShowErrorDialog("TM:PE has not been updated yet", msg);
} else if (current > expected) {
// TMPE too old
if (current != expected) {
string msg = string.Format(
"Traffic Manager: President Edition has been built for game version {0}. " +
"You are running game version {1}. Some features of TM:PE will not " +
"work with older game versions. Please let Steam update your game.",
"{0} is designed for Cities: Skylines {1}. However you are using Cities: " +
"Skylines {2} - this is likely to cause severe problems or crashes." +
"\n\n" +
"Please ensure you're using the right version of TM:PE for this version of " +
"Cities: Skylines before proceeding, or disable TM:PE until the problem is " +
"resolved. If you need help, contact us via Steam Workshop page or Discord chat.",
TrafficManagerMod.ModName,
ExpectedGameVersionString,
BuildConfig.applicationVersion);
Log.Error(msg);
Shortcuts.ShowErrorDialog("Your game should be updated", msg);

Shortcuts.ShowErrorDialog(
current > expected
? "TM:PE needs updating!"
: "Cities: Skylines needs updating!",
msg);

return false;
}
}
return true;
}
}
}