fix concurrency issue with accent color setup

This commit is contained in:
RaidMax 2021-11-24 09:49:44 -06:00
parent 4a89744ee9
commit 17c9944eef
2 changed files with 12 additions and 9 deletions

View File

@ -27,6 +27,7 @@ using IW4MAdmin.Application.Migration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Serilog.Context;
using SharedLibraryCore.Formatting;
using static SharedLibraryCore.GameEvent;
using ILogger = Microsoft.Extensions.Logging.ILogger;
using ObsoleteLogger = SharedLibraryCore.Interfaces.ILogger;
@ -455,6 +456,17 @@ namespace IW4MAdmin.Application
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Utilities.EncodingType = Encoding.GetEncoding(!string.IsNullOrEmpty(_appConfig.CustomParserEncoding) ? _appConfig.CustomParserEncoding : "windows-1252");
foreach (var parser in AdditionalRConParsers)
{
if (!parser.Configuration.ColorCodeMapping.ContainsKey(ColorCodes.Accent.ToString()))
{
parser.Configuration.ColorCodeMapping.Add(ColorCodes.Accent.ToString(),
parser.Configuration.ColorCodeMapping.TryGetValue(_appConfig.IngameAccentColorKey, out var colorCode)
? colorCode
: "");
}
}
#endregion
#region COMMANDS

View File

@ -1111,15 +1111,6 @@ namespace IW4MAdmin
Version = RconParser.Version;
}
if (!RconParser.Configuration.ColorCodeMapping.ContainsKey(ColorCodes.Accent.ToString()))
{
var accentKey = Manager.GetApplicationSettings().Configuration().IngameAccentColorKey;
RconParser.Configuration.ColorCodeMapping.Add(ColorCodes.Accent.ToString(),
RconParser.Configuration.ColorCodeMapping.TryGetValue(accentKey, out var colorCode)
? colorCode
: "");
}
var svRunning = await this.GetMappedDvarValueOrDefaultAsync<string>("sv_running");
if (!string.IsNullOrEmpty(svRunning.Value) && svRunning.Value != "1")