From 46c0f69f089dcf42365698a1726fa4f77132c57d Mon Sep 17 00:00:00 2001 From: Esper Thomson Date: Fri, 16 Jun 2023 03:27:38 -0400 Subject: [PATCH] Added support for loading `.optoctreepatc` (sic) files. Discord shortens uploaded file extensions to 13 characters, for some reason. This cuts off the final `h` character in an `.optoctreepatch` file, making it `optoctreepatc`. --- src/FileLoading.cs | 13 ++++++++----- src/Mod.cs | 10 +++++++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/FileLoading.cs b/src/FileLoading.cs index 58b0953..51fb615 100644 --- a/src/FileLoading.cs +++ b/src/FileLoading.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; namespace TerrainPatcher { @@ -18,11 +19,13 @@ private static string[] GetPatchFiles() { string searchDir = Directory.GetParent(Constants.MOD_DIR).FullName; - string[] paths = Directory.GetFiles( - searchDir, - $"*{Constants.PATCH_EXTENSION}", - SearchOption.AllDirectories - ); + string[] paths = Constants.PATCH_EXTENSIONS + .SelectMany(ext => Directory.GetFiles( + searchDir, + $"*.{ext}", + SearchOption.AllDirectories + )) + .ToArray(); return SortFiles(paths, GetLoadOrder()); diff --git a/src/Mod.cs b/src/Mod.cs index 2613409..095a8d2 100644 --- a/src/Mod.cs +++ b/src/Mod.cs @@ -69,11 +69,15 @@ internal bool IncludePatches internal static class Constants { - // The current version number of the optoctreepatch format. + // The current version number of the patch format. internal const uint PATCH_VERSION = 0; - // The current file extension for the optoctreepatch format. - internal static readonly string PATCH_EXTENSION = ".optoctreepatch"; + // All valid file extensions for the patch format. + internal static readonly string[] PATCH_EXTENSIONS = + { + "optoctreepatch", + "optoctreepatc", // Discord shortens uploaded file extensions to 13 characters. + }; // The current version number of the game's batch format. internal const uint BATCH_VERSION = 4;