mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 13:22:55 +08:00
Recommended fixes (obsolete try/catch, fix infinite loop during variable parsing in a better way)
This commit is contained in:
parent
e42c279229
commit
e216bfcf10
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user