1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 09:27:34 +08:00
osu-lazer/osu.Game/Beatmaps
Bartłomiej Dach 995338029c
Fix difficulty cache lookups sharing underlying mod instances
`DifficultyCacheLookup`s were storing raw `Mod` instances into their
`OrderedMods` field. This could cause the cache lookups to wrongly
succeed in cases of mods with settings. The particular case that
triggered this fix was Difficulty Adjust.

Because the difficulty cache is backed by a dictionary, there are two
stages to the lookup; first `GetHashCode()` is used to find the
appropriate hash bucket to look in, and then items from that hash bucket
are compared against the key being searched for via the implementation
of `Equals()`.

As it turns out, the first hashing step ended up being the saving grace
in most cases, as the hash computation included the values of the mod
settings. But the Difficulty Adjust failure case was triggered by the
quirk that `GetHashCode(0) == GetHashCode(null) == 0`.

In such a case, the `Equals()` fallback was used. But as it turns out,
because the `Mod` instance stored to lookups was not cloned and
therefore potentially externally mutable, it could be polluted after
being stored to the dictionary, and therefore breaking the equality
check. Even though all of the setting values were compared, the hash
bucket didn't match the actual contents of the lookup anymore (because
they were mutated externally, e.g. by the user changing the mod setting
values in the mod settings overlay).

To resolve, clone out the mod structure before creating all difficulty
lookups.
2021-08-21 15:50:33 +02:00
..
ControlPoints Add IDeepCloneable interface and update existing CreateCopy methods to use it 2021-07-19 12:54:17 +09:00
Drawables Add animation support for the star rating display 2021-08-19 07:17:43 +03:00
Formats Fix broken obsoletion message 2021-08-16 01:01:56 +02:00
Legacy Add legacy flag value for mirror mod 2020-08-29 11:45:59 +02:00
Timing Add new display for timing row attributes 2021-04-19 16:23:06 +09:00
Beatmap.cs Sort beat lengths rather than linear search 2021-02-08 19:03:19 +09:00
BeatmapConverter.cs Remove obsolete code 2021-04-09 13:56:58 +09:00
BeatmapDifficulty.cs Sadly, xmldoc doesn't support tuple elements. 2019-11-17 21:01:56 +08:00
BeatmapDifficultyCache.cs Fix difficulty cache lookups sharing underlying mod instances 2021-08-21 15:50:33 +02:00
BeatmapInfo.cs Make versionString private 2021-04-18 20:57:25 +08:00
BeatmapManager_BeatmapOnlineLookupQueue.cs Remove overly verbose logging during beatmap imports 2021-06-27 14:29:02 +09:00
BeatmapManager_WorkingBeatmap.cs Retrieve separated skin instance from working beatmap for editing 2021-08-15 21:18:09 +02:00
BeatmapManager.cs Allow intro screen to retrieve beatmap even if rulesets is not loaded 2021-08-20 19:43:48 +09:00
BeatmapMetadata.cs Fix playlist item displays as empty string if no unicode title is present 2021-07-04 08:09:38 +08:00
BeatmapMetrics.cs Move metrics to beatmap set 2019-06-13 16:52:49 +09:00
BeatmapOnlineInfo.cs Move Length out of OnlineInfo 2019-07-07 20:25:36 +03:00
BeatmapProcessor.cs Rename property, reword xmldoc and improve readability of update code 2021-07-21 17:32:56 +09:00
BeatmapSetFileInfo.cs Update licence header (and remove year) 2019-01-24 17:43:03 +09:00
BeatmapSetInfo.cs Revert "Revert "Make BeatmapSetInfo.Files non-nullable"" 2021-05-28 14:33:05 +09:00
BeatmapSetMetrics.cs Move metrics to beatmap set 2019-06-13 16:52:49 +09:00
BeatmapSetOnlineInfo.cs Add online beatmap "explicit content" property 2021-01-13 12:13:14 +03:00
BeatmapSetOnlineStatus.cs Update mapper usages with LocalisableDescription 2021-07-31 01:47:14 +03:00
BeatmapStatistic.cs Remove obsolete code 2021-04-09 13:56:58 +09:00
BeatmapStatisticIcon.cs Strongly type and expose default beatmap information icon implementations for other rulesets 2020-09-04 15:01:32 +09:00
BeatmapStore.cs Allow intro screen to retrieve beatmap even if rulesets is not loaded 2021-08-20 19:43:48 +09:00
DifficultyRating.cs Replace DifficultyColouredContainer with a more scalable solution 2019-08-17 15:16:24 +09:00
DifficultyRecommender.cs Fix possible nullref in difficulty recommender 2021-06-16 11:27:38 +09:00
DummyWorkingBeatmap.cs Retrieve separated skin instance from working beatmap for editing 2021-08-15 21:18:09 +02:00
IBeatmap.cs Remove empty <returns> xmldoc 2021-04-12 17:46:14 +09:00
IBeatmapConverter.cs Add default token 2020-09-17 18:37:48 +09:00
IBeatmapProcessor.cs Update licence header (and remove year) 2019-01-24 17:43:03 +09:00
IBeatmapResourceProvider.cs Expose resources to skin via interface (and share common pieces with beatmap) 2020-12-21 15:18:52 +09:00
IWorkingBeatmap.cs Improve xmldoc consistency 2021-04-20 02:30:27 +02:00
MetadataUtils.cs Check empty string more explicitly in IsRomanised() 2021-06-11 06:38:53 +02:00
StarDifficulty.cs Move StarDifficulty to own file 2020-11-06 13:51:25 +09:00
WorkingBeatmap.cs Retrieve separated skin instance from working beatmap for editing 2021-08-15 21:18:09 +02:00