mirror of
https://github.com/ppy/osu.git
synced 2025-02-10 13:03:01 +08:00
Merge pull request #31747 from bdach/do-not-reset-online-info-on-save
Do not reset online information when saving beatmap
This commit is contained in:
commit
f65be009a3
@ -4,6 +4,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Extensions;
|
using osu.Framework.Extensions;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Tests.Resources;
|
using osu.Game.Tests.Resources;
|
||||||
|
|
||||||
@ -25,13 +26,16 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestLocallyModifyingOnlineBeatmap()
|
public void TestLocallyModifyingOnlineBeatmap()
|
||||||
{
|
{
|
||||||
|
string initialHash = string.Empty;
|
||||||
AddAssert("editor beatmap has online ID", () => EditorBeatmap.BeatmapInfo.OnlineID, () => Is.GreaterThan(0));
|
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));
|
AddStep("delete first hitobject", () => EditorBeatmap.RemoveAt(0));
|
||||||
SaveEditor();
|
SaveEditor();
|
||||||
|
|
||||||
ReloadEditorToSameBeatmap();
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -475,11 +475,8 @@ namespace osu.Game.Beatmaps
|
|||||||
beatmapContent.BeatmapInfo = beatmapInfo;
|
beatmapContent.BeatmapInfo = beatmapInfo;
|
||||||
|
|
||||||
// Since now this is a locally-modified beatmap, we also set all relevant flags to indicate this.
|
// 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.LastLocalUpdate = DateTimeOffset.Now;
|
||||||
beatmapInfo.Status = BeatmapOnlineStatus.LocallyModified;
|
beatmapInfo.Status = BeatmapOnlineStatus.LocallyModified;
|
||||||
beatmapInfo.ResetOnlineInfo();
|
|
||||||
|
|
||||||
Realm.Write(r =>
|
Realm.Write(r =>
|
||||||
{
|
{
|
||||||
|
@ -152,7 +152,7 @@ namespace osu.Game.Screens.Play
|
|||||||
Logger.Log($"Please ensure that you are using the latest version of the official game releases.\n\n{whatWillHappen}", level: LogLevel.Important);
|
Logger.Log($"Please ensure that you are using the latest version of the official game releases.\n\n{whatWillHappen}", level: LogLevel.Important);
|
||||||
break;
|
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);
|
Logger.Log($"This beatmap does not match the online version. Please update or redownload it.\n\n{whatWillHappen}", level: LogLevel.Important);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user