Skip to content

Commit d5809a4

Browse files
authored
Merge pull request #488 from Kevga/version-fix
Filter out new version suffix
2 parents a2190c1 + ec126d5 commit d5809a4

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

ModAssistant/Classes/Utils.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,11 @@ public static string GetVersion()
275275
var strlen = reader.ReadInt32();
276276
var strbytes = reader.ReadBytes(strlen);
277277

278-
return Encoding.UTF8.GetString(strbytes);
278+
var version = Encoding.UTF8.GetString(strbytes);
279+
280+
//There is one version ending in "p1" on BeatMods
281+
var filteredVersionMatch = Regex.Match(version, @"[\d]+.[\d]+.[\d]+(p1)?");
282+
return filteredVersionMatch.Success ? filteredVersionMatch.Value : version;
279283
}
280284
}
281285

ModAssistant/MainWindow.xaml.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,16 @@ private async void LoadVersionsAsync()
122122
body = await resp.Content.ReadAsStringAsync();
123123
Dictionary<string, string[]> aliases = JsonSerializer.Deserialize<Dictionary<string, string[]>>(body);
124124

125+
string version = Utils.GetVersion();
126+
if (!versions.Contains(version) && CheckAliases(versions, aliases, version) == string.Empty)
127+
{
128+
versions.Insert(0, version);
129+
}
130+
131+
125132
Dispatcher.Invoke(() =>
126133
{
127-
GameVersion = GetGameVersion(versions, aliases);
134+
GameVersion = GetGameVersion(version, versions, aliases);
128135

129136
GameVersionsBox.ItemsSource = versions;
130137
GameVersionsBox.SelectedValue = GameVersion;
@@ -157,9 +164,8 @@ private async void LoadVersionsAsync()
157164
}
158165
}
159166

160-
private string GetGameVersion(List<string> versions, Dictionary<string, string[]> aliases)
167+
private string GetGameVersion(string version, List<string> versions, Dictionary<string, string[]> aliases)
161168
{
162-
string version = Utils.GetVersion();
163169
if (!string.IsNullOrEmpty(version) && versions.Contains(version))
164170
{
165171
return version;

0 commit comments

Comments
 (0)