Skip to content
Closed

a #333

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
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableHit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ protected override void UpdateHitStateTransforms(ArmedState state)
MainPiece.MoveToX(-X);

// Rate independent to match stable.
double rate = (Clock as IGameplayClock)?.GetTrueGameplayRate() ?? Clock.Rate;
double rate = Math.Abs((Clock as IGameplayClock)?.GetTrueGameplayRate() ?? Clock.Rate);
double length = gravity_time * (rateAdjustedHitAnimations.Value ? 1 : rate);

this.ScaleTo(0.8f, length * 2, Easing.OutQuad);
Expand Down
8 changes: 7 additions & 1 deletion osu.Game/Screens/Play/PlayerLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ public partial class PlayerLoader : ScreenWithBeatmapBackground

protected Task? DisposalTask { get; private set; }

/// <summary>
/// By default, the loader screen will block until the window is focused.
/// Can be overridden by setting this to <c>false</c>.
/// </summary>
protected bool WindowShouldBeActiveForGameplayStart { get; init; } = true;

private FillFlowContainer disclaimers = null!;
private GridContainer sideContent = null!;

Expand Down Expand Up @@ -125,7 +131,7 @@ protected bool BackgroundBrightnessReduction
}

protected virtual bool ReadyForGameplay =>
host.IsActive.Value &&
(!WindowShouldBeActiveForGameplayStart || host.IsActive.Value) &&
// not ready if the user is hovering one of the panes (logo is excluded), unless they are idle.
(IsHovered || osuLogo?.IsHovered == true || idleTracker.IsIdle.Value)
// not ready if the user is dragging a slider or otherwise.
Expand Down
1 change: 1 addition & 0 deletions osu.Game/Screens/Play/ReplayPlayerLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public ReplayPlayerLoader(Score score)
throw new ArgumentException($"{nameof(score)} must have a non-null {nameof(score.Replay)}.", nameof(score));

Score = score.ScoreInfo;
WindowShouldBeActiveForGameplayStart = false;
}

public override void OnEntering(ScreenTransitionEvent e)
Expand Down
1 change: 1 addition & 0 deletions osu.Game/Screens/Play/SpectatorPlayerLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public SpectatorPlayerLoader(Score score, Func<SpectatorPlayer> createPlayer)
throw new ArgumentException($"{nameof(score)} must have a non-null {nameof(score.Replay)}.", nameof(score));

Score = score.ScoreInfo;
WindowShouldBeActiveForGameplayStart = false;
}

public override void OnEntering(ScreenTransitionEvent e)
Expand Down
20 changes: 15 additions & 5 deletions osu.Game/Screens/Select/PanelLocalRankDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Leaderboards;
using osu.Game.Rulesets;
using osu.Game.Scoring;
Expand All @@ -27,6 +28,9 @@ public BeatmapInfo? Beatmap
get => beatmap;
set
{
if (beatmap?.Equals(value) == true)
return;

beatmap = value;

if (IsLoaded)
Expand All @@ -40,8 +44,7 @@ public BeatmapInfo? Beatmap
[Resolved]
private RealmAccess realm { get; set; } = null!;

[Resolved]
private IAPIProvider api { get; set; } = null!;
private readonly IBindable<APIUser> localUser = new Bindable<APIUser>();

private IDisposable? scoreSubscription;

Expand All @@ -62,11 +65,18 @@ public PanelLocalRankDisplay(BeatmapInfo? beatmap = null)
Beatmap = beatmap;
}

[BackgroundDependencyLoader]
private void load(IAPIProvider api)
{
localUser.BindTo(api.LocalUser);
}

protected override void LoadComplete()
{
base.LoadComplete();

ruleset.BindValueChanged(_ => updateSubscription(), true);
ruleset.BindValueChanged(_ => updateSubscription());
localUser.BindValueChanged(_ => updateSubscription(), true);
}

private void updateSubscription()
Expand All @@ -89,8 +99,8 @@ private void localScoresChanged(IRealmCollection<ScoreInfo> sender, ChangeSet? c

ScoreInfo? topScore = sender
// doing these post realm filter is most efficient.
.Where(s => s.UserID == api.LocalUser.Value.Id || s.UserID <= 1)
.Where(s => s.Ruleset.ShortName == ruleset.Value.ShortName)
.Where(s => s.UserID == localUser.Value.Id || s.UserID <= 1)
.Where(s => ruleset.Value.Equals(s.Ruleset))
.MaxBy(info => (info.TotalScore, -info.Date.UtcDateTime.Ticks));

setRankFromScore(topScore);
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Users/UserPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private void load()
// We can't colour the properly because we don't have the required percentile data.

Colour = Colours.BlueLighter,
Text = User.Rank?.Rank?.ToLocalisableString("\\##,##0") ?? string.Empty,
Text = (User.Rank?.Rank ?? User.Statistics.GlobalRank)?.ToLocalisableString("\\##,##0") ?? string.Empty,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Null-guard User.Statistics in the fallback chain.

Line 144 can throw if User.Statistics is null. Please null-check statistics before reading GlobalRank.

Proposed fix
-            Text = (User.Rank?.Rank ?? User.Statistics.GlobalRank)?.ToLocalisableString("\\##,##0") ?? string.Empty,
+            Text = (User.Rank?.Rank ?? User.Statistics?.GlobalRank)?.ToLocalisableString("\\##,##0") ?? string.Empty,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Text = (User.Rank?.Rank ?? User.Statistics.GlobalRank)?.ToLocalisableString("\\##,##0") ?? string.Empty,
Text = (User.Rank?.Rank ?? User.Statistics?.GlobalRank)?.ToLocalisableString("\\##,##0") ?? string.Empty,
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@osu.Game/Users/UserPanel.cs` at line 144, Null reference can occur when
reading User.Statistics.GlobalRank in the Text assignment; update the fallback
to null-guard statistics by using User.Statistics?.GlobalRank (i.e. change the
expression using User.Rank?.Rank ?? User.Statistics.GlobalRank to use
User.Rank?.Rank ?? User.Statistics?.GlobalRank) so the null-coalescing chain
produces null safely before calling ToLocalisableString on the result in the
UserPanel.Text assignment.

};

protected UpdateableAvatar CreateAvatar() => new UpdateableAvatar(User, false);
Expand Down