Update some more incorrect types for primary key access/set

This commit is contained in:
Dean Herbert 2021-12-13 17:09:13 +09:00
parent 2a4bee61dd
commit aac2aa341c
4 changed files with 17 additions and 14 deletions

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using NUnit.Framework;
using osu.Game.Scoring;
@ -29,8 +30,8 @@ public void TestMatchingByReference()
[Test]
public void TestNonMatchingByPrimaryKey()
{
ScoreInfo score1 = new ScoreInfo { ID = 1 };
ScoreInfo score2 = new ScoreInfo { ID = 2 };
ScoreInfo score1 = new ScoreInfo { ID = Guid.NewGuid() };
ScoreInfo score2 = new ScoreInfo { ID = Guid.NewGuid() };
Assert.That(score1, Is.Not.EqualTo(score2));
}
@ -38,8 +39,10 @@ public void TestNonMatchingByPrimaryKey()
[Test]
public void TestMatchingByPrimaryKey()
{
ScoreInfo score1 = new ScoreInfo { ID = 1 };
ScoreInfo score2 = new ScoreInfo { ID = 1 };
Guid id = Guid.NewGuid();
ScoreInfo score1 = new ScoreInfo { ID = id };
ScoreInfo score2 = new ScoreInfo { ID = id };
Assert.That(score1, Is.EqualTo(score2));
}

View File

@ -11,7 +11,6 @@
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
using osu.Game.Users;
using APIUser = osu.Game.Online.API.Requests.Responses.APIUser;
namespace osu.Game.Online.Solo
{

View File

@ -490,7 +490,8 @@ public void PresentScore(IScoreInfo score, ScorePresentType presentType = ScoreP
if (score.OnlineID > 0)
databasedScoreInfo = ScoreManager.Query(s => s.OnlineID == score.OnlineID);
databasedScoreInfo ??= ScoreManager.Query(s => s.Hash == score.Hash);
if (score is ScoreInfo scoreInfo)
databasedScoreInfo ??= ScoreManager.Query(s => s.Hash == scoreInfo.Hash);
if (databasedScoreInfo == null)
{

View File

@ -9,7 +9,7 @@ public static class ScoreInfoExtensions
{
public static int? GetCountGeki(this ScoreInfo scoreInfo)
{
switch (scoreInfo.Ruleset?.ID ?? scoreInfo.RulesetID)
switch (scoreInfo.Ruleset.OnlineID)
{
case 3:
return getCount(scoreInfo, HitResult.Perfect);
@ -20,7 +20,7 @@ public static class ScoreInfoExtensions
public static void SetCountGeki(this ScoreInfo scoreInfo, int value)
{
switch (scoreInfo.Ruleset?.ID ?? scoreInfo.RulesetID)
switch (scoreInfo.Ruleset.OnlineID)
{
case 3:
scoreInfo.Statistics[HitResult.Perfect] = value;
@ -34,7 +34,7 @@ public static void SetCountGeki(this ScoreInfo scoreInfo, int value)
public static int? GetCountKatu(this ScoreInfo scoreInfo)
{
switch (scoreInfo.Ruleset?.ID ?? scoreInfo.RulesetID)
switch (scoreInfo.Ruleset.OnlineID)
{
case 3:
return getCount(scoreInfo, HitResult.Good);
@ -48,7 +48,7 @@ public static void SetCountGeki(this ScoreInfo scoreInfo, int value)
public static void SetCountKatu(this ScoreInfo scoreInfo, int value)
{
switch (scoreInfo.Ruleset?.ID ?? scoreInfo.RulesetID)
switch (scoreInfo.Ruleset.OnlineID)
{
case 3:
scoreInfo.Statistics[HitResult.Good] = value;
@ -62,7 +62,7 @@ public static void SetCountKatu(this ScoreInfo scoreInfo, int value)
public static int? GetCount100(this ScoreInfo scoreInfo)
{
switch (scoreInfo.Ruleset?.ID ?? scoreInfo.RulesetID)
switch (scoreInfo.Ruleset.OnlineID)
{
case 0:
case 1:
@ -78,7 +78,7 @@ public static void SetCountKatu(this ScoreInfo scoreInfo, int value)
public static void SetCount100(this ScoreInfo scoreInfo, int value)
{
switch (scoreInfo.Ruleset?.ID ?? scoreInfo.RulesetID)
switch (scoreInfo.Ruleset.OnlineID)
{
case 0:
case 1:
@ -94,7 +94,7 @@ public static void SetCount100(this ScoreInfo scoreInfo, int value)
public static int? GetCount50(this ScoreInfo scoreInfo)
{
switch (scoreInfo.Ruleset?.ID ?? scoreInfo.RulesetID)
switch (scoreInfo.Ruleset.OnlineID)
{
case 0:
case 3:
@ -109,7 +109,7 @@ public static void SetCount100(this ScoreInfo scoreInfo, int value)
public static void SetCount50(this ScoreInfo scoreInfo, int value)
{
switch (scoreInfo.Ruleset?.ID ?? scoreInfo.RulesetID)
switch (scoreInfo.Ruleset.OnlineID)
{
case 0:
case 3: