Skip to content

Commit 82ef139

Browse files
Merge pull request #5 from PolyTech-Modding/update_check_fix
fixed issue when receiving invalid version when checking for mod updates
2 parents d9b7c43 + c6e2311 commit 82ef139

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

ParseClasses.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,21 @@ public class Release
4848

4949
public System.Version GetVersion()
5050
{
51+
System.Version version;
5152
string parsed = this.tag_name.ToLower().Replace("v", "");
52-
return new System.Version(parsed);
53+
int pos;
54+
pos = parsed.IndexOf("-");
55+
if (pos != -1) parsed = parsed.Substring(0, pos);
56+
pos = parsed.IndexOf("+");;
57+
if (pos != -1) parsed = parsed.Substring(0, pos);
58+
try {
59+
version = new System.Version(parsed);
60+
}
61+
catch (FormatException ex){
62+
PolyTechMain.ptfInstance.ptfLogger.LogError("Invalid Version found while checking for mod updates, using fallback value 0.0.0");
63+
version = new System.Version("0.0.0");
64+
}
65+
return version;
5366
}
5467
}
5568

PolyTechMain.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class PolyTechMain : PolyTechMod
2323
public new const string
2424
PluginGuid = "polytech.polytechframework",
2525
PluginName = "PolyTech Framework",
26-
PluginVersion = "0.9.1";
26+
PluginVersion = "0.9.2";
2727
private static BindingList<PolyTechMod>
2828
noncheatMods = new BindingList<PolyTechMod> { },
2929
cheatMods = new BindingList<PolyTechMod> { };

0 commit comments

Comments
 (0)