forked from 2009Scape/Server
Merge branch 'refactor-library-loading'
# Conflicts: # Client/src/main/kotlin/org/rs09/SlayerTracker.kt
This commit is contained in:
commit
6d814042b0
16 changed files with 92 additions and 41 deletions
|
|
@ -10,6 +10,7 @@ import java.lang.reflect.Method;
|
|||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
|
||||
|
|
@ -394,20 +395,20 @@ public class Signlink implements Runnable {
|
|||
if (osArchitecture.equals("aarch64"))
|
||||
SystemLogger.logWarn("Going into HD will fail - current libs do not support ARM.");
|
||||
if (osName.startsWith("linux") || isSunOS) {
|
||||
createLibs(isSunOS ? (is64Bit ? 7 : 6) : (is64Bit ? 5 : 4));
|
||||
var7.invoke(runtime, var1.anObject977, method1448(this.gameName, this.anInt1215, "libgluegen-rt.so").toString());
|
||||
Class var8 = ((Class) var1.anObject977).getClassLoader().loadClass("com.sun.opengl.impl.x11.DRIHack");
|
||||
String[] libs = createLibs(isSunOS ? (is64Bit ? 7 : 6) : (is64Bit ? 5 : 4));
|
||||
var7.invoke(runtime, var1.anObject977, libs[2]);
|
||||
Class var8 = getClass().getClassLoader().loadClass("com.sun.opengl.impl.x11.DRIHack");
|
||||
var8.getMethod("begin", new Class[0]).invoke(null);
|
||||
var7.invoke(runtime, var1.anObject977, method1448(this.gameName, this.anInt1215, "libjogl.so").toString());
|
||||
var7.invoke(runtime, var1.anObject977, libs[0]);
|
||||
var8.getMethod("end", new Class[0]).invoke(null);
|
||||
var7.invoke(runtime, var1.anObject977, method1448(this.gameName, this.anInt1215, "libjogl_awt.so").toString());
|
||||
var7.invoke(runtime, var1.anObject977, libs[1]);
|
||||
|
||||
|
||||
} else if (osName.startsWith("mac")) {
|
||||
createLibs(is64Bit ? 2 : 3);
|
||||
String[] libs = createLibs(is64Bit ? 2 : 3);
|
||||
try {
|
||||
var7.invoke(runtime, var1.anObject977, method1448(this.gameName, this.anInt1215, "libjogl.jnilib").toString());
|
||||
var7.invoke(runtime, var1.anObject977, method1448(this.gameName, this.anInt1215, "libjogl_awt.jnilib").toString());
|
||||
var7.invoke(runtime, var1.anObject977, libs[0]);
|
||||
var7.invoke(runtime, var1.anObject977, libs[1]);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
@ -416,10 +417,12 @@ public class Signlink implements Runnable {
|
|||
if (!osName.startsWith("win")) {
|
||||
throw new Exception();
|
||||
}
|
||||
createLibs(is64Bit ? 1 : 0);
|
||||
// System.out.println("Trying to invoke libs");
|
||||
var7.invoke(runtime, var1.anObject977, method1448(this.gameName, this.anInt1215, "jogl.dll").toString());
|
||||
var7.invoke(runtime, var1.anObject977, method1448(this.gameName, this.anInt1215, "jogl_awt.dll").toString());
|
||||
String[] libs = createLibs(is64Bit ? 1 : 0);
|
||||
//Windows has to load them this way because temporary files are illegal.
|
||||
String jogl = method1448(this.gameName, this.anInt1215, libs[0]).toString();
|
||||
String awt = method1448(this.gameName, this.anInt1215, libs[1]).toString();
|
||||
var7.invoke(runtime, var1.anObject977, jogl);
|
||||
var7.invoke(runtime, var1.anObject977, awt);
|
||||
}
|
||||
|
||||
var7.setAccessible(false);
|
||||
|
|
@ -499,38 +502,58 @@ public class Signlink implements Runnable {
|
|||
}
|
||||
}
|
||||
|
||||
public void createLibs(int archive) throws Throwable {
|
||||
String jogl = archive < 2 ? "jogl.dll" : archive < 4 ? "libjogl.jnilib" : "libjogl.so";
|
||||
String joglAwt = archive < 2 ? "jogl_awt.dll" : archive < 4 ? "libjogl_awt.jnilib" : "libjogl_awt.so";
|
||||
byte[] bs = CacheIndex.libIndex.getFile(archive, 0);
|
||||
if (bs == null || bs.length < 1) {
|
||||
System.err.println("Could not create native lib " + joglAwt + ", archive=" + archive + "!");
|
||||
return;
|
||||
/**
|
||||
* Extracts the libs from the client resources
|
||||
* @param archive deprecated - used to point to the cache archive for the lib, now indicates OS|Architecture "hash"
|
||||
* @return an array of the created filenames to load.
|
||||
* @author Ceikry
|
||||
*/
|
||||
public String[] createLibs(int archive) throws Throwable {
|
||||
ArrayList<String> filenames = new ArrayList<>();
|
||||
String jogl;
|
||||
String awt;
|
||||
String glueGen = "";
|
||||
boolean isGluegenRequired = false;
|
||||
boolean is64Bit = osArchitecture.contains("64");
|
||||
boolean isWindowsOrMac = archive < 4;
|
||||
|
||||
jogl = (archive < 2 ? "jogl" : "libjogl") +
|
||||
(is64Bit ? "_64" : "_32") +
|
||||
(archive < 2 ? ".dll" : archive < 4 ? ".jnilib" : ".so");
|
||||
|
||||
awt = (archive < 2 ? "jogl_awt" : "libjogl_awt") +
|
||||
(is64Bit ? "_64" : "_32") +
|
||||
(archive < 2 ? ".dll" : archive < 4 ? ".jnilib" : ".so");
|
||||
|
||||
if(!isWindowsOrMac) isGluegenRequired = true;
|
||||
if(isGluegenRequired) glueGen = "libgluegen-rt_" + (is64Bit ? "64" : "32") + ".so";
|
||||
|
||||
File joglLib = isWindowsOrMac ? method1448(this.gameName, this.anInt1215, "jogl.dll") : File.createTempFile("jogl", "." + jogl.split("\\.")[1]);
|
||||
File awtLib = isWindowsOrMac ? method1448(this.gameName, this.anInt1215, "jogl_awt.dll") : File.createTempFile("jogl_awt", "." + awt.split("\\.")[1]);
|
||||
|
||||
try (InputStream in = getClass().getResourceAsStream("/lib/" + jogl); OutputStream out = openOutputStream(joglLib)) {
|
||||
if (in == null) throw new FileNotFoundException("Needed library does not exist: " + jogl);
|
||||
copyFile(in, out);
|
||||
filenames.add(isWindowsOrMac ? joglLib.getName() : joglLib.getAbsolutePath());
|
||||
}
|
||||
FileOutputStream fos = new FileOutputStream(method1448(this.gameName, this.anInt1215, joglAwt));
|
||||
fos.write(bs);
|
||||
fos.flush();
|
||||
fos.close();
|
||||
bs = CacheIndex.libIndex.getFile(archive, 1);
|
||||
if (bs == null || bs.length < 1) {
|
||||
System.err.println("Could not create native lib " + jogl + ", archive=" + archive + "!");
|
||||
return;
|
||||
|
||||
try (InputStream in = getClass().getResourceAsStream("/lib/" + awt); OutputStream out = openOutputStream(awtLib)) {
|
||||
if (in == null) throw new FileNotFoundException("Needed library does not exist: " + awt);
|
||||
copyFile(in, out);
|
||||
filenames.add(isWindowsOrMac ? awtLib.getName() : awtLib.getAbsolutePath());
|
||||
}
|
||||
fos = new FileOutputStream(method1448(this.gameName, this.anInt1215, jogl));
|
||||
fos.write(bs);
|
||||
fos.flush();
|
||||
fos.close();
|
||||
if (archive > 3) {
|
||||
bs = CacheIndex.libIndex.getFile(archive, 2);
|
||||
if (bs == null || bs.length < 1) {
|
||||
System.err.println("Could not create native lib libgluegen-rt.so, archive=" + archive + "!");
|
||||
return;
|
||||
|
||||
if (isGluegenRequired) {
|
||||
File glueLib = File.createTempFile("libgluegen", ".so");
|
||||
try (InputStream in = getClass().getResourceAsStream("/lib/" + glueGen); OutputStream out = openOutputStream(glueLib)) {
|
||||
if (in == null) throw new FileNotFoundException("Needed library does not exist: " + glueGen);
|
||||
copyFile(in, out);
|
||||
filenames.add(glueLib.getAbsolutePath());
|
||||
}
|
||||
fos = new FileOutputStream(method1448(this.gameName, this.anInt1215, "libgluegen-rt.so"));
|
||||
fos.write(bs);
|
||||
fos.flush();
|
||||
fos.close();
|
||||
}
|
||||
|
||||
|
||||
return filenames.toArray(new String[]{});
|
||||
}
|
||||
|
||||
public final Class64 method1444(int var1, Class var2) {
|
||||
|
|
@ -638,4 +661,31 @@ public class Signlink implements Runnable {
|
|||
|
||||
return this.method1435(5, 0, null, 0);
|
||||
}
|
||||
|
||||
private static FileOutputStream openOutputStream(final File file) throws IOException {
|
||||
if (file.exists()) {
|
||||
if (file.isDirectory()) {
|
||||
throw new IOException("File '" + file + "' exists but is a directory");
|
||||
}
|
||||
if (!file.canWrite()) {
|
||||
throw new IOException("File '" + file + "' cannot be written to");
|
||||
}
|
||||
} else {
|
||||
final File parent = file.getParentFile();
|
||||
if (parent != null) {
|
||||
if (!parent.mkdirs() && !parent.isDirectory()) {
|
||||
throw new IOException("Directory '" + parent + "' could not be created");
|
||||
}
|
||||
}
|
||||
}
|
||||
return new FileOutputStream(file);
|
||||
}
|
||||
|
||||
private static void copyFile(final InputStream input, final OutputStream output) throws IOException {
|
||||
byte[] buffer = new byte[1024 * 4];
|
||||
int n;
|
||||
while (-1 != (n = input.read(buffer))) {
|
||||
output.write(buffer, 0, n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import org.rs09.client.config.GameConfig
|
|||
import org.rs09.client.rendering.RenderingUtils
|
||||
import org.rs09.client.rendering.Toolkit
|
||||
import org.runite.client.*
|
||||
import java.lang.Exception
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
object SlayerTracker {
|
||||
|
|
@ -145,6 +146,6 @@ object SlayerTracker {
|
|||
}
|
||||
|
||||
curSprite = sprite
|
||||
} catch (ignored: Exception){ }
|
||||
} catch (ignored: Exception){}
|
||||
}
|
||||
}
|
||||
BIN
Client/src/main/resources/lib/jogl_32.dll
Normal file
BIN
Client/src/main/resources/lib/jogl_32.dll
Normal file
Binary file not shown.
BIN
Client/src/main/resources/lib/jogl_64.dll
Normal file
BIN
Client/src/main/resources/lib/jogl_64.dll
Normal file
Binary file not shown.
BIN
Client/src/main/resources/lib/jogl_awt_32.dll
Normal file
BIN
Client/src/main/resources/lib/jogl_awt_32.dll
Normal file
Binary file not shown.
BIN
Client/src/main/resources/lib/jogl_awt_64.dll
Normal file
BIN
Client/src/main/resources/lib/jogl_awt_64.dll
Normal file
Binary file not shown.
BIN
Client/src/main/resources/lib/libgluegen-rt_32.so
Normal file
BIN
Client/src/main/resources/lib/libgluegen-rt_32.so
Normal file
Binary file not shown.
BIN
Client/src/main/resources/lib/libgluegen-rt_64.so
Normal file
BIN
Client/src/main/resources/lib/libgluegen-rt_64.so
Normal file
Binary file not shown.
BIN
Client/src/main/resources/lib/libjogl_32.jnilib
Normal file
BIN
Client/src/main/resources/lib/libjogl_32.jnilib
Normal file
Binary file not shown.
BIN
Client/src/main/resources/lib/libjogl_32.so
Normal file
BIN
Client/src/main/resources/lib/libjogl_32.so
Normal file
Binary file not shown.
BIN
Client/src/main/resources/lib/libjogl_64.jnilib
Normal file
BIN
Client/src/main/resources/lib/libjogl_64.jnilib
Normal file
Binary file not shown.
BIN
Client/src/main/resources/lib/libjogl_64.so
Normal file
BIN
Client/src/main/resources/lib/libjogl_64.so
Normal file
Binary file not shown.
BIN
Client/src/main/resources/lib/libjogl_awt_32.jnilib
Normal file
BIN
Client/src/main/resources/lib/libjogl_awt_32.jnilib
Normal file
Binary file not shown.
BIN
Client/src/main/resources/lib/libjogl_awt_32.so
Normal file
BIN
Client/src/main/resources/lib/libjogl_awt_32.so
Normal file
Binary file not shown.
BIN
Client/src/main/resources/lib/libjogl_awt_64.jnilib
Normal file
BIN
Client/src/main/resources/lib/libjogl_awt_64.jnilib
Normal file
Binary file not shown.
BIN
Client/src/main/resources/lib/libjogl_awt_64.so
Normal file
BIN
Client/src/main/resources/lib/libjogl_awt_64.so
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue