Skip to content

Commit

Permalink
Added hardReset() exported at SmartHardReset() which will kill the cl…
Browse files Browse the repository at this point in the history
…ient, free the jvm, and reset the SMART dll to it's initial state. v6.9b
  • Loading branch information
BenLand100 committed Nov 10, 2011
1 parent a94decc commit 9b05936
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ using namespace std;
//Export list for the SCAR/Simba plugin loaders
static char* exports[] = {
(char*)"std_setup", (char*)"procedure SmartSetup(root, params: String; width, height: Integer; initseq: String);",
(char*)"std_hardReset", (char*)"procedure SmartHardReset();",
(char*)"std_setJVMPath", (char*)"procedure SmartSetJVMPath(path: String);",
(char*)"std_setMaxJVMMem", (char*)"procedure SmartSetMaxJVMMem(mb: integer);",
#ifdef WINDOWS
Expand Down Expand Up @@ -114,7 +115,7 @@ static char* exports[] = {

#ifdef LINUX

#define NumExports 78
#define NumExports 79

//STDCALL - SCAR/Simba
long GetFunctionCount() {
Expand Down Expand Up @@ -149,7 +150,7 @@ void unload(void) {

#ifdef WINDOWS

#define NumExports 80
#define NumExports 81

HMODULE dllinst;

Expand Down
5 changes: 5 additions & 0 deletions src/STD_Wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ void std_setup(char* root, char* args, long w, long h, char* initseq) {
setup(root, args, w, h, initseq);
}

void std_hardReset() {
hardReset();
}



//from Reflection.cpp

Expand Down
1 change: 1 addition & 0 deletions src/STD_Wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ extern "C" bool std_isBlocking() __attribute__((stdcall));
extern "C" long std_getRefresh() __attribute__((stdcall));
extern "C" void std_setRefresh(long x) __attribute__((stdcall));
extern "C" void std_setup(char*,char*,long,long,char*) __attribute__((stdcall));
extern "C" void std_hardReset() __attribute__((stdcall));

//from Reflection.h

Expand Down
13 changes: 13 additions & 0 deletions src/Smart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,19 @@ void setup(char* root, char* params, long width, long height, char* initseq) {
}
}

void hardReset() {
vm->AttachCurrentThreadAsDaemon((void**)&jre, 0);
clearOld();
free(curserver);
free(curparams);
curserver = (char*) malloc(1);
*curserver = 0;
curparams = (char*) malloc(1);
*curparams = 0;
jre = 0;
vm = 0;
}

//Called at Library loading to ensure a 'neat' state since initilizers might not always get run
void internalConstructor() {
curserver = (char*) malloc(1);
Expand Down
2 changes: 2 additions & 0 deletions src/Smart.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ extern "C" bool isBlocking() __attribute__((cdecl));
extern "C" long getRefresh() __attribute__((cdecl));
extern "C" void setRefresh(long x) __attribute__((cdecl));
extern "C" void setup(char*,char*,long,long,char*) __attribute__((cdecl));
extern "C" void hardReset() __attribute__((cdecl));


#endif /* _SMART_H */

2 changes: 1 addition & 1 deletion src/smart/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
*/
public class Client implements ActionListener, ChangeListener {

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

//mantains a list of classloader strings and clients associated with it
Expand Down
24 changes: 17 additions & 7 deletions test-apps/test-python.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ def setRefresh(self, x):
def setup(self, root, args, w, h, initseq):
"""(Re)Initilizes SMART with the given arguments."""
self._dll.setup(root, args, w, h, initseq)

def hardReset(self):
"""Returns the value of the FPS slider."""

This comment has been minimized.

Copy link
@Nava2

Nava2 Nov 12, 2011

o rly?

self._dll.hardReset()

#from Reflection.cpp

Expand Down Expand Up @@ -603,10 +607,16 @@ def findColorSpiralTol(self, x, y, color, xs, ys, xe, ye, tol):
return None

if __name__ == "__main__":
smart = Smart('http://world19.runescape.com/', ',f5', 765, 503, '')
import time
import random
while True:
time.sleep(1)
smart.windMouse(int(random.random()*700),int(random.random()*500))

smart = Smart('http://world19.runescape.com/', ',f5', 765, 503, '')
import time
from threading import *
t = Timer(10.0, smart.hardReset)
t.start()
time.sleep(50)



#import random
#while True:
# time.sleep(1)
# smart.windMouse(int(random.random()*700),int(random.random()*500))

0 comments on commit 9b05936

Please sign in to comment.