1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-04 03:53:21 +08:00

Add prefix Online to BeatmapID and BeatmapSetID

This commit is contained in:
柯十六夜 2017-01-09 21:05:01 +08:00
parent c940b48bba
commit acfbf2e32e
9 changed files with 27 additions and 24 deletions

View File

@ -49,12 +49,12 @@ namespace osu.Desktop.VisualTests.Tests
{ {
return new BeatmapSetInfo return new BeatmapSetInfo
{ {
BeatmapSetID = 1234 + i, OnlineBeatmapSetID = 1234 + i,
Hash = "d8e8fca2dc0f896fd7cb4cb0031ba249", Hash = "d8e8fca2dc0f896fd7cb4cb0031ba249",
Path = string.Empty, Path = string.Empty,
Metadata = new BeatmapMetadata Metadata = new BeatmapMetadata
{ {
BeatmapSetID = 1234 + i, OnlineBeatmapSetID = 1234 + i,
Artist = "MONACA", Artist = "MONACA",
Title = "Black Song", Title = "Black Song",
Author = "Some Guy", Author = "Some Guy",
@ -63,7 +63,7 @@ namespace osu.Desktop.VisualTests.Tests
{ {
new BeatmapInfo new BeatmapInfo
{ {
BeatmapID = 1234 + i, OnlineBeatmapID = 1234 + i,
Mode = PlayMode.Osu, Mode = PlayMode.Osu,
Path = "normal.osu", Path = "normal.osu",
Version = "Normal", Version = "Normal",
@ -74,7 +74,7 @@ namespace osu.Desktop.VisualTests.Tests
}, },
new BeatmapInfo new BeatmapInfo
{ {
BeatmapID = 1235 + i, OnlineBeatmapID = 1235 + i,
Mode = PlayMode.Osu, Mode = PlayMode.Osu,
Path = "hard.osu", Path = "hard.osu",
Version = "Hard", Version = "Hard",
@ -85,7 +85,7 @@ namespace osu.Desktop.VisualTests.Tests
}, },
new BeatmapInfo new BeatmapInfo
{ {
BeatmapID = 1236 + i, OnlineBeatmapID = 1236 + i,
Mode = PlayMode.Osu, Mode = PlayMode.Osu,
Path = "insane.osu", Path = "insane.osu",
Version = "Insane", Version = "Insane",

View File

@ -23,6 +23,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
OsuLegacyDecoder.Register(); OsuLegacyDecoder.Register();
Ruleset.Register(new OsuRuleset()); Ruleset.Register(new OsuRuleset());
} }
[Test] [Test]
public void TestDecodeMetadata() public void TestDecodeMetadata()
{ {
@ -31,7 +32,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
{ {
var beatmap = decoder.Decode(new StreamReader(stream)); var beatmap = decoder.Decode(new StreamReader(stream));
var meta = beatmap.BeatmapInfo.Metadata; var meta = beatmap.BeatmapInfo.Metadata;
Assert.AreEqual(241526, meta.BeatmapSetID); Assert.AreEqual(241526, meta.OnlineBeatmapSetID);
Assert.AreEqual("Soleily", meta.Artist); Assert.AreEqual("Soleily", meta.Artist);
Assert.AreEqual("Soleily", meta.ArtistUnicode); Assert.AreEqual("Soleily", meta.ArtistUnicode);
Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile); Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile);
@ -125,7 +126,8 @@ namespace osu.Game.Tests.Beatmaps.Formats
} }
} }
[Test] public void TestDecodeHitObjects() [Test]
public void TestDecodeHitObjects()
{ {
var decoder = new OsuLegacyDecoder(); var decoder = new OsuLegacyDecoder();
using (var stream = Resource.OpenResource("Soleily - Renatus (Gamu) [Insane].osu")) using (var stream = Resource.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))

View File

@ -83,7 +83,7 @@ namespace osu.Game.Tests.Beatmaps.IO
Action waitAction = () => Action waitAction = () =>
{ {
while ((resultSets = osu.Dependencies.Get<BeatmapDatabase>() while ((resultSets = osu.Dependencies.Get<BeatmapDatabase>()
.Query<BeatmapSetInfo>().Where(s => s.BeatmapSetID == 241526)).Count() != 1) .Query<BeatmapSetInfo>().Where(s => s.OnlineBeatmapSetID == 241526)).Count() != 1)
Thread.Sleep(1); Thread.Sleep(1);
}; };
@ -100,7 +100,7 @@ namespace osu.Game.Tests.Beatmaps.IO
waitAction = () => waitAction = () =>
{ {
while ((resultBeatmaps = osu.Dependencies.Get<BeatmapDatabase>() while ((resultBeatmaps = osu.Dependencies.Get<BeatmapDatabase>()
.Query<BeatmapInfo>().Where(s => s.BeatmapSetID == 241526 && s.BaseDifficultyID > 0)).Count() != 12) .Query<BeatmapInfo>().Where(s => s.OnlineBeatmapSetID == 241526 && s.BaseDifficultyID > 0)).Count() != 12)
Thread.Sleep(1); Thread.Sleep(1);
}; };
@ -113,7 +113,7 @@ namespace osu.Game.Tests.Beatmaps.IO
Assert.IsTrue(set.Beatmaps.Count == resultBeatmaps.Count()); Assert.IsTrue(set.Beatmaps.Count == resultBeatmaps.Count());
foreach (BeatmapInfo b in resultBeatmaps) foreach (BeatmapInfo b in resultBeatmaps)
Assert.IsTrue(set.Beatmaps.Any(c => c.BeatmapID == b.BeatmapID)); Assert.IsTrue(set.Beatmaps.Any(c => c.OnlineBeatmapID == b.OnlineBeatmapID));
Assert.IsTrue(set.Beatmaps.Count > 0); Assert.IsTrue(set.Beatmaps.Count > 0);

View File

@ -52,7 +52,7 @@ namespace osu.Game.Tests.Beatmaps.IO
{ {
var reader = new OszArchiveReader(osz); var reader = new OszArchiveReader(osz);
var meta = reader.ReadMetadata(); var meta = reader.ReadMetadata();
Assert.AreEqual(241526, meta.BeatmapSetID); Assert.AreEqual(241526, meta.OnlineBeatmapSetID);
Assert.AreEqual("Soleily", meta.Artist); Assert.AreEqual("Soleily", meta.Artist);
Assert.AreEqual("Soleily", meta.ArtistUnicode); Assert.AreEqual("Soleily", meta.ArtistUnicode);
Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile); Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile);
@ -65,6 +65,7 @@ namespace osu.Game.Tests.Beatmaps.IO
Assert.AreEqual("Renatus", meta.TitleUnicode); Assert.AreEqual("Renatus", meta.TitleUnicode);
} }
} }
[Test] [Test]
public void TestReadFile() public void TestReadFile()
{ {

View File

@ -136,11 +136,11 @@ namespace osu.Game.Beatmaps.Formats
beatmap.BeatmapInfo.Metadata.Tags = val; beatmap.BeatmapInfo.Metadata.Tags = val;
break; break;
case @"BeatmapID": case @"BeatmapID":
beatmap.BeatmapInfo.BeatmapID = int.Parse(val); beatmap.BeatmapInfo.OnlineBeatmapID = int.Parse(val);
break; break;
case @"BeatmapSetID": case @"BeatmapSetID":
beatmap.BeatmapInfo.BeatmapSetID = int.Parse(val); beatmap.BeatmapInfo.OnlineBeatmapSetID = int.Parse(val);
metadata.BeatmapSetID = int.Parse(val); metadata.OnlineBeatmapSetID = int.Parse(val);
break; break;
} }
} }

View File

@ -69,8 +69,8 @@ namespace osu.Game.Database
using (var reader = ArchiveReader.GetReader(storage, path)) using (var reader = ArchiveReader.GetReader(storage, path))
metadata = reader.ReadMetadata(); metadata = reader.ReadMetadata();
if (metadata.BeatmapSetID != -1 && if (metadata.OnlineBeatmapSetID.HasValue &&
connection.Table<BeatmapSetInfo>().Count(b => b.BeatmapSetID == metadata.BeatmapSetID) != 0) connection.Table<BeatmapSetInfo>().Count(b => b.OnlineBeatmapSetID == metadata.OnlineBeatmapSetID) != 0)
return; // TODO: Update this beatmap instead return; // TODO: Update this beatmap instead
if (File.Exists(path)) // Not always the case, i.e. for LegacyFilesystemReader if (File.Exists(path)) // Not always the case, i.e. for LegacyFilesystemReader
@ -87,7 +87,7 @@ namespace osu.Game.Database
} }
var beatmapSet = new BeatmapSetInfo var beatmapSet = new BeatmapSetInfo
{ {
BeatmapSetID = metadata.BeatmapSetID, OnlineBeatmapSetID = metadata.OnlineBeatmapSetID,
Beatmaps = new List<BeatmapInfo>(), Beatmaps = new List<BeatmapInfo>(),
Path = path, Path = path,
Hash = hash, Hash = hash,
@ -140,7 +140,7 @@ namespace osu.Game.Database
public BeatmapSetInfo GetBeatmapSet(int id) public BeatmapSetInfo GetBeatmapSet(int id)
{ {
return Query<BeatmapSetInfo>().FirstOrDefault(s => s.BeatmapSetID == id); return Query<BeatmapSetInfo>().FirstOrDefault(s => s.OnlineBeatmapSetID == id);
} }
public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null) public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null)

View File

@ -16,9 +16,9 @@ namespace osu.Game.Database
[PrimaryKey, AutoIncrement] [PrimaryKey, AutoIncrement]
public int ID { get; set; } public int ID { get; set; }
public int BeatmapID { get; set; } = 0; public int? OnlineBeatmapID { get; set; } = null;
public int BeatmapSetID { get; set; } = -1; public int? OnlineBeatmapSetID { get; set; } = null;
[ForeignKey(typeof(BeatmapSetInfo))] [ForeignKey(typeof(BeatmapSetInfo))]
public int BeatmapSetInfoID { get; set; } public int BeatmapSetInfoID { get; set; }

View File

@ -10,7 +10,7 @@ namespace osu.Game.Database
[PrimaryKey, AutoIncrement] [PrimaryKey, AutoIncrement]
public int ID { get; set; } public int ID { get; set; }
public int BeatmapSetID { get; set; } = -1; public int? OnlineBeatmapSetID { get; set; } = null;
public string Title { get; set; } public string Title { get; set; }
public string TitleUnicode { get; set; } public string TitleUnicode { get; set; }

View File

@ -13,7 +13,7 @@ namespace osu.Game.Database
[PrimaryKey, AutoIncrement] [PrimaryKey, AutoIncrement]
public int ID { get; set; } public int ID { get; set; }
public int BeatmapSetID { get; set; } = -1; public int? OnlineBeatmapSetID { get; set; } = null;
[OneToOne(CascadeOperations = CascadeOperation.All)] [OneToOne(CascadeOperations = CascadeOperation.All)]
public BeatmapMetadata Metadata { get; set; } public BeatmapMetadata Metadata { get; set; }