Skip to content

Commit

Permalink
Added support for loading .optoctreepatc (sic) files.
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
Esper89 committed Jun 16, 2023
1 parent 8c19540 commit 46c0f69
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
13 changes: 8 additions & 5 deletions src/FileLoading.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace TerrainPatcher
{
Expand All @@ -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());

Expand Down
10 changes: 7 additions & 3 deletions src/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 46c0f69

Please sign in to comment.