v2.4.5: Add multi-instance setting for mod developers

Allow running multiple game clients simultaneously via a new
"Allow multiple game instances" toggle in Settings. When enabled,
skips the Electron single-instance lock and the pre-launch process
kill, so existing game instances stay alive.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
sanasol
2026-02-27 21:52:13 +01:00
parent e1a3f919a2
commit 3abdd10cab
19 changed files with 103 additions and 6 deletions

View File

@@ -708,6 +708,15 @@ function loadLauncherHardwareAcceleration() {
return config.launcherHardwareAcceleration !== undefined ? config.launcherHardwareAcceleration : true;
}
function saveAllowMultiInstance(enabled) {
saveConfig({ allowMultiInstance: !!enabled });
}
function loadAllowMultiInstance() {
const config = loadConfig();
return config.allowMultiInstance !== undefined ? config.allowMultiInstance : false;
}
// =============================================================================
// MODS MANAGEMENT
// =============================================================================
@@ -1105,6 +1114,8 @@ module.exports = {
loadCloseLauncherOnStart,
saveLauncherHardwareAcceleration,
loadLauncherHardwareAcceleration,
saveAllowMultiInstance,
loadAllowMultiInstance,
// Mods
saveModsToConfig,

View File

@@ -20,6 +20,8 @@ const {
saveLauncherHardwareAcceleration,
loadLauncherHardwareAcceleration,
saveAllowMultiInstance,
loadAllowMultiInstance,
loadConfig,
saveConfig,
@@ -151,6 +153,10 @@ module.exports = {
saveLauncherHardwareAcceleration,
loadLauncherHardwareAcceleration,
// Multi-instance functions
saveAllowMultiInstance,
loadAllowMultiInstance,
// Config functions
loadConfig,
saveConfig,

View File

@@ -30,6 +30,7 @@ const { syncModsForCurrentProfile } = require('./modManager');
const { getUserDataPath } = require('../utils/userDataMigration');
const { syncServerList } = require('../utils/serverListSync');
const { killGameProcesses } = require('./gameManager');
const { loadAllowMultiInstance } = require('../core/config');
// Client patcher for custom auth server (sanasol.ws)
let clientPatcher = null;
@@ -464,8 +465,10 @@ async function launchGame(playerNameOverride = null, progressCallback, javaPathO
}
// Kill any stalled game processes from a previous launch to prevent file locks
// and "game already running" issues
await killGameProcesses();
// and "game already running" issues (skip if multi-instance mode is enabled)
if (!loadAllowMultiInstance()) {
await killGameProcesses();
}
// Remove AOT cache: generated by official Hytale JRE, incompatible with F2P JRE.
// Client adds -XX:AOTCache when this file exists, causing classloading failures.