From 3ebdc03951d8d8ee05b4a2d08083cffe95ddb0e8 Mon Sep 17 00:00:00 2001 From: Slendy Date: Tue, 28 Mar 2023 15:19:25 -0500 Subject: [PATCH] Properly serialize slot resources --- .../Controllers/Slots/PublishController.cs | 18 +++++++++--------- .../Types/Serialization/GameUserSlot.cs | 5 +---- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/PublishController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/PublishController.cs index f785ba72..5ad61e75 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/PublishController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/PublishController.cs @@ -56,9 +56,9 @@ public class PublishController : ControllerBase return this.BadRequest(); } - if (slot.ResourceList?.Length == 0) slot.ResourceList = new[]{slot.RootLevel,}; + if (slot.Resources?.Length == 0) slot.Resources = new[]{slot.RootLevel,}; - if (slot.ResourceList == null) + if (slot.Resources == null) { Logger.Warn("Rejecting level upload, resource list is null", LogArea.Publish); return this.BadRequest(); @@ -86,7 +86,7 @@ public class PublishController : ControllerBase return this.Forbid(); } - HashSet resources = new(slot.ResourceList) + HashSet resources = new(slot.Resources) { slot.IconHash, }; @@ -114,13 +114,13 @@ public class PublishController : ControllerBase return this.BadRequest(); } - if (slot.ResourceList?.Length == 0) + if (slot.Resources?.Length == 0) { Logger.Warn("Rejecting level upload, resource list is null", LogArea.Publish); return this.BadRequest(); } // Yes Rider, this isn't null - Debug.Assert(slot.ResourceList != null, "slot.ResourceList != null"); + Debug.Assert(slot.Resources != null, "slot.ResourceList != null"); if (string.IsNullOrWhiteSpace(slot.BackgroundHash)) { @@ -144,7 +144,7 @@ public class PublishController : ControllerBase return this.BadRequest(); } - if (slot.ResourceList.Any(resource => !FileHelper.ResourceExists(resource))) + if (slot.Resources.Any(resource => !FileHelper.ResourceExists(resource))) { Logger.Warn("Rejecting level upload, missing resource(s)", LogArea.Publish); return this.BadRequest(); @@ -182,10 +182,10 @@ public class PublishController : ControllerBase slot.AuthorLabels = LabelHelper.RemoveInvalidLabels(slot.AuthorLabels); - if (!slot.ResourceList.Contains(slot.RootLevel)) - slot.ResourceList = slot.ResourceList.Append(rootLevel.Hash).ToArray(); + if (!slot.Resources.Contains(slot.RootLevel)) + slot.Resources = slot.Resources.Append(rootLevel.Hash).ToArray(); - string resourceCollection = string.Join(",", slot.ResourceList); + string resourceCollection = string.Join(",", slot.Resources); // Republish logic if (slot.SlotId != 0) diff --git a/ProjectLighthouse/Types/Serialization/GameUserSlot.cs b/ProjectLighthouse/Types/Serialization/GameUserSlot.cs index d81f66b7..9faecb52 100644 --- a/ProjectLighthouse/Types/Serialization/GameUserSlot.cs +++ b/ProjectLighthouse/Types/Serialization/GameUserSlot.cs @@ -34,9 +34,6 @@ public class GameUserSlot : SlotBase, INeedsPreparationForSerialization [XmlIgnore] public SerializationMode SerializationMode { get; set; } - [XmlIgnore] - public string[]? Resources { get; set; } - [XmlElement("id")] public int SlotId { get; set; } @@ -62,7 +59,7 @@ public class GameUserSlot : SlotBase, INeedsPreparationForSerialization public string? RootLevel { get; set; } [XmlElement("resource")] - public string[]? ResourceList { get; set; } + public string[]? Resources { get; set; } [XmlElement("icon")] public string IconHash { get; set; } = "";