Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix osu! difficulty/performance calculation failing or giving wrong values #2525

Merged
merged 6 commits into from May 12, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion osu.Game.Rulesets.Osu/Scoring/OsuPerformanceCalculator.cs
Expand Up @@ -32,7 +32,8 @@ public OsuPerformanceCalculator(Ruleset ruleset, IBeatmap beatmap, Score score)
countHitCircles = Beatmap.HitObjects.Count(h => h is HitCircle);

beatmapMaxCombo = Beatmap.HitObjects.Count();
beatmapMaxCombo += Beatmap.HitObjects.OfType<Slider>().Sum(s => s.NestedHitObjects.Count) + 1;
// Add the ticks + tail of the slider. 1 is subtracted because the "headcircle" would be counted twice (once for the slider itself in the line above)
beatmapMaxCombo += Beatmap.HitObjects.OfType<Slider>().Sum(s => s.NestedHitObjects.Count - 1);
}

public override double Calculate(Dictionary<string, double> categoryRatings = null)
Expand Down
55 changes: 43 additions & 12 deletions osu.Game/Rulesets/Scoring/Legacy/LegacyScoreParser.cs
Expand Up @@ -49,18 +49,21 @@ public Score Parse(Stream stream)
score.User = new User { Username = sr.ReadString() };
/* var localScoreChecksum = */
sr.ReadString();
/* score.Count300 = */
sr.ReadUInt16();
/* score.Count100 = */
sr.ReadUInt16();
/* score.Count50 = */
sr.ReadUInt16();
/* score.CountGeki = */
sr.ReadUInt16();
/* score.CountKatu = */
sr.ReadUInt16();
/* score.CountMiss = */
sr.ReadUInt16();

var count300 = sr.ReadUInt16();
var count100 = sr.ReadUInt16();
var count50 = sr.ReadUInt16();
var countGeki = sr.ReadUInt16();
var countKatu = sr.ReadUInt16();
var countMiss = sr.ReadUInt16();

score.Statistics[HitResult.Great] = count300;
score.Statistics[HitResult.Good] = count100;
score.Statistics[HitResult.Meh] = count50;
score.Statistics[HitResult.Perfect] = countGeki;
score.Statistics[HitResult.Ok] = countKatu;
score.Statistics[HitResult.Miss] = countMiss;

score.TotalScore = sr.ReadInt32();
score.MaxCombo = sr.ReadUInt16();
/* score.Perfect = */
Expand All @@ -81,6 +84,34 @@ public Score Parse(Stream stream)
/*OnlineId =*/
sr.ReadInt32();

switch (score.Ruleset.ID)
{
case 0:
{
int totalHits = count50 + count100 + count300 + countMiss;
score.Accuracy = totalHits > 0 ? (double)(count50 * 50 + count100 * 100 + count300 * 300) / (totalHits * 300) : 1;
break;
}
case 1:
{
int totalHits = count50 + count100 + count300 + countMiss;
score.Accuracy = totalHits > 0 ? (double)(count100 * 150 + count300 * 300) / (totalHits * 300) : 1;
break;
}
case 2:
{
int totalHits = count50 + count100 + count300 + countMiss + countKatu;
score.Accuracy = totalHits > 0 ? (double)(count50 + count100 + count300 ) / totalHits : 1;
break;
}
case 3:
{
int totalHits = count50 + count100 + count300 + countMiss + countGeki + countKatu;
score.Accuracy = totalHits > 0 ? (double)(count50 * 50 + count100 * 100 + countKatu * 200 + (count300 + countGeki) * 300) / (totalHits * 300) : 1;
break;
}
}

using (var replayInStream = new MemoryStream(compressedReplay))
{
byte[] properties = new byte[5];
Expand Down