Агент ищет свой дом, а не доверяет месту jar
Путь к агенту в конфиге лаунчера переписывает сам лаунчер, и однажды он
потерял целый сегмент пути: осталось ...\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") -
наш фильтр не сработал, потому что маркер с базовым хешем к тому моменту не
совпадал. Сейчас это лечится автоматически, но в логах видно.
This commit is contained in:
@@ -26,8 +26,8 @@ public final class RsxAgent {
|
|||||||
|
|
||||||
public static void premain(String args, java.lang.instrument.Instrumentation inst) {
|
public static void premain(String args, java.lang.instrument.Instrumentation inst) {
|
||||||
try {
|
try {
|
||||||
home = new File(RsxAgent.class.getProtectionDomain()
|
home = findHome(new File(RsxAgent.class.getProtectionDomain()
|
||||||
.getCodeSource().getLocation().toURI()).getParentFile();
|
.getCodeSource().getLocation().toURI()));
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
home = new File(".");
|
home = new File(".");
|
||||||
}
|
}
|
||||||
@@ -527,6 +527,27 @@ public final class RsxAgent {
|
|||||||
|
|
||||||
// ----------------------------------------------------------------- utils
|
// ----------------------------------------------------------------- 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.
|
* Put every jar from libs\ on the system class path.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ public class pvdafug {
|
|||||||
|
|
||||||
public pvdafug(String url) {
|
public pvdafug(String url) {
|
||||||
this.url = 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() {
|
public String url() {
|
||||||
|
|||||||
+11
-4
@@ -135,12 +135,15 @@ Say "Модлоадер: $ModHome"
|
|||||||
Say ''
|
Say ''
|
||||||
|
|
||||||
# --------------------------------------------------------------- copy the runtime
|
# --------------------------------------------------------------- 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
|
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'
|
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'
|
$repoProfile = Join-Path $Repo 'profiles\latest.rsxp'
|
||||||
$oldProfile = 'G:\rsx-mod\bridge\profiles\latest.rsxp'
|
$oldProfile = 'G:\rsx-mod\bridge\profiles\latest.rsxp'
|
||||||
if (Test-Path $existingProfile) {
|
if (Test-Path $existingProfile) {
|
||||||
@@ -182,7 +185,11 @@ if (-not (Test-Path -LiteralPath $Marker)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# --------------------------------------------------------------- wire the agent
|
# --------------------------------------------------------------- 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'
|
$ErrorActionPreference = 'Continue'
|
||||||
$out = & $java -jar $patcher setenv $Config $agentArg 2>&1
|
$out = & $java -jar $patcher setenv $Config $agentArg 2>&1
|
||||||
$code = $LASTEXITCODE
|
$code = $LASTEXITCODE
|
||||||
|
|||||||
Reference in New Issue
Block a user