Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion TLM/TLM/TrafficManagerMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class TrafficManagerMod : IUserMod {

public string Description => "Manage your city's traffic";

public void OnEnabled() {
public void OnEnabled() {
Log.Info($"TM:PE enabled. Version {Version}, Build {Assembly.GetExecutingAssembly().GetName().Version} {Branch} for game version {GameVersionA}.{GameVersionB}.{GameVersionC}-f{GameVersionBuild}");

// check for incompatible mods
Expand Down
35 changes: 29 additions & 6 deletions TLM/TLM/Util/ModsCompatibilityChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,24 @@ public void PerformModCheck()
}
catch (Exception e)
{
Log.Info("Something went wrong while checking incompatible mods - see main game log for details.");
Debug.LogException(e);
}
}

/// <summary>
/// Iterates installed mods looking for known incompatibilities.
/// </summary>
///
///
/// <returns>A list of detected incompatible mods.</returns>
///
/// <exception cref="ArgumentException">Invalid folder path (contains invalid characters, is empty, or contains only white spaces).</exception>
/// <exception cref="PathTooLongException">Path is too long (longer than the system-defined maximum length).</exception>
public Dictionary<PluginInfo, string> ScanForIncompatibleMods()
{
Log.Info("Scanning for incompatible mods");
Guid selfModVerId = Assembly.GetExecutingAssembly().ManifestModule.ModuleVersionId;

Log.Info($"Scanning for incompatible mods; Self GUID = {selfModVerId}");

// list of installed incompatible mods
Dictionary<PluginInfo, string> results = new Dictionary<PluginInfo, string>();
Expand Down Expand Up @@ -95,10 +98,16 @@ public Dictionary<PluginInfo, string> ScanForIncompatibleMods()
// Workshop TM:PE builds treat local builds as incompatible
else if (!offline && mod.publishedFileID.AsUInt64 == LOCAL_MOD && (modName.Contains("TM:PE") || modName.Contains("Traffic Manager")))
{
Log.Info($"Local TM:PE detected: '{modName}' in '{mod.modPath}'");
string folder = Path.GetFileName(mod.modPath);
//string folder = mod.modPath.Split(Path.DirectorySeparatorChar).Last();
results.Add(mod, $"{modName} in /{folder}");
if (GetModVerId(mod) == selfModVerId)
{
Log.Info($"Skipping local TM:PE with GUID '{selfModVerId}' in '{mod.modPath}'");
}
else
{
Log.Info($"Local TM:PE detected: '{modName}' in '{mod.modPath}'");
string folder = Path.GetFileName(mod.modPath);
results.Add(mod, $"{modName} in /{folder}");
}
}
#endif
}
Expand All @@ -123,6 +132,20 @@ public string GetModName(PluginInfo plugin)
return ((IUserMod)plugin.userModInstance).Name;
}

/// <summary>
/// Gets the build number of an offline TM:PE mod
///
/// It will return the <see cref="IUserMod.Build"/> if found, otherwise <c>0</c>.
/// </summary>
///
/// <param name="plugin">The <see cref="PluginInfo"/> associated with the mod.</param>
///
/// <returns>The name of the specified plugin.</returns>
public Guid GetModVerId(PluginInfo plugin)
{
return plugin.userModInstance.GetType().Assembly.ManifestModule.ModuleVersionId;
}

/// <summary>
/// Works out if the game is effectively running in offline mode, in which no workshop mod subscriptions will be active.
///
Expand Down