diff --git a/EOLib.Config/ConfigFileLoadActions.cs b/EOLib.Config/ConfigFileLoadActions.cs index 151256d36..dafaed210 100644 --- a/EOLib.Config/ConfigFileLoadActions.cs +++ b/EOLib.Config/ConfigFileLoadActions.cs @@ -60,6 +60,8 @@ public void LoadConfigFile() _configRepository.Interaction = !configFile.GetValue(ConfigStrings.Chat, ConfigStrings.Interaction, out tempBool) || tempBool; _configRepository.LogChatToFile = configFile.GetValue(ConfigStrings.Chat, ConfigStrings.LogChat, out tempBool) && tempBool; + _configRepository.MainCloneCompat = configFile.GetValue(ConfigStrings.Custom, ConfigStrings.MainCloneCompat, out tempBool) && tempBool; + 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; diff --git a/EOLib.Config/ConfigStrings.cs b/EOLib.Config/ConfigStrings.cs index e0ac31397..58f551657 100644 --- a/EOLib.Config/ConfigStrings.cs +++ b/EOLib.Config/ConfigStrings.cs @@ -27,6 +27,7 @@ public static class ConfigStrings public const string Custom = "CUSTOM"; public const string NPCDropProtectTime = "NPCDropProtectTime"; public const string PlayerDropProtectTime = "PlayerDropProtectTime"; + public const string MainCloneCompat = nameof(MainCloneCompat); public const string LANGUAGE = "LANGUAGE"; public const string Language = "Language"; diff --git a/EOLib.Config/IConfigurationRepository.cs b/EOLib.Config/IConfigurationRepository.cs index 6b8ed5085..0d4775ee3 100644 --- a/EOLib.Config/IConfigurationRepository.cs +++ b/EOLib.Config/IConfigurationRepository.cs @@ -29,6 +29,8 @@ public interface IConfigurationRepository bool Interaction { get; set; } bool LogChatToFile { get; set; } + bool MainCloneCompat { get; set; } + bool EnableLog { get; set; } } @@ -59,6 +61,8 @@ public interface IConfigurationProvider bool Interaction { get; } bool LogChatToFile { get; } + bool MainCloneCompat { get; } + bool EnableLog { get; } } @@ -91,6 +95,8 @@ public class ConfigurationRepository : IConfigurationRepository, IConfigurationP public bool Interaction { get; set; } public bool LogChatToFile { get; set; } + public bool MainCloneCompat { get; set; } + public bool EnableLog { get; set; } } } diff --git a/EOLib.Graphics.Test/NativeGraphicsLoaderTest.cs b/EOLib.Graphics.Test/NativeGraphicsLoaderTest.cs index 74f87a46a..4bba0be2a 100644 --- a/EOLib.Graphics.Test/NativeGraphicsLoaderTest.cs +++ b/EOLib.Graphics.Test/NativeGraphicsLoaderTest.cs @@ -6,6 +6,7 @@ using SixLabors.ImageSharp; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Formats.Bmp; +using EOLib.Config; namespace EOLib.Graphics.Test { @@ -15,12 +16,14 @@ public class NativeGraphicsLoaderTest private IPEFileCollection _modules; private INativeGraphicsLoader _nativeGraphicsLoader; + private const int ExpectedCulture = 0; + private const BitmapVersion ExpectedBitmapVersion = BitmapVersion.BitmapInfoHeader; + [SetUp] public void SetUp() { _modules = Mock.Of(); - - _nativeGraphicsLoader = new NativeGraphicsLoader(_modules); + _nativeGraphicsLoader = new NativeGraphicsLoader(_modules, Mock.Of(x => x.MainCloneCompat == false)); } [Test] @@ -31,7 +34,7 @@ public void WhenLoadGFX_CallsPEFile_GetEmbeddedBitmapResourceByID() using (var bmp = _nativeGraphicsLoader.LoadGFX(GFXTypes.PreLoginUI, 1)) bmp.Dispose(); //hide warning for empty using statement - peFileMock.Verify(x => x.GetEmbeddedBitmapResourceByID(It.IsAny(), It.IsAny()), Times.Once()); + peFileMock.Verify(x => x.GetEmbeddedBitmapResourceByID(It.IsAny(), ExpectedBitmapVersion, ExpectedCulture), Times.Once()); } [Test] @@ -45,7 +48,7 @@ public void WhenLoadGFX_CallsPEFile_WithResourceValueIncreasedBy100() using (var bmp = _nativeGraphicsLoader.LoadGFX(GFXTypes.PreLoginUI, requestedResourceID)) bmp.Dispose(); //hide warning for empty using statement - peFileMock.Verify(x => x.GetEmbeddedBitmapResourceByID(expectedResourceID, It.IsAny())); + peFileMock.Verify(x => x.GetEmbeddedBitmapResourceByID(expectedResourceID, ExpectedBitmapVersion, ExpectedCulture)); } [Test] @@ -78,7 +81,7 @@ private Mock SetupPEFileForGFXType(GFXTypes type, byte[] array) var peFile = new Mock(); collectionMock.Setup(x => x[type]).Returns(peFile.Object); - peFile.Setup(x => x.GetEmbeddedBitmapResourceByID(It.IsAny(), It.IsAny())) + peFile.Setup(x => x.GetEmbeddedBitmapResourceByID(It.IsAny(), ExpectedBitmapVersion, ExpectedCulture)) .Returns(array); return peFile; diff --git a/EOLib.Graphics/EOLib.Graphics.csproj b/EOLib.Graphics/EOLib.Graphics.csproj index 4991f18d6..f7f8fc1ef 100644 --- a/EOLib.Graphics/EOLib.Graphics.csproj +++ b/EOLib.Graphics/EOLib.Graphics.csproj @@ -13,9 +13,12 @@ - + + + + diff --git a/EOLib.Graphics/INativeGraphicsLoader.cs b/EOLib.Graphics/INativeGraphicsLoader.cs index a05713615..75ad144df 100644 --- a/EOLib.Graphics/INativeGraphicsLoader.cs +++ b/EOLib.Graphics/INativeGraphicsLoader.cs @@ -1,4 +1,5 @@ -using SixLabors.ImageSharp; +using PELoaderLib; +using SixLabors.ImageSharp; namespace EOLib.Graphics { diff --git a/EOLib.Graphics/NativeGraphicsLoader.cs b/EOLib.Graphics/NativeGraphicsLoader.cs index a3edf335e..a14965c95 100644 --- a/EOLib.Graphics/NativeGraphicsLoader.cs +++ b/EOLib.Graphics/NativeGraphicsLoader.cs @@ -1,4 +1,6 @@ using AutomaticTypeMapper; +using EOLib.Config; +using PELoaderLib; using SixLabors.ImageSharp; namespace EOLib.Graphics @@ -6,16 +8,23 @@ namespace EOLib.Graphics [MappedType(BaseType = typeof(INativeGraphicsLoader), IsSingleton = true)] public class NativeGraphicsLoader : INativeGraphicsLoader { + private const int CULTURE_EN_US = 1033; + private readonly IPEFileCollection _modules; + private readonly IConfigurationProvider _configurationProvider; - public NativeGraphicsLoader(IPEFileCollection modules) + public NativeGraphicsLoader(IPEFileCollection modules, + IConfigurationProvider configurationProvider) { _modules = modules; + _configurationProvider = configurationProvider; } public IImage LoadGFX(GFXTypes file, int resourceValue) { - var fileBytes = _modules[file].GetEmbeddedBitmapResourceByID(resourceValue + 100); + var version = _configurationProvider.MainCloneCompat ? BitmapVersion.BitmapV3InfoHeader : BitmapVersion.BitmapInfoHeader; + var culture = _configurationProvider.MainCloneCompat ? CULTURE_EN_US : 0; + var fileBytes = _modules[file].GetEmbeddedBitmapResourceByID(resourceValue + 100, version, culture); if (fileBytes.Length == 0) throw new GFXLoadException(resourceValue, file); diff --git a/EndlessClient/GameExecution/GameRunnerBase.cs b/EndlessClient/GameExecution/GameRunnerBase.cs index 231b7998b..42eeb13ba 100644 --- a/EndlessClient/GameExecution/GameRunnerBase.cs +++ b/EndlessClient/GameExecution/GameRunnerBase.cs @@ -75,6 +75,11 @@ public virtual bool SetupDependencies() i++; } + else if(string.Equals(arg, "--clonecompat")) + { + _registry.Resolve() + .MainCloneCompat = true; + } else { Debug.WriteLine($"Unrecognized argument: {arg}. Will be ignored.");