From 3b518c1eb84f0be2cb3828c16fa8a21a6c2e43ec Mon Sep 17 00:00:00 2001 From: Lucca Faria Ferri Date: Fri, 27 Jan 2023 08:58:19 -0800 Subject: [PATCH] Breakdown chart of SNO dictionaries, AnsiTarget.cs update, changed MPQPatchChain.cs logger name, prevent multiple ansi outputs --- src/DiIiS-NA/Core/Logging/AnsiTarget.cs | 3 +- src/DiIiS-NA/Core/Logging/LogConfig.cs | 4 +-- src/DiIiS-NA/Core/MPQ/Data.cs | 38 +++++++++++++++++++++++++ src/DiIiS-NA/Core/MPQ/MPQPatchChain.cs | 2 +- src/DiIiS-NA/Program.cs | 12 ++++---- 5 files changed, 48 insertions(+), 11 deletions(-) diff --git a/src/DiIiS-NA/Core/Logging/AnsiTarget.cs b/src/DiIiS-NA/Core/Logging/AnsiTarget.cs index 63edd80..d3d127f 100644 --- a/src/DiIiS-NA/Core/Logging/AnsiTarget.cs +++ b/src/DiIiS-NA/Core/Logging/AnsiTarget.cs @@ -63,7 +63,8 @@ public class AnsiTarget : LogTarget return text .Replace("Blizzless", "[dodgerblue1]Blizz[/][deepskyblue2]less[/]") .Replace("Diablo III", "[red3_1]Diablo[/] [red]III[/]") - .Replace("MPQ", "[underline yellow4]MPQ[/]"); + .Replace("MPQ", "[underline yellow4]MPQ[/]") + .Replace("Discord", "[blue]Discord[/]"); } diff --git a/src/DiIiS-NA/Core/Logging/LogConfig.cs b/src/DiIiS-NA/Core/Logging/LogConfig.cs index 08cc892..51c2345 100644 --- a/src/DiIiS-NA/Core/Logging/LogConfig.cs +++ b/src/DiIiS-NA/Core/Logging/LogConfig.cs @@ -12,11 +12,11 @@ namespace DiIiS_NA.Core.Logging public LogTargetConfig[] Targets = new[] { new LogTargetConfig("ConsoleLog"), - new LogTargetConfig("AnsiLog") + new LogTargetConfig("AnsiLog"), //new LogTargetConfig("ServerLog"), //new LogTargetConfig("ChatLog"), //new LogTargetConfig("RenameAccountLog"), - //new LogTargetConfig("PacketLog") + new LogTargetConfig("PacketLog") }; private LogConfig() : diff --git a/src/DiIiS-NA/Core/MPQ/Data.cs b/src/DiIiS-NA/Core/MPQ/Data.cs index 173b7d3..28e40e1 100644 --- a/src/DiIiS-NA/Core/MPQ/Data.cs +++ b/src/DiIiS-NA/Core/MPQ/Data.cs @@ -24,6 +24,7 @@ using System.Reflection; using System.Text; //Blizzless Project 2022 using System.Threading.Tasks; +using Spectre.Console; namespace DiIiS_NA.Core.MPQ { @@ -198,6 +199,43 @@ using (StreamWriter sw = new StreamWriter(writePath, false, System.Text.Encoding this.LoadSNODict(DictSNOWeathers, SNOGroup.Weather); this.LoadSNODict(DictSNOWorlds, SNOGroup.Worlds); + #if DEBUG + Console.WriteLine(); + AnsiConsole.Write(new BreakdownChart() + .FullSize() + .AddItem("Accolade", DictSNOAccolade.Count, Color.Gold1) + .AddItem("Act", DictSNOAct.Count, Color.Green) + .AddItem("Actor", DictSNOActor.Count, Color.Blue) + .AddItem("Adventure", DictSNOAdventure.Count, Color.Orange4_1) + .AddItem("Ambient Sound", DictSNOAmbientSound.Count, Color.OrangeRed1) + .AddItem("Animations", DictSNOAnim.Count, Color.Orchid) + .AddItem("Animation 2D", DictSNOAnimation2D.Count, Color.BlueViolet) + .AddItem("Animation Set", DictSNOAnimSet.Count, Color.Blue3) + .AddItem("Boss Encounter", DictSNOBossEncounter.Count, Color.Aquamarine1) + .AddItem("Conversation", DictSNOConversation.Count, Color.Aquamarine1_1) + .AddItem("Effect Group", DictSNOEffectGroup.Count, Color.Yellow) + .AddItem("Encounter", DictSNOEncounter.Count, Color.Green3_1) + .AddItem("Game Balance", DictSNOGameBalance.Count, Color.GreenYellow) + .AddItem("Level Area", DictSNOLevelArea.Count, Color.Grey62) + .AddItem("Lore", DictSNOLore.Count, Color.Plum4) + .AddItem("Marker Set", DictSNOMarkerSet.Count, Color.Salmon1) + .AddItem("Monster", DictSNOMonster.Count, Color.Red) + .AddItem("Music", DictSNOMusic.Count, Color.Olive) + .AddItem("Observer", DictSNOObserver.Count, Color.Violet) + .AddItem("Phys Mesh", DictSNOPhysMesh.Count, Color.CornflowerBlue) + .AddItem("Power", DictSNOPower.Count, Color.LightPink1) + .AddItem("Quest", DictSNOQuest.Count, Color.LightGreen) + .AddItem("Quest Range", DictSNOQuestRange.Count, Color.LightGreen_1) + .AddItem("Recipe", DictSNORecipe.Count, Color.Yellow2) + .AddItem("Ropes", DictSNORopes.Count, Color.Yellow1) + .AddItem("Scene", DictSNOScene.Count, Color.DarkOrange3) + .AddItem("Skill Kit", DictSNOSkillKit.Count, Color.DeepPink4_1) + .AddItem("Tutorial", DictSNOTutorial.Count, Color.NavajoWhite3) + .AddItem("Weather", DictSNOWeathers.Count, Color.Navy) + .AddItem("Worlds", DictSNOWorlds.Count, Color.SlateBlue3_1) + ); + Console.WriteLine(); + #endif this.LoadDBCatalog(); } diff --git a/src/DiIiS-NA/Core/MPQ/MPQPatchChain.cs b/src/DiIiS-NA/Core/MPQ/MPQPatchChain.cs index 4d5ef05..368647b 100644 --- a/src/DiIiS-NA/Core/MPQ/MPQPatchChain.cs +++ b/src/DiIiS-NA/Core/MPQ/MPQPatchChain.cs @@ -19,7 +19,7 @@ namespace DiIiS_NA.Core.MPQ { public class MPQPatchChain { - protected static readonly Logger Logger = LogManager.CreateLogger("FS"); + protected static readonly Logger Logger = LogManager.CreateLogger("MPQPatchChain"); public bool Loaded { get; private set; } public List BaseMPQFiles = new List(); diff --git a/src/DiIiS-NA/Program.cs b/src/DiIiS-NA/Program.cs index 8d387d2..7d6cf63 100644 --- a/src/DiIiS-NA/Program.cs +++ b/src/DiIiS-NA/Program.cs @@ -162,10 +162,8 @@ namespace DiIiS_NA } } }); - AchievementManager.Initialize(); Core.Storage.AccountDataBase.SessionProvider.RebuildSchema(); - string GeneratePassword(int size) => new string(Enumerable.Repeat("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", size) .Select(s => s[new Random().Next(s.Length)]).ToArray()); void LogAccountCreated(string username, string password) @@ -333,15 +331,15 @@ namespace DiIiS_NA Logger.ErrorException(ex, "A root error of the server was detected but was handled."); } - static bool IsTargetEnabled(string target) => LogConfig.Instance.Targets.Any(t => t.Target.ToLower() == target && t.Enabled); + static int TargetsEnabled(string target) => LogConfig.Instance.Targets.Count(t => t.Target.ToLower() == target && t.Enabled); + static bool IsTargetEnabled(string target) => TargetsEnabled(target) > 0; private static void InitLoggers() { LogManager.Enabled = true; - - - if (IsTargetEnabled("ansi") && IsTargetEnabled("console")) + + if (TargetsEnabled("ansi") > 1 || (IsTargetEnabled("console") && IsTargetEnabled("ansi"))) { - AnsiConsole.MarkupLine("[underline red on white]Fatal:[/] [red]You can't use both ansi and console targets at the same time.[/]"); + AnsiConsole.MarkupLine("[underline red on white]Fatal:[/] [red]You can't use both ansi and console targets at the same time, nor have more than one ansi target.[/]"); AnsiConsole.Progress().Start(ctx => { var sd = ctx.AddTask("[red3_1]Shutting down[/]");