ppy / osu-tools

command line tools to get stuff done
MIT License
105 stars 78 forks source link

Fix online attribute flag in score performance command not retrieving full difficulty attributes #204

Closed bdach closed 6 months ago

bdach commented 6 months ago

Found when investigating https://github.com/ppy/osu/issues/28006.

If the performance score command is given the -a flag, it is supposed to use the current online beatmap difficulty attributes. It does so by querying API, which queries osu-beatmap-difficulty-cache.

Problem is, that some of the difficulty attributes, namely the ones that are already present on APIBeatmap, are not serialised out by osu-beatmap-difficulty-cache.

osu-tools is blissfully unaware of this, and as such attempts to deserialise the difficulty attributes returned from cache-then-web raw, which leads to it just using the default values (e.g. zeroes) for attributes that the difficulty lookup cache does not serialise out. This leads to obviously bogus results.

To fix, retrieve the APIBeatmap manually and do some (admittedly gnarly) grafting in order to produce a fully populated object. It's a bit ugly but it works locally without further changes so maybe fine?

The alternative would be to fix this on the beatmap difficulty cache, I guess. That said it's not like the cache/API returns these fields wrong either, it does correctly omit them, which is why I'm trying this first.