From fa66381193a1c180e777c66ee8b5f8062600075e Mon Sep 17 00:00:00 2001 From: RaidMax Date: Sat, 14 Aug 2021 11:30:15 -0500 Subject: [PATCH] small fixes --- .../LiveRadar/Controllers/RadarController.cs | 19 +++++++++++++------ SharedLibraryCore/Server.cs | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Plugins/LiveRadar/Controllers/RadarController.cs b/Plugins/LiveRadar/Controllers/RadarController.cs index 4180ddc5d..f45a970d8 100644 --- a/Plugins/LiveRadar/Controllers/RadarController.cs +++ b/Plugins/LiveRadar/Controllers/RadarController.cs @@ -5,6 +5,7 @@ using SharedLibraryCore; using SharedLibraryCore.Dtos; using SharedLibraryCore.Interfaces; using System.Linq; +using Microsoft.AspNetCore.Http; namespace LiveRadar.Web.Controllers { @@ -48,16 +49,22 @@ namespace LiveRadar.Web.Controllers public IActionResult Map(long? serverId = null) { var server = serverId == null ? _manager.GetServers().FirstOrDefault() : _manager.GetServers().FirstOrDefault(_server => _server.EndPoint == serverId); + + if (server == null) + { + return NotFound(); + } + var map = _config.Maps.FirstOrDefault(_map => _map.Name == server.CurrentMap.Name); - if (map != null) + if (map == null) { - map.Alias = server.CurrentMap.Alias; - return Json(map); + // occurs if we don't recognize the map + return StatusCode(StatusCodes.Status422UnprocessableEntity); } - - // occurs if we don't recognize the map - return StatusCode(500); + + map.Alias = server.CurrentMap.Alias; + return Json(map); } [HttpGet] diff --git a/SharedLibraryCore/Server.cs b/SharedLibraryCore/Server.cs index fba519eaa..d145b5594 100644 --- a/SharedLibraryCore/Server.cs +++ b/SharedLibraryCore/Server.cs @@ -306,7 +306,7 @@ namespace SharedLibraryCore { get { - return Clients.Count(p => p != null && !p.IsBot); + return Clients.ToArray().Count(p => p != null && !p.IsBot); } } public int MaxClients { get; protected set; }