From 84325596eefecc280aa2b996f4f7ff7c09b4cb4b Mon Sep 17 00:00:00 2001 From: Slendy Date: Sat, 11 Feb 2023 19:13:01 -0600 Subject: [PATCH] Clamp minimum and maximum players on slot publish --- .../Controllers/Slots/PublishController.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/PublishController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/PublishController.cs index 8dec6fee..6468e022 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/PublishController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/PublishController.cs @@ -229,6 +229,9 @@ public class PublishController : ControllerBase slot.MaximumPlayers = 4; } + slot.MinimumPlayers = Math.Clamp(slot.MinimumPlayers, 1, 4); + slot.MaximumPlayers = Math.Clamp(slot.MaximumPlayers, 1, 4); + this.database.Entry(oldSlot).CurrentValues.SetValues(slot); await this.database.SaveChangesAsync(); return this.Ok(oldSlot.Serialize(token.GameVersion)); @@ -259,6 +262,9 @@ public class PublishController : ControllerBase slot.MaximumPlayers = 4; } + slot.MinimumPlayers = Math.Clamp(slot.MinimumPlayers, 1, 4); + slot.MaximumPlayers = Math.Clamp(slot.MaximumPlayers, 1, 4); + this.database.Slots.Add(slot); await this.database.SaveChangesAsync();