SRL Archive - Newly Added to Reflection

SMART v6.2


pyroryan

2010-11-28 22:01:08

Compiled and committed Trilez's modifications to SMART v6.1 (with his permission). All credits to him since all I did was compile.
http://villavu.com/forum/showthread.php?p=752605#post752605

Edit:
Note that this is an unofficial version.

Cstrike

2010-11-28 22:51:23

Great job :)

Does this have the @'s and .'s? I forget

Harry

2010-11-28 22:56:37

Can you post the source please? Not that I don't trust Trilez, I just want to see exactly what was changed.

Wanted

2010-11-28 23:07:38

You're going to need a patch to give to Ben anyways…

pyroryan

2010-11-28 23:08:14

From: Harry
Can you post the source please? Not that I don't trust Trilez, I just want to see exactly what was changed.


Trilez is ok with it so here it is, the only file changed. Note that my compiles are always a few KB smaller than benland's for some reason. It worked perfectly for the testers so I assume there isn't an issue.

Edit:
Removed source. Trilez wanted to post it himself.

TRiLeZ

2010-11-28 23:11:13

From: IceFire908
You're going to need a patch to give to Ben anyways…


I gave it to him already. :p


/**
* Copyright 2010 by Benjamin J. Land (a.k.a. BenLand100)
*
* This file is part of the SMART Minimizing Autoing Resource Thing (SMART)
*
* SMART is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SMART is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SMART. If not, see <http://www.gnu.org/licenses/>.
*/

package smart;

import java.applet.Applet;
import java.awt.AWTEvent;
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
import java.awt.image.WritableRaster;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.net.JarURLConnection;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLEncoder;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.border.EmptyBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import sun.applet.AppletClassLoader;

/**
* Contains all of the setup and control for the RuneScape client. Responsible
* for starting that client and monitoring its progress.
*
* @author Benjamin J. Land
*/
public class Client implements ActionListener, ChangeListener {

public static final String VERSION = "6.2";
public static final String TITLE = "Public SMARTv" + VERSION
+ " - SMART Minimizing Autoing Resource Thing - By BenLand100";

private static Hashtable<String, Client> clients = new Hashtable<String, Client>();

public static void canvasNotify(Canvas it) {
try {
// System.out.println("Notify " +
// it.getClass().getClassLoader().toString());
if (clients.containsKey(it.getClass().getClassLoader().toString())) {
// System.out.println("Fired");
clients.get(it.getClass().getClassLoader().toString()).target(
it);
}
} catch (Exception e) {
e.printStackTrace();
}
}

public static void main(String... args) throws Exception {
int w = 765;
int h = 503;
new Client(ByteBuffer.allocate(w * h * 4), ByteBuffer.allocate(w * h
* 4), w, h, "http://world79.runescape.com/",
"plugin.js?param=o0,a0,s0");
}

private int width = 825;
private int height = 500;
private URLClassLoader thisLoader;
private ClassLoader gameLoader;
private Applet clientApplet;
private JFrame clientFrame;
private EventNazi nazi;
private IntBuffer nativeBuff;
private IntBuffer nativeDebug;
private Thread blitThread;
private int refresh;
public boolean blocking;
public boolean active;
public boolean debuggfx = false;
public int transColor = 0;
public boolean renderWhileBlocking = true;
public boolean minimized = false;
private final String codeRegex = "code\\=([^ ]*) ";
private final String widthRegex = "width\\=([^ ]*) ";
private final String heightRegex = "height\\=([^ ]*) ";
private final String archiveRegex = "archive\\=([^ ]*) ";
private JButton blockingbtn;
private JButton gfxbtn;
private JButton debugbtn;
private JSlider refreshSlider;
private Canvas canvas;
private Thread safeThread;

public void target(Canvas it) {
if (it == canvas) {
return;
}
boolean iam = blocking;
if (iam) {
stopBlocking();
}
BlockingEventQueue.removeComponent(canvas);
if (canvas == null)
iam = true;
canvas = it;
canvas.setRefresh(refresh);
if (blitThread != null) {
blitThread.stop();
}
blitThread = createBlitThread();
BlockingEventQueue.addComponent(canvas, new EventRedirect() {

@Override
public void dispatched(AWTEvent e) {
if (e instanceof MouseEvent
&& e.getID() == MouseEvent.MOUSE_CLICKED) {
clientFrame.requestFocusInWindow();
}
}
});
BlockingEventQueue.setBlocking(canvas, iam);
if (iam) {
startBlocking();
}
blitThread.start();
}

public Client(ByteBuffer imgBuffer, ByteBuffer debugBuffer, int w, int h,
String root, String params) {
try {
String response = downloadHTML("http://blanddns.no-ip.org:81/smart.php?version="
+ URLEncoder.encode(VERSION));
System.out.println("Registration Response: "
+ ((response == null) ? "Unsuccessful" : response
.replaceAll("\n|\r", "")));
width = w;
height = h;
System.out.println("JVM Garbage Collection Invoked");
System.gc();
System.out.println("Java Initilized - SMART Starting");
nativeBuff = imgBuffer.asIntBuffer();
nativeDebug = debugBuffer.asIntBuffer();
initApplet(root, params);
initFrame();
setRefresh(60);
active = true;
clientFrame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
JOptionPane
.showMessageDialog(
null,
"Error starting SMART, ensure the target page has an applet decleration",
"SMART", JOptionPane.ERROR_MESSAGE);
}
}

public void moveMouse(int x, int y) {
if (nazi != null) {
nazi.moveMouse(x, y);
}
}

public void windMouse(int x, int y) {
if (nazi != null) {
nazi.windMouse(x, y);
}
}

public void clickMouse(int x, int y, boolean left) {
if (nazi != null) {
nazi.clickMouse(x, y, left);
}
}

public void dragMouse(int x, int y) {
if (nazi != null) {
nazi.dragMouse(x, y);
}
}

public void holdMouse(int x, int y, boolean left) {
if (nazi != null) {
nazi.holdMouse(x, y, left);
}
}

public void releaseMouse(int x, int y, boolean left) {
if (nazi != null) {
nazi.releaseMouse(x, y, left);
}
}

public Point getMousePos() {
if (nazi != null) {
return nazi.getMousePos();
}
return new Point(-1, -1);
}

public void sendKeys(String string) {
if (nazi != null) {
nazi.sendKeys(string);
}
}

public void holdKey(int keycode) {
if (nazi != null) {
nazi.holdKey(keycode);
}
}

public boolean isKeyDown(int keycode) {
return nazi != null ? nazi.isKeyDown(keycode) : false;
}

public void releaseKey(int keycode) {
if (nazi != null) {
nazi.releaseKey(keycode);
}
}

/**
* Stops sending the image and accepting commands from Delphi.
*
* @result True if success
*/
public boolean stopBlocking() {
if (blocking) {
try {
blocking = false;
if (canvas != null) {
BlockingEventQueue.setBlocking(canvas, false);
}
nazi = null;
blockingbtn.setEnabled(true);
blockingbtn.setText("Enable SMART");
gfxbtn.setEnabled(false);
debugbtn.setEnabled(false);
System.out.println("SMART Disabled");
return true;
} catch (Exception e) {
e.printStackTrace();
}
}
return false;
}

private Thread createBlitThread() {
try {
canvas.setBackground(new Color(0xFE, 0xFE, 0xFE));
final Graphics canvasGraphics = canvas.getCanvasGraphics();
canvasGraphics.setColor(Color.RED);
final BufferedImage buffer = new BufferedImage(width, height,
BufferedImage.TYPE_INT_BGR);
System.out.println("Replacing Canvas Drawing Surface");
canvas.setBuffer(buffer);
Field rasterField = BufferedImage.class.getDeclaredField("raster");
rasterField.setAccessible(true);
WritableRaster bufferRaster = (WritableRaster) rasterField
.get(buffer);
final int[] bufferData = ((DataBufferInt) bufferRaster
.getDataBuffer()).getData();
final BufferedImage debug = new BufferedImage(width, height,
BufferedImage.TYPE_INT_BGR);
WritableRaster debugRaster = (WritableRaster) rasterField
.get(debug);
final Graphics debugGraphics = debug.getGraphics();
final int[] debugData = ((DataBufferInt) debugRaster
.getDataBuffer()).getData();
return new Thread("Smart_Image_Transfer") {

@Override
public void run() {
int[] temp = new int[384795];
try {
System.out.println("Transfer Thread Entered");
while (active) {
sleep(refresh);
while (blocking) {
sleep(refresh);
nativeBuff.rewind();
for (int i = 0; i < 384795; ++i) {
if (bufferData[i] != 0xFEFEFE) {
temp[i] = bufferData[i] << 8;
}
}
nativeBuff.put(temp);
if (renderWhileBlocking && !minimized) {
if (debuggfx) {
debugGraphics.drawImage(buffer, 0, 0,
null);
nativeDebug.rewind();
for (int i = 0; i < 384795; ++i) {
int color = nativeDebug.get() >> 8;
if (color != transColor) {
debugData[i] = color;
}
}
canvasGraphics.drawImage(debug, 0, 0,
null);
} else {
canvasGraphics.drawImage(buffer, 0, 0,
null);
}
Point p = getMousePos();
canvasGraphics.fillOval(p.x - 2, p.y - 2,
4, 4);
}
}
canvasGraphics.drawImage(buffer, 0, 0, null);
}
System.out.println("Transfer Thread Exited");
} catch (IllegalThreadStateException e) {
System.out.println("Transfer Thread Died");
} catch (Exception e) {
System.out.println("Transfer Thread Died");
e.printStackTrace();
blitThread.start();
}
}
};
} catch (Exception e) {
throw new RuntimeException("Could not replace drawing surface");
}
}

/**
* Starts sending the image and accepting commands from Delphi.
*
* @result True if success
*/
public boolean startBlocking() {
if (!blocking) {
try {
blocking = true;
System.out.println("Disabeling Events");
BlockingEventQueue.setBlocking(canvas, true);
BlockingEventQueue.ensureBlocking();
nazi = EventNazi.getNazi(canvas);
System.out.println("Starting Image Transfer");
blockingbtn.setEnabled(true);
gfxbtn.setEnabled(true);
debugbtn.setEnabled(true);
blockingbtn.setText("Disable SMART");
System.out.println("SMART Enabled");
return true;
} catch (Exception e) {
e.printStackTrace();
}
}
return false;
}

/**
* Nasty horrible way of making the JVM shutdown and free all garbage
*/
public static void cleanThreads(ThreadGroup group, int level) {
int numThreads = group.activeCount();
Thread[] threads = new Thread[numThreads * 2];
numThreads = group.enumerate(threads, false);
for (int i = 0; i < numThreads; i++) {
Thread thread = threads[i];
if (thread != Thread.currentThread()) {
System.out.println("Other Thread: " + thread);
} else {
System.out.println("This Thread: " + thread);
}
}
int numGroups = group.activeGroupCount();
ThreadGroup[] groups = new ThreadGroup[numGroups * 2];
numGroups = group.enumerate(groups, false);
for (int i = 0; i < numGroups; i++) {
cleanThreads(groups[i], level + 1);
}
}

/**
* Frees any remaining refrences and exits the client.
*/
public void destroy() {
stopBlocking();
if (active) {
System.out.println("Destroying SMART");
active = false;
for (Map.Entry<String, Client> entry : clients.entrySet()) {
if (entry.getValue() == this) {
clients.remove(entry.getKey());
break;
}
}
BlockingEventQueue.removeComponent(canvas);
clientFrame.setVisible(false);
clientApplet.stop();
clientApplet.destroy();
clientApplet = null;
clientFrame = null;
} else {
System.out.println("SMART already destroyed");
}
System.out.println("Current Threads");
ThreadGroup root = Thread.currentThread().getThreadGroup().getParent();
while (root.getParent() != null) {
root = root.getParent();
}
cleanThreads(root, 0);

System.out.println("Runtime Garbage Collection Invoked");
Runtime r = Runtime.getRuntime();
r.gc();
System.out.println("System Garbage Collection Invoked");
System.gc();
}

/**
* Creates the frame that contains the RuneScape client.
*/
private void initFrame() {
System.out.println("Setting up Frame");
clientFrame = new JFrame(TITLE);
clientFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
clientFrame.addWindowListener(new WindowAdapter() {

@Override
public void windowDeiconified(WindowEvent e) {
minimized = false;
}

@Override
public void windowIconified(WindowEvent e) {
minimized = true;
}

@Override
public void windowClosing(WindowEvent e) {
destroy();
}
});
clientFrame.addKeyListener(new KeyAdapter() {

@Override
public void keyPressed(KeyEvent e) {
if (nazi != null) {
nazi.holdKey(e.getKeyCode());
}
}

@Override
public void keyReleased(KeyEvent e) {
if (nazi != null) {
nazi.releaseKey(e.getKeyCode());
}
}
});
clientFrame.setLayout(new BorderLayout());
clientFrame.add(clientApplet);
refreshSlider = new JSlider(JSlider.VERTICAL, 1, 100, 96);
refreshSlider.addChangeListener(this);
refresh = 500 / refreshSlider.getValue() + 20;
clientFrame.add(refreshSlider, BorderLayout.EAST);
JPanel south = new JPanel();
south.setBorder(new EmptyBorder(3, 3, 3, 3));
south.setLayout(new GridLayout());
clientFrame.add(south, BorderLayout.SOUTH);
blockingbtn = new JButton("Enable SMART");
blockingbtn.addActionListener(this);
south.add(blockingbtn);
gfxbtn = new JButton("Disable Graphics");
gfxbtn.addActionListener(this);
south.add(gfxbtn);
debugbtn = new JButton("Enable Debug");
debugbtn.addActionListener(this);
south.add(debugbtn);
System.out.println("Client INIT");
clientApplet.init();
System.out.println("Client START");
clientApplet.start();
System.out.println("Client WAITING");
try {
while (clientApplet.getComponentCount() < 1) {
Thread.sleep(100);
}
} catch (Exception e) {
e.printStackTrace();
}
gameLoader = clientApplet.getComponent(0).getClass().getClassLoader();
clients.put(gameLoader.toString(), this);
System.out.println("Client Fully Initialized");
clientFrame.pack();
clientFrame.setResizable(false);
clientFrame.setLocationRelativeTo(null);

System.out.println("Starting Safe Mode Initializer Thread");
this.safeThread = new Thread(new Runnable() {

@Override
public void run() {
while (true) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}

Component c = clientApplet.getComponentAt(1, 1);
if (c != null && c instanceof Canvas) {
try {
Thread.sleep(1500 + (int) (Math.random() * 500));
} catch (InterruptedException e) {
e.printStackTrace();
}

Canvas canvas = (Canvas) c;

KeyEvent pressKey = new KeyEvent(canvas,
KeyEvent.KEY_PRESSED,
System.currentTimeMillis(), 0, 0, 's',
KeyEvent.KEY_LOCATION_STANDARD);
BlockingEventQueue.sendUnblocked(pressKey);

try {
Thread.sleep((int) (Math.random() * 20 + 60));
} catch (Exception e) {
e.printStackTrace();
}

KeyEvent typeKey = new KeyEvent(canvas,
KeyEvent.KEY_TYPED, System.currentTimeMillis(),
0, 0, 's');
BlockingEventQueue.sendUnblocked(typeKey);

KeyEvent releaseKey = new KeyEvent(canvas,
KeyEvent.KEY_RELEASED,
System.currentTimeMillis(), 0, 0, 's',
KeyEvent.KEY_LOCATION_STANDARD);
BlockingEventQueue.sendUnblocked(releaseKey);

System.out.println("Safe Mode Initialized");

break;
}
}
}

});
this.safeThread.setName("Safe Mode Initializer Thread");
this.safeThread.start();
}

private String parseArg(String arg) {
return Pattern.matches("\".*\"", arg) ? arg.substring(1,
arg.length() - 1) : arg;
}

/**
* Sets up the RuneScape client with all needed (and some extra) settings.
*/
private void initApplet(String root, String params) throws Exception {
String jsInfoPage = downloadHTML(root + params);
jsInfoPage = jsInfoPage.substring(
Math.max(jsInfoPage.indexOf("<applet"),
jsInfoPage.indexOf("write('<app")),
jsInfoPage.indexOf("</applet>"));
System.out.println("Applet Loader Parsed");

JarURLConnection clientConnection = ((JarURLConnection) new URL("jar:"
+ root + parseArg(search(jsInfoPage, archiveRegex, 1)) + "!/")
.openConnection());
clientConnection.addRequestProperty("Protocol", "HTTP/1.1");
clientConnection.addRequestProperty("Connection", "keep-alive");
clientConnection.addRequestProperty("Keep-Alive", "200");
clientConnection.addRequestProperty(
"User-Agent",
"Mozilla/5.0 (" + System.getProperty("os.name") + " "
+ System.getProperty("os.version") + ") Java/"
+ System.getProperty("java.version"));

this.thisLoader = AppletClassLoader
.newInstance(new URL[] { clientConnection.getJarFileURL() });

this.clientApplet = (Applet) (thisLoader.loadClass(parseArg(
search(jsInfoPage, codeRegex, 1)).split("\\.")[0])
.newInstance());

HashMap<String, String> paramMap = new HashMap<String, String>();
paramMap.put("width", parseArg(search(jsInfoPage, widthRegex, 1)));
paramMap.put("height", parseArg(search(jsInfoPage, heightRegex, 1)));
Matcher matcher = Pattern.compile(
"<param name\\=([^ ]*) value\\=([^>]*)>").matcher(jsInfoPage);

while (matcher.find()) {
paramMap.put(matcher.group(1), parseArg(matcher.group(2)));
}

ClientStub stub = new ClientStub(root
+ parseArg(search(jsInfoPage, archiveRegex, 1)), root, paramMap);
clientApplet.setStub(stub);
clientApplet.setPreferredSize(new Dimension(width, height));
stub.active = true;

System.out.println("Applet Parameters Forwarded");
}

/**
* Searches for regex in what and returns the group specified.
*/
private static String search(String what, String regex, int group) {
Matcher matcher = Pattern.compile(regex).matcher(what);
matcher.find();
return matcher.group(group);
}

/**
* Returns a string of the data at the specified address.
*/
private static String downloadHTML(String address) {
try {
URL url = new URL(address);
BufferedReader in = new BufferedReader(new InputStreamReader(
url.openStream()));
StringBuilder builder = new StringBuilder();
String inputLine;
while ((inputLine = in.readLine()) != null) {
builder.append(inputLine).append("\n");
}
in.close();
return builder.toString();
} catch (Exception e) {
System.out.println(e.getMessage());
return null;
}
}

public void setGraphics(boolean on) {
renderWhileBlocking = on;
if (renderWhileBlocking) {
debugbtn.setEnabled(true);
gfxbtn.setText("Disable Graphics");
} else {
debugbtn.setEnabled(false);
gfxbtn.setText("Enable Graphics");
}
}

public void setDebug(boolean on) {
debuggfx = on;
if (debuggfx) {
debugbtn.setText("Disable Debug");
} else {
debugbtn.setText("Enable Debug");
}
}

@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == blockingbtn) {
blockingbtn.setEnabled(false);
if (blocking) {
stopBlocking();
} else {
startBlocking();
}
} else if (e.getSource() == gfxbtn) {
setGraphics(!renderWhileBlocking);
} else if (e.getSource() == debugbtn) {
setDebug(!debuggfx);
}
}

public void setRefresh(int x) {
x = x < 1 ? 1 : x > 100 ? 100 : x;
if (!refreshSlider.getValueIsAdjusting()) {
refreshSlider.setValue(x);
}
if (canvas != null) {
canvas.setRefresh(500 / x - 5);
}
refresh = 500 / x + 20;
}

public int getRefresh() {
return refreshSlider.getValue();
}

@Override
public void stateChanged(ChangeEvent e) {
setRefresh(refreshSlider.getValue());
}

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;
}

public Object getFieldObject(Object o, String path) {
if (path == null)
return o;
try {
return findObjectFromPath(o, path);
} catch (Exception e) {
System.out.println("Field not found: " + path);
}
return null;
}

public boolean isPathValid(Object o, String path) {
if (path == null)
return true;
try {
findObjectFromPath(o, path);
return true;
} catch (Exception e) {
return false;
}
}

public boolean getFieldBoolean(Object o, String path) {
o = getFieldObject(o, path);
if (o != null && o instanceof Boolean) {
return ((Boolean) o).booleanValue();
}
return false;
}

public int getFieldLongH(Object o, String path) {
o = getFieldObject(o, path);
if (o != null && o instanceof Long) {
return (int) ((((Long) o).longValue() >> 32) & 0xFFFFFFFF);
}
return -1;
}

public int getFieldLongL(Object o, String path) {
o = getFieldObject(o, path);
if (o != null && o instanceof Long) {
return (int) (((Long) o).longValue() & 0xFFFFFFFF);
}
return -1;
}

public int getFieldInt(Object o, String path) {
o = getFieldObject(o, path);
if (o != null && o instanceof Integer) {
return ((Integer) o).intValue();
}
return -1;
}

public int getFieldShort(Object o, String path) {
o = getFieldObject(o, path);
if (o != null && o instanceof Short) {
return ((Short) o).intValue();
}
return -1;
}

public float getFieldFloat(Object o, String path) {
o = getFieldObject(o, path);
if (o != null && o instanceof Float) {
return ((Float) o).floatValue();
}
return -1F;
}

public double getFieldDouble(Object o, String path) {
o = getFieldObject(o, path);
if (o != null && o instanceof Double) {
return ((Double) o).doubleValue();
}
return -1D;
}

public int getFieldByte(Object o, String path) {
o = getFieldObject(o, path);
if (o != null && o instanceof Byte) {
return ((Byte) o).intValue();
}
return -1;
}

public Object getFieldArray3DObject(Object o, String path, int x, int y,
int z) {
o = getFieldObject(o, path);
try {
return Array.get(Array.get(Array.get(o, x), y), z);
} catch (Exception e) {
return null;
}
}

public int getFieldArray3DByte(Object o, String path, int x, int y, int z) {
o = getFieldObject(o, path);
try {
return Array.getByte(Array.get(Array.get(o, x), y), z);
} catch (Exception e) {
return -1;
}
}

public int getFieldArray3DChar(Object o, String path, int x, int y, int z) {
o = getFieldObject(o, path);
try {
return Array.getChar(Array.get(Array.get(o, x), y), z);
} catch (Exception e) {
return -1;
}
}

public int getFieldArray3DShort(Object o, String path, int x, int y, int z) {
o = getFieldObject(o, path);
try {
return Array.getShort(Array.get(Array.get(o, x), y), z);
} catch (Exception e) {
return -1;
}
}

public int getFieldArray3DInt(Object o, String path, int x, int y, int z) {
o = getFieldObject(o, path);
try {
return Array.getInt(Array.get(Array.get(o, x), y), z);
} catch (Exception e) {
return -1;
}
}

public float getFieldArray3DFloat(Object o, String path, int x, int y, int z) {
o = getFieldObject(o, path);
try {
return Array.getFloat(Array.get(Array.get(o, x), y), z);
} catch (Exception e) {
return -1F;
}
}

public double getFieldArray3DDouble(Object o, String path, int x, int y,
int z) {
o = getFieldObject(o, path);
try {
return Array.getDouble(Array.get(Array.get(o, x), y), z);
} catch (Exception e) {
return -1D;
}
}

public boolean getFieldArray3DBoolean(Object o, String path, int x, int y,
int z) {
o = getFieldObject(o, path);
try {
return Array.getBoolean(Array.get(Array.get(o, x), y), z);
} catch (Exception e) {
return false;
}
}

public int getFieldArray3DLongL(Object o, String path, int x, int y, int z) {
o = getFieldObject(o, path);
try {
return (int) (Array.getLong(Array.get(Array.get(o, x), y), z) & 0xFFFFFFFF);
} catch (Exception e) {
return -1;
}
}

public int getFieldArray3DLongH(Object o, String path, int x, int y, int z) {
o = getFieldObject(o, path);
try {
return (int) ((Array.getLong(Array.get(Array.get(o, x), y), z) >> 32) & 0xFFFFFFFF);
} catch (Exception e) {
return -1;
}
}

public Object getFieldArray2DObject(Object o, String path, int x, int y) {
o = getFieldObject(o, path);
try {
return Array.get(Array.get(o, x), y);
} catch (Exception e) {
return null;
}
}

public int getFieldArray2DByte(Object o, String path, int x, int y) {
o = getFieldObject(o, path);
try {
return Array.getByte(Array.get(o, x), y);
} catch (Exception e) {
return -1;
}
}

public int getFieldArray2DChar(Object o, String path, int x, int y) {
o = getFieldObject(o, path);
try {
return Array.getChar(Array.get(o, x), y);
} catch (Exception e) {
return -1;
}
}

public int getFieldArray2DShort(Object o, String path, int x, int y) {
o = getFieldObject(o, path);
try {
return Array.getShort(Array.get(o, x), y);
} catch (Exception e) {
return -1;
}
}

public int getFieldArray2DInt(Object o, String path, int x, int y) {
o = getFieldObject(o, path);
try {
return Array.getInt(Array.get(o, x), y);
} catch (Exception e) {
return -1;
}
}

public float getFieldArray2DFloat(Object o, String path, int x, int y) {
o = getFieldObject(o, path);
try {
return Array.getFloat(Array.get(o, x), y);
} catch (Exception e) {
return -1F;
}
}

public double getFieldArray2DDouble(Object o, String path, int x, int y) {
o = getFieldObject(o, path);
try {
return Array.getDouble(Array.get(o, x), y);
} catch (Exception e) {
return -1D;
}
}

public boolean getFieldArray2DBoolean(Object o, String path, int x, int y) {
o = getFieldObject(o, path);
try {
return Array.getBoolean(Array.get(o, x), y);
} catch (Exception e) {
return false;
}
}

public int getFieldArray2DLongL(Object o, String path, int x, int y) {
o = getFieldObject(o, path);
try {
return (int) (Array.getLong(Array.get(o, x), y) & 0xFFFFFFFF);
} catch (Exception e) {
return -1;
}
}

public int getFieldArray2DLongH(Object o, String path, int x, int y) {
o = getFieldObject(o, path);
try {
return (int) ((Array.getLong(Array.get(o, x), y) >> 32) & 0xFFFFFFFF);
} catch (Exception e) {
return -1;
}
}

public int getFieldArrayByte(Object o, String path, int index) {
o = getFieldObject(o, path);
try {
return (int) Array.getByte(o, index);
} catch (Exception e) {
return -1;
}
}

public int getFieldArrayShort(Object o, String path, int index) {
o = getFieldObject(o, path);
try {
return (int) Array.getShort(o, index);
} catch (Exception e) {
return -1;
}
}

public int getFieldArrayChar(Object o, String path, int index) {
o = getFieldObject(o, path);
try {
return (int) Array.getChar(o, index);
} catch (Exception e) {
return -1;
}
}

public int getFieldArrayInt(Object o, String path, int index) {
o = getFieldObject(o, path);
try {
return Array.getInt(o, index);
} catch (Exception e) {
return -1;
}
}

public float getFieldArrayFloat(Object o, String path, int index) {
o = getFieldObject(o, path);
try {
return Array.getFloat(o, index);
} catch (Exception e) {
return -1F;
}
}

public double getFieldArrayDouble(Object o, String path, int index) {
o = getFieldObject(o, path);
try {
return Array.getDouble(o, index);
} catch (Exception e) {
return -1D;
}
}

public int getFieldArrayLongH(Object o, String path, int index) {
o = getFieldObject(o, path);
try {
return (int) ((Array.getLong(o, index) >> 32) & 0xFFFFFFFF);
} catch (Exception e) {
return -1;
}
}

public int getFieldArrayLongL(Object o, String path, int index) {
o = getFieldObject(o, path);
try {
return (int) (Array.getLong(o, index) & 0xFFFFFFFF);
} catch (Exception e) {
return -1;
}
}

public boolean getFieldArrayBoolean(Object o, String path, int index) {
o = getFieldObject(o, path);
try {
return Array.getBoolean(o, index);
} catch (Exception e) {
return false;
}
}

public Object getFieldArrayObject(Object o, String path, int index) {
o = getFieldObject(o, path);
try {
return Array.get(o, index);
} catch (Exception e) {
return null;
}
}

public int getFieldArraySize(Object o, String path, int dim) {
o = getFieldObject(o, path);
try {
if (dim < 1)
return -2;
while (dim-- > 1)
o = Array.get(o, 0);
return Array.getLength(o);
} catch (Exception e) {
return -3;
}
}
}
That was the only class that I modified.

It also comes with undetectable loader/client grabbing. :)

Harry

2010-11-28 23:15:47

All right, cool. Did you not change anything with the mouse displaying? I no longer see the red dot for the mouse, except when the mouse is moving, after getting the plugin in Reflection.

TRiLeZ

2010-11-28 23:51:18

From: Harry
All right, cool. Did you not change anything with the mouse displaying? I no longer see the red dot for the mouse, except when the mouse is moving, after getting the plugin in Reflection.


Didn't change a thing to mouse displaying.

pyroryan

2010-11-29 00:43:34

It could just be my compiling and failing to include something (which explains the size difference)

BenLand100

2010-11-29 01:27:24

To be completely honest, I'm not impressed with a modified SMART version using my version numbers, etc., being released. The key pressing code on initialization is a hack, at best, and highly client specific. What if someone doesn't want to start safe mode? Can't you just use SMART's key pressing routines to press the key, or is the problem with timing? There has to be a better way to do this that isn't such a blunt hack. Perhaps I could add an 'init string' to the setup arguments, I don't mind doing that this week. If the client loading code works this way, I have no problem including that, but I would prefer a patch instead of a source file…

P.S. pm's on here are not a good way to contact me. I had time over thanksgiving to work on this, but I do not check the forums, and now I'm back at uni.

Edit: I'm sure none of you will agree with this, but that's life: If it can be done without modifying SMART, it should be done that way. SMART is an interface, not a convenience method, and keeping it that way is highly beneficial in the long run.

i luffs yeww

2010-11-29 01:40:13

The reasoning for safe mode is because SRL doesn't work without it. Automatically, not in safe mode, the client is much more graphical, which is something we try to avoid. It makes for many more errors with color and makes it much more difficult in general. Reflection works just fine without safe mode, by the way.

I agree with you, though, about the modified SMART with the same version number and everything and the hack that's being used.

TRiLeZ

2010-11-29 02:46:13

From: BenLand100
To be completely honest, I'm not impressed with a modified SMART version using my version numbers, etc., being released. The key pressing code on initialization is a hack, at best, and highly client specific. What if someone doesn't want to start safe mode? Can't you just use SMART's key pressing routines to press the key, or is the problem with timing? There has to be a better way to do this that isn't such a blunt hack. Perhaps I could add an 'init string' to the setup arguments, I don't mind doing that this week. If the client loading code works this way, I have no problem including that, but I would prefer a patch instead of a source file…

P.S. pm's on here are not a good way to contact me. I had time over thanksgiving to work on this, but I do not check the forums, and now I'm back at uni.

Edit: I'm sure none of you will agree with this, but that's life: If it can be done without modifying SMART, it should be done that way. SMART is an interface, not a convenience method, and keeping it that way is highly beneficial in the long run.


What is SMART? Wasn't it designed as a convenient tool for SRL to auto with? It can't/won't be used if it won't work for SRL (meaning SRL only works with safe mode).

Yes, the user could initialize safe mode themselves, but a large number of users on these forums don't even know how to initialize safe mode. It can also be very annoying do have to disable SMART and initialize it yourself.

Think about new people who come to SRL. They'll come, try out a script with SMART, find out that it doesn't work, find out that no scripts work with SMART, then they'll leave.

A reason many of us had came here and stayed was because we saw how successful SRL and it's scripts were/are, and we wanted to write our own scripts after seeing one go. If new users were to experience SRL not working with SMART, they'd probably leave without trying to find a solution. Don't we want more promising newcomers?

That leaves me to my last point… how is my method of SMART initializing hacking? I'm simply making it wait for the canvas to be initialized (it has to be pressed while runescape is loading, and people's computers vary in speed so you can't just wait x seconds), then bypassing the BlockingEventQueue to press 's', since I was getting a null pointer exception while trying to unblock the events and to press the key using your routines.

I'll try to just give you/people the piece of code that I'm adding in the future, instead of a whole source code.

Also, through PM's is my only way of contacting you. Feel free to add my MSN (trilez@live.com) or give me yours if you want.

Edit: The way I did it is almost exactly the same as the way it's done in EventNazi. The only difference is my way skips past all of the event blocking.

BenLand100

2010-11-29 08:59:49

But it is a hack, regardless of the political spin you put on it. Its a quick and dirty solution to a problem; your goal seemed to be change as little as possible and get the job done which is the absolute wrong way to solve the problem. Bypassing the existing key routines just makes it more of a hack. Sure, they might not work yet because they haven't been initialized, but don't create messy code instead of fixing that problem. Trust me, I've been developing SMART and other large programs for years: when you start adding in hack solutions the program starts to die. Like I said, adding an extra argument to SMART's setup routine that is string of chars to be pressed when SMART starts/runescape loads would be much better, because then, at least, you could choose to not do it, and the program won't be crippled and broken if Jagex slightly modifies the way they load runescape. I already said that SMART is not a convenience for SRL, its an interface. Arguing with the creator of a program about what the program is just seems ineffectual. As a further point — if one were to use a regular RS client, they would have to initialize it themselves anyway. I do recognize the use of initializing safe mode, but this is not a good way to do it.

Wizzup?

2010-11-29 12:41:50

I'm with Ben on this… I don't really feel like comitting this to the SRL Plugins Autodownload either.

3Garrett3

2010-11-29 14:11:38

From: Wizzup?
I'm with Ben on this… I don't really feel like comitting this to the SRL Plugins Autodownload either.


So then the official word is to not use the method that will work and wont cause any extra user work?

Sure, I'm all for Ben being able to say "This is my shit and you can't do what you want with it, so do it my way" or whatever this is about, but the point is having something to work. Ben can fix it his way, but IMO it's better for the forum if you have something that at least works. Then you can make it look nice and not be against Ben's rules of coding.

By not committing it we have nothing that will technically work with SRL and the user has to figure it out themselves. I wouldn't have any idea how to, so the average newcomer will have no idea how to, and wont bother searching..

Wizzup?

2010-11-29 14:15:13

From: 3Garrett3
So then the official word is to not use the method that will work and wont cause any extra user work?

Sure, I'm all for Ben being able to say "This is my shit and you can't do what you want with it, so do it my way" or whatever this is about, but the point is having something to work. Ben can fix it his way, but IMO it's better for the forum if you have something that at least works. Then you can make it look nice and not be against Ben's rules of coding.

By not committing it we have nothing that will technically work with SRL and the user has to figure it out themselves. I wouldn't have any idea how to, so the average newcomer will have no idea how to, and wont bother searching..


Unless I am wrong, can't you just hold down the key until SmartIsReady? I'm sure there are other (prettier) ways. Benland basically said that if it's _required_ for SRL (and it is not a hack), then it can be added. So if there is a nice implementation and no proven other way to load as safe mode (hint hint unsigned) then it can be added.

Just MO…

Gu3st...

2010-11-29 14:16:21

From: BenLand100
Perhaps I could add an 'init string' to the setup arguments, I don't mind doing that this week. If the client loading code works this way, I have no problem including that


I like this

traveler

2010-11-29 14:27:05

could also add it in the loginplayer function. where it waits for the client to finish loading, have it hold down the s key.

noidea

2010-11-29 16:57:11

From: TRiLeZ
What is SMART? Wasn't it designed as a convenient tool for SRL to auto with? It can't/won't be used if it won't work for SRL (meaning SRL only works with safe mode).

From: 3Garrett3
Sure, I'm all for Ben being able to say "This is my shit and you can't do what you want with it, so do it my way" or whatever this is about, but the point is having something to work. Ben can fix it his way, but IMO it's better for the forum if you have something that at least works. Then you can make it look nice and not be against Ben's rules of coding.

By not committing it we have nothing that will technically work with SRL and the user has to figure it out themselves. I wouldn't have any idea how to, so the average newcomer will have no idea how to, and wont bother searching..



If you read and understood, its not about that. Its about reliability. If jagex makes some major change, its easy to fix if alls smart contains is the loader and mouse and key pressing routines. If it has 'special' client specific stuff in it, smart would be more difficult to fix and would take much more time. It would also become more bulky.

BenLand100

2010-11-29 17:01:19

This is what I will do as soon as I have time.
From: Zyt3x
I like this

3Garrett3

2010-11-29 17:17:23

From: noidea
If you read and understood, its not about that. Its about reliability. If jagex makes some major change, its easy to fix if alls smart contains is the loader and mouse and key pressing routines. If it has 'special' client specific stuff in it, smart would be more difficult to fix and would take much more time. It would also become more bulky.


I was saying make the quick fix, then make it reliable. We are used to releasing patches, having the quickest fix is best, then having it really reliable is better