diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ScoreController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ScoreController.cs index 5f3a5283..c5be03bd 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ScoreController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/ScoreController.cs @@ -48,6 +48,10 @@ public class ScoreController : ControllerBase 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) { 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(); Logger.Warn("Rejecting score upload, requester username is not present in 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(); } @@ -169,7 +173,10 @@ public class ScoreController : ControllerBase UserFriendData? store = UserFriendStore.GetUserFriendData(token.UserId); if (store == null) return this.Ok(); - List friendNames = new(); + List friendNames = new() + { + username, + }; foreach (int friendId in store.FriendIds) { diff --git a/ProjectLighthouse/Administration/Maintenance/MigrationTasks/CleanupBrokenVersusScoresMigration.cs b/ProjectLighthouse/Administration/Maintenance/MigrationTasks/CleanupBrokenVersusScoresMigration.cs new file mode 100644 index 00000000..d85370a4 --- /dev/null +++ b/ProjectLighthouse/Administration/Maintenance/MigrationTasks/CleanupBrokenVersusScoresMigration.cs @@ -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 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; + } +} \ No newline at end of file