Skip to content

Commit

Permalink
Fix HandleColours
Browse files Browse the repository at this point in the history
  • Loading branch information
huoyaoyuan committed Jul 9, 2024
1 parent bc8fe3d commit 6a98ba1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions osu.Game/Beatmaps/Formats/LegacyDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,20 @@ protected void HandleColours<TModel>(TModel output, ReadOnlySpan<char> line, boo
var pair = SplitKeyVal(line);

bool isCombo = pair.Key.StartsWith(@"Combo", StringComparison.Ordinal);
var colourValue = pair.Value;

Span<Range> ranges = stackalloc Range[5];
int splitCount = line.Split(ranges, ',');
int splitCount = colourValue.Split(ranges, ',');

if (splitCount != 3 && splitCount != 4)
throw new InvalidOperationException($@"Color specified in incorrect format (should be R,G,B or R,G,B,A): {pair.Value}");
throw new InvalidOperationException($@"Color specified in incorrect format (should be R,G,B or R,G,B,A): {colourValue}");

Color4 colour;

try
{
byte alpha = allowAlpha && splitCount == 4 ? byte.Parse(line[ranges[3]]) : (byte)255;
colour = new Color4(byte.Parse(line[ranges[0]]), byte.Parse(line[ranges[1]]), byte.Parse(line[ranges[2]]), alpha);
byte alpha = allowAlpha && splitCount == 4 ? byte.Parse(colourValue[ranges[3]]) : (byte)255;
colour = new Color4(byte.Parse(colourValue[ranges[0]]), byte.Parse(colourValue[ranges[1]]), byte.Parse(colourValue[ranges[2]]), alpha);
}
catch
{
Expand Down

0 comments on commit 6a98ba1

Please sign in to comment.