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

Apply adjustments for struct attributes #301

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,12 @@ protected Beatmap AddBeatmap(Action<Beatmap>? beatmapSetup = null, Action<Beatma
}

protected void AddBeatmapAttributes<TDifficultyAttributes>(uint? beatmapId = null, Action<TDifficultyAttributes>? setup = null, ushort mode = 0, Mod[]? mods = null)
where TDifficultyAttributes : DifficultyAttributes, new()
where TDifficultyAttributes : IDifficultyAttributes, new()
{
var attribs = new TDifficultyAttributes
{
StarRating = 5,
MaxCombo = 5,
Mods = mods ?? []
MaxCombo = 5
};

setup?.Invoke(attribs);
Expand All @@ -238,7 +237,7 @@ protected void AddBeatmapAttributes<TDifficultyAttributes>(uint? beatmapId = nul
var ruleset = rulesetInfo.CreateInstance();

beatmapId ??= TEST_BEATMAP_ID;
uint modsInt = (uint)ruleset.ConvertToLegacyMods(attribs.Mods);
uint modsInt = (uint)ruleset.ConvertToLegacyMods(mods ?? []);

using (var db = Processor.GetDatabaseConnection())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -961,11 +961,10 @@ private void setUpBeatmapsForPackMedal(IEnumerable<Beatmap> beatmaps, bool allMo
{
AddBeatmapAttributes<OsuDifficultyAttributes>(beatmap.beatmap_id, setup: attr =>
{
attr.Mods = ModUtils.FlattenMod(combination).ToArray();
attr.AimDifficulty = 3;
attr.SpeedDifficulty = 3;
attr.OverallDifficulty = 3;
});
}, mods: ModUtils.FlattenMod(combination).ToArray());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
}
}

public static DifficultyAttributes CreateDifficultyAttributes(int legacyId)
public static IDifficultyAttributes CreateDifficultyAttributes(int legacyId)

Check failure on line 46 in osu.Server.Queues.ScoreStatisticsProcessor/Helpers/LegacyRulesetHelper.cs

View workflow job for this annotation

GitHub Actions / Test

The type or namespace name 'IDifficultyAttributes' could not be found (are you missing a using directive or an assembly reference?)
{
switch (legacyId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private async IAsyncEnumerable<Medal> checkAsync(IEnumerable<Medal> medals, Meda
yield break;

// Get map star rating (including mods)
DifficultyAttributes difficultyAttributes = await context.BeatmapStore.GetDifficultyAttributesAsync(beatmap, ruleset, mods, context.Connection, context.Transaction);
IDifficultyAttributes difficultyAttributes = await context.BeatmapStore.GetDifficultyAttributesAsync(beatmap, ruleset, mods, context.Connection, context.Transaction);

// Award pass medals
foreach (var medal in medals)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ public async Task<bool> ProcessScoreAsync(SoloScore score, MySqlConnection conne
if (check_client_version && score.legacy_score_id == null && (score.build_id == null || buildStore.GetBuild(score.build_id.Value)?.allow_performance != true))
return false;

DifficultyAttributes difficultyAttributes = await BeatmapStore.GetDifficultyAttributesAsync(beatmap, ruleset, mods, connection, transaction);
PerformanceAttributes? performanceAttributes = ruleset.CreatePerformanceCalculator()?.Calculate(score.ToScoreInfo(), difficultyAttributes);
IDifficultyAttributes difficultyAttributes = await BeatmapStore.GetDifficultyAttributesAsync(beatmap, ruleset, mods, connection, transaction);
IPerformanceAttributes? performanceAttributes = ruleset.CreatePerformanceCalculator()?.Calculate(score.ToScoreInfo(), difficultyAttributes);

if (performanceAttributes == null)
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
private const int beatmap_difficulty_attribute_size = 24;

/// <summary>
/// The rough size of <see cref="DifficultyAttributes"/> base class in bytes.
/// The rough size of <see cref="IDifficultyAttributes"/> base class in bytes.
/// </summary>
private const int difficulty_attribute_size = 24;

Expand Down Expand Up @@ -107,7 +107,7 @@
/// <returns>The difficulty attributes or <c>null</c> if not existing.</returns>
/// <exception cref="DifficultyAttributesMissingException">If the difficulty attributes don't exist in the database.</exception>
/// <exception cref="Exception">If realtime difficulty attributes couldn't be computed.</exception>
public async Task<DifficultyAttributes> GetDifficultyAttributesAsync(Beatmap beatmap, Ruleset ruleset, Mod[] mods, MySqlConnection connection, MySqlTransaction? transaction = null)
public async Task<IDifficultyAttributes> GetDifficultyAttributesAsync(Beatmap beatmap, Ruleset ruleset, Mod[] mods, MySqlConnection connection, MySqlTransaction? transaction = null)

Check failure on line 110 in osu.Server.Queues.ScoreStatisticsProcessor/Stores/BeatmapStore.cs

View workflow job for this annotation

GitHub Actions / Test

The type or namespace name 'IDifficultyAttributes' could not be found (are you missing a using directive or an assembly reference?)
{
if (use_realtime_difficulty_calculation)
{
Expand Down Expand Up @@ -144,7 +144,7 @@
cacheEntry.SetSize(difficulty_attribute_size + beatmap_difficulty_attribute_size * dbAttributes.Length);
cacheEntry.SetSlidingExpiration(memory_cache_sliding_expiration);

DifficultyAttributes attributes = LegacyRulesetHelper.CreateDifficultyAttributes(ruleset.RulesetInfo.OnlineID);
IDifficultyAttributes attributes = LegacyRulesetHelper.CreateDifficultyAttributes(ruleset.RulesetInfo.OnlineID);
attributes.FromDatabaseAttributes(dbAttributes.ToDictionary(a => (int)a.attrib_id, a => (double)a.value), beatmap);
return attributes;
}
Expand Down
Loading