diff --git a/Application/IW4MServer.cs b/Application/IW4MServer.cs index 3d1352860..5b74456b7 100644 --- a/Application/IW4MServer.cs +++ b/Application/IW4MServer.cs @@ -26,6 +26,7 @@ namespace IW4MAdmin { private static readonly Index loc = Utilities.CurrentLocalization.LocalizationIndex; private GameLogEventDetection LogEvent; + private const int REPORT_FLAG_COUNT = 4; public int Id { get; private set; } @@ -329,6 +330,14 @@ namespace IW4MAdmin }; await Manager.GetPenaltyService().Create(newReport); + + int reportNum = await Manager.GetClientService().GetClientReportCount(E.Target.ClientId); + bool isAutoFlagged = await Manager.GetClientService().IsAutoFlagged(E.Target.ClientId); + + if (reportNum >= REPORT_FLAG_COUNT && !isAutoFlagged) + { + E.Target.Flag(Utilities.CurrentLocalization.LocalizationIndex["SERVER_AUTO_FLAG_REPORT"].FormatExt(reportNum), Utilities.IW4MAdminClient(E.Owner)); + } } else if (E.Type == GameEvent.EventType.TempBan) diff --git a/Plugins/LiveRadar/Controllers/RadarController.cs b/Plugins/LiveRadar/Controllers/RadarController.cs index 9cc302453..d10701e22 100644 --- a/Plugins/LiveRadar/Controllers/RadarController.cs +++ b/Plugins/LiveRadar/Controllers/RadarController.cs @@ -20,13 +20,15 @@ namespace LiveRadar.Web.Controllers public IActionResult Index(long? serverId = null) { ViewBag.IsFluid = true; - ViewBag.Title = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_RADAR_TITLE"]; + ViewBag.Title = Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_RADAR_TITLE"]; ViewBag.ActiveServerId = serverId ?? Manager.GetServers().FirstOrDefault()?.EndPoint; - ViewBag.Servers = Manager.GetServers().Select(_server => new ServerInfo() - { - Name = _server.Hostname, - ID = _server.EndPoint - }); + ViewBag.Servers = Manager.GetServers() + .Where(_server => _server.GameName == Server.Game.IW4) + .Select(_server => new ServerInfo() + { + Name = _server.Hostname, + ID = _server.EndPoint + }); return View(); } diff --git a/Plugins/Stats/Helpers/StatManager.cs b/Plugins/Stats/Helpers/StatManager.cs index 9f56523d6..c70d2c70a 100644 --- a/Plugins/Stats/Helpers/StatManager.cs +++ b/Plugins/Stats/Helpers/StatManager.cs @@ -132,6 +132,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers var iqStatsInfo = (from stat in context.Set() where clientIds.Contains(stat.ClientId) where stat.Kills > 0 || stat.Deaths > 0 + where serverId == null ? true : stat.ServerId == serverId group stat by stat.ClientId into s select new { @@ -139,7 +140,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers Kills = s.Sum(c => c.Kills), Deaths = s.Sum(c => c.Deaths), KDR = s.Sum(c => (c.Kills / (double)(c.Deaths == 0 ? 1 : c.Deaths)) * c.TimePlayed) / s.Sum(c => c.TimePlayed), - TotalTimePlayed = s.Sum(c => c.TimePlayed) + TotalTimePlayed = s.Sum(c => c.TimePlayed), }); #if DEBUG == true diff --git a/SharedLibraryCore/Commands/CommandProcessing.cs b/SharedLibraryCore/Commands/CommandProcessing.cs index c5bc4e101..c9acd25f5 100644 --- a/SharedLibraryCore/Commands/CommandProcessing.cs +++ b/SharedLibraryCore/Commands/CommandProcessing.cs @@ -96,7 +96,7 @@ namespace SharedLibraryCore.Commands { E.Target = matchingPlayers.First(); - string escapedName = Regex.Escape(E.Target.Name); + string escapedName = Regex.Escape(E.Target.CleanedName); var reg = new Regex($"(\"{escapedName}\")|({escapedName})", RegexOptions.IgnoreCase); E.Data = reg.Replace(E.Data, "", 1).Trim(); @@ -126,12 +126,12 @@ namespace SharedLibraryCore.Commands { E.Target = matchingPlayers.First(); - string escapedName = Regex.Escape(E.Target.Name); + string escapedName = Regex.Escape(E.Target.CleanedName); string escapedArg = Regex.Escape(Args[0]); var reg = new Regex($"({escapedName})|({escapedArg})", RegexOptions.IgnoreCase); E.Data = reg.Replace(E.Data, "", 1).Trim(); - if ((E.Data.Trim() == E.Target.Name.ToLower().Trim() || + if ((E.Data.Trim() == E.Target.CleanedName.ToLower().Trim() || E.Data == String.Empty) && C.RequiresTarget) { diff --git a/SharedLibraryCore/PartialEntities/EFClient.cs b/SharedLibraryCore/PartialEntities/EFClient.cs index 12b419ace..47fa54819 100644 --- a/SharedLibraryCore/PartialEntities/EFClient.cs +++ b/SharedLibraryCore/PartialEntities/EFClient.cs @@ -94,6 +94,10 @@ namespace SharedLibraryCore.Database.Models get { return CurrentAlias?.Name ?? "--"; } set { if (CurrentAlias != null) CurrentAlias.Name = value; } } + + [NotMapped] + public string CleanedName => Name.StripColors(); + [NotMapped] public virtual int? IPAddress { diff --git a/SharedLibraryCore/Services/ClientService.cs b/SharedLibraryCore/Services/ClientService.cs index 3d3cf3859..ab02baed1 100644 --- a/SharedLibraryCore/Services/ClientService.cs +++ b/SharedLibraryCore/Services/ClientService.cs @@ -594,7 +594,7 @@ namespace SharedLibraryCore.Services #endregion /// - /// retrieves the number of time the given client id has been reported + /// retrieves the number of times the given client id has been reported /// /// client id to search for report counts of /// @@ -609,5 +609,25 @@ namespace SharedLibraryCore.Services .CountAsync(); } } + + /// + /// indicates if the given clientid has been autoflagged + /// + /// + /// + public async Task IsAutoFlagged(int clientId) + { + using (var ctx = new DatabaseContext(true)) + { + var now = DateTime.UtcNow; + return await ctx.Penalties + .Where(_penalty => _penalty.Active) + .Where(_penalty => _penalty.OffenderId == clientId) + .Where(_penalty => _penalty.Type == EFPenalty.PenaltyType.Flag) + .Where(_penalty => _penalty.PunisherId == 1) + .Where(_penalty => _penalty.Expires == null || _penalty.Expires > now) + .AnyAsync(); + } + } } }