-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ppy#30453 from bdach/everything-is-terrible
Fix several issues with beatmap online ID management
- Loading branch information
Showing
7 changed files
with
34 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System.Globalization; | ||
using osu.Framework.IO.Network; | ||
using osu.Game.Beatmaps; | ||
using osu.Game.Online.API.Requests.Responses; | ||
|
@@ -9,23 +10,30 @@ namespace osu.Game.Online.API.Requests | |
{ | ||
public class GetBeatmapRequest : APIRequest<APIBeatmap> | ||
{ | ||
public readonly IBeatmapInfo BeatmapInfo; | ||
public readonly string Filename; | ||
public readonly int OnlineID; | ||
public readonly string? MD5Hash; | ||
public readonly string? Filename; | ||
|
||
public GetBeatmapRequest(IBeatmapInfo beatmapInfo) | ||
: this(onlineId: beatmapInfo.OnlineID, md5Hash: beatmapInfo.MD5Hash, filename: (beatmapInfo as BeatmapInfo)?.Path) | ||
{ | ||
BeatmapInfo = beatmapInfo; | ||
Filename = (beatmapInfo as BeatmapInfo)?.Path ?? string.Empty; | ||
} | ||
|
||
public GetBeatmapRequest(int onlineId = -1, string? md5Hash = null, string? filename = null) | ||
{ | ||
OnlineID = onlineId; | ||
MD5Hash = md5Hash; | ||
Filename = filename; | ||
} | ||
|
||
protected override WebRequest CreateWebRequest() | ||
{ | ||
var request = base.CreateWebRequest(); | ||
|
||
if (BeatmapInfo.OnlineID > 0) | ||
request.AddParameter(@"id", BeatmapInfo.OnlineID.ToString()); | ||
if (!string.IsNullOrEmpty(BeatmapInfo.MD5Hash)) | ||
request.AddParameter(@"checksum", BeatmapInfo.MD5Hash); | ||
if (OnlineID > 0) | ||
request.AddParameter(@"id", OnlineID.ToString(CultureInfo.InvariantCulture)); | ||
if (!string.IsNullOrEmpty(MD5Hash)) | ||
request.AddParameter(@"checksum", MD5Hash); | ||
if (!string.IsNullOrEmpty(Filename)) | ||
request.AddParameter(@"filename", Filename); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters