Skip to content

Commit

Permalink
Keep provided IDs where possible if not online
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Mar 30, 2020
1 parent 09d860d commit 7ecce71
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
15 changes: 9 additions & 6 deletions osu.Game/Beatmaps/BeatmapManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -451,12 +451,15 @@ private void update(BeatmapSetInfo set, BeatmapInfo beatmap)

var res = req.Result;

beatmap.Status = res.Status;
beatmap.BeatmapSet.Status = res.BeatmapSet.Status;
beatmap.BeatmapSet.OnlineBeatmapSetID = res.OnlineBeatmapSetID;
beatmap.OnlineBeatmapID = res.OnlineBeatmapID;

LogForModel(set, $"Online retrieval mapped {beatmap} to {res.OnlineBeatmapSetID} / {res.OnlineBeatmapID}.");
if (res != null)
{
beatmap.Status = res.Status;
beatmap.BeatmapSet.Status = res.BeatmapSet.Status;
beatmap.BeatmapSet.OnlineBeatmapSetID = res.OnlineBeatmapSetID;
beatmap.OnlineBeatmapID = res.OnlineBeatmapID;

LogForModel(set, $"Online retrieval mapped {beatmap} to {res.OnlineBeatmapSetID} / {res.OnlineBeatmapID}.");
}
}
catch (Exception e)
{
Expand Down
4 changes: 2 additions & 2 deletions osu.Game/Online/API/APIRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ namespace osu.Game.Online.API
/// An API request with a well-defined response type.
/// </summary>
/// <typeparam name="T">Type of the response (used for deserialisation).</typeparam>
public abstract class APIRequest<T> : APIRequest
public abstract class APIRequest<T> : APIRequest where T : class
{
protected override WebRequest CreateWebRequest() => new OsuJsonWebRequest<T>(Uri);

public T Result => ((OsuJsonWebRequest<T>)WebRequest).ResponseObject;
public T Result => ((OsuJsonWebRequest<T>)WebRequest)?.ResponseObject;

protected APIRequest()
{
Expand Down
3 changes: 2 additions & 1 deletion osu.Game/Online/API/Requests/GetRankingsRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

namespace osu.Game.Online.API.Requests
{
public abstract class GetRankingsRequest<TModel> : APIRequest<TModel>
public abstract class GetRankingsRequest<TModel> : APIRequest<TModel> where TModel : class

{
private readonly RulesetInfo ruleset;
private readonly int page;
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Online/API/Requests/PaginatedAPIRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace osu.Game.Online.API.Requests
{
public abstract class PaginatedAPIRequest<T> : APIRequest<T>
public abstract class PaginatedAPIRequest<T> : APIRequest<T> where T : class
{
private readonly int page;
private readonly int itemsPerPage;
Expand Down

0 comments on commit 7ecce71

Please sign in to comment.