1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

Merge pull request #8959 from smoogipoo/fix-catch-crash

Fix catch crashing when finishing maps
This commit is contained in:
Dean Herbert 2020-05-07 23:46:36 +09:00 committed by GitHub
commit e8aebada3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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