Skip to content

Commit

Permalink
Merge pull request #29406 from peppy/fix-skin-change-crash
Browse files Browse the repository at this point in the history
Fix crash on changing skins when classic mod is enabled and game is rewound
  • Loading branch information
smoogipoo authored Aug 14, 2024
2 parents a6aa35a + 2221c48 commit 8bfb5ce
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,20 @@ public TestSceneDrawableJudgement()
AddStep("Show " + result.GetDescription(), () =>
{
SetContents(_ =>
new DrawableManiaJudgement(new JudgementResult(new HitObject { StartTime = Time.Current }, new Judgement())
{
Type = result
}, null)
{
var drawableManiaJudgement = new DrawableManiaJudgement
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
});
};
drawableManiaJudgement.Apply(new JudgementResult(new HitObject { StartTime = Time.Current }, new Judgement())
{
Type = result
}, null);
return drawableManiaJudgement;
});
// for test purposes, undo the Y adjustment related to the `ScorePosition` legacy positioning config value
// (see `LegacyManiaJudgementPiece.load()`).
Expand Down
10 changes: 0 additions & 10 deletions osu.Game.Rulesets.Mania/UI/DrawableManiaJudgement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,12 @@

using osu.Framework.Graphics;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring;

namespace osu.Game.Rulesets.Mania.UI
{
public partial class DrawableManiaJudgement : DrawableJudgement
{
public DrawableManiaJudgement(JudgementResult result, DrawableHitObject judgedObject)
: base(result, judgedObject)
{
}

public DrawableManiaJudgement()
{
}

protected override Drawable CreateDefaultJudgement(HitResult result) => new DefaultManiaJudgementPiece(result);

private partial class DefaultManiaJudgementPiece : DefaultJudgementPiece
Expand Down
18 changes: 4 additions & 14 deletions osu.Game/Rulesets/Judgements/DrawableJudgement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Pooling;
using osu.Framework.Logging;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring;
Expand Down Expand Up @@ -35,17 +36,6 @@ public partial class DrawableJudgement : PoolableDrawable
private readonly Lazy<Drawable> proxiedAboveHitObjectsContent;
public Drawable ProxiedAboveHitObjectsContent => proxiedAboveHitObjectsContent.Value;

/// <summary>
/// Creates a drawable which visualises a <see cref="Judgements.Judgement"/>.
/// </summary>
/// <param name="result">The judgement to visualise.</param>
/// <param name="judgedObject">The object which was judged.</param>
public DrawableJudgement(JudgementResult result, DrawableHitObject judgedObject)
: this()
{
Apply(result, judgedObject);
}

public DrawableJudgement()
{
Size = new Vector2(judgement_size);
Expand Down Expand Up @@ -112,16 +102,16 @@ protected override void PrepareForUse()
{
base.PrepareForUse();

if (!IsInPool)
Logger.Log($"{nameof(DrawableJudgement)} for judgement type {Result} was not retrieved from a pool. Consider adding to a JudgementPooler.");

Debug.Assert(Result != null);

runAnimation();
}

private void runAnimation()
{
// is a no-op if the drawables are already in a correct state.
prepareDrawables();

// undo any transforms applies in ApplyMissAnimations/ApplyHitAnimations to get a sane initial state.
ApplyTransformsAt(double.MinValue, true);
ClearTransforms(true);
Expand Down

0 comments on commit 8bfb5ce

Please sign in to comment.