diff --git a/Application/EventParsers/IW5EventParser.cs b/Application/EventParsers/IW5EventParser.cs index 10bbabd4b..e452bdaa7 100644 --- a/Application/EventParsers/IW5EventParser.cs +++ b/Application/EventParsers/IW5EventParser.cs @@ -32,7 +32,7 @@ namespace IW4MAdmin.Application.EventParsers return new GameEvent() { - Type = GameEvent.EventType.Connect, + Type = GameEvent.EventType.Join, Origin = new Player() { ClientId = 1 diff --git a/Application/Main.cs b/Application/Main.cs index aff42373f..4c216580e 100644 --- a/Application/Main.cs +++ b/Application/Main.cs @@ -20,7 +20,7 @@ namespace IW4MAdmin.Application public static void Main(string[] args) { AppDomain.CurrentDomain.SetData("DataDirectory", OperatingDirectory); - System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.BelowNormal; + //System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.BelowNormal; Localization.Configure.Initialize(); var loc = Utilities.CurrentLocalization.LocalizationSet; Console.OutputEncoding = Encoding.UTF8; diff --git a/Application/RconParsers/IW5MRConParser.cs b/Application/RconParsers/IW5MRConParser.cs index ab00e9a37..c75f6878b 100644 --- a/Application/RconParsers/IW5MRConParser.cs +++ b/Application/RconParsers/IW5MRConParser.cs @@ -140,7 +140,7 @@ namespace Application.RconParsers Int32.TryParse(playerInfo[2], out Ping); string name = Encoding.UTF8.GetString(Encoding.Convert(Utilities.EncodingType, Encoding.UTF8, Utilities.EncodingType.GetBytes(responseLine.Substring(23, 15).StripColors().Trim()))); - long networkId = playerInfo[4].ConvertLong(); + long networkId = 0;//playerInfo[4].ConvertLong(); int.TryParse(playerInfo[0], out clientId); var regex = Regex.Match(responseLine, @"\d+\.\d+\.\d+.\d+\:\d{1,5}"); int ipAddress = regex.Value.Split(':')[0].ConvertToIP(); @@ -155,7 +155,7 @@ namespace Application.RconParsers IPAddress = ipAddress, Ping = Ping, Score = score, - IsBot = networkId == 0 + IsBot = false }; StatusPlayers.Add(p); diff --git a/Application/Server.cs b/Application/Server.cs index f9ff61f36..9abbd4542 100644 --- a/Application/Server.cs +++ b/Application/Server.cs @@ -186,7 +186,7 @@ namespace IW4MAdmin var e = new GameEvent(GameEvent.EventType.Connect, "", player, null, this); Manager.GetEventHandler().AddEvent(e); - e.OnProcessed.Wait(); + // e.OnProcessed.Wait(); if (!Manager.GetApplicationSettings().Configuration().EnableClientVPNs && await VPNCheck.UsingVPN(player.IPAddressString, Manager.GetApplicationSettings().Configuration().IPHubAPIKey)) @@ -413,6 +413,19 @@ namespace IW4MAdmin override protected async Task ProcessEvent(GameEvent E) { if (E.Type == GameEvent.EventType.Connect) + { + ChatHistory.Add(new ChatInfo() + { + Name = E.Origin.Name, + Message = "CONNECTED", + Time = DateTime.UtcNow + }); + + if (E.Origin.Level > Player.Permission.Moderator) + await E.Origin.Tell(string.Format(loc["SERVER_REPORT_COUNT"], E.Owner.Reports.Count)); + } + + else if (E.Type == GameEvent.EventType.Join) { // special case for IW5 when connect is from the log if (E.Extra != null && GameName == Game.IW5) @@ -424,22 +437,6 @@ namespace IW4MAdmin client.NetworkId = logClient.NetworkId; await AddPlayer(client); - - // hack: to prevent plugins from registering it as a real connect - E.Type = GameEvent.EventType.Unknown; - } - - else - { - ChatHistory.Add(new ChatInfo() - { - Name = E.Origin.Name, - Message = "CONNECTED", - Time = DateTime.UtcNow - }); - - if (E.Origin.Level > Player.Permission.Moderator) - await E.Origin.Tell(string.Format(loc["SERVER_REPORT_COUNT"], E.Owner.Reports.Count)); } } @@ -484,7 +481,7 @@ namespace IW4MAdmin } E.Extra = C; - + // reprocess event as a command @@ -570,10 +567,19 @@ namespace IW4MAdmin Throttled = false; var clients = GetPlayersAsList(); - foreach(var client in clients) + foreach (var client in clients) { - if (!CurrentPlayers.Select(c => c.NetworkId).Contains(client.NetworkId)) - await RemovePlayer(client.ClientNumber); + if (GameName == Game.IW5) + { + if (!CurrentPlayers.Select(c => c.ClientNumber).Contains(client.ClientNumber)) + await RemovePlayer(client.ClientNumber); + } + + else + { + if (!CurrentPlayers.Select(c => c.NetworkId).Contains(client.NetworkId)) + await RemovePlayer(client.ClientNumber); + } } for (int i = 0; i < CurrentPlayers.Count; i++) @@ -717,10 +723,10 @@ namespace IW4MAdmin var infoResponse = await this.GetInfoAsync(); // this is normally slow, but I'm only doing it because different games have different prefixes - var hostname = infoResponse == null ? + var hostname = infoResponse == null ? (await this.GetDvarAsync("sv_hostname")).Value : infoResponse.Where(kvp => kvp.Key.Contains("hostname")).Select(kvp => kvp.Value).First(); - var mapname = infoResponse == null ? + var mapname = infoResponse == null ? (await this.GetDvarAsync("mapname")).Value : infoResponse["mapname"]; int maxplayers = (GameName == Game.IW4) ? // gotta love IW4 idiosyncrasies @@ -728,11 +734,11 @@ namespace IW4MAdmin infoResponse == null ? (await this.GetDvarAsync("sv_maxclients")).Value : Convert.ToInt32(infoResponse["sv_maxclients"]); - var gametype = infoResponse == null ? + var gametype = infoResponse == null ? (await this.GetDvarAsync("g_gametype")).Value : infoResponse.Where(kvp => kvp.Key.Contains("gametype")).Select(kvp => kvp.Value).First(); var basepath = await this.GetDvarAsync("fs_basepath"); - var game = infoResponse == null || !infoResponse.ContainsKey("fs_game") ? + var game = infoResponse == null || !infoResponse.ContainsKey("fs_game") ? (await this.GetDvarAsync("fs_game")).Value : infoResponse["fs_game"]; var logfile = await this.GetDvarAsync("g_log"); @@ -807,7 +813,7 @@ namespace IW4MAdmin { LogEvent = new GameLogEvent(this, logPath, logfile.Value); } - + Logger.WriteInfo($"Log file is {logPath}"); #if DEBUG // LogFile = new RemoteFile("https://raidmax.org/IW4MAdmin/getlog.php"); diff --git a/Plugins/Login/Commands/CLogin.cs b/Plugins/Login/Commands/CLogin.cs index 61fdbb2a4..c12937eb8 100644 --- a/Plugins/Login/Commands/CLogin.cs +++ b/Plugins/Login/Commands/CLogin.cs @@ -8,7 +8,7 @@ namespace IW4MAdmin.Plugins.Login.Commands { public class CLogin : Command { - public CLogin() : base("login", Utilities.CurrentLocalization.LocalizationSet["PLUGINS_LOGIN_COMMANDS_LOGIN_DESC"], "l", Player.Permission.Trusted, false, new CommandArgument[] + public CLogin() : base("login", Utilities.CurrentLocalization.LocalizationSet["PLUGINS_LOGIN_COMMANDS_LOGIN_DESC"], "li", Player.Permission.Trusted, false, new CommandArgument[] { new CommandArgument() { diff --git a/Plugins/Stats/Cheat/Detection.cs b/Plugins/Stats/Cheat/Detection.cs index 2aab26908..77d9feab6 100644 --- a/Plugins/Stats/Cheat/Detection.cs +++ b/Plugins/Stats/Cheat/Detection.cs @@ -83,7 +83,7 @@ namespace IW4MAdmin.Plugins.Stats.Cheat { double marginOfError = Thresholds.GetMarginOfError(Kills); // determine what the max headshot percentage can be for current number of kills - double lerpAmount = Math.Min(1.0, (Kills - Thresholds.LowSampleMinKills) / (double)(Thresholds.HighSampleMinKills - Thresholds.LowSampleMinKills)); + double lerpAmount = Math.Min(1.0, (Kills - Thresholds.LowSampleMinKills) / (double)(/*Thresholds.HighSampleMinKills*/ 60 - Thresholds.LowSampleMinKills)); double maxHeadshotLerpValueForFlag = Thresholds.Lerp(Thresholds.HeadshotRatioThresholdLowSample(2.0), Thresholds.HeadshotRatioThresholdHighSample(2.0), lerpAmount) + marginOfError; double maxHeadshotLerpValueForBan = Thresholds.Lerp(Thresholds.HeadshotRatioThresholdLowSample(3.0), Thresholds.HeadshotRatioThresholdHighSample(3.0), lerpAmount) + marginOfError; // determine what the max bone percentage can be for current number of kills @@ -91,7 +91,7 @@ namespace IW4MAdmin.Plugins.Stats.Cheat double maxBoneRatioLerpValueForBan = Thresholds.Lerp(Thresholds.BoneRatioThresholdLowSample(3.25), Thresholds.BoneRatioThresholdHighSample(3.25), lerpAmount) + marginOfError; // calculate headshot ratio - double currentHeadshotRatio = ((HitLocationCount[IW4Info.HitLocation.head] + HitLocationCount[IW4Info.HitLocation.helmet]) / (double)Kills); + double currentHeadshotRatio = ((HitLocationCount[IW4Info.HitLocation.head] + HitLocationCount[IW4Info.HitLocation.helmet] + HitLocationCount[IW4Info.HitLocation.neck]) / (double)Kills); // calculate maximum bone double currentMaxBoneRatio = (HitLocationCount.Values.Select(v => v / (double)Kills).Max()); @@ -276,8 +276,8 @@ namespace IW4MAdmin.Plugins.Stats.Cheat double marginOfError = Thresholds.GetMarginOfError(totalChestKills); double lerpAmount = Math.Min(1.0, (totalChestKills - 60) / 250.0); // determine max acceptable ratio of chest to abdomen kills - double chestAbdomenRatioLerpValueForFlag = Thresholds.Lerp(Thresholds.ChestAbdomenRatioThresholdHighSample(3.0), Thresholds.ChestAbdomenRatioThresholdHighSample(2), lerpAmount) + marginOfError; - double chestAbdomenLerpValueForBan = Thresholds.Lerp(Thresholds.ChestAbdomenRatioThresholdHighSample(4.0), Thresholds.ChestAbdomenRatioThresholdHighSample(4.0), lerpAmount) + marginOfError; + double chestAbdomenRatioLerpValueForFlag = Thresholds.Lerp(Thresholds.ChestAbdomenRatioThresholdHighSample(3.0), Thresholds.ChestAbdomenRatioThresholdHighSample(2.0), lerpAmount) + marginOfError; + double chestAbdomenLerpValueForBan = Thresholds.Lerp(Thresholds.ChestAbdomenRatioThresholdHighSample(4.0), Thresholds.ChestAbdomenRatioThresholdHighSample(3.0), lerpAmount) + marginOfError; double currentChestAbdomenRatio = totalChestKills / stats.HitLocations.Single(hl => hl.Location == IW4Info.HitLocation.torso_lower).HitCount; diff --git a/Plugins/Stats/Helpers/StatManager.cs b/Plugins/Stats/Helpers/StatManager.cs index 8e48c6233..da026fc3b 100644 --- a/Plugins/Stats/Helpers/StatManager.cs +++ b/Plugins/Stats/Helpers/StatManager.cs @@ -230,7 +230,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers catch (FormatException) { Log.WriteWarning("Could not parse kill or death origin or viewangle vectors"); - Log.WriteDebug($"Kill - {killOrigin} Death - {deathOrigin} ViewAgnel - {viewAngles}"); + Log.WriteDebug($"Kill - {killOrigin} Death - {deathOrigin} ViewAngle - {viewAngles}"); await AddStandardKill(attacker, victim); return; } diff --git a/SharedLibraryCore/Event.cs b/SharedLibraryCore/Event.cs index 2ae783e1f..3d7a36aad 100644 --- a/SharedLibraryCore/Event.cs +++ b/SharedLibraryCore/Event.cs @@ -15,6 +15,8 @@ namespace SharedLibraryCore Start, Stop, Connect, + // this is for IW5 compatibility + Join, Disconnect, Say, MapChange, diff --git a/SharedLibraryCore/Services/GenericRepository.cs b/SharedLibraryCore/Services/GenericRepository.cs index 146ff1d98..4d5ee4047 100644 --- a/SharedLibraryCore/Services/GenericRepository.cs +++ b/SharedLibraryCore/Services/GenericRepository.cs @@ -15,11 +15,6 @@ namespace SharedLibraryCore.Services private dynamic _context; private DbSet _dbSet; - ~GenericRepository() - { - _context.Dispose(); - } - protected DbContext Context { get diff --git a/WebfrontCore/Controllers/BaseController.cs b/WebfrontCore/Controllers/BaseController.cs index a40aea365..3d0951ddc 100644 --- a/WebfrontCore/Controllers/BaseController.cs +++ b/WebfrontCore/Controllers/BaseController.cs @@ -38,7 +38,9 @@ namespace WebfrontCore.Controllers { Client = Client ?? new EFClient() { - ClientId = -1 + ClientId = -1, + Level = Player.Permission.User, + CurrentAlias = new EFAlias() { Name = "Web Console Guest" } }; if (!HttpContext.Connection.RemoteIpAddress.GetAddressBytes().SequenceEqual(LocalHost)) @@ -49,7 +51,7 @@ namespace WebfrontCore.Controllers Client.Level = (Player.Permission)Enum.Parse(typeof(Player.Permission), User.Claims.First(c => c.Type == ClaimTypes.Role).Value); Client.CurrentAlias = new EFAlias() { Name = User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value }; var stillExists = Manager.GetPrivilegedClients()[Client.ClientId]; - + // this happens if their level has been updated if (stillExists.Level != Client.Level) { @@ -78,9 +80,9 @@ namespace WebfrontCore.Controllers Authorized = Client.ClientId >= 0; ViewBag.Authorized = Authorized; - ViewBag.Url = Startup.Configuration["Web:Address"]; + ViewBag.Url = Manager.GetApplicationSettings().Configuration().WebfrontBindUrl; ViewBag.User = Client; - ViewBag.DiscordLink = DiscordLink; + ViewBag.DiscordLink = DiscordLink ?? ""; base.OnActionExecuting(context); } diff --git a/WebfrontCore/Controllers/ConsoleController.cs b/WebfrontCore/Controllers/ConsoleController.cs index 1a573ecd4..036d96975 100644 --- a/WebfrontCore/Controllers/ConsoleController.cs +++ b/WebfrontCore/Controllers/ConsoleController.cs @@ -35,7 +35,7 @@ namespace WebfrontCore.Controllers ClientId = Client.ClientId, Level = Client.Level, CurrentServer = server, - CurrentAlias = new Alias() { Name = Client.Name } + Name = Client.Name }; var remoteEvent = new GameEvent() {