Open-source multiplayer game server compatible with the RuneScape client
https://www.openrs2.org/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.2 KiB
47 lines
1.2 KiB
package dev.openrs2.bundler.transform;
|
|
|
|
import dev.openrs2.asm.classpath.ClassPath;
|
|
import dev.openrs2.asm.classpath.Library;
|
|
import dev.openrs2.asm.transform.Transformer;
|
|
import org.objectweb.asm.Opcodes;
|
|
import org.objectweb.asm.tree.ClassNode;
|
|
import org.objectweb.asm.tree.LdcInsnNode;
|
|
import org.objectweb.asm.tree.MethodNode;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
public final class CachePathTransformer extends Transformer {
|
|
private static final Logger logger = LoggerFactory.getLogger(CachePathTransformer.class);
|
|
|
|
private int paths;
|
|
|
|
@Override
|
|
protected void preTransform(ClassPath classPath) {
|
|
paths = 0;
|
|
}
|
|
|
|
@Override
|
|
protected boolean transformCode(ClassPath classPath, Library library, ClassNode clazz, MethodNode method) {
|
|
for (var insn : method.instructions) {
|
|
if (insn.getOpcode() != Opcodes.LDC) {
|
|
continue;
|
|
}
|
|
|
|
var ldc = (LdcInsnNode) insn;
|
|
if (ldc.cst.equals(".jagex_cache_") || ldc.cst.equals(".file_store_")) {
|
|
ldc.cst = ".openrs2_cache_";
|
|
paths++;
|
|
} else if (ldc.cst.equals("jagex_")) {
|
|
ldc.cst = ".openrs2_";
|
|
paths++;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
protected void postTransform(ClassPath classPath) {
|
|
logger.info("Updated {} cache paths", paths);
|
|
}
|
|
}
|
|
|