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 playlist total time not considering rate adjust mods #28399

Conversation

matheus-cesquim
Copy link
Contributor

@matheus-cesquim matheus-cesquim commented Jun 5, 2024

Closes #28398

osu.Game/Online/Rooms/PlaylistExtensions.cs Outdated Show resolved Hide resolved
osu.Game/Online/Rooms/PlaylistExtensions.cs Outdated Show resolved Hide resolved
@peppy peppy changed the title Fixing the GetTotalDuration in PlaylistExtesions to consider speed changes mods in song length calculation Fix playlist total time not considering rate adjust mods Jun 5, 2024
@pull-request-size pull-request-size bot added size/M and removed size/S labels Jun 6, 2024
@peppy peppy self-requested a review June 6, 2024 15:58
Comment on lines 49 to 55
IEnumerable<Mod> modList = [];
if (p.RequiredMods.Length > 0)
{
var ruleset = p.Beatmap.Ruleset.CreateInstance();
modList = p.RequiredMods.Select(mod => mod.ToMod(ruleset));
}
double rate = ModUtils.CalculateRateWithMods(modList);
Copy link
Contributor Author

@matheus-cesquim matheus-cesquim Jun 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created this validation to deal with the problem of instancing ruleset every time for every map

if (p.RequiredMods.Length > 0)
{
var ruleset = p.Beatmap.Ruleset.CreateInstance();
rate = ModUtils.CalculateRateWithMods(p.RequiredMods.Select(mod => mod.ToMod(ruleset)));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't going to work for wind up/down but I guess this is better than nothing for now.

@bdach bdach merged commit a6d0cd5 into ppy:master Jun 7, 2024
15 of 17 checks passed
bdach added a commit to bdach/osu that referenced this pull request Jun 25, 2024
…e present

Regressed in ppy#28399.

To reproduce, enter a playlist that has an item with a rate-changing mod
(rather than create it yourself).

This is happening because `APIRuleset` has `CreateInstance()`
unimplemented:

    https://github.com/ppy/osu/blob/b4cefe0cc2fda0ab4b5af6138ee158bd32262f9a/osu.Game/Online/API/Requests/Responses/APIBeatmap.cs#L159

and only triggers when the playlist items in question originate from
web.

This is why it is bad to have interface implementations throw outside of
maybe mock implementations for tests. `CreateInstance()` is a scourge
elsewhere in general, we need way less of it in the codebase (because
while convenient, it's also problematic to implement in online contexts,
and also expensive because reflection).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants