Skip to content

Commit 624d0a5

Browse files
authored
LBP PSP score uploading workarounds (#924)
I can't test any of this because I don't have this game, this PR is based on what was reported on Discord (mostly https://discord.com/channels/1049223665243389953/1262898863774105620/1403461202528702546). Also removed an unnessesary Assert.
2 parents 1c0be83 + 29ca5dd commit 624d0a5

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

Refresh.Interfaces.Game/Endpoints/Levels/LeaderboardEndpoints.cs

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,35 +101,44 @@ public Response SubmitScore(RequestContext context, GameUser user, GameServerCon
101101
GameDatabaseContext database, string slotType, int id, SerializedScore body, Token token,
102102
DataContext dataContext)
103103
{
104+
// Try to not return any non-OK responses for LBP PSP here, since that apparently bugs the game
105+
104106
if (user.IsWriteBlocked(config))
105-
return Unauthorized;
107+
return context.IsPSP() ? OK : Unauthorized;
106108

107109
GameLevel? level = database.GetLevelByIdAndType(slotType, id);
108-
if (level == null) return NotFound;
110+
if (level == null) return context.IsPSP() ? OK : NotFound;
109111

110-
// A user has to play a level in order to submit a score
112+
// A user has to play a level in order to submit a score (unless the game is LBP PSP)
111113
if (!database.HasUserPlayedLevel(level, user) && !context.IsPSP())
112114
{
113115
return Unauthorized;
114116
}
115117

116-
// Validate the score is a non-negative amount and not above the in-game limit
117-
if (body.Score is < 0 or > 16_000_000)
118+
// LBP PSP doesn't have any score limits, and checking the score type isn't really useful
119+
// since there is no multiplayer in that game
120+
if (!context.IsPSP())
118121
{
119-
return BadRequest;
122+
// Validate the score is a non-negative amount and not above the in-game limit
123+
if (body.Score is < 0 or > 16_000_000)
124+
{
125+
return BadRequest;
126+
}
127+
128+
// Ensure score type is valid
129+
// Only valid values are 1-4 players and 7 for versus
130+
if (body.ScoreType is (> 4 or < 1) and not 7)
131+
{
132+
return BadRequest;
133+
}
120134
}
121-
122-
// Ensure score type is valid
123-
// Only valid values are 1-4 players and 7 for versus
124-
if (body.ScoreType is (> 4 or < 1) and not 7)
135+
else
125136
{
126-
return BadRequest;
137+
body.ScoreType = 1;
127138
}
128139

129140
GameScore score = database.SubmitScore(body, token, level);
130-
131-
DatabaseList<ScoreWithRank>? scores = database.GetRankedScoresAroundScore(score, 5);
132-
Debug.Assert(scores != null);
141+
DatabaseList<ScoreWithRank> scores = database.GetRankedScoresAroundScore(score, 5);
133142

134143
this.AwardScoreboardPins(scores, dataContext, user, level);
135144

0 commit comments

Comments
 (0)