Skip to content

Commit

Permalink
Fix internal field change causing issue on ModSet creation
Browse files Browse the repository at this point in the history
  • Loading branch information
DoctorVanGogh committed Dec 9, 2018
1 parent da09406 commit f8df230
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
Binary file modified Assemblies/ModSwitch.dll
Binary file not shown.
7 changes: 4 additions & 3 deletions Source/ModSwitch/Model/ModSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
using System.Text;
using System.Text.RegularExpressions;
using Harmony;
using RimWorld;
using UnityEngine;
using Verse;

namespace DoctorVanGogh.ModSwitch {
internal class ModSet : IExposable {
private static readonly FieldInfo fiModsConfig_data;
private static readonly FieldInfo fiModsConfigData_activeMods;
private static readonly FieldInfo fiModsConfigData_buildNumber;
private static readonly FieldInfo fiModsConfigData_version;

private static readonly Regex rgxSteamModId;

Expand All @@ -37,7 +38,7 @@ static ModSet() {
Type tModsConfig = typeof(ModsConfig);
Type tModsConfigData = AccessTools.Inner(tModsConfig, @"ModsConfigData");
fiModsConfigData_activeMods = AccessTools.Field(tModsConfigData, @"activeMods");
fiModsConfigData_buildNumber = AccessTools.Field(tModsConfigData, @"buildNumber");
fiModsConfigData_version = AccessTools.Field(tModsConfigData, @"version");
fiModsConfig_data = AccessTools.Field(tModsConfig, @"data");

rgxSteamModId = new Regex(@"^\d+$", RegexOptions.Singleline | RegexOptions.Compiled);
Expand Down Expand Up @@ -229,7 +230,7 @@ public static ModSet FromCurrent(string name, Settings owner) {

return new ModSet(owner) {
Name = name,
BuildNumber = (int) fiModsConfigData_buildNumber.GetValue(modsConfigData),
BuildNumber = VersionControl.BuildFromVersionString((string)fiModsConfigData_version.GetValue(modsConfigData)),
Mods = new List<string>((IEnumerable<string>) fiModsConfigData_activeMods.GetValue(modsConfigData))
};
}
Expand Down
2 changes: 1 addition & 1 deletion Source/ModSwitch/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
[assembly: System.Reflection.AssemblyCopyright("Copyright © DoctorVanGogh 2017")]
[assembly: System.Runtime.InteropServices.ComVisible(false)]
[assembly: System.Runtime.InteropServices.Guid("ab2e8e89-3d1d-4e36-a0ae-489b6ebc84a6")]
[assembly: System.Reflection.AssemblyVersion("1.7.0.218")]
[assembly: System.Reflection.AssemblyVersion("1.7.1.223")]


2 changes: 1 addition & 1 deletion Source/ModSwitch/Properties/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.7.0.218
1.7.1.223
7 changes: 4 additions & 3 deletions Source/ModSwitch/[Patches]/Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -790,9 +790,10 @@ public static bool FindFragment(List<CodeInstruction> instructions, OpCode[] opC
return false;
}

public static string ShortVerisonString(string targetVersion)
{
return VersionControl.MajorFromVersionString(targetVersion).ToString() + "." + VersionControl.MinorFromVersionString(targetVersion).ToString();
public static string ShortVerisonString(string targetVersion) {
return VersionControl.IsWellFormattedVersionString(targetVersion)
? VersionControl.VersionFromString(targetVersion).ToString(2)
: targetVersion;
}
}
}
Expand Down

0 comments on commit f8df230

Please sign in to comment.