1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00
osu-lazer/osu.Game.Rulesets.Taiko
Bartłomiej Dach 7c9adc7ad3
Fix incorrect score conversion on selected beatmaps due to incorrect difficultyPeppyStars rounding
Fixes issue that occurs on *about* 246 beatmaps and was first described
by me on discord:

    https://discord.com/channels/188630481301012481/188630652340404224/1154367700378865715

and then rediscovered again during work on
https://github.com/ppy/osu/pull/26405:

    https://gist.github.com/bdach/414d5289f65b0399fa8f9732245a4f7c#venenog-on-ultmate-end-by-blacky-overdose-631

It so happens that in stable, due to .NET Framework internals, float
math would be performed using x87 registers and opcodes.
.NET (Core) however uses SSE instructions on 32- and 64-bit words.
x87 registers are _80 bits_ wide. Which is notably wider than _both_
float and double. Therefore, on a significant number of beatmaps,
the rounding would not produce correct values due to insufficient
precision.

See following gist for corroboration of the above:

    https://gist.github.com/bdach/dcde58d5a3607b0408faa3aa2b67bf10

Thus, to crudely - but, seemingly accurately, after checking across
all ranked maps - emulate this, use `decimal`, which is slow, but has
bigger precision than `double`. The single known exception beatmap
in whose case this results in an incorrect result is

    https://osu.ppy.sh/beatmapsets/1156087#osu/2625853

which is considered an "acceptable casualty" of sorts.

Doing this requires some fooling of the compiler / runtime (see second
inline comment in new method). To corroborate that this is required,
you can try the following code snippet:

    Console.WriteLine(string.Join(' ', BitConverter.GetBytes(1.3f).Select(x => x.ToString("X2"))));
    Console.WriteLine(string.Join(' ', BitConverter.GetBytes(1.3).Select(x => x.ToString("X2"))));
    Console.WriteLine();

    decimal d1 = (decimal)1.3f;
    decimal d2 = (decimal)1.3;
    decimal d3 = (decimal)(double)1.3f;

    Console.WriteLine(string.Join(' ', decimal.GetBits(d1).SelectMany(BitConverter.GetBytes).Select(x => x.ToString("X2"))));
    Console.WriteLine(string.Join(' ', decimal.GetBits(d2).SelectMany(BitConverter.GetBytes).Select(x => x.ToString("X2"))));
    Console.WriteLine(string.Join(' ', decimal.GetBits(d3).SelectMany(BitConverter.GetBytes).Select(x => x.ToString("X2"))));

which will print

    66 66 A6 3F
    CD CC CC CC CC CC F4 3F

    0D 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00
    0D 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00
    8C 5D 89 FB 3B 76 00 00 00 00 00 00 00 00 0E 00

Note that despite `d1` being converted from a less-precise floating-
-point value than `d2`, it still is represented 100% accurately as
a decimal number.

After applying this change, recomputation of legacy scoring attributes
for *all* rulesets will be required.
2024-01-10 19:30:18 +01:00
..
Beatmaps Remove unnecessary prefix 2023-12-06 22:00:35 +09:00
Configuration Removed unnecessary directives that were added automatically and I forgot to remove 2023-01-10 12:44:27 +00:00
Difficulty Fix incorrect score conversion on selected beatmaps due to incorrect difficultyPeppyStars rounding 2024-01-10 19:30:18 +01:00
Edit fix near-zero length sliders n stuff being placeable 2023-12-19 21:20:21 +01:00
Judgements Automated pass 2023-06-24 01:00:03 +09:00
Mods Use update-invariant way of checking for second press on same frame 2023-07-25 20:07:03 +02:00
Objects Move constant local to taiko 2023-12-06 15:59:34 +09:00
Properties Automated pass 2023-06-24 01:00:03 +09:00
Replays Use AsNonNull() instead. 2022-07-02 19:48:32 +08:00
Resources Add conversion tests 2023-02-09 23:23:58 +01:00
Scoring Expose only as one method 2023-12-21 14:58:23 +09:00
Skinning Merge pull request #25190 from frenzibyte/match-skin-element-animation-support 2023-10-30 18:25:06 +09:00
UI Add more inline commenting around VELOCITY_MULTIPLIER application to TimeRange 2023-12-07 16:34:26 +09:00
osu.Game.Rulesets.Taiko.csproj Update netstandard2.1 references to net6.0 2022-12-16 17:16:13 +09:00
TaikoInputManager.cs Automated pass 2023-06-24 01:00:03 +09:00
TaikoRuleset.cs Don't convert TaikoModRandom to/from legacy mods 2023-12-17 23:47:50 -08:00
TaikoSettingsSubsection.cs Updated touch control scheme setting capitalization to be consistent with the rest of the settings menu 2023-01-10 11:57:21 +00:00
TaikoSkinComponentLookup.cs Add "Component" prefix to lookup naming 2022-11-09 17:46:43 +09:00
TaikoSkinComponents.cs Move DrumSamplePlayer to be a skinnable component 2023-07-05 18:44:27 +09:00