diff --git a/docs/launcher.md b/docs/launcher.md index e392c60..942662c 100644 --- a/docs/launcher.md +++ b/docs/launcher.md @@ -1069,7 +1069,9 @@ the server's `mod-state.txt` (no backup, no client), which a stopped Gateway rea applies within a second (LocalExile since 2026-11-07; an older Gateway applies it at its next start). While Gateway runs, Windows and Linux show a restart notice when the checkout's source does not identify the live-choice hook; release installs also show the notice because they have no source to verify. The checkbox represents the saved choice, not proof of a live -load. A switch holds the workspace lock and is refused while another operation holds it. **Update** and +load. A switch holds the workspace lock and is refused while another operation holds it. A program that is no LocalExile +server holding one of the servers' ports (Steam's helper on 8080, say) does not block mod changes, nor Modules, Leagues +or Accounts: it blocks only a start, and the message names it. **Update** and **Update all** appear when a repository has a newer version. The ⋮ menu holds the rarer tools: Install from folder…, Build all mods, Check live status (Python with Frida), Gateway log, the operation log, and the backup choice. diff --git a/docs/runtime-contract.md b/docs/runtime-contract.md index a96bc89..3edc465 100644 --- a/docs/runtime-contract.md +++ b/docs/runtime-contract.md @@ -129,6 +129,9 @@ Accept a server as owned only when: Do not adopt unrelated absolute build folders, identical relative DLL paths in another checkout, shared terminal sessions or orphaned relative commands. Conflicting listeners block start/play; failed inventory queries fail closed. +A conflict names the program holding the port. When that program is no LocalExile server or watcher (Steam's helper on +8080, say), the snapshot also lists it in `PortsInUse`: it still blocks start/play, but not a change of mods, modules, +leagues or accounts, since it holds none of their files. A listener whose process Waypoint cannot name blocks everything. This is a compatibility/ownership guard, not an isolation boundary against malicious same-user code forging command lines. Gateway may instead be a verified `dotnet watch run --project src\GameServer.Gateway --non-interactive --` root, diff --git a/scripts/AccountBridge.ps1 b/scripts/AccountBridge.ps1 index 05a8f2c..0c3eaf8 100644 --- a/scripts/AccountBridge.ps1 +++ b/scripts/AccountBridge.ps1 @@ -1,6 +1,8 @@ # Offline account operations. RuntimeBridge owns the global writer lock and runtime/profile inventory. function Assert-AccountsStopped($snapshot) { - Require (-not $snapshot.Conflicts.Count) ($snapshot.Conflicts -join "`n") + # A port held by a program that is no LocalExile server (PortsInUse) blocks a start, not this change of files. + $blocking = @($snapshot.Conflicts | Where-Object { $_ -notin @($snapshot.PortsInUse) }) + Require (-not $blocking.Count) ($blocking -join "`n") Require (-not @($snapshot.Services | Where-Object { $_.ProcessId -or $_.WatchProcessId }).Count) 'Close the game and stop LocalExile services before changing player accounts.' Require (-not @($script:listeners | Where-Object LocalPort -eq 7000).Count) 'Stop the local account service before changing player accounts.' $writers = @($script:processes | Where-Object { diff --git a/scripts/ContentBridge.ps1 b/scripts/ContentBridge.ps1 index 2d56fae..bb78128 100644 --- a/scripts/ContentBridge.ps1 +++ b/scripts/ContentBridge.ps1 @@ -19,7 +19,9 @@ function Save-ContentFile($snapshot) { # A release older than 0.2.0-beta does not read these files (Get-ContentEnvironment); what a newer one takes is checked # below, by what the environment allows. Require (-not (Test-LegacyReleaseMods)) 'This release is older than module and league editing. Update LocalExile to edit them.' - Require (-not $snapshot.Conflicts.Count) ($snapshot.Conflicts -join "`n") + # A port held by a program that is no LocalExile server (PortsInUse) blocks a start, not this change of files. + $blocking = @($snapshot.Conflicts | Where-Object { $_ -notin @($snapshot.PortsInUse) }) + Require (-not $blocking.Count) ($blocking -join "`n") $environment = Get-ContentEnvironment $staged = Get-StagedModPath $ModStaged -File Require ((Get-Item -LiteralPath $staged).Length -le 262144) 'Settings exceed 256 KB.' diff --git a/scripts/ModBridge.ps1 b/scripts/ModBridge.ps1 index 2675222..71a99e4 100644 --- a/scripts/ModBridge.ps1 +++ b/scripts/ModBridge.ps1 @@ -349,7 +349,9 @@ function Invoke-ModOperation($snapshot) { if ($Action -in @('InstallMod','SaveModSettings','UninstallMod')) { Require (-not (Test-LegacyReleaseMods)) 'This release does not declare compatibility with downloadable mods. Use a current source checkout to install or update mods.' } - Require (-not $snapshot.Conflicts.Count) ($snapshot.Conflicts -join "`n") + # A port held by a program that is no LocalExile server (PortsInUse) blocks a start, not this change of files. + $blocking = @($snapshot.Conflicts | Where-Object { $_ -notin @($snapshot.PortsInUse) }) + Require (-not $blocking.Count) ($blocking -join "`n") $environment = Get-ModEnvironment $snapshot.Services Require $environment.Supported 'This LocalExile revision has no supported mod host.' $gateway = $snapshot.Services | Where-Object Name -eq 'Gateway' diff --git a/scripts/RuntimeBridge.ps1 b/scripts/RuntimeBridge.ps1 index 3db2f7f..1017d3e 100644 --- a/scripts/RuntimeBridge.ps1 +++ b/scripts/RuntimeBridge.ps1 @@ -221,9 +221,25 @@ function Descends-From($process, $ancestor) { function Owned-WatchedGateway($process, $watcher) { return $process -and (Same-Path $process.ExecutablePath (At 'src\GameServer.Gateway\bin\Debug\net10.0\GameServer.Gateway.exe')) -and (Descends-From $process $watcher) } +# A LocalExile server or watcher, of this checkout or any other: what live.ps1 stops by name. +function Test-ServerProcess($process) { + if ($process.Name -notin @('dotnet.exe','cmd.exe','GameServer.Gateway.exe','GameServer.Auth.exe','GameServer.Patch.exe')) { return $false } + return $process.CommandLine -match 'GameServer\.(Gateway|Auth|Patch)(\.dll|\.exe|[\\\s"]|$)' -and $process.CommandLine -notmatch '\s(build|test)\s|GameServer\.(Gateway|Auth|Patch)\.Tests' +} +# A server's port held by a process this checkout does not own: the message names the program. OtherProgram is a program +# that is no LocalExile server (Steam's helper on 8080, say): it blocks a start, but not a change of mods, modules, leagues +# or accounts, since it holds none of their files. A process Waypoint cannot name is never one. +function Get-PortConflict([int]$port, [string]$name, [int]$owner) { + $holder = $script:byId[$owner] + $named = $holder -and $holder.Name + $message = if ($named) { "Port $port is used by $($holder.Name) (PID $owner). $name needs this port." } + else { "Port $port is used by another program (PID $owner). $name needs this port." } + return [pscustomobject]@{ Message=$message; OtherProgram=($named -and -not (Test-ServerProcess $holder)) } +} function Get-Snapshot { Get-Inventory $conflicts = [Collections.Generic.List[string]]::new() + $portsInUse = [Collections.Generic.List[string]]::new() $services = @() $watchers = @($script:processes | Where-Object { Owned-Watcher $_ }) if ($watchers.Count -gt 1) { $conflicts.Add('Multiple Gateway watchers belong to this checkout.') } @@ -242,7 +258,9 @@ function Get-Snapshot { if (-not $onPort.Count) { $ready = $false } foreach ($connection in $onPort) { if (-not $process -or $connection.OwningProcess -ne $process.ProcessId) { - $conflicts.Add("Port $port is occupied by another process (PID $($connection.OwningProcess)); $name is not owned by this checkout.") + $held = Get-PortConflict $port $name ([int]$connection.OwningProcess) + $conflicts.Add($held.Message) + if ($held.OtherProgram) { $portsInUse.Add($held.Message) } $ready = $false } } @@ -257,8 +275,7 @@ function Get-Snapshot { # Upstream live.ps1 stops processes by name before launch, even before they hold a port. # Block foreign server/watch processes as well as foreign listeners so upstream cannot kill them. foreach ($p in $script:processes) { - if ($p.Name -notin @('dotnet.exe','cmd.exe','GameServer.Gateway.exe','GameServer.Auth.exe','GameServer.Patch.exe')) { continue } - if ($p.CommandLine -notmatch 'GameServer\.(Gateway|Auth|Patch)(\.dll|\.exe|[\\\s"]|$)' -or $p.CommandLine -match '\s(build|test)\s|GameServer\.(Gateway|Auth|Patch)\.Tests') { continue } + if (-not (Test-ServerProcess $p)) { continue } $ownedProcess = $false foreach ($s in $services) { if ($p.ProcessId -eq $s.ProcessId) { $ownedProcess = $true } @@ -309,10 +326,10 @@ function Get-Snapshot { } catch { $sourceLabel = '' } } $accountBlock = '' - try { Assert-AccountsStopped ([pscustomobject]@{ Conflicts=$conflicts.ToArray(); Services=$services }) } + try { Assert-AccountsStopped ([pscustomobject]@{ Conflicts=$conflicts.ToArray(); PortsInUse=$portsInUse.ToArray(); Services=$services }) } catch { $accountBlock = $_.Exception.Message } @{ Root=$script:root; Profile=$script:profile; SaveDatabase=$script:savePath; AuthDatabase=$script:authPath; EarlierSaveDatabase=$script:earlierSavePath; SourceCommit=$commit; SourceBranch=$branch; AccountWriteBlockedReason=$accountBlock; - SourceLabel=$sourceLabel; BuildCommit=($builds -join '; '); Requirements=@($requirements); Services=@($services); Conflicts=@($conflicts.ToArray()); ModEnvironment=(Get-ModEnvironment $services); Capture=(Get-CaptureSnapshot $services); Content=(Get-ContentEnvironment) } + SourceLabel=$sourceLabel; BuildCommit=($builds -join '; '); Requirements=@($requirements); Services=@($services); Conflicts=@($conflicts.ToArray()); PortsInUse=@($portsInUse.ToArray()); ModEnvironment=(Get-ModEnvironment $services); Capture=(Get-CaptureSnapshot $services); Content=(Get-ContentEnvironment) } } function Get-SourceSelectionPath { $sha = [Security.Cryptography.SHA256]::Create() diff --git a/src/Launcher.Core/Localization.cs b/src/Launcher.Core/Localization.cs index 27b2119..a6474c9 100644 --- a/src/Launcher.Core/Localization.cs +++ b/src/Launcher.Core/Localization.cs @@ -52,7 +52,8 @@ static readonly (string Pattern, string Format)[] Descriptions = (@"\A(.+) \| hot reload watcher PID (\d+)\z", "{0} | hot reload watcher PID {1}"), (@"\A(.+) · Checked (.+)\z", "{0} · Checked {1}"), (@"\AMultiple (Patch|Gateway|Auth) processes belong to this checkout\.\z", "Multiple {0} processes belong to this checkout."), - (@"\APort (\d+) is occupied by another process \(PID (\d+)\); (Patch|Gateway|Auth) is not owned by this checkout\.\z", "Port {0} is occupied by another process (PID {1}); {2} is not owned by this checkout."), + (@"\APort (\d+) is used by another program \(PID (\d+)\)\. (Patch|Gateway|Auth) needs this port\.\z", "Port {0} is used by another program (PID {1}). {2} needs this port."), + (@"\APort (\d+) is used by (.+) \(PID (\d+)\)\. (Patch|Gateway|Auth) needs this port\.\z", "Port {0} is used by {1} (PID {2}). {3} needs this port."), (@"\AAnother server or watcher is running \(PID (\d+)\)\. Stop it from its own installation before launching here\.\z", "Another server or watcher is running (PID {0}). Stop it from its own installation before launching here.") ]; public static string Describe(string source) diff --git a/src/Launcher.Core/Models.cs b/src/Launcher.Core/Models.cs index a54d6e3..ab0ef73 100644 --- a/src/Launcher.Core/Models.cs +++ b/src/Launcher.Core/Models.cs @@ -10,13 +10,16 @@ public sealed record ServiceStatus(string Name, string Status, int ProcessId, st } public sealed record RuntimeSnapshot(string Root, string Profile, string SaveDatabase, string SourceCommit, string SourceBranch, string BuildCommit, Requirement[] Requirements, ServiceStatus[] Services, string[] Conflicts, string SourceLabel = "", ModEnvironment? ModEnvironment = null, string AccountWriteBlockedReason = "", CaptureSnapshot? Capture = null, - ContentEnvironment? Content = null, string AuthDatabase = "", string EarlierSaveDatabase = "") + ContentEnvironment? Content = null, string AuthDatabase = "", string EarlierSaveDatabase = "", string[]? PortsInUse = null) { public bool SetupReady => Requirements.All(r => r.Ready); public bool ServersReady => Services.Where(s => s.Name != "Game").All(s => s.Status == "Ready"); public bool HasServers => Services.Any(s => s.Name != "Game" && s.IsRunning); public bool GameRunning => Services.Any(s => s.Name == "Game" && s.ProcessId != 0); public bool SafeToLaunch => SetupReady && Conflicts.Length == 0; + /// The conflicts that block a change of mods, modules, leagues or accounts: all but a port held by a program + /// that is no LocalExile server (), which blocks only a start. + public string[] EditConflicts => [.. Conflicts.Where(c => PortsInUse?.Contains(c) != true)]; } public sealed record BridgeResult(bool Ok, string Message, RuntimeSnapshot? Snapshot, string? FailedStage = null, AccountInventory? AccountData = null, diff --git a/src/Launcher.Core/Resources/Strings.resx b/src/Launcher.Core/Resources/Strings.resx index 905ae4e..5961f99 100644 --- a/src/Launcher.Core/Resources/Strings.resx +++ b/src/Launcher.Core/Resources/Strings.resx @@ -2461,6 +2461,9 @@ This checkout has modified tracked files. Open Waypoint + + Port {0} is used by another program (PID {1}). {2} needs this port. + Clears the view; the file is not changed @@ -2563,9 +2566,6 @@ This checkout has modified tracked files. Level up - - Port {0} is occupied by another process (PID {1}); {2} is not owned by this checkout. - LocalExile names no Steam download for this version. @@ -2764,6 +2764,9 @@ This checkout has modified tracked files. Waypoint downloads {0:0} MB, checks it, and puts it over this install. Your characters, keys and game client are kept, and your saves are copied first when Automatic backups is on. The next Play may extract game data again. + + Port {0} is used by {1} (PID {2}). {3} needs this port. + {0} already has files in it, so Waypoint will not replace it with a link. diff --git a/src/Launcher.Core/Resources/Strings.ru.resx b/src/Launcher.Core/Resources/Strings.ru.resx index 18d2887..32a45e7 100644 --- a/src/Launcher.Core/Resources/Strings.ru.resx +++ b/src/Launcher.Core/Resources/Strings.ru.resx @@ -2461,6 +2461,9 @@ Открыть Waypoint + + Порт {0} занят другой программой (PID {1}). Этот порт нужен {2}. + Очищает окно; файл не меняется @@ -2563,9 +2566,6 @@ Новый уровень - - Порт {0} занят другим процессом (PID {1}); {2} не принадлежит этой установке. - LocalExile не указывает загрузку из Steam для этой версии. @@ -2764,6 +2764,9 @@ Waypoint скачает {0:0} МБ, проверит их и установит поверх текущей версии. Персонажи, ключи и клиент игры сохранятся, а если включено автоматическое резервное копирование, сначала будет сделана копия сохранений. При следующем запуске данные игры могут извлекаться заново. + + Порт {0} занят программой {1} (PID {2}). Этот порт нужен {3}. + В {0} уже есть файлы, поэтому Waypoint не будет заменять эту папку ссылкой. diff --git a/src/Launcher.Core/Resources/Strings.zh-CN.resx b/src/Launcher.Core/Resources/Strings.zh-CN.resx index 833af69..96ca2fd 100644 --- a/src/Launcher.Core/Resources/Strings.zh-CN.resx +++ b/src/Launcher.Core/Resources/Strings.zh-CN.resx @@ -2461,6 +2461,9 @@ 打开 Waypoint + + 端口 {0} 已被另一个程序(PID {1})占用。{2} 需要此端口。 + 清空视图;文件不会被更改 @@ -2563,9 +2566,6 @@ 升级 - - 端口 {0} 已被另一个进程(PID {1})占用;{2} 不属于此源码副本。 - LocalExile 没有为此版本提供 Steam 下载信息。 @@ -2764,6 +2764,9 @@ Waypoint 会下载 {0:0} MB,校验后覆盖到当前安装上。你的角色、密钥和游戏客户端都会保留;如果开启了“自动备份”,还会先复制你的存档。下次“开始游戏”时可能会重新提取游戏数据。 + + 端口 {0} 已被 {1}(PID {2})占用。{3} 需要此端口。 + {0} 中已有文件,因此 Waypoint 不会将其替换为链接。 diff --git a/src/Waypoint.Linux/Views/AccountsTab.axaml.cs b/src/Waypoint.Linux/Views/AccountsTab.axaml.cs index aa78018..5b3af73 100644 --- a/src/Waypoint.Linux/Views/AccountsTab.axaml.cs +++ b/src/Waypoint.Linux/Views/AccountsTab.axaml.cs @@ -122,7 +122,7 @@ void AccountSelected(object? sender, SelectionChangedEventArgs e) void ShowAccess() { var state = _shared.Workspace.Latest; - bool stopped = state is { HasServers: false, GameRunning: false, Conflicts.Length: 0, AccountWriteBlockedReason.Length: 0 }; + bool stopped = state is { HasServers: false, GameRunning: false, EditConflicts.Length: 0, AccountWriteBlockedReason.Length: 0 }; bool available = stopped && !_shared.IsLiveRunning; foreach (var button in AccountActions.Children.OfType