mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Fix NaN handling
This commit is contained in:
@ -348,7 +348,10 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
CustomSampleBank = customSampleBank
|
CustomSampleBank = customSampleBank
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (FormatException e)
|
catch (FormatException)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
catch (OverflowException)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,14 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
|
|
||||||
public const double MAX_PARSE_VALUE = int.MaxValue;
|
public const double MAX_PARSE_VALUE = int.MaxValue;
|
||||||
|
|
||||||
public static double ParseFloat(string input, float parseLimit = (float)MAX_PARSE_VALUE)
|
public static float ParseFloat(string input, float parseLimit = (float)MAX_PARSE_VALUE)
|
||||||
{
|
{
|
||||||
var output = float.Parse(input, CultureInfo.InvariantCulture);
|
var output = float.Parse(input, CultureInfo.InvariantCulture);
|
||||||
if (output < -parseLimit) throw new FormatException("Value is too low");
|
|
||||||
if (output > parseLimit) throw new FormatException("Value is too high");
|
if (output < -parseLimit) throw new OverflowException("Value is too low");
|
||||||
|
if (output > parseLimit) throw new OverflowException("Value is too high");
|
||||||
|
|
||||||
|
if (float.IsNaN(output)) throw new FormatException("Not a number");
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
@ -27,8 +30,11 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
public static double ParseDouble(string input, double parseLimit = MAX_PARSE_VALUE)
|
public static double ParseDouble(string input, double parseLimit = MAX_PARSE_VALUE)
|
||||||
{
|
{
|
||||||
var output = double.Parse(input, CultureInfo.InvariantCulture);
|
var output = double.Parse(input, CultureInfo.InvariantCulture);
|
||||||
if (output < -parseLimit) throw new FormatException("Value is too low");
|
|
||||||
if (output > parseLimit) throw new FormatException("Value is too high");
|
if (output < -parseLimit) throw new OverflowException("Value is too low");
|
||||||
|
if (output > parseLimit) throw new OverflowException("Value is too high");
|
||||||
|
|
||||||
|
if (double.IsNaN(output)) throw new FormatException("Not a number");
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
@ -36,8 +42,9 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
public static int ParseInt(string input, int parseLimit = (int)MAX_PARSE_VALUE)
|
public static int ParseInt(string input, int parseLimit = (int)MAX_PARSE_VALUE)
|
||||||
{
|
{
|
||||||
var output = int.Parse(input, CultureInfo.InvariantCulture);
|
var output = int.Parse(input, CultureInfo.InvariantCulture);
|
||||||
if (output < -parseLimit) throw new FormatException("Value is too low");
|
|
||||||
if (output > parseLimit) throw new FormatException("Value is too high");
|
if (output < -parseLimit) throw new OverflowException("Value is too low");
|
||||||
|
if (output > parseLimit) throw new OverflowException("Value is too high");
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
@ -225,8 +225,12 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
|||||||
}
|
}
|
||||||
catch (FormatException)
|
catch (FormatException)
|
||||||
{
|
{
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
catch (OverflowException)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readCustomSampleBanks(string str, SampleBankInfo bankInfo)
|
private void readCustomSampleBanks(string str, SampleBankInfo bankInfo)
|
||||||
|
Reference in New Issue
Block a user