1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-23 16:20:30 +08:00
Files
osu-lazer/osu.Game/Screens/Play/RoomSubmittingPlayer.cs
T
Bartłomiej Dach 2a85f7b7c8 Do not attempt to retrieve score submission tokens for locally-modified beatmaps
Because it is 99% sure that doing so will fail and spam the user with
"this beatmap doesn't match the online version" notifications, and
because the map status is "locally modified", they should be pretty
aware of that already. This fixes the primary mode of the failure that
https://github.com/ppy/osu/pull/35173 was attempting to hack around.

This will have regressed somewhere around the time that BSS went live,
because at that point the editor stopped resetting online IDs for
beatmaps that got locally modified, making the `beatmapId <= 0` guards
no longer prevent attempts of submission.
2025-10-02 09:16:17 +02:00

55 lines
1.8 KiB
C#

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Diagnostics;
using osu.Game.Beatmaps;
using osu.Game.Extensions;
using osu.Game.Online.API;
using osu.Game.Online.Rooms;
using osu.Game.Scoring;
namespace osu.Game.Screens.Play
{
/// <summary>
/// A player instance which submits to a room backing. This is generally used by playlists and multiplayer.
/// </summary>
public abstract partial class RoomSubmittingPlayer : SubmittingPlayer
{
protected readonly PlaylistItem PlaylistItem;
protected readonly Room Room;
protected RoomSubmittingPlayer(Room room, PlaylistItem playlistItem, PlayerConfiguration? configuration = null)
: base(configuration)
{
Room = room;
PlaylistItem = playlistItem;
}
protected override APIRequest<APIScoreToken>? CreateTokenRequest()
{
if (Room.RoomID is not long roomId)
return null;
int beatmapId = Beatmap.Value.BeatmapInfo.OnlineID;
int rulesetId = Ruleset.Value.OnlineID;
if (beatmapId <= 0)
return null;
if (Beatmap.Value.BeatmapInfo.Status == BeatmapOnlineStatus.LocallyModified)
return null;
if (!Ruleset.Value.IsLegacyRuleset())
return null;
return new CreateRoomScoreRequest(roomId, PlaylistItem.ID, Beatmap.Value.BeatmapInfo, rulesetId, Game.VersionHash);
}
protected override APIRequest<MultiplayerScore> CreateSubmissionRequest(Score score, long token)
{
Debug.Assert(Room.RoomID != null);
return new SubmitRoomScoreRequest(score.ScoreInfo, token, Room.RoomID.Value, PlaylistItem.ID);
}
}
}