Skip to content

Commit

Permalink
Allow multiplayer scores with arbitrary beatmap/ruleset combinations
Browse files Browse the repository at this point in the history
  • Loading branch information
smoogipoo committed Dec 23, 2024
1 parent 5bacdc6 commit 68c2605
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Exceptions\InvariantException;
use App\Http\Controllers\Controller as BaseController;
use App\Libraries\ClientCheck;
use App\Models\Beatmap;
use App\Models\Multiplayer\PlaylistItem;
use App\Models\Multiplayer\PlaylistItemUserHighScore;
use App\Models\Multiplayer\Room;
Expand Down Expand Up @@ -184,8 +185,15 @@ public function store($roomId, $playlistId)
$request = \Request::instance();
$params = $request->all();

if (get_string($params['beatmap_hash'] ?? null) !== $playlistItem->beatmap->checksum) {
throw new InvariantException(osu_trans('score_tokens.create.beatmap_hash_invalid'));
if ($playlistItem->beatmapset_id === null) {
if (get_string($params['beatmap_hash'] ?? null) !== $playlistItem->beatmap->checksum) {
throw new InvariantException(osu_trans('score_tokens.create.beatmap_hash_invalid'));
}
} else {
// Todo: Validate beatmap_hash param matches any checksum from the playlist item's beatmap set.
// Todo: Modifying the playlist item looks dodgy to me and is likely failing some internal validations.
$playlistItem->beatmap_id = Beatmap::firstWhere('checksum', get_string($params['beatmap_hash'] ?? null))->beatmap_id;
$playlistItem->ruleset_id = get_int($params['ruleset_id'] ?? null);
}

$buildId = ClientCheck::parseToken($request)['buildId'];
Expand Down

0 comments on commit 68c2605

Please sign in to comment.