mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-15 06:02:28 +00:00
Add workaround for weird score bug
This commit is contained in:
parent
a253e768a7
commit
75de1d0faa
2 changed files with 31 additions and 2 deletions
|
@ -48,6 +48,10 @@ public class ScoreController : ControllerBase
|
||||||
return this.BadRequest();
|
return this.BadRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This only seems to happens on lbp2 versus levels, not sure why
|
||||||
|
if(score.PlayerIdCollection.Contains(':'))
|
||||||
|
score.PlayerIdCollection = score.PlayerIdCollection.Replace(':', ',');
|
||||||
|
|
||||||
if (score.PlayerIds.Length == 0)
|
if (score.PlayerIds.Length == 0)
|
||||||
{
|
{
|
||||||
Logger.Warn($"Rejecting score upload, there are 0 playerIds (slotType={slotType}, slotId={id}, user={username})", LogArea.Score);
|
Logger.Warn($"Rejecting score upload, there are 0 playerIds (slotType={slotType}, slotId={id}, user={username})", LogArea.Score);
|
||||||
|
@ -77,7 +81,7 @@ public class ScoreController : ControllerBase
|
||||||
string bodyString = await new StreamReader(this.Request.Body).ReadToEndAsync();
|
string bodyString = await new StreamReader(this.Request.Body).ReadToEndAsync();
|
||||||
Logger.Warn("Rejecting score upload, requester username is not present in playerIds" +
|
Logger.Warn("Rejecting score upload, requester username is not present in playerIds" +
|
||||||
$" (user={username}, playerIds={string.Join(",", score.PlayerIds)}, " +
|
$" (user={username}, playerIds={string.Join(",", score.PlayerIds)}, " +
|
||||||
$"gameVersion={token.GameVersion.ToPrettyString()}, type={score.Type}, id={score.SlotId}, slotType={slotType}, body='{bodyString}')", LogArea.Score);
|
$"gameVersion={token.GameVersion.ToPrettyString()}, type={score.Type}, id={id}, slotType={slotType}, body='{bodyString}')", LogArea.Score);
|
||||||
return this.BadRequest();
|
return this.BadRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +173,10 @@ public class ScoreController : ControllerBase
|
||||||
UserFriendData? store = UserFriendStore.GetUserFriendData(token.UserId);
|
UserFriendData? store = UserFriendStore.GetUserFriendData(token.UserId);
|
||||||
if (store == null) return this.Ok();
|
if (store == null) return this.Ok();
|
||||||
|
|
||||||
List<string> friendNames = new();
|
List<string> friendNames = new()
|
||||||
|
{
|
||||||
|
username,
|
||||||
|
};
|
||||||
|
|
||||||
foreach (int friendId in store.FriendIds)
|
foreach (int friendId in store.FriendIds)
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using LBPUnion.ProjectLighthouse.PlayerData;
|
||||||
|
|
||||||
|
namespace LBPUnion.ProjectLighthouse.Administration.Maintenance.MigrationTasks;
|
||||||
|
|
||||||
|
public class FixBrokenVersusScores : IMigrationTask
|
||||||
|
{
|
||||||
|
public string Name() => "Cleanup versus scores";
|
||||||
|
|
||||||
|
async Task<bool> IMigrationTask.Run(Database database)
|
||||||
|
{
|
||||||
|
foreach (Score score in database.Scores)
|
||||||
|
{
|
||||||
|
if (!score.PlayerIdCollection.Contains(':')) continue;
|
||||||
|
|
||||||
|
score.PlayerIdCollection = score.PlayerIdCollection.Replace(':', ',');
|
||||||
|
}
|
||||||
|
|
||||||
|
await database.SaveChangesAsync();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue