Merge pull request #960 from Lucwousin/reeeee-facts-boi
RSClient: More refactoring
This commit is contained in:
@@ -94,7 +94,7 @@ public class ClassFile
|
||||
|
||||
public void accept(ClassVisitor visitor)
|
||||
{
|
||||
String[] ints = interfaces.getInterfaces().stream().map(i -> i.getName()).toArray(String[]::new);
|
||||
String[] ints = interfaces.getInterfaces().stream().map(Class::getName).toArray(String[]::new);
|
||||
|
||||
visitor.visit(version, access, name.getName(), null, super_class.getName(), ints);
|
||||
visitor.visitSource(source, null);
|
||||
@@ -113,7 +113,7 @@ public class ClassFile
|
||||
|
||||
for (Method method : methods)
|
||||
{
|
||||
String[] exceptions = method.getExceptions().getExceptions().stream().map(cl -> cl.getName()).toArray(String[]::new);
|
||||
String[] exceptions = method.getExceptions().getExceptions().stream().map(Class::getName).toArray(String[]::new);
|
||||
if (exceptions.length == 0)
|
||||
{
|
||||
exceptions = null;
|
||||
@@ -294,6 +294,20 @@ public class ClassFile
|
||||
return null;
|
||||
}
|
||||
|
||||
public Method findStaticMethod(String name, Signature type)
|
||||
{
|
||||
for (Method m : methods)
|
||||
{
|
||||
if (m.isStatic() &&
|
||||
m.getName().equals(name) &&
|
||||
m.getDescriptor().equals(type))
|
||||
{
|
||||
return m;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Method findMethod(String name)
|
||||
{
|
||||
for (Method m : methods)
|
||||
@@ -306,6 +320,18 @@ public class ClassFile
|
||||
return null;
|
||||
}
|
||||
|
||||
public Method findStaticMethod(String name)
|
||||
{
|
||||
for (Method m : methods)
|
||||
{
|
||||
if (m.isStatic() && m.getName().equals(name))
|
||||
{
|
||||
return m;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Method findMethodDeep(String name, Signature type)
|
||||
{
|
||||
Method m = findMethod(name, type);
|
||||
@@ -325,8 +351,8 @@ public class ClassFile
|
||||
|
||||
public Method findMethodDeepStatic(String name, Signature type)
|
||||
{
|
||||
Method m = findMethod(name, type);
|
||||
if (m != null && m.isStatic())
|
||||
Method m = findStaticMethod(name, type);
|
||||
if (m != null)
|
||||
{
|
||||
return m;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.runelite.asm.attributes.Code;
|
||||
import net.runelite.asm.signature.Signature;
|
||||
|
||||
public class ClassGroup
|
||||
{
|
||||
@@ -107,4 +108,38 @@ public class ClassGroup
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Method findStaticMethod(String name, Signature type)
|
||||
{
|
||||
Method m = null;
|
||||
|
||||
for (ClassFile cf : classes)
|
||||
{
|
||||
m = cf.findStaticMethod(name, type);
|
||||
|
||||
if (m != null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
public Method findStaticMethod(String name)
|
||||
{
|
||||
Method m = null;
|
||||
|
||||
for (ClassFile cf : classes)
|
||||
{
|
||||
m = cf.findStaticMethod(name);
|
||||
|
||||
if (m != null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ public enum ScriptOpcode
|
||||
CC_RESUME_PAUSEBUTTON(1121),
|
||||
CC_SETFILLCOLOUR(1123),
|
||||
CC_SETLINEDIRECTION(1126),
|
||||
CC_SETMODELTRANSPARENT(1127),
|
||||
CC_SETOBJECT(1200),
|
||||
CC_SETNPCHEAD(1201),
|
||||
CC_SETPLAYERHEAD_SELF(1202),
|
||||
@@ -86,6 +87,12 @@ public enum ScriptOpcode
|
||||
CC_SETOPBASE(1305),
|
||||
CC_SETTARGETVERB(1306),
|
||||
CC_CLEAROPS(1307),
|
||||
CC_SETOPKEY(1350),
|
||||
CC_SETOPTKEY(1351),
|
||||
CC_SETOPKEYRATE(1352),
|
||||
CC_SETOPTKEYRATE(1353),
|
||||
CC_SETOPKEYIGNOREHELD(1354),
|
||||
CC_SETOPTKEYIGNOREHELD(1355),
|
||||
CC_SETONCLICK(1400),
|
||||
CC_SETONHOLD(1401),
|
||||
CC_SETONRELEASE(1402),
|
||||
@@ -130,6 +137,7 @@ public enum ScriptOpcode
|
||||
CC_GETTRANS(1609),
|
||||
CC_GETCOLOUR(1611),
|
||||
CC_GETFILLCOLOUR(1612),
|
||||
CC_GETMODELTRANSPARENT(1614),
|
||||
CC_GETINVOBJECT(1700),
|
||||
CC_GETINVCOUNT(1701),
|
||||
CC_GETID(1702),
|
||||
@@ -228,6 +236,7 @@ public enum ScriptOpcode
|
||||
IF_GETTRANS(2609),
|
||||
IF_GETCOLOUR(2611),
|
||||
IF_GETFILLCOLOUR(2612),
|
||||
IF_GETMODELTRANSPARENT(2614),
|
||||
IF_GETINVOBJECT(2700),
|
||||
IF_GETINVCOUNT(2701),
|
||||
IF_HASSUB(2702),
|
||||
@@ -260,6 +269,9 @@ public enum ScriptOpcode
|
||||
GETTAPTODROP(3128),
|
||||
SETOCULUSORBSPEED(3129),
|
||||
GETCANVASSIZE(3132),
|
||||
MOBILE_SETFPS(3133),
|
||||
MOBILE_OPENSTORE(3134),
|
||||
MOBILE_OPENSTORECATEGORY(3135),
|
||||
SETHIDEUSERNAME(3141),
|
||||
GETHIDEUSERNAME(3142),
|
||||
SETREMEMBERUSERNAME(3143),
|
||||
@@ -444,6 +456,7 @@ public enum ScriptOpcode
|
||||
STRUCT_PARAM(6516),
|
||||
ON_MOBILE(6518),
|
||||
CLIENTTYPE(6519),
|
||||
MOBILE_KEYBOARDHIDE(6521),
|
||||
BATTERYLEVEL(6524),
|
||||
BATTERYCHARGING(6525),
|
||||
WIFIAVAILABLE(6526),
|
||||
@@ -480,7 +493,9 @@ public enum ScriptOpcode
|
||||
MEC_TEXT(6693),
|
||||
MEC_TEXTSIZE(6694),
|
||||
MEC_CATEGORY(6695),
|
||||
MEC_SPRITE(6696);
|
||||
MEC_SPRITE(6696),
|
||||
WORLDMAP_ELEMENT(6697),
|
||||
WORLDMAP_ELEMENTCOORD(6699);
|
||||
|
||||
public final int opcode;
|
||||
|
||||
|
||||
@@ -51,7 +51,17 @@ public class ParameterRenamer
|
||||
{
|
||||
for (Method sourceM : sourceCF.getMethods())
|
||||
{
|
||||
Method destM = (Method) mapping.get(sourceM);
|
||||
Method destM;
|
||||
if (sourceM.getName().equals("<init>"))
|
||||
{
|
||||
ClassFile destCF = (ClassFile) mapping.get(sourceCF);
|
||||
destM = destCF.findMethod("<init>", sourceM.getDescriptor());
|
||||
}
|
||||
else
|
||||
{
|
||||
destM = (Method) mapping.get(sourceM);
|
||||
}
|
||||
|
||||
if (sourceM.getParameters() != null && !sourceM.getParameters().isEmpty() && destM.getParameters().size() >= 1)
|
||||
{
|
||||
List<Parameter> oldParams = destM.getParameters();
|
||||
|
||||
Reference in New Issue
Block a user