Skip to content

Commit

Permalink
Merge pull request #99 from llllllllll/parse-float-coords
Browse files Browse the repository at this point in the history
fix parsing failing on maps with float x and y positions
  • Loading branch information
tybug authored Jan 4, 2022
2 parents 15fc196 + f6edca5 commit 2fa26e0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions slider/beatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,20 @@ def parse(cls, data, timing_points, slider_multiplier, slider_tick_rate):
raise ValueError(f'not enough elements in line, got {data!r}')

try:
x = int(x)
# in old beatmaps (and potentially newer ones which were manually
# edited?), x and y can be floats (see b/128). Without the
# secondary float cast, parsing these maps would fail.
# Lazer casts these to integers
# (https://github.com/ppy/osu/blob/d4ea57c6607a77abb8a5e2fe55b220d8
# dfeeb456/osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.
# cs#L49), so we're still matching in-game positions even though we
# technically lose precision from the .osu file by casting.
x = int(float(x))
except ValueError:
raise ValueError(f'x should be an int, got {x!r}')

try:
y = int(y)
y = int(float(y))
except ValueError:
raise ValueError(f'y should be an int, got {y!r}')

Expand Down

0 comments on commit 2fa26e0

Please sign in to comment.