Skip to content

Commit

Permalink
feat: disallow mods in speedruns
Browse files Browse the repository at this point in the history
closes #347
  • Loading branch information
DorielRivalet committed Jun 12, 2024
1 parent 3934e15 commit 88af1fc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
21 changes: 17 additions & 4 deletions MHFZ_Overlay/DataLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ namespace MHFZ_Overlay;
using Memory;
using MHFZ_Overlay.Models.Addresses;
using MHFZ_Overlay.Models.Constant;
using MHFZ_Overlay.Models.Structures;
using MHFZ_Overlay.Services;
using MHFZ_Overlay.ViewModels.Windows;

Expand Down Expand Up @@ -110,7 +111,7 @@ public DataLoader()

// first we check if there are duplicate mhf.exe
this.CheckForExternalProcesses();
this.CheckForIllegalModifications();
this.CheckForIllegalModifications(this);

// if there aren't then this runs and sets the game folder and also the database folder if needed
GetMHFFolderLocation();
Expand Down Expand Up @@ -246,7 +247,12 @@ private static void GetMHFFolderLocation()

private readonly List<string> bannedFolders = new ()
{
"scripts", "plugins", "script", "plugin", "localize-dat", "mods",
"scripts", "plugins", "script", "plugin", "localize-dat",
};

private readonly List<string> bannedFoldersInSpeedruns = new()
{
"scripts", "plugins", "script", "plugin", "localize-dat", "mods"
};

private readonly List<string> allowedProcesses = new ()
Expand Down Expand Up @@ -335,7 +341,7 @@ public void CheckForExternalProcesses()

// This checks for illegal folders or files in the game folder
// TODO: test
public void CheckForIllegalModifications()
public void CheckForIllegalModifications(DataLoader? dataLoader)
{
if (Program.IsVelopackUpdating)
{
Expand Down Expand Up @@ -379,7 +385,14 @@ public void CheckForIllegalModifications()
var files = Directory.GetFiles(mhfDirectory, "*", SearchOption.AllDirectories);
var folders = Directory.GetDirectories(mhfDirectory, "*", SearchOption.AllDirectories);
var isFatal = true;
FileService.CheckIfFileExtensionFolderExists(files, folders, this.bannedFiles, this.bannedFileExtensions, this.bannedFolders, isFatal);
if (dataLoader != null && dataLoader.Model.GetOverlayMode() is OverlayMode.Speedrun)
{
FileService.CheckIfFileExtensionFolderExists(files, folders, this.bannedFiles, this.bannedFileExtensions, this.bannedFoldersInSpeedruns, isFatal);
}
else
{
FileService.CheckIfFileExtensionFolderExists(files, folders, this.bannedFiles, this.bannedFileExtensions, this.bannedFolders, isFatal);
}
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion MHFZ_Overlay/Services/DatabaseService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16832,7 +16832,7 @@ private void CheckDatabaseVersion(SQLiteConnection connection, DataLoader dataLo

Updating the database structure may take some time, it will transport all of your current data straight to the latest database structure, regardless of the previous database version.

Release notes: https://wycademy.vercel.app/overlay/release-notes (clicking yes will open the browser with the mentioned link)",
Release notes: https://wycademy.vercel.app/overlay/release-notes (clicking ""Yes"" will open the browser with the mentioned link)",
string.Format(CultureInfo.InvariantCulture, "MHF-Z Overlay Database Update ({0} to {1})", previousVersion, Program.CurrentProgramVersion), MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);
if (result == MessageBoxResult.Yes)
{
Expand Down

0 comments on commit 88af1fc

Please sign in to comment.