mirror of
https://github.com/ppy/osu
synced 2025-03-19 01:24:34 +00:00
Merge pull request #1098 from MillhioreF/MillhioreF/fix_stable_import_errors
Fix or clarify various errors when importing from stable
This commit is contained in:
commit
371917838f
@ -307,6 +307,11 @@ namespace osu.Game.Beatmaps
|
||||
/// <returns>The imported beatmap, or an existing instance if it is already present.</returns>
|
||||
private BeatmapSetInfo importToStorage(ArchiveReader reader)
|
||||
{
|
||||
// let's make sure there are actually .osu files to import.
|
||||
string mapName = reader.Filenames.FirstOrDefault(f => f.EndsWith(".osu"));
|
||||
if (string.IsNullOrEmpty(mapName))
|
||||
throw new InvalidOperationException("No beatmap files found in the map folder.");
|
||||
|
||||
// for now, concatenate all .osu files in the set to create a unique hash.
|
||||
MemoryStream hashable = new MemoryStream();
|
||||
foreach (string file in reader.Filenames.Where(f => f.EndsWith(".osu")))
|
||||
@ -339,7 +344,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
BeatmapMetadata metadata;
|
||||
|
||||
using (var stream = new StreamReader(reader.GetStream(reader.Filenames.First(f => f.EndsWith(".osu")))))
|
||||
using (var stream = new StreamReader(reader.GetStream(mapName)))
|
||||
metadata = BeatmapDecoder.GetDecoder(stream).Decode(stream).Metadata;
|
||||
|
||||
beatmapSet = new BeatmapSetInfo
|
||||
|
@ -19,7 +19,9 @@ namespace osu.Game.Beatmaps.Formats
|
||||
|
||||
public static BeatmapDecoder GetDecoder(StreamReader stream)
|
||||
{
|
||||
string line = stream.ReadLine()?.Trim();
|
||||
string line;
|
||||
do { line = stream.ReadLine()?.Trim(); }
|
||||
while (line != null && line.Length == 0);
|
||||
|
||||
if (line == null || !decoders.ContainsKey(line))
|
||||
throw new IOException(@"Unknown file format");
|
||||
|
@ -27,7 +27,9 @@ namespace osu.Game.Beatmaps.Formats
|
||||
AddDecoder<OsuLegacyDecoder>(@"osu file format v7");
|
||||
AddDecoder<OsuLegacyDecoder>(@"osu file format v6");
|
||||
AddDecoder<OsuLegacyDecoder>(@"osu file format v5");
|
||||
// TODO: Not sure how far back to go, or differences between versions
|
||||
AddDecoder<OsuLegacyDecoder>(@"osu file format v4");
|
||||
AddDecoder<OsuLegacyDecoder>(@"osu file format v3");
|
||||
// TODO: differences between versions
|
||||
}
|
||||
|
||||
private ConvertHitObjectParser parser;
|
||||
@ -222,6 +224,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
while (line.IndexOf('$') >= 0)
|
||||
{
|
||||
string origLine = line;
|
||||
string[] split = line.Split(',');
|
||||
for (int i = 0; i < split.Length; i++)
|
||||
{
|
||||
@ -231,6 +234,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
}
|
||||
|
||||
line = string.Join(",", split);
|
||||
if (line == origLine) break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,8 +18,11 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
||||
internal abstract class ConvertHitObjectParser : HitObjectParser
|
||||
{
|
||||
public override HitObject Parse(string text)
|
||||
{
|
||||
try
|
||||
{
|
||||
string[] split = text.Split(',');
|
||||
|
||||
ConvertHitObjectType type = (ConvertHitObjectType)int.Parse(split[3]) & ~ConvertHitObjectType.ColourHax;
|
||||
bool combo = type.HasFlag(ConvertHitObjectType.NewCombo);
|
||||
type &= ~ConvertHitObjectType.NewCombo;
|
||||
@ -161,6 +164,11 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
throw new FormatException("One or more hit objects were malformed.");
|
||||
}
|
||||
}
|
||||
|
||||
private void readCustomSampleBanks(string str, SampleBankInfo bankInfo)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user