1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-12 13:22:56 +08:00

Fix catch crashing when finishing maps

This commit is contained in:
smoogipoo 2020-05-07 12:22:07 +09:00
parent c8134162b5
commit e91e4a73af

View File

@ -12,7 +12,7 @@ namespace osu.Game.Scoring.Legacy
switch (scoreInfo.Ruleset?.ID ?? scoreInfo.RulesetID) switch (scoreInfo.Ruleset?.ID ?? scoreInfo.RulesetID)
{ {
case 3: case 3:
return scoreInfo.Statistics[HitResult.Perfect]; return getCount(scoreInfo, HitResult.Perfect);
} }
return null; return null;
@ -35,10 +35,10 @@ namespace osu.Game.Scoring.Legacy
case 0: case 0:
case 1: case 1:
case 3: case 3:
return scoreInfo.Statistics[HitResult.Great]; return getCount(scoreInfo, HitResult.Great);
case 2: case 2:
return scoreInfo.Statistics[HitResult.Perfect]; return getCount(scoreInfo, HitResult.Perfect);
} }
return null; return null;
@ -65,10 +65,10 @@ namespace osu.Game.Scoring.Legacy
switch (scoreInfo.Ruleset?.ID ?? scoreInfo.RulesetID) switch (scoreInfo.Ruleset?.ID ?? scoreInfo.RulesetID)
{ {
case 3: case 3:
return scoreInfo.Statistics[HitResult.Good]; return getCount(scoreInfo, HitResult.Good);
case 2: case 2:
return scoreInfo.Statistics[HitResult.SmallTickMiss]; return getCount(scoreInfo, HitResult.SmallTickMiss);
} }
return null; return null;
@ -94,13 +94,13 @@ namespace osu.Game.Scoring.Legacy
{ {
case 0: case 0:
case 1: case 1:
return scoreInfo.Statistics[HitResult.Good]; return getCount(scoreInfo, HitResult.Good);
case 3: case 3:
return scoreInfo.Statistics[HitResult.Ok]; return getCount(scoreInfo, HitResult.Ok);
case 2: case 2:
return scoreInfo.Statistics[HitResult.LargeTickHit]; return getCount(scoreInfo, HitResult.LargeTickHit);
} }
return null; return null;
@ -131,10 +131,10 @@ namespace osu.Game.Scoring.Legacy
{ {
case 0: case 0:
case 3: case 3:
return scoreInfo.Statistics[HitResult.Meh]; return getCount(scoreInfo, HitResult.Meh);
case 2: case 2:
return scoreInfo.Statistics[HitResult.SmallTickHit]; return getCount(scoreInfo, HitResult.SmallTickHit);
} }
return null; return null;
@ -156,9 +156,17 @@ namespace osu.Game.Scoring.Legacy
} }
public static int? GetCountMiss(this ScoreInfo scoreInfo) => public static int? GetCountMiss(this ScoreInfo scoreInfo) =>
scoreInfo.Statistics[HitResult.Miss]; getCount(scoreInfo, HitResult.Miss);
public static void SetCountMiss(this ScoreInfo scoreInfo, int value) => public static void SetCountMiss(this ScoreInfo scoreInfo, int value) =>
scoreInfo.Statistics[HitResult.Miss] = value; scoreInfo.Statistics[HitResult.Miss] = value;
private static int? getCount(ScoreInfo scoreInfo, HitResult result)
{
if (scoreInfo.Statistics.TryGetValue(result, out var existing))
return existing;
return null;
}
} }
} }