mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-28 16:08:38 +00:00
Merge branch 'LBPUnion:main' into playlists
This commit is contained in:
commit
fbe203d84a
23 changed files with 484 additions and 216 deletions
|
@ -60,12 +60,12 @@ public class PublishController : ControllerBase
|
|||
Slot? oldSlot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == slot.SlotId);
|
||||
if (oldSlot == null)
|
||||
{
|
||||
Logger.Warn("Rejecting level reupload, could not find old slot", LogArea.Publish);
|
||||
Logger.Warn("Rejecting level republish, could not find old slot", LogArea.Publish);
|
||||
return this.NotFound();
|
||||
}
|
||||
if (oldSlot.CreatorId != user.UserId)
|
||||
{
|
||||
Logger.Warn("Rejecting level reupload, old slot's creator is not publishing user", LogArea.Publish);
|
||||
Logger.Warn("Rejecting level republish, old slot's creator is not publishing user", LogArea.Publish);
|
||||
return this.BadRequest();
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ public class PublishController : ControllerBase
|
|||
/// Endpoint actually used to publish a level
|
||||
/// </summary>
|
||||
[HttpPost("publish")]
|
||||
public async Task<IActionResult> Publish()
|
||||
public async Task<IActionResult> Publish([FromQuery] string? game)
|
||||
{
|
||||
(User, GameToken)? userAndToken = await this.database.UserAndGameTokenFromRequest(this.Request);
|
||||
|
||||
|
@ -178,6 +178,22 @@ public class PublishController : ControllerBase
|
|||
return this.BadRequest();
|
||||
}
|
||||
|
||||
// I hate lbp3
|
||||
if (game != null)
|
||||
{
|
||||
GameVersion intendedVersion = FromAbbreviation(game);
|
||||
if (intendedVersion != GameVersion.Unknown && intendedVersion != slotVersion)
|
||||
{
|
||||
// Delete the useless rootLevel that lbp3 just uploaded
|
||||
if(slotVersion == GameVersion.LittleBigPlanet3)
|
||||
FileHelper.DeleteResource(slot.RootLevel);
|
||||
|
||||
slot.GameVersion = oldSlot.GameVersion;
|
||||
slot.RootLevel = oldSlot.RootLevel;
|
||||
slot.ResourceCollection = oldSlot.ResourceCollection;
|
||||
}
|
||||
}
|
||||
|
||||
oldSlot.Location.X = slot.Location.X;
|
||||
oldSlot.Location.Y = slot.Location.Y;
|
||||
|
||||
|
@ -277,6 +293,19 @@ public class PublishController : ControllerBase
|
|||
return this.Ok();
|
||||
}
|
||||
|
||||
private static GameVersion FromAbbreviation(string abbr)
|
||||
{
|
||||
return abbr switch
|
||||
{
|
||||
"lbp1" => GameVersion.LittleBigPlanet1,
|
||||
"lbp2" => GameVersion.LittleBigPlanet2,
|
||||
"lbp3" => GameVersion.LittleBigPlanet3,
|
||||
"lbpv" => GameVersion.LittleBigPlanetVita,
|
||||
"lbppsp" => GameVersion.LittleBigPlanetPSP,
|
||||
_ => GameVersion.Unknown,
|
||||
};
|
||||
}
|
||||
|
||||
private async Task<Slot?> getSlotFromBody()
|
||||
{
|
||||
this.Request.Body.Position = 0;
|
||||
|
|
|
@ -214,8 +214,8 @@ public class ScoreController : ControllerBase
|
|||
var rankedScores = this.database.Scores
|
||||
.Where(s => s.SlotId == slotId && s.Type == type)
|
||||
.Where(s => s.ChildSlotId == 0 || s.ChildSlotId == childId)
|
||||
.Where(s => playerIds == null || playerIds.Any(id => s.PlayerIdCollection.Contains(id)))
|
||||
.AsEnumerable()
|
||||
.Where(s => playerIds == null || playerIds.Any(id => s.PlayerIdCollection.Contains(id)))
|
||||
.OrderByDescending(s => s.Points)
|
||||
.ThenBy(s => s.ScoreId)
|
||||
.ToList()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue