From: traveler
if that not how reflection works, then answer this. why do all the other reflection style bots do it?
Traveler, I am going to ask this as sensitively as possible — do you know what you are talking about or are you just arguing because you don't want me to be right / you to be wrong?
HERE IS A BASIC REFLECTION NEED-TO-KNOW TUTORIAL:
SMART provides an interface to access fields inside the RS client.
What do I mean by fields? A field is a slot in a java class (known as a static field) or object (known as a instance field) that is akin to a "variable" in pascal. Fields are components of OOP (Object Oriented Programming) in the way that they are associated with the life of objects. Objects are instances of classes. So, all objects have their own copy of their instance fields, and all Classes have their own static fields. You can think of Objects/Classes as pascal records. Fields in Java have a type, just as in pascal. The important types are the primitive types (int, long, float, double, boolean) and object types (Any descendant of the java.lang.Object class, arrays, and enums (l2objectorientedprogramming)). Note that arrays are considered objects, but they are special in that they have numbered ordered slots of the type they are of. Multidimensional arrays in java are just arrays of array types.
How does SMART access fields? This is done with a 'path' which is sometimes loosely called a 'hook' although the process of 'hooking' is the process the updater uses to find the field in question. All of SMART's reflection methods provide at least two arguments, the 'parent' and the 'path'. A parent can be an object reference, or zero. All basic hooks use zero as the parent, and this means that the path starts from the static domain. If the parent is nonzero (i.e. an object reference) then the path starts from inside that object's domain.
What is a 'path'? It is basically a roadmap to a field. The path is delimited by a period, and each element is the name of SOMETHING in the RS client (the meaning of that something can change periodically). When in the Static Domain, the first element of the path is a class name, i.e. the class to start in. The following element is the name of some static field in that class. Static Domain paths must always have these two elements. Any following elements in the path are applied sequentially in depth to the current object by accessing a field in that object. For instance the path "lol.hai.wat.win" will get the object out of class lol in the static field hai, then get the object from inside hai in the field wat, then get the value of the field win in the object that was in wat. The values of the fields must be objects if there are more elements remaining in the path, otherwise an error value will be returned because only objects have fields.
What about the non static domain? If the 'parent' is nonzero then the path starts in the current object. This was made so that the reflection methods can cache objects and access their values more quickly/efficiently. In this domain, all of the elements of the path are sequential-depth fields pulling a value out of the field of the current object. So if the parent was an object reference (It must be, otherwise it might crash SMART), and the path is "whatsup" then SMART will return the value of the field whatsup in the object. The path "whatsup.nuthin" will return the value of the field nuthin in the object in the field whatsup in the parent reference. You see?
If you're interested, this code is open source in my repository and is how SMART accomplishes this:
public Object findObjectFromPath(Object o, String path) throws Exception {
String[] parts = path.split("\\.");
Stack<String> stack = new Stack<String>();
Field field;
if (o == null) {
Class c = gameLoader.loadClass(parts[0]);
for (int i = parts.length - 1; i > 0; i--) {
stack.push(parts[i]);
}
field = c.getDeclaredField(stack.pop());
field.setAccessible(true);
o = field.get(null);
} else {
for (int i = parts.length - 1; i >= 0; i--) {
stack.push(parts[i]);
}
}
if (!stack.empty()) {
while (!stack.empty()) {
String theField = stack.pop();
Class theClass = o.getClass();
field = null;
while (field == null && theClass != Object.class) {
try {
field = theClass.getDeclaredField(theField);
} catch (Exception e) {
try {
theClass = theClass.getSuperclass();
} catch (Exception x) {
break;
}
}
}
field.setAccessible(true);
o = field.get(o);
}
}
return o;
}
Why so many different methods? Well, the path and parent procedure is the same for all methods (the one above), but since fields can be of many different type, I needed to include a method for each different possible return type. Use the right ones. I also included convenience methods related to arrays that allow you to automatically access their indexes and return the value at that point.
What should I watch out for? Objects. The damn things can leak memory if you don't free them. Any SMART method that returns an object reference REQUIRES that the reference be freed. There also appears to be a bug in the JVM that makes it unable to access many objects very quickly without crashing. This only seems to happen when objects are used VERY quickly, though, and has nothing to do with the number used over a long period of time. Also, invalid object references passed to SMART can cause the JVM to crash. Be sure, as well, to use the appropriate return type method for the value of the field/arrayindex you want to return.
…
So, traveler, to answer your question, this is not how all other reflection style bots do it. The same algorithms can be applied, but the ALGORITHMS for doing stuff are written in pascal and use the above interface to access data in the client. Cstrike did not understand this, and now, hopefully, you can see why adding a "method to find interfaces x/y coords" makes no sense. That should be written in pascal / whatever else uses SMART's interface.
E: I posted this in a thread in the reflection section as well. If you have questions/comments ask them there.