diff --git a/src/Terrain.cs b/src/Terrain.cs
index 2b39113..5e40e21 100644
--- a/src/Terrain.cs
+++ b/src/Terrain.cs
@@ -10,12 +10,18 @@ public static class TerrainRegistry
/// Applies a terrain patch file to the game's terrain.
/// The name of the patch file to apply.
/// The patch file to apply.
- public static void PatchTerrain(string patchName, Stream patchFile)
+ /// Force-overwrites batches in this patch, resetting them to
+ /// their original states before applying patches.
+ public static void PatchTerrain(
+ string patchName,
+ Stream patchFile,
+ bool forceOriginal = false
+ )
{
try
{
Mod.LogInfo($"Applying patch '{patchName}'");
- ApplyPatchFile(patchFile);
+ ApplyPatchFile(patchFile, forceOriginal);
}
catch (Exception ex)
{
@@ -24,7 +30,7 @@ public static void PatchTerrain(string patchName, Stream patchFile)
}
// Applies a terrain patch.
- internal static void ApplyPatchFile(Stream patchFile)
+ internal static void ApplyPatchFile(Stream patchFile, bool forceOriginal = false)
{
if (patchFile is null)
{
@@ -65,7 +71,7 @@ internal static void ApplyPatchFile(Stream patchFile)
// Lists all batches as they are patched.
Mod.LogInfo($"- Patching batch ({id.x}, {id.y}, {id.z})");
- ApplyBatchPatch(reader, id);
+ ApplyBatchPatch(reader, id, forceOriginal);
}
catch (EndOfStreamException ex)
{
@@ -93,11 +99,11 @@ internal static void ApplyPatchFile(Stream patchFile)
new Dictionary { };
// Loads a batch into patchedBatches if necessary, then applies the patch.
- private static void ApplyBatchPatch(BinaryReader patch, Int3 batchId)
+ private static void ApplyBatchPatch(BinaryReader patch, Int3 batchId, bool forceOriginal)
{
lock (patchedBatches)
{
- if (!patchedBatches.ContainsKey(batchId))
+ if (!patchedBatches.ContainsKey(batchId) || forceOriginal)
{
RegisterNewBatch(batchId);
}