1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 10:42:54 +08:00

Recommended fixes (obsolete try/catch, fix infinite loop during variable parsing in a better way)

This commit is contained in:
MillhioreF 2017-08-13 00:40:05 -05:00
parent e42c279229
commit e216bfcf10
2 changed files with 5 additions and 9 deletions

View File

@ -307,16 +307,10 @@ namespace osu.Game.Beatmaps
/// <returns>The imported beatmap, or an existing instance if it is already present.</returns>
private BeatmapSetInfo importToStorage(ArchiveReader reader)
{
string mapName;
// let's make sure there are actually .osu files to import.
try
{
mapName = reader.Filenames.First(f => f.EndsWith(".osu"));
}
catch
{
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();

View File

@ -222,8 +222,9 @@ namespace osu.Game.Beatmaps.Formats
/// <param name="line">The line which may contains variables.</param>
private void decodeVariables(ref string line)
{
if (line.IndexOf('$') >= 0)
while (line.IndexOf('$') >= 0)
{
string origLine = line;
string[] split = line.Split(',');
for (int i = 0; i < split.Length; i++)
{
@ -233,6 +234,7 @@ namespace osu.Game.Beatmaps.Formats
}
line = string.Join(",", split);
if (line == origLine) break;
}
}