From 2542b7de126c019a6cc6f51ebc76b7f762a310e1 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Wed, 17 Jul 2019 12:29:51 -0500 Subject: [PATCH] Clean up some old files --- Application/Application.csproj | 6 +- Application/ApplicationManager.cs | 2 - Plugins/Stats/Helpers/Extensions.cs | 3 +- Plugins/Stats/MinimapConfig.cs | 70 ------------------- .../Configuration/ApplicationConfiguration.cs | 12 ++-- ...uratinLinked.cs => ConfigurationLinked.cs} | 4 +- SharedLibraryCore/Database/Models/EFAlias.cs | 2 +- SharedLibraryCore/Events/Change.cs | 21 ------ SharedLibraryCore/Helpers/AsyncStatus.cs | 62 ---------------- SharedLibraryCore/Interfaces/ISerializable.cs | 60 ---------------- SharedLibraryCore/PartialEntities/EFAlias.cs | 2 +- SharedLibraryCore/RCon/StaticHelpers.cs | 2 +- SharedLibraryCore/Utilities.cs | 2 +- WebfrontCore/Views/Configuration/Index.cshtml | 4 +- _customcallbacks.gsc | 4 +- 15 files changed, 20 insertions(+), 236 deletions(-) delete mode 100644 Plugins/Stats/MinimapConfig.cs rename SharedLibraryCore/Configuration/Attributes/{ConfiguratinLinked.cs => ConfigurationLinked.cs} (70%) delete mode 100644 SharedLibraryCore/Events/Change.cs delete mode 100644 SharedLibraryCore/Helpers/AsyncStatus.cs delete mode 100644 SharedLibraryCore/Interfaces/ISerializable.cs diff --git a/Application/Application.csproj b/Application/Application.csproj index 364bd0e4d..692c71eb0 100644 --- a/Application/Application.csproj +++ b/Application/Application.csproj @@ -6,7 +6,7 @@ 2.2.2 false RaidMax.IW4MAdmin.Application - 2.2.7.7 + 2.2.8.1 RaidMax Forever None IW4MAdmin @@ -32,8 +32,8 @@ true true - 2.2.7.7 - 2.2.7.7 + 2.2.8.1 + 2.2.8.1 7.1 diff --git a/Application/ApplicationManager.cs b/Application/ApplicationManager.cs index 4566c96bc..fad4c3f14 100644 --- a/Application/ApplicationManager.cs +++ b/Application/ApplicationManager.cs @@ -45,7 +45,6 @@ namespace IW4MAdmin.Application public string ExternalIPAddress { get; private set; } public bool IsRestartRequested { get; private set; } static ApplicationManager Instance; - private readonly List _taskStatuses; List Commands; readonly List MessageTokens; ClientService ClientSvc; @@ -64,7 +63,6 @@ namespace IW4MAdmin.Application { _servers = new ConcurrentBag(); Commands = new List(); - _taskStatuses = new List(); MessageTokens = new List(); ClientSvc = new ClientService(); AliasSvc = new AliasService(); diff --git a/Plugins/Stats/Helpers/Extensions.cs b/Plugins/Stats/Helpers/Extensions.cs index 12b860d51..3f5a2339b 100644 --- a/Plugins/Stats/Helpers/Extensions.cs +++ b/Plugins/Stats/Helpers/Extensions.cs @@ -14,9 +14,8 @@ namespace IW4MAdmin.Plugins.Stats.Helpers { 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); + return new Vector3(Y, X, vector.Z); } public static float ToRadians(this float value) => (float)Math.PI * value / 180.0f; diff --git a/Plugins/Stats/MinimapConfig.cs b/Plugins/Stats/MinimapConfig.cs deleted file mode 100644 index ddb2c8805..000000000 --- a/Plugins/Stats/MinimapConfig.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using SharedLibraryCore.Helpers; -using SharedLibraryCore.Interfaces; - -namespace IW4MAdmin.Plugins.Stats -{ - public class MinimapInfo - { - public string MapName { 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; - } - - public class MinimapConfig : Serialize - { - public List MapInfo; - - public static MinimapConfig IW4Minimaps() - { - return new MinimapConfig() - { - MapInfo = new List() - { - new MinimapInfo() - { - MapName = "mp_terminal", - Top = 85, - Bottom = 89, - Left = 7, - Right = 6, - MaxTop = 2929, - MaxBottom = -513, - MaxLeft = 7520, - MaxRight = 2447 - }, - - new MinimapInfo() - { - MapName = "mp_rust", - Top = 122, - Bottom = 104, - Left = 155, - Right = 82, - MaxRight = -225, - MaxLeft = 1809, - MaxTop = 1641, - MaxBottom = -469 - } - } - }; - } - } -} diff --git a/SharedLibraryCore/Configuration/ApplicationConfiguration.cs b/SharedLibraryCore/Configuration/ApplicationConfiguration.cs index c6bd523cc..09ca66c5f 100644 --- a/SharedLibraryCore/Configuration/ApplicationConfiguration.cs +++ b/SharedLibraryCore/Configuration/ApplicationConfiguration.cs @@ -10,7 +10,7 @@ namespace SharedLibraryCore.Configuration { [LocalizedDisplayName("SETUP_ENABLE_WEBFRONT")] - [ConfiguratinLinked("WebfrontBindUrl", "ManualWebfrontUrl")] + [ConfigurationLinked("WebfrontBindUrl", "ManualWebfrontUrl")] public bool EnableWebFront { get; set; } [LocalizedDisplayName("WEBFRONT_CONFIGURATION_BIND_URL")] public string WebfrontBindUrl { get; set; } @@ -27,14 +27,14 @@ namespace SharedLibraryCore.Configuration [LocalizedDisplayName("WEBFRONT_CONFIGURATION_IGNORE_BOTS")] public bool IgnoreBots { get; set; } - [ConfiguratinLinked("CustomSayName")] + [ConfigurationLinked("CustomSayName")] [LocalizedDisplayName("SETUP_ENABLE_CUSTOMSAY")] public bool EnableCustomSayName { get; set; } [LocalizedDisplayName("SETUP_SAY_NAME")] public string CustomSayName { get; set; } [LocalizedDisplayName("SETUP_DISPLAY_SOCIAL")] - [ConfiguratinLinked("SocialLinkAddress", "SocialLinkTitle")] + [ConfigurationLinked("SocialLinkAddress", "SocialLinkTitle")] public bool EnableSocialLink { get; set; } [LocalizedDisplayName("SETUP_SOCIAL_LINK")] public string SocialLinkAddress { get; set; } @@ -42,19 +42,19 @@ namespace SharedLibraryCore.Configuration public string SocialLinkTitle { get; set; } [LocalizedDisplayName("SETUP_USE_CUSTOMENCODING")] - [ConfiguratinLinked("CustomParserEncoding")] + [ConfigurationLinked("CustomParserEncoding")] public bool EnableCustomParserEncoding { get; set; } [LocalizedDisplayName("WEBFRONT_CONFIGURATION_ENCODING")] public string CustomParserEncoding { get; set; } [LocalizedDisplayName("WEBFRONT_CONFIGURATION_ENABLE_WHITELIST")] - [ConfiguratinLinked("WebfrontConnectionWhitelist")] + [ConfigurationLinked("WebfrontConnectionWhitelist")] public bool EnableWebfrontConnectionWhitelist { get; set; } [LocalizedDisplayName("WEBFRONT_CONFIGURATION_WHITELIST_LIST")] public List WebfrontConnectionWhitelist { get; set; } [LocalizedDisplayName("WEBFRONT_CONFIGURATION_CUSTOM_LOCALE")] - [ConfiguratinLinked("CustomLocale")] + [ConfigurationLinked("CustomLocale")] public bool EnableCustomLocale { get; set; } [LocalizedDisplayName("WEBFRONT_CONFIGURATION_CUSTOM_LOCALE")] public string CustomLocale { get; set; } diff --git a/SharedLibraryCore/Configuration/Attributes/ConfiguratinLinked.cs b/SharedLibraryCore/Configuration/Attributes/ConfigurationLinked.cs similarity index 70% rename from SharedLibraryCore/Configuration/Attributes/ConfiguratinLinked.cs rename to SharedLibraryCore/Configuration/Attributes/ConfigurationLinked.cs index fb3beec7c..0c0efcd9d 100644 --- a/SharedLibraryCore/Configuration/Attributes/ConfiguratinLinked.cs +++ b/SharedLibraryCore/Configuration/Attributes/ConfigurationLinked.cs @@ -3,11 +3,11 @@ namespace SharedLibraryCore.Configuration.Attributes { [AttributeUsage(AttributeTargets.Property, Inherited = false)] - public class ConfiguratinLinked : Attribute + public class ConfigurationLinked : Attribute { public string[] LinkedPropertyNames { get; set; } - public ConfiguratinLinked(params string[] linkedPropertyNames) + public ConfigurationLinked(params string[] linkedPropertyNames) { LinkedPropertyNames = linkedPropertyNames; } diff --git a/SharedLibraryCore/Database/Models/EFAlias.cs b/SharedLibraryCore/Database/Models/EFAlias.cs index f0cce2eb6..15ca4e5a7 100644 --- a/SharedLibraryCore/Database/Models/EFAlias.cs +++ b/SharedLibraryCore/Database/Models/EFAlias.cs @@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations.Schema; namespace SharedLibraryCore.Database.Models { - public partial class EFAlias : SharedEntity + public partial class EFAlias { [Key] public int AliasId { get; set; } diff --git a/SharedLibraryCore/Events/Change.cs b/SharedLibraryCore/Events/Change.cs deleted file mode 100644 index 6e4eaea12..000000000 --- a/SharedLibraryCore/Events/Change.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SharedLibraryCore.Events -{ - /// - /// represents change from one value to another - /// - class Change - { - /// - /// represents the previous value of the item - /// - public string PreviousValue { get; set; } - /// - /// represents the new/current value of the item - /// - public string NewValue { get; set; } - } -} diff --git a/SharedLibraryCore/Helpers/AsyncStatus.cs b/SharedLibraryCore/Helpers/AsyncStatus.cs deleted file mode 100644 index c6679f636..000000000 --- a/SharedLibraryCore/Helpers/AsyncStatus.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; - -namespace SharedLibraryCore.Helpers -{ - public sealed class AsyncStatus - { - DateTime StartTime; - int TimesRun; - int UpdateFrequency; - public double RunAverage { get; private set; } - public object Dependant { get; private set; } - public Task RequestedTask { get; private set; } - public CancellationTokenSource TokenSrc { get; private set; } - - public AsyncStatus(object dependant, int frequency) - { - TokenSrc = new CancellationTokenSource(); - StartTime = DateTime.Now; - Dependant = dependant; - UpdateFrequency = frequency; - // technically 0 but it's faster than checking for division by 0 - TimesRun = 1; - } - - public CancellationToken GetToken() - { - return TokenSrc.Token; - } - - public double ElapsedMillisecondsTime() - { - return (DateTime.Now - StartTime).TotalMilliseconds; - } - - public void Update(Task T) - { - // reset the token source - TokenSrc.Dispose(); - TokenSrc = new CancellationTokenSource(); - - RequestedTask = T; - // Console.WriteLine($"Starting Task {T.Id} "); - RequestedTask.Start(); - - if (TimesRun > 25) - TimesRun = 1; - - RunAverage = RunAverage + ((DateTime.Now - StartTime).TotalMilliseconds - RunAverage - UpdateFrequency) / TimesRun; - StartTime = DateTime.Now; - } - - public void Abort() - { - RequestedTask = null; - } - } -} diff --git a/SharedLibraryCore/Interfaces/ISerializable.cs b/SharedLibraryCore/Interfaces/ISerializable.cs deleted file mode 100644 index 515bc4cab..000000000 --- a/SharedLibraryCore/Interfaces/ISerializable.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.IO; - -namespace SharedLibraryCore.Interfaces -{ - interface ISerializable - { - void Write(); - } - - public class Serialize : ISerializable - { - public static T Read(string filename) - { - try - { - string configText = File.ReadAllText(filename); - return Newtonsoft.Json.JsonConvert.DeserializeObject(configText); - } - - catch (Exception e) - { - throw new Exceptions.SerializeException($"Could not deserialize file {filename}: {e.Message}"); - } - } - - public void Write() - { - try - { - string configText = Newtonsoft.Json.JsonConvert.SerializeObject(this); - File.WriteAllText(Filename(), configText); - } - - catch (Exception e) - { - throw new Exceptions.SerializeException($"Could not serialize file {Filename()}: {e.Message}"); - } - } - - public static void Write(string filename, T data) - { - try - { - string configText = Newtonsoft.Json.JsonConvert.SerializeObject(data, Newtonsoft.Json.Formatting.Indented); - File.WriteAllText(filename, configText); - } - - catch (Exception e) - { - throw new Exceptions.SerializeException($"Could not serialize file {filename}: {e.Message}"); - } - } - - public virtual string Filename() { return ToString(); } - } -} diff --git a/SharedLibraryCore/PartialEntities/EFAlias.cs b/SharedLibraryCore/PartialEntities/EFAlias.cs index 30105e940..a7aeba982 100644 --- a/SharedLibraryCore/PartialEntities/EFAlias.cs +++ b/SharedLibraryCore/PartialEntities/EFAlias.cs @@ -1,6 +1,6 @@ namespace SharedLibraryCore.Database.Models { - public partial class EFAlias + public partial class EFAlias : SharedEntity { } diff --git a/SharedLibraryCore/RCon/StaticHelpers.cs b/SharedLibraryCore/RCon/StaticHelpers.cs index 9ee9fd714..eb1e74368 100644 --- a/SharedLibraryCore/RCon/StaticHelpers.cs +++ b/SharedLibraryCore/RCon/StaticHelpers.cs @@ -55,7 +55,7 @@ namespace SharedLibraryCore.RCon /// public static readonly int FloodProtectionInterval = 650; /// - /// how mant failed connection attempts before aborting connection + /// how many failed connection attempts before aborting connection /// public static readonly int AllowedConnectionFails = 3; } diff --git a/SharedLibraryCore/Utilities.cs b/SharedLibraryCore/Utilities.cs index 2d5b11c56..7241a0e5e 100644 --- a/SharedLibraryCore/Utilities.cs +++ b/SharedLibraryCore/Utilities.cs @@ -500,7 +500,7 @@ namespace SharedLibraryCore /// public static PenaltyType[] LinkedPenaltyTypes() { - return new PenaltyType[] + return new[] { PenaltyType.Ban, PenaltyType.Unban, diff --git a/WebfrontCore/Views/Configuration/Index.cshtml b/WebfrontCore/Views/Configuration/Index.cshtml index 7ca7a030e..f8aafa4d2 100644 --- a/WebfrontCore/Views/Configuration/Index.cshtml +++ b/WebfrontCore/Views/Configuration/Index.cshtml @@ -15,8 +15,8 @@ string[] getLinkedPropertyName(System.Reflection.PropertyInfo info) { var test = (info.GetCustomAttributes(false) - .Where(_attr => _attr.GetType() == typeof(ConfiguratinLinked)) - .FirstOrDefault() as ConfiguratinLinked); + .Where(_attr => _attr.GetType() == typeof(ConfigurationLinked)) + .FirstOrDefault() as ConfigurationLinked); return test?.LinkedPropertyNames ?? new string[0]; } diff --git a/_customcallbacks.gsc b/_customcallbacks.gsc index 3754416b1..90e3077fc 100644 --- a/_customcallbacks.gsc +++ b/_customcallbacks.gsc @@ -6,8 +6,8 @@ init() { SetDvarIfUninitialized("sv_customcallbacks", true); SetDvarIfUninitialized("sv_framewaittime", 0.05); - SetDvarIfUninitialized("sv_additionalwaittime", 0.05); - SetDvarIfUninitialized("sv_maxstoredframes", 3); + SetDvarIfUninitialized("sv_additionalwaittime", 0.1); + SetDvarIfUninitialized("sv_maxstoredframes", 4); level thread onPlayerConnect();