diff --git a/EOLib.Config.Test/ConfigFileLoadActionsTest.cs b/EOLib.Config.Test/ConfigFileLoadActionsTest.cs index 7f0b372eb..7452e0923 100644 --- a/EOLib.Config.Test/ConfigFileLoadActionsTest.cs +++ b/EOLib.Config.Test/ConfigFileLoadActionsTest.cs @@ -1,4 +1,5 @@ -using System.Diagnostics.CodeAnalysis; +using System; +using System.Diagnostics.CodeAnalysis; using System.IO; using NUnit.Framework; @@ -45,9 +46,6 @@ public void InvalidConfigFileThatExists_UsesConfigurationValueDefaults() Assert.That(_configurationRepository.Host, Is.EqualTo(ConfigDefaults.Host)); Assert.That(_configurationRepository.Port, Is.EqualTo(ConfigDefaults.Port)); - Assert.That(_configurationRepository.NPCDropProtectTime, Is.EqualTo(ConfigDefaults.NPCDropProtectionSeconds)); - Assert.That(_configurationRepository.PlayerDropProtectTime, Is.EqualTo(ConfigDefaults.PlayerDropProtectionSeconds)); - Assert.That(_configurationRepository.Language, Is.EqualTo(EOLanguage.English)); Assert.That(_configurationRepository.CurseFilterEnabled, Is.False); Assert.That(_configurationRepository.StrictFilterEnabled, Is.False); @@ -62,14 +60,13 @@ public void InvalidConfigFileThatExists_UsesConfigurationValueDefaults() Assert.That(_configurationRepository.HearWhispers, Is.True); Assert.That(_configurationRepository.Interaction, Is.True); Assert.That(_configurationRepository.LogChatToFile, Is.False); - Assert.That(_configurationRepository.EnableLog, Is.False); } [Test] public void ValidConfigFile_LoadsSpecifiedSettings() { const string contents = @"[CONNECTION] -Host=ewmoffat.ddns.net +Host=eoserv.moffat.io Port=12345 [VERSION] Major=10 @@ -80,13 +77,11 @@ public void ValidConfigFile_LoadsSpecifiedSettings() Sound=on ShowBaloons=off ShowShadows=no -ShowTransition=true -EnableLogging=true +[CUSTOM] InGameWidth=123 InGameHeight=321 -[CUSTOM] -NPCDropProtectTime=5000 -PlayerDropProtectTime=10000 +ShowTransition=true +AccountCreateTimeout=12345 [LANGUAGE] Language=2 [CHAT] @@ -100,33 +95,34 @@ public void ValidConfigFile_LoadsSpecifiedSettings() _configFileLoadActions.LoadConfigFile(); - Assert.That(_configurationRepository.VersionMajor, Is.EqualTo(10)); - Assert.That(_configurationRepository.VersionMinor, Is.EqualTo(20)); - Assert.That(_configurationRepository.VersionBuild, Is.EqualTo(30)); + Assert.Multiple(() => + { + Assert.That(_configurationRepository.VersionMajor, Is.EqualTo(10)); + Assert.That(_configurationRepository.VersionMinor, Is.EqualTo(20)); + Assert.That(_configurationRepository.VersionBuild, Is.EqualTo(30)); - Assert.That(_configurationRepository.Host, Is.EqualTo("ewmoffat.ddns.net")); - Assert.That(_configurationRepository.Port, Is.EqualTo(12345)); + Assert.That(_configurationRepository.Host, Is.EqualTo("eoserv.moffat.io")); + Assert.That(_configurationRepository.Port, Is.EqualTo(12345)); - Assert.That(_configurationRepository.NPCDropProtectTime, Is.EqualTo(5000)); - Assert.That(_configurationRepository.PlayerDropProtectTime, Is.EqualTo(10000)); + Assert.That(_configurationRepository.Language, Is.EqualTo(EOLanguage.Swedish)); + Assert.That(_configurationRepository.CurseFilterEnabled, Is.True); + Assert.That(_configurationRepository.StrictFilterEnabled, Is.True); - Assert.That(_configurationRepository.Language, Is.EqualTo(EOLanguage.Swedish)); - Assert.That(_configurationRepository.CurseFilterEnabled, Is.True); - Assert.That(_configurationRepository.StrictFilterEnabled, Is.True); + Assert.That(_configurationRepository.ShowShadows, Is.False); + Assert.That(_configurationRepository.ShowChatBubbles, Is.False); - Assert.That(_configurationRepository.ShowShadows, Is.False); - Assert.That(_configurationRepository.ShowChatBubbles, Is.False); - Assert.That(_configurationRepository.ShowTransition, Is.True); - Assert.That(_configurationRepository.InGameWidth, Is.EqualTo(123)); - Assert.That(_configurationRepository.InGameHeight, Is.EqualTo(321)); + Assert.That(_configurationRepository.ShowTransition, Is.True); + Assert.That(_configurationRepository.InGameWidth, Is.EqualTo(123)); + Assert.That(_configurationRepository.InGameHeight, Is.EqualTo(321)); + Assert.That(_configurationRepository.AccountCreateTimeout, Is.EqualTo(TimeSpan.FromMilliseconds(12345))); - Assert.That(_configurationRepository.MusicEnabled, Is.True); - Assert.That(_configurationRepository.SoundEnabled, Is.True); + Assert.That(_configurationRepository.MusicEnabled, Is.True); + Assert.That(_configurationRepository.SoundEnabled, Is.True); - Assert.That(_configurationRepository.HearWhispers, Is.False); - Assert.That(_configurationRepository.Interaction, Is.False); - Assert.That(_configurationRepository.LogChatToFile, Is.True); - Assert.That(_configurationRepository.EnableLog, Is.True); + Assert.That(_configurationRepository.HearWhispers, Is.False); + Assert.That(_configurationRepository.Interaction, Is.False); + Assert.That(_configurationRepository.LogChatToFile, Is.True); + }); } private static void CreateTestConfigurationInDirectory(string contents) diff --git a/EOLib.Config/ConfigDefaults.cs b/EOLib.Config/ConfigDefaults.cs index e2ebf8795..b1911f09e 100644 --- a/EOLib.Config/ConfigDefaults.cs +++ b/EOLib.Config/ConfigDefaults.cs @@ -9,9 +9,6 @@ public static class ConfigDefaults public const string Host = "127.0.0.1"; public const int Port = 8078; - public const int NPCDropProtectionSeconds = 30; - public const int PlayerDropProtectionSeconds = 5; - public const int AccountCreateTimeout = 2000; } } diff --git a/EOLib.Config/ConfigFileLoadActions.cs b/EOLib.Config/ConfigFileLoadActions.cs index 606a7d0be..6643f4911 100644 --- a/EOLib.Config/ConfigFileLoadActions.cs +++ b/EOLib.Config/ConfigFileLoadActions.cs @@ -36,42 +36,28 @@ public void LoadConfigFile() ? (EOLanguage)tempInt : EOLanguage.English; - _configRepository.PlayerDropProtectTime = configFile.GetValue(ConfigStrings.Custom, - ConfigStrings.PlayerDropProtectTime, out tempInt) - ? tempInt - : ConfigDefaults.PlayerDropProtectionSeconds; - - _configRepository.NPCDropProtectTime = configFile.GetValue(ConfigStrings.Custom, ConfigStrings.NPCDropProtectTime, - out tempInt) - ? tempInt - : ConfigDefaults.NPCDropProtectionSeconds; - bool tempBool; _configRepository.CurseFilterEnabled = configFile.GetValue(ConfigStrings.Chat, ConfigStrings.Filter, out tempBool) && tempBool; _configRepository.StrictFilterEnabled = configFile.GetValue(ConfigStrings.Chat, ConfigStrings.FilterAll, out tempBool) && tempBool; _configRepository.ShowShadows = !configFile.GetValue(ConfigStrings.Settings, ConfigStrings.ShowShadows, out tempBool) || tempBool; - _configRepository.ShowTransition = configFile.GetValue(ConfigStrings.Settings, ConfigStrings.ShowTransition, out tempBool) && tempBool; _configRepository.MusicEnabled = configFile.GetValue(ConfigStrings.Settings, ConfigStrings.Music, out tempBool) && tempBool; _configRepository.SoundEnabled = configFile.GetValue(ConfigStrings.Settings, ConfigStrings.Sound, out tempBool) && tempBool; _configRepository.ShowChatBubbles = !configFile.GetValue(ConfigStrings.Settings, ConfigStrings.ShowBaloons, out tempBool) || tempBool; - _configRepository.EnableLog = configFile.GetValue(ConfigStrings.Settings, ConfigStrings.EnableLogging, out tempBool) && tempBool; _configRepository.HearWhispers = !configFile.GetValue(ConfigStrings.Chat, ConfigStrings.HearWhisper, out tempBool) || tempBool; _configRepository.Interaction = !configFile.GetValue(ConfigStrings.Chat, ConfigStrings.Interaction, out tempBool) || tempBool; _configRepository.LogChatToFile = configFile.GetValue(ConfigStrings.Chat, ConfigStrings.LogChat, out tempBool) && tempBool; - _configRepository.AccountCreateTimeout = TimeSpan.FromMilliseconds( - configFile.GetValue(ConfigStrings.Custom, ConfigStrings.AccountCreateTimeout, out tempInt) - ? tempInt - : ConfigDefaults.AccountCreateTimeout); + var timeoutValue = configFile.GetValue(ConfigStrings.Custom, ConfigStrings.AccountCreateTimeout, out tempInt) ? tempInt : ConfigDefaults.AccountCreateTimeout; + _configRepository.AccountCreateTimeout = TimeSpan.FromMilliseconds(timeoutValue); + _configRepository.ShowTransition = configFile.GetValue(ConfigStrings.Custom, ConfigStrings.ShowTransition, out tempBool) && tempBool; + _configRepository.InGameWidth = configFile.GetValue(ConfigStrings.Custom, ConfigStrings.InGameWidth, out tempInt) ? tempInt : 0; + _configRepository.InGameHeight = configFile.GetValue(ConfigStrings.Custom, ConfigStrings.InGameHeight, out tempInt) ? tempInt : 0; string host; _configRepository.Host = configFile.GetValue(ConfigStrings.Connection, ConfigStrings.Host, out host) ? host : ConfigDefaults.Host; _configRepository.Port = configFile.GetValue(ConfigStrings.Connection, ConfigStrings.Port, out tempInt) ? tempInt : ConfigDefaults.Port; - - _configRepository.InGameWidth = configFile.GetValue(ConfigStrings.Settings, ConfigStrings.InGameWidth, out tempInt) ? tempInt : 0; - _configRepository.InGameHeight = configFile.GetValue(ConfigStrings.Settings, ConfigStrings.InGameHeight, out tempInt) ? tempInt : 0; } } } diff --git a/EOLib.Config/ConfigStrings.cs b/EOLib.Config/ConfigStrings.cs index be4909c75..94b82bcb4 100644 --- a/EOLib.Config/ConfigStrings.cs +++ b/EOLib.Config/ConfigStrings.cs @@ -19,7 +19,6 @@ public static class ConfigStrings public const string Settings = "SETTINGS"; public const string ShowShadows = "ShowShadows"; public const string ShowTransition = "ShowTransition"; - public const string EnableLogging = "EnableLogging"; public const string Music = "Music"; public const string Sound = "Sound"; public const string ShowBaloons = "ShowBaloons"; @@ -28,9 +27,6 @@ public static class ConfigStrings public static string InGameHeight = nameof(InGameHeight); public const string Custom = "CUSTOM"; - public const string NPCDropProtectTime = "NPCDropProtectTime"; - public const string PlayerDropProtectTime = "PlayerDropProtectTime"; - public const string MainCloneCompat = nameof(MainCloneCompat); public const string AccountCreateTimeout = nameof(AccountCreateTimeout); public const string LANGUAGE = "LANGUAGE"; diff --git a/EOLib.Config/IConfigurationRepository.cs b/EOLib.Config/IConfigurationRepository.cs index 919c1c5cb..3ed752478 100644 --- a/EOLib.Config/IConfigurationRepository.cs +++ b/EOLib.Config/IConfigurationRepository.cs @@ -20,8 +20,6 @@ public interface IConfigurationRepository bool ShowShadows { get; set; } bool ShowChatBubbles { get; set; } bool ShowTransition { get; set; } - int PlayerDropProtectTime { get; set; } - int NPCDropProtectTime { get; set; } bool MusicEnabled { get; set; } bool SoundEnabled { get; set; } @@ -32,12 +30,8 @@ public interface IConfigurationRepository TimeSpan AccountCreateTimeout { get; set; } - bool EnableLog { get; set; } - int InGameWidth { get; set; } int InGameHeight { get; set; } - - bool DebugCrashes { get; set; } } public interface IConfigurationProvider @@ -57,8 +51,6 @@ public interface IConfigurationProvider bool ShowShadows { get; } bool ShowChatBubbles { get; } bool ShowTransition { get; } - int PlayerDropProtectTime { get; } - int NPCDropProtectTime { get; } bool MusicEnabled { get; } bool SoundEnabled { get; } @@ -69,12 +61,8 @@ public interface IConfigurationProvider TimeSpan AccountCreateTimeout { get; } - bool EnableLog { get; } - int InGameWidth { get; } int InGameHeight { get; } - - bool DebugCrashes { get; } } [AutoMappedType(IsSingleton = true)] @@ -95,8 +83,6 @@ public class ConfigurationRepository : IConfigurationRepository, IConfigurationP public bool ShowShadows { get; set; } public bool ShowChatBubbles { get; set; } public bool ShowTransition { get; set; } - public int PlayerDropProtectTime { get; set; } - public int NPCDropProtectTime { get; set; } public bool MusicEnabled { get; set; } public bool SoundEnabled { get; set; } @@ -107,11 +93,7 @@ public class ConfigurationRepository : IConfigurationRepository, IConfigurationP public TimeSpan AccountCreateTimeout { get; set; } - public bool EnableLog { get; set; } - public int InGameWidth { get; set; } public int InGameHeight { get; set; } - - public bool DebugCrashes { get; set; } } } diff --git a/EOLib.Logger/DebugOnlyLogger.cs b/EOLib.Logger/DebugOnlyLogger.cs deleted file mode 100644 index c232609b8..000000000 --- a/EOLib.Logger/DebugOnlyLogger.cs +++ /dev/null @@ -1,123 +0,0 @@ -using System; -using System.Diagnostics; -using System.IO; -using System.Threading; -using EOLib.Config; - -namespace EOLib.Logger -{ - public class DebugOnlyLogger : ILogger - { - private readonly object _fileStreamLock = new object(); - - private readonly Timer _logTimer; - private readonly bool _enabled; - - private StreamWriter _fileStream; - private int _writesSinceLastFlush; - - public DebugOnlyLogger() { } - - internal DebugOnlyLogger(IConfigurationProvider configurationProvider) - { - if (!configurationProvider.EnableLog) - return; - - _enabled = true; - - Directory.CreateDirectory(Constants.LOG_DIRECTORY); - _fileStream = new StreamWriter(Constants.LOG_FILE_PATH, true); - - _logTimer = new Timer(FlushLogToNewFileIfNeeded, - null, - Constants.FLUSH_TIME_MS, - Constants.FLUSH_TIME_MS); - - WriteFileOpenedHeader(); - } - - public void Log(string format, params object[] parameters) - { - if (!_enabled) return; - - var threadID = Thread.CurrentThread.ManagedThreadId; - var processID = Process.GetCurrentProcess().Id; - var front = $"{processID,-5} {threadID,5} {GetDateTimeString(),-25} {format}"; - - WriteToFile(string.Format(front, parameters)); - } - - private void FlushLogToNewFileIfNeeded(object state) - { - if (!_enabled || _writesSinceLastFlush <= 0) - return; - - lock (_fileStreamLock) - { - _writesSinceLastFlush = 0; - _fileStream.Close(); - - //check if the file should be split (based on length) - var append = true; - var fi = new FileInfo(Constants.LOG_FILE_PATH); - if (fi.Length > Constants.SPLIT_FILE_BYTE_LENGTH) - { - append = false; - var fileName = string.Format(Constants.LOG_FILE_FMT, DateTime.Now.ToString("MM-dd-yyyy-HH-mm-ss")); - File.Copy(Constants.LOG_FILE_PATH, fileName); - } - - _fileStream = new StreamWriter(Constants.LOG_FILE_PATH, append); - } - } - - private void WriteFileOpenedHeader() - { - _fileStream.WriteLine("------------------------------------------------------------------"); - _fileStream.WriteLine("Log opened at {0}", GetDateTimeString()); - _fileStream.WriteLine("Process ID - Managed Thread ID - DateTime - Info"); - _fileStream.WriteLine("------------------------------------------------------------------"); - } - - private string GetDateTimeString() - { - return DateTime.Now.ToString("MM-dd-yyyy HH:mm:ss:fff"); - } - - private void WriteToFile(string logStr) - { - lock (_fileStreamLock) - { - _fileStream.WriteLine(logStr); - _writesSinceLastFlush++; - - if (_writesSinceLastFlush > Constants.FLUSH_LINES_WRITTEN) - { - _fileStream.Close(); - _fileStream = new StreamWriter(Constants.LOG_FILE_PATH, true); - _writesSinceLastFlush = 0; - } - } - } - - ~DebugOnlyLogger() - { - Dispose(false); - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (disposing && _enabled) - { - _logTimer.Dispose(); - _fileStream.Dispose(); - } - } - } -} diff --git a/EOLib.Logger/LoggerProvider.cs b/EOLib.Logger/LoggerProvider.cs deleted file mode 100644 index e72fe5e4c..000000000 --- a/EOLib.Logger/LoggerProvider.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using AutomaticTypeMapper; - -namespace EOLib.Logger -{ - [MappedType(BaseType = typeof(ILoggerProvider), IsSingleton = true)] - public class LoggerProvider : ILoggerProvider - { - public ILogger Logger { get; } - - public LoggerProvider(ILoggerFactory loggerFactory) - { - Logger = CreateLogger(loggerFactory); - } - - private static ILogger CreateLogger(ILoggerFactory loggerFactory) - { -#if DEBUG - return loggerFactory.CreateLogger(); -#else - return loggerFactory.CreateLogger(); -#endif - } - - public void Dispose() - { - Logger.Dispose(); - } - } - - public interface ILoggerProvider : IDisposable - { - ILogger Logger { get; } - } -} diff --git a/EOLib/Domain/Item/ItemPickupValidator.cs b/EOLib/Domain/Item/ItemPickupValidator.cs index 5ce014970..edb6143f5 100644 --- a/EOLib/Domain/Item/ItemPickupValidator.cs +++ b/EOLib/Domain/Item/ItemPickupValidator.cs @@ -37,8 +37,8 @@ public ItemPickupResult ValidateItemPickup(Character.Character mainCharacter, Ma item.DropTime.Match( some: dropTime => { - if (item.IsNPCDrop && (now - dropTime).TotalSeconds <= _configurationProvider.NPCDropProtectTime || - !item.IsNPCDrop && (now - dropTime).TotalSeconds <= _configurationProvider.PlayerDropProtectTime) + if (item.IsNPCDrop && (now - dropTime).TotalSeconds <= Constants.NPCDropProtectSeconds || + !item.IsNPCDrop && (now - dropTime).TotalSeconds <= Constants.PlayerDropProtectSeconds) return ItemPickupResult.DropProtection; return ItemPickupResult.Ok; diff --git a/EOLib/Net/PacketProcessing/PacketProcessActions.cs b/EOLib/Net/PacketProcessing/PacketProcessActions.cs index 585c223a1..a2d16791c 100644 --- a/EOLib/Net/PacketProcessing/PacketProcessActions.cs +++ b/EOLib/Net/PacketProcessing/PacketProcessActions.cs @@ -13,20 +13,17 @@ namespace EOLib.Net.PacketProcessing public class PacketProcessActions : IPacketProcessActions { private readonly IPacketEncoderService _encoderService; - private readonly ILoggerProvider _loggerProvider; private readonly IPacketEncoderRepository _encoderRepository; private readonly ISequenceRepository _sequenceRepository; public PacketProcessActions(ISequenceRepository sequenceNumberRepository, IPacketEncoderRepository encoderRepository, - IPacketEncoderService encoderService, - ILoggerProvider loggerProvider) + IPacketEncoderService encoderService) { _sequenceRepository = sequenceNumberRepository; _encoderRepository = encoderRepository; _encoderService = encoderService; - _loggerProvider = loggerProvider; } public void SetSequenceStart(ISequenceStart sequenceStart) @@ -42,9 +39,6 @@ public void SetEncodeMultiples(int emulti_d, int emulti_e) { _encoderRepository.ReceiveMultiplier = emulti_d; _encoderRepository.SendMultiplier = emulti_e; - - _loggerProvider.Logger.Log("**** PACKET ENCODING MULTIPLES FOR THIS SESSION ARE: RECV={0} SEND={1}", - _encoderRepository.ReceiveMultiplier, _encoderRepository.SendMultiplier); } public byte[] EncodePacket(IPacket pkt) diff --git a/EOLib/misc.cs b/EOLib/misc.cs index 8f975832d..f72a59ea1 100644 --- a/EOLib/misc.cs +++ b/EOLib/misc.cs @@ -36,6 +36,10 @@ public static class Constants //not a config option because this shouldn't be exposed at the user level public static readonly int[] TrapSpikeGFXObjectIDs = { 449, 450, 451, 452 }; + //not a config option because this shouldn't be exposed at the user level + public const int NPCDropProtectSeconds = 30; + public const int PlayerDropProtectSeconds = 5; + // Weapon graphics of instruments (there is no pub flag for this) public static readonly int[] Instruments = { 49, 50 }; public const string FontSize07 = @"BitmapFonts/sans_09px"; diff --git a/EndlessClient/EndlessClient.csproj b/EndlessClient/EndlessClient.csproj index 720eab2a7..0c23e55f8 100644 --- a/EndlessClient/EndlessClient.csproj +++ b/EndlessClient/EndlessClient.csproj @@ -80,7 +80,7 @@ - + diff --git a/EndlessClient/GameExecution/DebugGameRunner.cs b/EndlessClient/GameExecution/DebugGameRunner.cs index 6c71c75c3..922665e93 100644 --- a/EndlessClient/GameExecution/DebugGameRunner.cs +++ b/EndlessClient/GameExecution/DebugGameRunner.cs @@ -1,5 +1,4 @@ using AutomaticTypeMapper; -using EOLib.Config; namespace EndlessClient.GameExecution { @@ -10,12 +9,5 @@ public class DebugGameRunner : GameRunnerBase { public DebugGameRunner(ITypeRegistry registry, string[] args) : base(registry, args) { } - - public override bool SetupDependencies() - { - var result = base.SetupDependencies(); - _registry.Resolve().DebugCrashes = true; - return result; - } } } diff --git a/EndlessClient/GameExecution/EndlessGame.cs b/EndlessClient/GameExecution/EndlessGame.cs index 3daf93f0f..bcf9ee47a 100644 --- a/EndlessClient/GameExecution/EndlessGame.cs +++ b/EndlessClient/GameExecution/EndlessGame.cs @@ -1,10 +1,12 @@ using System; +using System.Collections.Generic; using System.IO; using AutomaticTypeMapper; using EndlessClient.Audio; using EndlessClient.Content; using EndlessClient.Controllers; using EndlessClient.ControlSets; +using EndlessClient.Dialogs.Factories; using EndlessClient.Rendering; using EndlessClient.Rendering.Chat; using EndlessClient.Test; @@ -12,13 +14,12 @@ using EOLib; using EOLib.Config; using EOLib.Graphics; -using EOLib.IO; using EOLib.IO.Actions; -using EOLib.Logger; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; -using EndlessClient.Dialogs.Factories; + + #if DEBUG using System.Diagnostics; @@ -39,7 +40,6 @@ public class EndlessGame : Game, IEndlessGame private readonly IControlSetFactory _controlSetFactory; private readonly ITestModeLauncher _testModeLauncher; private readonly IPubFileLoadActions _pubFileLoadActions; - private readonly ILoggerProvider _loggerProvider; private readonly IChatBubbleTextureProvider _chatBubbleTextureProvider; private readonly IConfigurationProvider _configurationProvider; private readonly IMfxPlayer _mfxPlayer; @@ -68,7 +68,6 @@ public EndlessGame(IClientWindowSizeRepository windowSizeRepository, IControlSetFactory controlSetFactory, ITestModeLauncher testModeLauncher, IPubFileLoadActions pubFileLoadActions, - ILoggerProvider loggerProvider, IChatBubbleTextureProvider chatBubbleTextureProvider, IConfigurationProvider configurationProvider, IMfxPlayer mfxPlayer, @@ -85,7 +84,6 @@ public EndlessGame(IClientWindowSizeRepository windowSizeRepository, _controlSetFactory = controlSetFactory; _testModeLauncher = testModeLauncher; _pubFileLoadActions = pubFileLoadActions; - _loggerProvider = loggerProvider; _chatBubbleTextureProvider = chatBubbleTextureProvider; _configurationProvider = configurationProvider; _mfxPlayer = mfxPlayer; @@ -201,18 +199,18 @@ protected override void Update(GameTime gameTime) { base.Update(gameTime); } +#if DEBUG + catch + { + throw; + } +#else catch (Exception ex) { - if (_configurationProvider.DebugCrashes) - { - throw; - } - else - { - _mainButtonController.GoToInitialStateAndDisconnect(showLostConnection: false); - ShowExceptionDetailDialog(ex); - } + _mainButtonController.GoToInitialStateAndDisconnect(showLostConnection: false); + ShowExceptionDetailDialog(ex); } +#endif _lastFrameUpdate = gameTime.TotalGameTime; } @@ -246,42 +244,22 @@ protected override void Draw(GameTime gameTime) private void AttemptToLoadPubFiles() { - const string PUB_LOG_MSG = "**** Unable to load default PUB file: {0}. Exception message: {1}"; - - try - { - _pubFileLoadActions.LoadItemFile(); - } - catch (Exception ex) when (ex is IOException || ex is ArgumentException) - { - _loggerProvider.Logger.Log(PUB_LOG_MSG, string.Format(PubFileNameConstants.EIFFormat, 1), ex.Message); - } - - try - { - _pubFileLoadActions.LoadNPCFile(); - } - catch (Exception ex) when (ex is IOException || ex is ArgumentException) + List pubFileLoadActions = [ + _pubFileLoadActions.LoadItemFile, + _pubFileLoadActions.LoadNPCFile, + _pubFileLoadActions.LoadSpellFile, + _pubFileLoadActions.LoadClassFile + ]; + + foreach (var action in pubFileLoadActions) { - _loggerProvider.Logger.Log(PUB_LOG_MSG, string.Format(PubFileNameConstants.ENFFormat, 1), ex.Message); - } - - try - { - _pubFileLoadActions.LoadSpellFile(); - } - catch (Exception ex) when (ex is IOException || ex is ArgumentException) - { - _loggerProvider.Logger.Log(PUB_LOG_MSG, string.Format(PubFileNameConstants.ESFFormat, 1), ex.Message); - } - - try - { - _pubFileLoadActions.LoadClassFile(); - } - catch (Exception ex) when (ex is IOException || ex is ArgumentException) - { - _loggerProvider.Logger.Log(PUB_LOG_MSG, string.Format(PubFileNameConstants.ECFFormat, 1), ex.Message); + try + { + action(); + } + catch (Exception ex) when (ex is IOException || ex is ArgumentException) + { + } } } diff --git a/EndlessClient/GameExecution/GameRunnerBase.cs b/EndlessClient/GameExecution/GameRunnerBase.cs index 879c5eec2..8f0ed719c 100644 --- a/EndlessClient/GameExecution/GameRunnerBase.cs +++ b/EndlessClient/GameExecution/GameRunnerBase.cs @@ -116,10 +116,6 @@ public virtual bool SetupDependencies() i++; } - else if (string.Equals(arg, "--debug")) - { - _registry.Resolve().DebugCrashes = true; - } else { Debug.WriteLine($"Unrecognized argument: {arg}. Will be ignored.");