From 801f655ef371028bab20201f4b60796e0f8ec339 Mon Sep 17 00:00:00 2001 From: Timothy Baldridge Date: Tue, 20 Sep 2022 17:18:32 -0600 Subject: [PATCH] 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];