diff --git a/Application/Main.cs b/Application/Main.cs index f456fa7d9..a3f9839a4 100644 --- a/Application/Main.cs +++ b/Application/Main.cs @@ -58,7 +58,7 @@ namespace IW4MAdmin.Application { ServerManager = ApplicationManager.GetInstance(); var configuration = ServerManager.GetApplicationSettings().Configuration(); - Localization.Configure.Initialize(configuration?.EnableCustomLocale ?? false ? (configuration.CustomLocale ?? "windows-1252") : "windows-1252"); + Localization.Configure.Initialize(configuration?.EnableCustomLocale ?? false ? (configuration.CustomLocale ?? "en-US") : "en-US"); // do any needed housekeeping file/folder migrations ConfigurationMigration.MoveConfigFolder10518(null); diff --git a/Application/RconParsers/BaseRConParser.cs b/Application/RconParsers/BaseRConParser.cs index 8a5ac2bb6..7d9ed1ef0 100644 --- a/Application/RconParsers/BaseRConParser.cs +++ b/Application/RconParsers/BaseRConParser.cs @@ -162,6 +162,14 @@ namespace IW4MAdmin.Application.RconParsers State = EFClient.ClientState.Connecting }; +#if DEBUG + if (client.NetworkId < 1000) + { + client.IPAddress = 2147483646; + client.Ping = 0; + } +#endif + StatusPlayers.Add(client); } } diff --git a/SharedLibraryCore/PartialEntities/EFClient.cs b/SharedLibraryCore/PartialEntities/EFClient.cs index ecb0757ec..12b419ace 100644 --- a/SharedLibraryCore/PartialEntities/EFClient.cs +++ b/SharedLibraryCore/PartialEntities/EFClient.cs @@ -552,7 +552,7 @@ namespace SharedLibraryCore.Database.Models // we want to get any penalties that are tied to their IP or AliasLink (but not necessarily their GUID) var activePenalties = await CurrentServer.Manager.GetPenaltyService().GetActivePenaltiesAsync(AliasLinkId, ipAddress); - var banPenalty = ReceivedPenalties.FirstOrDefault(_penalty => _penalty.Type == EFPenalty.PenaltyType.Ban); + var banPenalty = activePenalties.FirstOrDefault(_penalty => _penalty.Type == EFPenalty.PenaltyType.Ban); var tempbanPenalty = activePenalties.FirstOrDefault(_penalty => _penalty.Type == EFPenalty.PenaltyType.TempBan); var flagPenalty = activePenalties.FirstOrDefault(_penalty => _penalty.Type == EFPenalty.PenaltyType.Flag); @@ -568,8 +568,9 @@ namespace SharedLibraryCore.Database.Models else { - CurrentServer.Logger.WriteWarning($"Client {this} is GUID banned, but no previous penalty exists for their ban"); - Ban(loc["SERVER_BAN_UNKNOWN"], autoKickClient, false); + CurrentServer.Logger.WriteDebug($"Client {this} is banned, but using a new GUID, we we're updating their level and kicking them"); + await SetLevel(Permission.Banned, autoKickClient).WaitAsync(Utilities.DefaultCommandTimeout, CurrentServer.Manager.CancellationToken); + Kick(loc["SERVER_BAN_PREV"].FormatExt(banPenalty?.Offense), autoKickClient); return false; } } @@ -585,7 +586,8 @@ namespace SharedLibraryCore.Database.Models // if we found a flag, we need to make sure all the accounts are flagged if (flagPenalty != null && Level != Permission.Flagged) { - SetLevel(Permission.Flagged, autoKickClient); + CurrentServer.Logger.WriteDebug($"Flagged client {this} joining with new GUID, so we are changing their level to flagged"); + await SetLevel(Permission.Flagged, autoKickClient).WaitAsync(Utilities.DefaultCommandTimeout, CurrentServer.Manager.CancellationToken); } // remove their auto flag diff --git a/SharedLibraryCore/Services/PenaltyService.cs b/SharedLibraryCore/Services/PenaltyService.cs index b77ee880b..c51c3b1d3 100644 --- a/SharedLibraryCore/Services/PenaltyService.cs +++ b/SharedLibraryCore/Services/PenaltyService.cs @@ -104,6 +104,8 @@ namespace SharedLibraryCore.Services /// public async Task> GetClientPenaltyForMetaAsync(int clientId, int count, int offset, DateTime? startAt) { + var linkedPenaltyType = Utilities.LinkedPenaltyTypes(); + using (var ctx = new DatabaseContext(true)) { var linkId = await ctx.Clients.AsNoTracking() @@ -112,7 +114,7 @@ namespace SharedLibraryCore.Services .FirstOrDefaultAsync(); var iqPenalties = ctx.Penalties.AsNoTracking() - .Where(_penalty => _penalty.OffenderId == clientId || _penalty.PunisherId == clientId || _penalty.LinkId == linkId) + .Where(_penalty => _penalty.OffenderId == clientId || _penalty.PunisherId == clientId || (linkedPenaltyType.Contains(_penalty.Type) && _penalty.LinkId == linkId)) .Where(_penalty => _penalty.When <= startAt) .OrderByDescending(_penalty => _penalty.When) .Skip(offset) @@ -136,8 +138,7 @@ namespace SharedLibraryCore.Services #if DEBUG == true var querySql = iqPenalties.ToSql(); #endif - - return await iqPenalties.ToListAsync(); + return await iqPenalties.Distinct().ToListAsync(); } } diff --git a/SharedLibraryCore/Utilities.cs b/SharedLibraryCore/Utilities.cs index 2e54b2a6e..2d5b11c56 100644 --- a/SharedLibraryCore/Utilities.cs +++ b/SharedLibraryCore/Utilities.cs @@ -31,7 +31,6 @@ namespace SharedLibraryCore public static Encoding EncodingType; public static Localization.Layout CurrentLocalization = new Localization.Layout(new Dictionary()); public static TimeSpan DefaultCommandTimeout = new TimeSpan(0, 0, 10); - public static CultureInfo BestCulture = CultureInfo.CreateSpecificCulture("en-US"); public static EFClient IW4MAdminClient(Server server = null) { @@ -295,6 +294,9 @@ namespace SharedLibraryCore else if (!string.IsNullOrEmpty(bot)) { id = -1; +#if DEBUG + id = str.Sum(_c => _c); +#endif } if (id == 0) @@ -492,13 +494,20 @@ namespace SharedLibraryCore return "unknown"; } - public static bool ShouldPenaltyApplyToAllProfiles(this PenaltyType penaltyType) + /// + /// returns a list of penalty types that should be shown across all profiles + /// + /// + public static PenaltyType[] LinkedPenaltyTypes() { - return penaltyType == PenaltyType.Ban || - penaltyType == PenaltyType.Unban || - penaltyType == PenaltyType.Flag || - penaltyType == PenaltyType.Unflag || - penaltyType == PenaltyType.TempBan; + return new PenaltyType[] + { + PenaltyType.Ban, + PenaltyType.Unban, + PenaltyType.TempBan, + PenaltyType.Flag, + PenaltyType.Unflag, + }; } ///