From 7ae143472d66bf2e706cc5e2ee108da59a90f4a1 Mon Sep 17 00:00:00 2001 From: Dave Corley Date: Thu, 12 Jun 2025 08:51:54 -0700 Subject: [PATCH 1/5] FEAT: Try loading TES3Merge.ini from a system config directory last --- TES3Merge/Util/Util.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/TES3Merge/Util/Util.cs b/TES3Merge/Util/Util.cs index 308c249..d6df208 100644 --- a/TES3Merge/Util/Util.cs +++ b/TES3Merge/Util/Util.cs @@ -136,6 +136,9 @@ internal static void LoadConfig() if (!File.Exists(iniPath)) iniPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TES3Merge.ini"); + if (!File.Exists(iniPath)) + iniPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "tes3merge", "TES3Merge.ini"); + Configuration = parser.ReadFile(iniPath); } From 730dabd728a3e39238ff648a42e28ae1e46e6fbf Mon Sep 17 00:00:00 2001 From: Dave Corley Date: Thu, 12 Jun 2025 08:54:03 -0700 Subject: [PATCH 2/5] FEAT: Throw explicitly if any configuration file is not found --- TES3Merge/Util/Util.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/TES3Merge/Util/Util.cs b/TES3Merge/Util/Util.cs index d6df208..9229a6a 100644 --- a/TES3Merge/Util/Util.cs +++ b/TES3Merge/Util/Util.cs @@ -139,6 +139,11 @@ internal static void LoadConfig() if (!File.Exists(iniPath)) iniPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "tes3merge", "TES3Merge.ini"); + if (!File.Exists(iniPath)) + { + throw new Exception("TES3Merge was unable to locate a configuration file in any possible location. Aborting."); + } + Configuration = parser.ReadFile(iniPath); } From d49ee095ca3cf5d2c9d77c8eea52e2807efce071 Mon Sep 17 00:00:00 2001 From: Dave Corley Date: Thu, 12 Jun 2025 10:04:11 -0700 Subject: [PATCH 3/5] FEAT: Document OutputFile param --- TES3Merge/TES3Merge.ini | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/TES3Merge/TES3Merge.ini b/TES3Merge/TES3Merge.ini index 62fa0a4..5e3d7a4 100644 --- a/TES3Merge/TES3Merge.ini +++ b/TES3Merge/TES3Merge.ini @@ -18,6 +18,10 @@ TextEncodingCode = 1252 ; * Have Morrowind's install path in your registry. This only functions on Windows, and will not find OpenMW installations. ; InstallPath = +; The folder in which Merged Objects.esp will be saved. +; If unset, TES3Merge will save Merged Objects.esp to Morrowind's Data Files folder, or a `data-local` folder defined by an openmw.cfg. +; OutputFile = + ; Blacklist a file from merging. Set a filename to false to ignore it when merging. [FileFilters] ; Tamriel_Data.esm = false From 8da049dc299d2968bac030686b3288ae6def63b1 Mon Sep 17 00:00:00 2001 From: Dave Corley Date: Thu, 12 Jun 2025 15:38:50 -0700 Subject: [PATCH 4/5] FIX: Prevent a scenario where certain exotic configurations may result in tes3merge choosing to place merged objects.esp alongside engine resources --- TES3Merge/Util/Installation.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/TES3Merge/Util/Installation.cs b/TES3Merge/Util/Installation.cs index dad4275..bf91ff5 100644 --- a/TES3Merge/Util/Installation.cs +++ b/TES3Merge/Util/Installation.cs @@ -604,8 +604,20 @@ public override string GetDefaultOutputDirectory() if (DataDirectories.Count == 0) throw new Exception("No data directories defined. No default output directory could be resolved."); - var outputDirIndex = string.IsNullOrEmpty(DataLocalDirectory) ? 0 : DataDirectories.Count - 1; - - return DataDirectories[outputDirIndex]; + if (!string.IsNullOrEmpty(DataLocalDirectory)) + { + // DataLocalDirectory is always added last + return DataDirectories[^1]; + } + else if (!string.IsNullOrEmpty(ResourcesDirectory) && DataDirectories.Count > 1) + { + // ResourcesDirectory is inserted at index 0, so skip it + return DataDirectories[1]; + } + else + { + // No ResourcesDirectory, so use the first data directory + return DataDirectories[0]; + } } } From 01ae521ea3ffc2ab9988a3f31040ccdb382cdbed Mon Sep 17 00:00:00 2001 From: Dave Corley Date: Thu, 12 Jun 2025 16:01:30 -0700 Subject: [PATCH 5/5] FEAT: Handle replacement keys properly --- TES3Merge/Util/Installation.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/TES3Merge/Util/Installation.cs b/TES3Merge/Util/Installation.cs index bf91ff5..9e81d27 100644 --- a/TES3Merge/Util/Installation.cs +++ b/TES3Merge/Util/Installation.cs @@ -528,6 +528,21 @@ private void LoadConfiguration(string configDir) case "resources": ResourcesDirectory = ParseDataDirectory(configDir, value); break; + case "replace": + if (value == "content") + GameFiles.Clear(); + else if (value == "data") + DataDirectories.Clear(); + else if (value == "config") + { + Archives.Clear(); + DataDirectories.Clear(); + GameFiles.Clear(); + subConfigs.Clear(); + ResourcesDirectory = null; + DataLocalDirectory = null; + } + break; } }