Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional gameplay metadata to room score request #27113

Merged
merged 1 commit into from Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion osu.Game/Online/Rooms/CreateRoomScoreRequest.cs
@@ -1,8 +1,10 @@
// 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.Globalization;
using System.Net.Http;
using osu.Framework.IO.Network;
using osu.Game.Beatmaps;
using osu.Game.Online.API;

namespace osu.Game.Online.Rooms
Expand All @@ -11,12 +13,16 @@ public class CreateRoomScoreRequest : APIRequest<APIScoreToken>
{
private readonly long roomId;
private readonly long playlistItemId;
private readonly BeatmapInfo beatmapInfo;
private readonly int rulesetId;
private readonly string versionHash;

public CreateRoomScoreRequest(long roomId, long playlistItemId, string versionHash)
public CreateRoomScoreRequest(long roomId, long playlistItemId, BeatmapInfo beatmapInfo, int rulesetId, string versionHash)
{
this.roomId = roomId;
this.playlistItemId = playlistItemId;
this.beatmapInfo = beatmapInfo;
this.rulesetId = rulesetId;
this.versionHash = versionHash;
}

Expand All @@ -25,6 +31,8 @@ protected override WebRequest CreateWebRequest()
var req = base.CreateWebRequest();
req.Method = HttpMethod.Post;
req.AddParameter("version_hash", versionHash);
req.AddParameter("beatmap_hash", beatmapInfo.MD5Hash);
req.AddParameter("ruleset_id", rulesetId.ToString(CultureInfo.InvariantCulture));
return req;
}

Expand Down
12 changes: 11 additions & 1 deletion osu.Game/Screens/Play/RoomSubmittingPlayer.cs
Expand Up @@ -4,6 +4,7 @@
#nullable disable

using System.Diagnostics;
using osu.Game.Extensions;
using osu.Game.Online.API;
using osu.Game.Online.Rooms;
using osu.Game.Scoring;
Expand All @@ -30,7 +31,16 @@ protected override APIRequest<APIScoreToken> CreateTokenRequest()
if (!(Room.RoomID.Value is long roomId))
return null;

return new CreateRoomScoreRequest(roomId, PlaylistItem.ID, Game.VersionHash);
int beatmapId = Beatmap.Value.BeatmapInfo.OnlineID;
int rulesetId = Ruleset.Value.OnlineID;

if (beatmapId <= 0)
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)
Expand Down