-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from Kylemc1413/fix/1.34.4
Update for game v1.35.0
- Loading branch information
Showing
24 changed files
with
379 additions
and
410 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 8 additions & 25 deletions
33
source/SongCore/HarmonyPatches/BeatmapVersionDetectionPatch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,19 @@ | ||
using System; | ||
using System.Text.RegularExpressions; | ||
using HarmonyLib; | ||
using JetBrains.Annotations; | ||
|
||
namespace SongCore.HarmonyPatches | ||
{ | ||
// This patch fixes the base game implementation, which fails with maps that have no version declared. | ||
// Without this patch affected maps don't load when selected. It is also 100 times faster on average. | ||
[HarmonyPatch(typeof(BeatmapSaveDataHelpers), nameof(BeatmapSaveDataHelpers.GetVersion))] | ||
[UsedImplicitly] | ||
/// <summary> | ||
/// This patch fixes the base game implementation, which fails with maps that have no version declared. | ||
/// Without this patch affected maps don't load when selected. | ||
/// </summary> | ||
[HarmonyPatch(typeof(BeatmapSaveDataHelpers.VersionSerializedData), nameof(BeatmapSaveDataHelpers.VersionSerializedData.v), MethodType.Getter)] | ||
internal static class BeatmapVersionDetectionPatch | ||
{ | ||
private static readonly Regex VersionRegex = new Regex( | ||
@"""_?version""\s*:\s*""(?<version>[0-9]+\.[0-9]+\.?[0-9]?)""", | ||
RegexOptions.Compiled | RegexOptions.CultureInvariant | ||
); | ||
|
||
private static readonly Version FallbackVersion = new Version("2.0.0"); | ||
|
||
[UsedImplicitly] | ||
private static bool Prefix(string data, ref Version __result) | ||
private static void Postfix(ref string? __result) | ||
{ | ||
var truncatedText = data.Substring(0, 50); | ||
var match = VersionRegex.Match(truncatedText); | ||
if (!match.Success) | ||
{ | ||
__result = FallbackVersion; | ||
return false; | ||
} | ||
|
||
__result = new Version(match.Groups["version"].Value); | ||
return false; | ||
__result ??= BeatmapSaveDataHelpers.noVersion.ToString(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.