Skip to content

Commit 47747ae

Browse files
committed
Add guards to prevent clamp calls with invalid bounds
1 parent 35b0ff8 commit 47747ae

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

osu.Game/Screens/Play/HUDOverlay.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -277,17 +277,17 @@ protected override void Update()
277277
if (rulesetComponents != null)
278278
processDrawables(rulesetComponents);
279279

280-
if (lowestTopScreenSpaceRight.HasValue)
280+
if (lowestTopScreenSpaceRight.HasValue && DrawHeight - TopRightElements.DrawHeight > 0)
281281
TopRightElements.Y = Math.Clamp(ToLocalSpace(new Vector2(0, lowestTopScreenSpaceRight.Value)).Y, 0, DrawHeight - TopRightElements.DrawHeight);
282282
else
283283
TopRightElements.Y = 0;
284284

285-
if (lowestTopScreenSpaceLeft.HasValue)
285+
if (lowestTopScreenSpaceLeft.HasValue && DrawHeight - LeaderboardFlow.DrawHeight > 0)
286286
LeaderboardFlow.Y = Math.Clamp(ToLocalSpace(new Vector2(0, lowestTopScreenSpaceLeft.Value)).Y, 0, DrawHeight - LeaderboardFlow.DrawHeight);
287287
else
288288
LeaderboardFlow.Y = 0;
289289

290-
if (highestBottomScreenSpace.HasValue)
290+
if (highestBottomScreenSpace.HasValue && DrawHeight - bottomRightElements.DrawHeight > 0)
291291
bottomRightElements.Y = BottomScoringElementsHeight = -Math.Clamp(DrawHeight - ToLocalSpace(highestBottomScreenSpace.Value).Y, 0, DrawHeight - bottomRightElements.DrawHeight);
292292
else
293293
bottomRightElements.Y = 0;

0 commit comments

Comments
 (0)