Unpatch saves started with save patching disabled

Turning factorio.enable_save_patching off did nothing to a save that
was patched before. Its control.lua still loaded every module, so the
clusterio_api interface, player_sync's join handling and the other
module event handlers kept running with no plugin on the host side.

When patching is disabled the instance now restores the original
control.lua that patching kept as scenario.lua and removes the module
files, locale files included, as listed in clusterio.json. The patch
info stays with an empty module list so the patch number keeps
counting. Otherwise patching the save again would reuse the number
stored in the game and on_server_startup would not be raised. Data
the modules put in storage is left alone.

PatchInfo.fromSave dropped the version read from the save, so the
check against newer patch versions never fired. It now keeps it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bbassieandClaude Opus 5.5 committed 2026-11-04 00:16:52 +00:00
1 parent 6eaf48aefe
commit ca3dbab49d
6 files changed
+229 -49

No files matched your search

+4 -1
View File
@@ -11,7 +11,7 @@ const execAsync = util.promisify(exec);
import * as lib from "@clusterio/lib";
import { FactorioServer, checkForUpdates } from "./server.js";
import { loadModules, patch } from "./patch.js";
import { loadModules, patch, unpatch } from "./patch.js";
import { exportData } from "./export.js";
import type Host from "./Host.js";
import { BaseInstancePlugin, InstanceHooks } from "./BaseInstancePlugin.js";
@@ -1082,6 +1082,9 @@ end`.replace(/\r?\n/g, " ");
}
if (!this.config.get("factorio.enable_save_patching")) {
if (await unpatch(this.path("saves", saveName))) {
this.logger.info("Removed Clusterio modules from save as save patching is disabled");
}
return saveName;
}