Skip to content

Commit

Permalink
Fix hit object coordinates being truncated to int values
Browse files Browse the repository at this point in the history
Closes ppy#29340.
  • Loading branch information
peppy committed Aug 9, 2024
1 parent 9f4025d commit e24f1e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions osu.Game/Beatmaps/Formats/LegacyDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ public abstract class LegacyDecoder<T> : Decoder<T>
{
public const int LATEST_VERSION = 14;

/// <summary>
/// The .osu format (beatmap) version.
///
/// osu!stable's versions end at <see cref="LATEST_VERSION"/>.
/// osu!lazer's versions starts at <see cref="LegacyBeatmapEncoder.FIRST_LAZER_VERSION"/>.
/// </summary>
protected readonly int FormatVersion;

protected LegacyDecoder(int version)
Expand Down
7 changes: 5 additions & 2 deletions osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public abstract class ConvertHitObjectParser : HitObjectParser
protected readonly double Offset;

/// <summary>
/// The beatmap version.
/// The .osu format (beatmap) version.
/// </summary>
protected readonly int FormatVersion;

Expand All @@ -48,7 +48,10 @@ public override HitObject Parse(string text)
{
string[] split = text.Split(',');

Vector2 pos = new Vector2((int)Parsing.ParseFloat(split[0], Parsing.MAX_COORDINATE_VALUE), (int)Parsing.ParseFloat(split[1], Parsing.MAX_COORDINATE_VALUE));
Vector2 pos =
FormatVersion >= LegacyBeatmapEncoder.FIRST_LAZER_VERSION
? new Vector2(Parsing.ParseFloat(split[0], Parsing.MAX_COORDINATE_VALUE), Parsing.ParseFloat(split[1], Parsing.MAX_COORDINATE_VALUE))
: new Vector2((int)Parsing.ParseFloat(split[0], Parsing.MAX_COORDINATE_VALUE), (int)Parsing.ParseFloat(split[1], Parsing.MAX_COORDINATE_VALUE));

double startTime = Parsing.ParseDouble(split[2]) + Offset;

Expand Down

0 comments on commit e24f1e9

Please sign in to comment.