diff --git a/Application/EventParsers/BaseEventParser.cs b/Application/EventParsers/BaseEventParser.cs index 45dd9af20..3dac27003 100644 --- a/Application/EventParsers/BaseEventParser.cs +++ b/Application/EventParsers/BaseEventParser.cs @@ -284,6 +284,7 @@ namespace IW4MAdmin.Application.EventParsers return new GameEvent() { Type = GameEvent.EventType.Unknown, + Data = logLine, Origin = Utilities.IW4MAdminClient(), Target = Utilities.IW4MAdminClient(), RequiredEntity = GameEvent.EventRequiredEntity.None diff --git a/IW4MAdmin.sln b/IW4MAdmin.sln index 84a779ef0..3d3a90ecf 100644 --- a/IW4MAdmin.sln +++ b/IW4MAdmin.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 -VisualStudioVersion = 16.0.28803.352 +VisualStudioVersion = 16.0.29009.5 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{26E8B310-269E-46D4-A612-24601F16065F}" EndProject @@ -53,6 +53,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StatsWeb", "Plugins\Web\Sta EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutomessageFeed", "Plugins\AutomessageFeed\AutomessageFeed.csproj", "{F5815359-CFC7-44B4-9A3B-C04BACAD5836}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiveRadar", "Plugins\LiveRadar\LiveRadar.csproj", "{00A1FED2-2254-4AF7-A5DB-2357FA7C88CD}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -377,6 +379,30 @@ Global {F5815359-CFC7-44B4-9A3B-C04BACAD5836}.Release|x64.Build.0 = Release|Any CPU {F5815359-CFC7-44B4-9A3B-C04BACAD5836}.Release|x86.ActiveCfg = Release|Any CPU {F5815359-CFC7-44B4-9A3B-C04BACAD5836}.Release|x86.Build.0 = Release|Any CPU + {00A1FED2-2254-4AF7-A5DB-2357FA7C88CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {00A1FED2-2254-4AF7-A5DB-2357FA7C88CD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {00A1FED2-2254-4AF7-A5DB-2357FA7C88CD}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {00A1FED2-2254-4AF7-A5DB-2357FA7C88CD}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {00A1FED2-2254-4AF7-A5DB-2357FA7C88CD}.Debug|x64.ActiveCfg = Debug|Any CPU + {00A1FED2-2254-4AF7-A5DB-2357FA7C88CD}.Debug|x64.Build.0 = Debug|Any CPU + {00A1FED2-2254-4AF7-A5DB-2357FA7C88CD}.Debug|x86.ActiveCfg = Debug|Any CPU + {00A1FED2-2254-4AF7-A5DB-2357FA7C88CD}.Debug|x86.Build.0 = Debug|Any CPU + {00A1FED2-2254-4AF7-A5DB-2357FA7C88CD}.Prerelease|Any CPU.ActiveCfg = Debug|Any CPU + {00A1FED2-2254-4AF7-A5DB-2357FA7C88CD}.Prerelease|Any CPU.Build.0 = Debug|Any CPU + {00A1FED2-2254-4AF7-A5DB-2357FA7C88CD}.Prerelease|Mixed Platforms.ActiveCfg = Debug|Any CPU + {00A1FED2-2254-4AF7-A5DB-2357FA7C88CD}.Prerelease|Mixed Platforms.Build.0 = Debug|Any CPU + {00A1FED2-2254-4AF7-A5DB-2357FA7C88CD}.Prerelease|x64.ActiveCfg = Debug|Any CPU + {00A1FED2-2254-4AF7-A5DB-2357FA7C88CD}.Prerelease|x64.Build.0 = Debug|Any CPU + {00A1FED2-2254-4AF7-A5DB-2357FA7C88CD}.Prerelease|x86.ActiveCfg = Debug|Any CPU + {00A1FED2-2254-4AF7-A5DB-2357FA7C88CD}.Prerelease|x86.Build.0 = Debug|Any CPU + {00A1FED2-2254-4AF7-A5DB-2357FA7C88CD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {00A1FED2-2254-4AF7-A5DB-2357FA7C88CD}.Release|Any CPU.Build.0 = Release|Any CPU + {00A1FED2-2254-4AF7-A5DB-2357FA7C88CD}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {00A1FED2-2254-4AF7-A5DB-2357FA7C88CD}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {00A1FED2-2254-4AF7-A5DB-2357FA7C88CD}.Release|x64.ActiveCfg = Release|Any CPU + {00A1FED2-2254-4AF7-A5DB-2357FA7C88CD}.Release|x64.Build.0 = Release|Any CPU + {00A1FED2-2254-4AF7-A5DB-2357FA7C88CD}.Release|x86.ActiveCfg = Release|Any CPU + {00A1FED2-2254-4AF7-A5DB-2357FA7C88CD}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -392,6 +418,7 @@ Global {A848FCF1-8527-4AA8-A1AA-50D29695C678} = {26E8B310-269E-46D4-A612-24601F16065F} {776B348B-F818-4A0F-A625-D0AF8BAD3E9B} = {A848FCF1-8527-4AA8-A1AA-50D29695C678} {F5815359-CFC7-44B4-9A3B-C04BACAD5836} = {26E8B310-269E-46D4-A612-24601F16065F} + {00A1FED2-2254-4AF7-A5DB-2357FA7C88CD} = {26E8B310-269E-46D4-A612-24601F16065F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {84F8F8E0-1F73-41E0-BD8D-BB6676E2EE87} diff --git a/Plugins/LiveRadar/LiveRadar.csproj b/Plugins/LiveRadar/LiveRadar.csproj new file mode 100644 index 000000000..0eea9ca31 --- /dev/null +++ b/Plugins/LiveRadar/LiveRadar.csproj @@ -0,0 +1,29 @@ + + + + netcoreapp2.2 + 0.1.0.0 + + + + + false + + + false + + + + + + + + + + + + + + + + diff --git a/Plugins/LiveRadar/MapInfo.cs b/Plugins/LiveRadar/MapInfo.cs new file mode 100644 index 000000000..eeb738453 --- /dev/null +++ b/Plugins/LiveRadar/MapInfo.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace LiveRadar +{ + public class MapInfo + { + public string Name { get; set; } + // distance from the edge of the minimap image + // to the "playable" area + public int Top { get; set; } + public int Bottom { get; set; } + public int Left { get; set; } + public int Right { get; set; } + // maximum coordinate values for the map + public int MaxTop { get; set; } + public int MaxBottom { get; set; } + public int MaxLeft { get; set; } + public int MaxRight { get; set; } + + public int Width => MaxLeft - MaxRight; + public int Height => MaxTop - MaxBottom; + } +} diff --git a/Plugins/LiveRadar/Plugin.cs b/Plugins/LiveRadar/Plugin.cs new file mode 100644 index 000000000..cbb519829 --- /dev/null +++ b/Plugins/LiveRadar/Plugin.cs @@ -0,0 +1,48 @@ +using SharedLibraryCore; +using SharedLibraryCore.Interfaces; +using System; +using System.Linq; +using System.Threading.Tasks; + +namespace LiveRadar +{ + public class Plugin : IPlugin + { + public string Name => "Live Radar"; + + public float Version => (float)Utilities.GetVersionAsDouble(); + + public string Author => "RaidMax"; + + public Task OnEventAsync(GameEvent E, Server S) + { + if (E.Type == GameEvent.EventType.Unknown) + { + if (E.Data?.StartsWith("LiveRadar") ?? false) + { + var radarUpdate = RadarEvent.Parse(E.Data); + var client = S.GetClientsAsList().First(_client => _client.NetworkId == radarUpdate.Guid); + radarUpdate.Name = client.Name; + client.SetAdditionalProperty("LiveRadar", radarUpdate); + } + } + + return Task.CompletedTask; + } + + public Task OnLoadAsync(IManager manager) + { + return Task.CompletedTask; + } + + public Task OnTickAsync(Server S) + { + return Task.CompletedTask; + } + + public Task OnUnloadAsync() + { + return Task.CompletedTask; + } + } +} diff --git a/Plugins/LiveRadar/RadarEvent.cs b/Plugins/LiveRadar/RadarEvent.cs new file mode 100644 index 000000000..b34ba9591 --- /dev/null +++ b/Plugins/LiveRadar/RadarEvent.cs @@ -0,0 +1,46 @@ +using SharedLibraryCore; +using SharedLibraryCore.Helpers; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace LiveRadar +{ + public class RadarEvent + { + public string Name { get; set; } + public long Guid { get; set; } + public Vector3 Location { get; set; } + public Vector3 ViewAngles { get; set; } + public string Team { get; set; } + public int Kills { get; set; } + public int Deaths { get; set; } + public int Score { get; set; } + public string Weapon { get; set; } + public int Health { get; set; } + public bool IsAlive { get; set; } + public Vector3 RadianAngles => new Vector3(ViewAngles.X.ToRadians(), ViewAngles.Y.ToRadians(), ViewAngles.Z.ToRadians()); + + public static RadarEvent Parse(string input) + { + var items = input.Split(';').ToList(); + + var parsedEvent = new RadarEvent() + { + Guid = items[0].ConvertLong(), + Location = Vector3.Parse(items[1]), + ViewAngles = Vector3.Parse(items[2]), + Team = items[3], + Kills = int.Parse(items[4]), + Deaths = int.Parse(items[5]), + Score = int.Parse(items[6]), + Weapon = items[7], + Health = int.Parse(items[8]), + IsAlive = items[9] == "1" + }; + + return parsedEvent; + } + } +} diff --git a/Plugins/LiveRadar/Web/Controllers/RadarController.cs b/Plugins/LiveRadar/Web/Controllers/RadarController.cs new file mode 100644 index 000000000..6db470855 --- /dev/null +++ b/Plugins/LiveRadar/Web/Controllers/RadarController.cs @@ -0,0 +1,59 @@ +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using WebfrontCore.Controllers; + +namespace LiveRadar.Web.Controllers +{ + public class RadarController : BaseController + { + [HttpGet] + public IActionResult Index() + { + return View(); + } + + public IActionResult Map(long? serverId = null) + { + var map = new MapInfo() + { + Name = "mp_rust", + Top = 248, + Bottom = 212, + Left = 314, + Right = 167, + MaxRight = -225, + MaxLeft = 1809, + MaxTop = 1641, + MaxBottom = -469 + }; + + return Json(map); + } + + public IActionResult Data(long? serverId = null) + { + var server = serverId == null ? Manager.GetServers()[0] : Manager.GetServers().First(_server => _server.GetHashCode() == serverId); + var radarInfo = server.GetClientsAsList().Select(_client => _client.GetAdditionalProperty("LiveRadar")); + + return Json(radarInfo); + } + + [HttpGet] + public IActionResult Update(string payload) + { + return Ok(); + + var radarUpdate = RadarEvent.Parse(payload); + var client = Manager.GetActiveClients().First(_client => _client.NetworkId == radarUpdate.Guid); + radarUpdate.Name = client.Name; + + client.SetAdditionalProperty("LiveRadar", radarUpdate); + + return Ok(); + } + } +} diff --git a/Plugins/LiveRadar/Web/Views/LiveRadar/Index.cshtml b/Plugins/LiveRadar/Web/Views/LiveRadar/Index.cshtml new file mode 100644 index 000000000..40454a2a3 --- /dev/null +++ b/Plugins/LiveRadar/Web/Views/LiveRadar/Index.cshtml @@ -0,0 +1,122 @@ +@model IEnumerable + + + + +
+
+ +@section scripts { + +} \ No newline at end of file diff --git a/Plugins/LiveRadar/Web/wwwroot/images/compass_map_mp_rust@2x.png b/Plugins/LiveRadar/Web/wwwroot/images/compass_map_mp_rust@2x.png new file mode 100644 index 000000000..c5f0d0713 Binary files /dev/null and b/Plugins/LiveRadar/Web/wwwroot/images/compass_map_mp_rust@2x.png differ diff --git a/Plugins/Stats/Cheat/Strain.cs b/Plugins/Stats/Cheat/Strain.cs index 56aee14b1..3f4fc01ab 100644 --- a/Plugins/Stats/Cheat/Strain.cs +++ b/Plugins/Stats/Cheat/Strain.cs @@ -1,4 +1,5 @@ -using SharedLibraryCore.Helpers; +using SharedLibraryCore; +using SharedLibraryCore.Helpers; using SharedLibraryCore.Interfaces; using System; using System.Collections.Generic; @@ -23,7 +24,7 @@ namespace IW4MAdmin.Plugins.Stats.Cheat double decayFactor = GetDecay(deltaTime); CurrentStrain *= decayFactor; - double[] distance = Helpers.Extensions.AngleStuff(newAngle, LastAngle); + double[] distance = Utilities.AngleStuff(newAngle, LastAngle); LastDistance = distance[0] + distance[1]; #if DEBUG == true diff --git a/Plugins/Stats/Helpers/Extensions.cs b/Plugins/Stats/Helpers/Extensions.cs deleted file mode 100644 index 3f5a2339b..000000000 --- a/Plugins/Stats/Helpers/Extensions.cs +++ /dev/null @@ -1,33 +0,0 @@ -using SharedLibraryCore.Helpers; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace IW4MAdmin.Plugins.Stats.Helpers -{ - static class Extensions - { - - public static Vector3 FixIW4Angles(this Vector3 vector) - { - float X = vector.X >= 0 ? vector.X : 360.0f + vector.X; - float Y = vector.Y >= 0 ? vector.Y : 360.0f + vector.Y; - - return new Vector3(Y, X, vector.Z); - } - - public static float ToRadians(this float value) => (float)Math.PI * value / 180.0f; - - public static float ToDegrees(this float value) => value * 180.0f / (float)Math.PI; - - public static double[] AngleStuff(Vector3 a, Vector3 b) - { - double deltaX = 180.0 - Math.Abs(Math.Abs(a.X - b.X) - 180.0); - double deltaY = 180.0 - Math.Abs(Math.Abs(a.Y - b.Y) - 180.0); - - return new[] { deltaX, deltaY }; - } - } -} diff --git a/SharedLibraryCore/Utilities.cs b/SharedLibraryCore/Utilities.cs index 7241a0e5e..3766cee6a 100644 --- a/SharedLibraryCore/Utilities.cs +++ b/SharedLibraryCore/Utilities.cs @@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore.Query.Internal; using Microsoft.EntityFrameworkCore.Storage; #endif using SharedLibraryCore.Database.Models; +using SharedLibraryCore.Helpers; using System; using System.Collections.Generic; using System.Diagnostics; @@ -812,6 +813,27 @@ namespace SharedLibraryCore return Regex.IsMatch(message, @"^\u0014(?:[A-Z]|_)+$"); } + public static Vector3 FixIW4Angles(this Vector3 vector) + { + float X = vector.X >= 0 ? vector.X : 360.0f + vector.X; + float Y = vector.Y >= 0 ? vector.Y : 360.0f + vector.Y; + float Z = vector.Z >= 0 ? vector.Z : 360.0f + vector.Z; + + return new Vector3(Y, X, Z); + } + + public static float ToRadians(this float value) => (float)Math.PI * value / 180.0f; + + public static float ToDegrees(this float value) => value * 180.0f / (float)Math.PI; + + public static double[] AngleStuff(Vector3 a, Vector3 b) + { + double deltaX = 180.0 - Math.Abs(Math.Abs(a.X - b.X) - 180.0); + double deltaY = 180.0 - Math.Abs(Math.Abs(a.Y - b.Y) - 180.0); + + return new[] { deltaX, deltaY }; + } + #if DEBUG == true private static readonly TypeInfo QueryCompilerTypeInfo = typeof(QueryCompiler).GetTypeInfo(); diff --git a/WebfrontCore/wwwroot/images/compass_map_mp_rust@2x.png b/WebfrontCore/wwwroot/images/compass_map_mp_rust@2x.png new file mode 100644 index 000000000..c5f0d0713 Binary files /dev/null and b/WebfrontCore/wwwroot/images/compass_map_mp_rust@2x.png differ