Skip to content

Commit

Permalink
Merge pull request #31747 from bdach/do-not-reset-online-info-on-save
Browse files Browse the repository at this point in the history
Do not reset online information when saving beatmap
  • Loading branch information
peppy authored Feb 2, 2025
2 parents cf3a379 + 7ef8616 commit f65be00
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using NUnit.Framework;
using osu.Framework.Extensions;
using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Tests.Resources;

Expand All @@ -25,13 +26,16 @@ public override void SetUpSteps()
[Test]
public void TestLocallyModifyingOnlineBeatmap()
{
string initialHash = string.Empty;
AddAssert("editor beatmap has online ID", () => EditorBeatmap.BeatmapInfo.OnlineID, () => Is.GreaterThan(0));
AddStep("store hash for later", () => initialHash = EditorBeatmap.BeatmapInfo.MD5Hash);

AddStep("delete first hitobject", () => EditorBeatmap.RemoveAt(0));
SaveEditor();

ReloadEditorToSameBeatmap();
AddAssert("editor beatmap online ID reset", () => EditorBeatmap.BeatmapInfo.OnlineID, () => Is.EqualTo(-1));
AddAssert("beatmap marked as locally modified", () => EditorBeatmap.BeatmapInfo.Status, () => Is.EqualTo(BeatmapOnlineStatus.LocallyModified));
AddAssert("beatmap hash changed", () => EditorBeatmap.BeatmapInfo.MD5Hash, () => Is.Not.EqualTo(initialHash));
}
}
}
3 changes: 0 additions & 3 deletions osu.Game/Beatmaps/BeatmapManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -475,11 +475,8 @@ private void save(BeatmapInfo beatmapInfo, IBeatmap beatmapContent, ISkin? beatm
beatmapContent.BeatmapInfo = beatmapInfo;

// Since now this is a locally-modified beatmap, we also set all relevant flags to indicate this.
// Importantly, the `ResetOnlineInfo()` call must happen before encoding, as online ID is encoded into the `.osu` file,
// which influences the beatmap checksums.
beatmapInfo.LastLocalUpdate = DateTimeOffset.Now;
beatmapInfo.Status = BeatmapOnlineStatus.LocallyModified;
beatmapInfo.ResetOnlineInfo();

Realm.Write(r =>
{
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Screens/Play/SubmittingPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void handleTokenFailure(Exception exception, bool displayNotification = false)
Logger.Log($"Please ensure that you are using the latest version of the official game releases.\n\n{whatWillHappen}", level: LogLevel.Important);
break;

case @"invalid beatmap_hash":
case @"invalid or missing beatmap_hash":
Logger.Log($"This beatmap does not match the online version. Please update or redownload it.\n\n{whatWillHappen}", level: LogLevel.Important);
break;

Expand Down

0 comments on commit f65be00

Please # to comment.