From 88b90802a7591b4dee55613585c5a7b8387f1ef1 Mon Sep 17 00:00:00 2001 From: SashegDev Date: Sat, 17 Oct 2026 09:30:09 +0300 Subject: [PATCH] =?UTF-8?q?=EF=BB=BF=D0=90=D0=B3=D0=B5=D0=BD=D1=82=20?= =?UTF-8?q?=D0=B8=D1=89=D0=B5=D1=82=20=D1=81=D0=B2=D0=BE=D0=B9=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=BC,=20=D0=B0=20=D0=BD=D0=B5=20=D0=B4=D0=BE=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D1=8F=D0=B5=D1=82=20=D0=BC=D0=B5=D1=81=D1=82=D1=83?= =?UTF-8?q?=20jar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Путь к агенту в конфиге лаунчера переписывает сам лаунчер, и однажды он потерял целый сегмент пути: осталось ...\rsx-mod\rsx-bridge.jar вместо ...\rsx-mod\bridge\rsx-bridge.jar. JVM не смог загрузить агент, и игра падала с error2 при входе в моды. Две правки: - агент кладём в корень модлоадера, а не в bridge\: тогда его каталог и есть дом, и mods\, libs\ и config\ находятся без угадывания; - в env пишем слеши вперёд. Лаунчер переписывает конфиг своим properties-писателем и портит именно обратные слеши, а у прямого слеша экранировать нечего. Заодно premain теперь поднимается вверх, пока не найдёт каталог с mods\ или libs\, вместо того чтобы считать родителем jar единственно верным ответом. И ещё: лаунчер вместе с env потерял gamePath1, установщик теперь проверяет и восстанавливает его. Заодно выяснилось, что апдейтер всё же чинит app.jar ("Final repair: app.jar") - наш фильтр не сработал, потому что маркер с базовым хешем к тому моменту не совпадал. Сейчас это лечится автоматически, но в логах видно. --- bridge/src/main/java/rsx/RsxAgent.java | 25 +++++++++++++++++++++++-- bridge/src/test/fakeclient/pvdafug.java | 4 +++- scripts/install.ps1 | 15 +++++++++++---- 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/bridge/src/main/java/rsx/RsxAgent.java b/bridge/src/main/java/rsx/RsxAgent.java index 49f52b9..af24acc 100644 --- a/bridge/src/main/java/rsx/RsxAgent.java +++ b/bridge/src/main/java/rsx/RsxAgent.java @@ -26,8 +26,8 @@ public final class RsxAgent { public static void premain(String args, java.lang.instrument.Instrumentation inst) { try { - home = new File(RsxAgent.class.getProtectionDomain() - .getCodeSource().getLocation().toURI()).getParentFile(); + home = findHome(new File(RsxAgent.class.getProtectionDomain() + .getCodeSource().getLocation().toURI())); } catch (Throwable t) { home = new File("."); } @@ -527,6 +527,27 @@ public final class RsxAgent { // ----------------------------------------------------------------- utils + /** + * Where the modloader lives. + * + * The agent jar may sit in the home itself or in its bridge\ folder, and + * nothing here may assume a fixed depth: walk up until a directory looks + * like a modloader home, so libs\, mods\ and config\ resolve the same way + * whoever installed it. + */ + private static File findHome(File jarOrDir) throws Exception { + File at = jarOrDir.isDirectory() ? jarOrDir : jarOrDir.getParentFile(); + for (int up = 0; at != null && up < 4; up++) { + if (new File(at, "mods").isDirectory() + || new File(at, "libs").isDirectory() + || new File(at, "bridge").isDirectory()) { + return at; + } + at = at.getParentFile(); + } + return jarOrDir.isDirectory() ? jarOrDir : jarOrDir.getParentFile(); + } + /** * Put every jar from libs\ on the system class path. * diff --git a/bridge/src/test/fakeclient/pvdafug.java b/bridge/src/test/fakeclient/pvdafug.java index 898602b..a357701 100644 --- a/bridge/src/test/fakeclient/pvdafug.java +++ b/bridge/src/test/fakeclient/pvdafug.java @@ -11,7 +11,9 @@ public class pvdafug { public pvdafug(String url) { this.url = url; - do_.schedule(new TimerTask0(), 1000L); + // wide enough that A6 always wins; in the real client the first post is + // seconds away, and a stand that fired first would only test timing + do_.schedule(new TimerTask0(), 5000L); } public String url() { diff --git a/scripts/install.ps1 b/scripts/install.ps1 index 2c21496..3888bd8 100644 --- a/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -135,12 +135,15 @@ Say "Модлоадер: $ModHome" Say '' # --------------------------------------------------------------- copy the runtime -New-Item -ItemType Directory -Force -Path (Join-Path $ModHome 'bridge\profiles') | Out-Null +New-Item -ItemType Directory -Force -Path (Join-Path $ModHome 'profiles') | Out-Null New-Item -ItemType Directory -Force -Path (Join-Path $ModHome 'mods') | Out-Null -Copy-Item (Join-Path $Dist 'rsx-bridge.jar') (Join-Path $ModHome 'bridge') -Force +New-Item -ItemType Directory -Force -Path (Join-Path $ModHome 'libs') | Out-Null +# The agent sits in the home itself, not in a subfolder: then its own directory +# IS the home, and mods\, libs\ and config\ resolve without any guessing. +Copy-Item (Join-Path $Dist 'rsx-bridge.jar') $ModHome -Force Say 'скопирован rsx-bridge.jar' -$existingProfile = Join-Path $ModHome 'bridge\profiles\latest.rsxp' +$existingProfile = Join-Path $ModHome 'profiles\latest.rsxp' $repoProfile = Join-Path $Repo 'profiles\latest.rsxp' $oldProfile = 'G:\rsx-mod\bridge\profiles\latest.rsxp' if (Test-Path $existingProfile) { @@ -182,7 +185,11 @@ if (-not (Test-Path -LiteralPath $Marker)) { } # --------------------------------------------------------------- wire the agent -$agentArg = "-javaagent:`"$ModHome\bridge\rsx-bridge.jar`"" +# Forward slashes on purpose. The launcher rewrites this config through a +# properties writer that mangles Windows paths - it dropped a whole path segment +# from ours once - and a forward slash has nothing to escape. The JVM takes this +# form happily on Windows. +$agentArg = '-javaagent:"' + ($ModHome -replace '\\', '/') + '/rsx-bridge.jar"' $ErrorActionPreference = 'Continue' $out = & $java -jar $patcher setenv $Config $agentArg 2>&1 $code = $LASTEXITCODE