From 57edbffb5fcd5858a940111e055fb38167dcd202 Mon Sep 17 00:00:00 2001 From: Timothy Baldridge Date: Mon, 19 Sep 2022 20:56:03 -0600 Subject: [PATCH 1/3] Several compilation fixes --- CHANGELOG.md | 4 ++++ .../CompilationSteps/IncludeRegex.cs | 2 +- Wabbajack.Compiler/CompilerSettingsInferencer.cs | 14 +++++++++++--- Wabbajack.Compiler/MO2Compiler.cs | 5 +++-- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6153d748..7470a6d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ### Changelog +#### Version - 3.0.1.3 - 9/??/2022 +* Auto-include splash.png files when compiling +* Fix support for `WABBAJACK_NOMATCH_INCLUDE_FILES.txt` and other variants + #### Version - 3.0.1.2 - 9/19/2022 * Fix error with FNV BSAs not building properly when files are in the root folder * Fix for UnknownError in the Launcher (will require the Wabbajack.exe launcher to be re-downloaded) diff --git a/Wabbajack.Compiler/CompilationSteps/IncludeRegex.cs b/Wabbajack.Compiler/CompilationSteps/IncludeRegex.cs index 82006f10..26ec0781 100644 --- a/Wabbajack.Compiler/CompilationSteps/IncludeRegex.cs +++ b/Wabbajack.Compiler/CompilationSteps/IncludeRegex.cs @@ -14,7 +14,7 @@ public class IncludeRegex : ACompilationStep public IncludeRegex(ACompiler compiler, string pattern) : base(compiler) { _pattern = pattern; - _regex = new Regex(pattern, RegexOptions.Compiled); + _regex = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase); } public override async ValueTask Run(RawSourceFile source) diff --git a/Wabbajack.Compiler/CompilerSettingsInferencer.cs b/Wabbajack.Compiler/CompilerSettingsInferencer.cs index 6145ed7b..83c84126 100644 --- a/Wabbajack.Compiler/CompilerSettingsInferencer.cs +++ b/Wabbajack.Compiler/CompilerSettingsInferencer.cs @@ -67,13 +67,13 @@ public class CompilerSettingsInferencer cs.Include = Array.Empty(); foreach (var file in mo2Folder.EnumerateFiles()) { - if (file.FileName.WithoutExtension().ToString() == Consts.WABBAJACK_INCLUDE) + if (MatchesVariants(file, Consts.WABBAJACK_INCLUDE)) cs.Include = cs.Include.Add(file.Parent.RelativeTo(mo2Folder)); - if (file.FileName.WithoutExtension().ToString() == Consts.WABBAJACK_NOMATCH_INCLUDE) + if (MatchesVariants(file, Consts.WABBAJACK_NOMATCH_INCLUDE)) cs.NoMatchInclude = cs.NoMatchInclude.Add(file.Parent.RelativeTo(mo2Folder)); - if (file.FileName.WithoutExtension().ToString() == Consts.WABBAJACK_IGNORE) + if (MatchesVariants(file, Consts.WABBAJACK_IGNORE)) cs.Ignore = cs.Ignore.Add(file.Parent.RelativeTo(mo2Folder)); } @@ -120,4 +120,12 @@ public class CompilerSettingsInferencer return null; } + + private static bool MatchesVariants(AbsolutePath file, string baseVariant) + { + var withoutExt = file.FileName.WithoutExtension().ToString(); + + return withoutExt == baseVariant || + withoutExt == baseVariant + "_FILES"; + } } \ No newline at end of file diff --git a/Wabbajack.Compiler/MO2Compiler.cs b/Wabbajack.Compiler/MO2Compiler.cs index 45c91260..614c507d 100644 --- a/Wabbajack.Compiler/MO2Compiler.cs +++ b/Wabbajack.Compiler/MO2Compiler.cs @@ -292,8 +292,9 @@ public class MO2Compiler : ACompiler new IgnoreFilename(this, "portable.txt".ToRelativePath()), new IgnoreExtension(this, Ext.Bin), new IgnoreFilename(this, ".refcache".ToRelativePath()), - //Include custom categories - new IncludeRegex(this, "categories.dat$"), + //Include custom categories / splash screens + new IncludeRegex(this, @"categories\.dat$"), + new IncludeRegex(this, @"splash\.png"), new IncludeAllConfigs(this), // TODO From 801f655ef371028bab20201f4b60796e0f8ec339 Mon Sep 17 00:00:00 2001 From: Timothy Baldridge Date: Tue, 20 Sep 2022 17:18:32 -0600 Subject: [PATCH 2/3] 3.0.1.3 --- CHANGELOG.md | 6 ++++- .../View Models/Installers/InstallerVM.cs | 23 +++++++++++++++++++ Wabbajack.DTOs/Game/GameRegistry.cs | 1 + Wabbajack.Installer/StandardInstaller.cs | 1 + Wabbajack.Paths/AbsolutePath.cs | 14 +++++++++++ 5 files changed, 44 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7470a6d2..2e4ccfce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,12 @@ ### Changelog -#### Version - 3.0.1.3 - 9/??/2022 +#### Version - 3.0.1.3 - 9/20/2022 * Auto-include splash.png files when compiling * Fix support for `WABBAJACK_NOMATCH_INCLUDE_FILES.txt` and other variants +* Fix missing MO2ArchiveName for stardewvalley +* Write the name/version of the modlist to the log before installing +* Refuse to install inside a Game folder or the a parent of a game folder +* Refuse to install inside the Wabbajack folder or a parent of the Wabbajack folder #### Version - 3.0.1.2 - 9/19/2022 * Fix error with FNV BSAs not building properly when files are in the root folder diff --git a/Wabbajack.App.Wpf/View Models/Installers/InstallerVM.cs b/Wabbajack.App.Wpf/View Models/Installers/InstallerVM.cs index a6aa1a7d..550ec88b 100644 --- a/Wabbajack.App.Wpf/View Models/Installers/InstallerVM.cs +++ b/Wabbajack.App.Wpf/View Models/Installers/InstallerVM.cs @@ -274,6 +274,29 @@ public class InstallerVM : BackNavigatingVM, IBackNavigatingVM, ICpuStatusVM yield return ErrorResponse.Fail("Install path isn't set to a folder"); if (installPath.InFolder(KnownFolders.Windows)) yield return ErrorResponse.Fail("Don't install modlists into your Windows folder"); + + foreach (var game in GameRegistry.Games) + { + if (!_gameLocator.TryFindLocation(game.Key, out var location)) + continue; + + if (installPath.InFolder(location)) + yield return ErrorResponse.Fail("Can't install a modlist into a game folder"); + + if (location.ThisAndAllParents().Any(path => installPath == path)) + { + yield return ErrorResponse.Fail( + "Can't install in this path, installed files may overwrite important game files"); + } + } + + if (installPath.InFolder(KnownFolders.EntryPoint)) + yield return ErrorResponse.Fail("Can't install a modlist into the Wabbajack.exe path"); + + if (KnownFolders.EntryPoint.ThisAndAllParents().Any(path => installPath == path)) + { + yield return ErrorResponse.Fail("Installing in this folder may overwrite Wabbajack"); + } } diff --git a/Wabbajack.DTOs/Game/GameRegistry.cs b/Wabbajack.DTOs/Game/GameRegistry.cs index 57e4f2ca..d27f05cc 100644 --- a/Wabbajack.DTOs/Game/GameRegistry.cs +++ b/Wabbajack.DTOs/Game/GameRegistry.cs @@ -258,6 +258,7 @@ public static class GameRegistry Game = Game.StardewValley, NexusName = "stardewvalley", MO2Name = "Stardew Valley", + MO2ArchiveName = "stardewvalley", NexusGameId = 1303, SteamIDs = new[] {413150}, GOGIDs = new[] {1453375253}, diff --git a/Wabbajack.Installer/StandardInstaller.cs b/Wabbajack.Installer/StandardInstaller.cs index ca7bf2e6..692bbad4 100644 --- a/Wabbajack.Installer/StandardInstaller.cs +++ b/Wabbajack.Installer/StandardInstaller.cs @@ -63,6 +63,7 @@ public class StandardInstaller : AInstaller public override async Task Begin(CancellationToken token) { if (token.IsCancellationRequested) return false; + _logger.LogInformation("Installing: {Name} - {Version}", _configuration.ModList.Name, _configuration.ModList.Version); await _wjClient.SendMetric(MetricNames.BeginInstall, ModList.Name); NextStep(Consts.StepPreparing, "Configuring Installer", 0); _logger.LogInformation("Configuring Processor"); diff --git a/Wabbajack.Paths/AbsolutePath.cs b/Wabbajack.Paths/AbsolutePath.cs index 3c99c58f..63769933 100644 --- a/Wabbajack.Paths/AbsolutePath.cs +++ b/Wabbajack.Paths/AbsolutePath.cs @@ -1,6 +1,8 @@ using System; +using System.Collections; using System.Collections.Generic; using System.Linq; +using System.Runtime.CompilerServices; namespace Wabbajack.Paths; @@ -69,6 +71,18 @@ public struct AbsolutePath : IPath, IComparable, IEquatable Parts?.Length ?? 0; + public IEnumerable ThisAndAllParents() + { + var p = this; + while (true) + { + yield return p; + if (p.Depth == 1) + yield break; + p = p.Parent; + } + } + public AbsolutePath ReplaceExtension(Extension newExtension) { var paths = new string[Parts.Length]; From 592b48e6a361b826b325ecfacb83e2c3215c9f5b Mon Sep 17 00:00:00 2001 From: Timothy Baldridge Date: Wed, 21 Sep 2022 06:44:54 -0600 Subject: [PATCH 3/3] 3.0.1.4 --- CHANGELOG.md | 3 +++ Wabbajack.Paths/AbsolutePath.cs | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e4ccfce..bc56c8bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ ### Changelog +#### Version - 3.0.1.4 - 9/21/2022 +* Fix several of case sensitive path comparisons, that could result in deleting downloads + #### Version - 3.0.1.3 - 9/20/2022 * Auto-include splash.png files when compiling * Fix support for `WABBAJACK_NOMATCH_INCLUDE_FILES.txt` and other variants diff --git a/Wabbajack.Paths/AbsolutePath.cs b/Wabbajack.Paths/AbsolutePath.cs index 63769933..7f849cff 100644 --- a/Wabbajack.Paths/AbsolutePath.cs +++ b/Wabbajack.Paths/AbsolutePath.cs @@ -140,7 +140,7 @@ public struct AbsolutePath : IPath, IComparable, IEquatable, IEquatable