SRL Archive - News and General

Probably possible: Smart threading.


Brandon

2011-07-25 18:27:45

K I somehow this weird idea came into my head about being able to use multi-threading with smart..

I mean smart is written in c++ and java so shouldn't smart be able to initialize a thread like Backgroundworker^ and then have simba send commands to smart who then gives the Backgroundworker.doWork() something to do?


So Simba Command -> Smart -> Smart's backgroundworker.dowork();


private: System::ComponentModel::BackgroundWorker^ Worker;

void InitializeComponent(void) //this would go in smart's source code itself.
{
this->Worker->DoWork += gcnew System::ComponentModel::DoWorkEventHandler(this, &Form1::Worker_DoWork);
}

//This would go in smart's source code itself..
private: System::Void Worker_DoWork(System::Object^ sender, System::ComponentModel::DoWorkEventArgs^ e) {
// [B]Work/comands to do here from SMART/Simba[/B]
}

Worker->RunWorkerAsync(); // Tells Smart's backgroundworker to do what it has been assigned.. could possibly implement this in simba?
Of course it's not going to be managed code though.. it would have to be Win32 API.. Don't think its cross platform either but most users use windows anyway so what do u guys think? Possible or no? Idea of making smart initialize the thread and have simba tell smart what to do with the thread..

masterBB

2011-07-25 18:36:04

I think so, but what kind of commands/uses do you have in mind for this thread?

E: I don't believe it's possible to tell the thread to do things like search for colors and such, since that is written in pascal.

grats

2011-07-25 18:40:52

From: masterBB
I think so, but what kind of commands/uses do you have in mind for this thread?

E: I don't believe it's possible to tell the thread to do things like search for colors and such, since that is written in pascal.


could have the thread do stuff like his SMARTchat plugin which types stuff.. so the bot can keep going and clicking as it's typing

Brandon

2011-07-25 18:59:55

From: masterBB
I think so, but what kind of commands/uses do you have in mind for this thread?

E: I don't believe it's possible to tell the thread to do things like search for colors and such, since that is written in pascal.



Source itself is in Smart.. and it definitely is C++ not pascal.. I believe wrappers or an interpreter was used to make simba tell smart to find colours..

Smart's Colour.Cpp file..

//Finds a color and returns the position --- historical
bool findColor(int& x, int& y, int color, int sx, int sy, int ex, int ey) {
sy *= width;
ey *= width;
for (int offset = sy; offset <= ey; offset += width) {
int end = ex + offset;
for (int i = sx + offset; i <= end; i++) {
if (target[i].color == color) {
x = i % width;
y = i / width;
return true;
}
}
}
x = -1;
y = -1;
return false;
}

//Finds a color given a tolerance and returns the position --- historical
bool findColorTol(int& x, int& y, int color, int sx, int sy, int ex, int ey, int tol) {
RGB find;
find.color = color;
sy *= width;
ey *= width;
for (int offset = sy; offset <= ey; offset += width) {
int end = ex + offset;
for (int i = sx + offset; i <= end; i++) {
if (cmpColors(target[i], find, tol)) {
x = i % width;
y = i / width;
return true;
}
}
}
x = -1;
y = -1;
return false;
}

masterBB

2011-07-25 19:19:47

//Finds a color and returns the position — historical


historical, like in never been used.

edit:
Benland made these color functions which where faster as the scar ones. I think they are also faster as the simba one. But they have never been used by simba. If you want to see the functions we use at the moment I suggest you look in to MML. We basically copy the client canvas as a bitmap, and search for colors on that bitmap.

From: grats
could have the thread do stuff like his SMARTchat plugin which types stuff.. so the bot can keep going and clicking as it's typing


But the typing we use for runescape client has certain random waits between each key it presses. Do you also want to implant such functions in SMART?

grats

2011-07-25 19:27:29

From: masterBB
historical, like in never been used.

edit:
Benland made these color functions which where faster as the scar ones. I think they are also faster as the simba one. But they have never been used by simba. If you want to see the functions we use at the moment I suggest you look in to MML. We basically copy the client canvas as a bitmap, and search for colors on that bitmap.



But the typing we use for runescape client has certain random waits between each key it presses. Do you also want to implant such functions in SMART?


his thing goes through simba, no? I figured it would be the same thing with the same waits since it all uses simba procedure stuff.. just on a different thread

idk how it works then

masterBB

2011-07-25 19:32:07

From: grats
his thing goes through simba, no? I figured it would be the same thing with the same waits since it all uses simba procedure stuff.. just on a different thread

idk how it works then


My wrong, SmartSendKeys(S); It has it own key sending proc.

Wizzup?

2011-07-25 19:36:32

From: masterBB
historical, like in never been used.

edit:
Benland made these color functions which where faster as the scar ones. I think they are also faster as the simba one. But they have never been used by simba. If you want to see the functions we use at the moment I suggest you look in to MML. We basically copy the client canvas as a bitmap, and search for colors on that bitmap.


When we use SMART, we don't copy data at all, we just directly read SMART's bitmap. :)

masterBB

2011-07-25 19:39:15

From: Wizzup?
When we use SMART, we don't copy data at all, we just directly read SMART's bitmap. :)


But we search for colors on that bitmap with functions from simba/mml right? So not the functions from SMART?

e:
used in the finding of the color:
PtrData := TClient(Client).IOManager.ReturnData(xs, ys, dX + 1, dY + 1);

Wouldn't this return a copy of the bitmap? Or does it just points towards the given points in SMART's bitmap?

Sorry for the questions and derailing the thread. But now I started reading the source…

mormonman

2011-07-25 22:11:53

I think perhaps this could be used with an onscreen paint? Is that what you wanted ggzz?

Brandon

2011-07-25 22:22:28

From: mormonman
I think perhaps this could be used with an onscreen paint? Is that what you wanted ggzz?


Yup.. Exactly. U send the data to the thread which paints in real time on smart.. I was only trying to see way of improving smart..

Such ways were: Forms on smart (with a handle.. was told its not possible atm) or using threading to have real time progress reports and multi-tasking.. This can actually do a lot more than just proggies :D

It seems possible to me but I don't know how simba works. I only know how smart and C++ works so if simba CAN actually send the commands to smart and smart give the work to the thread then it would actually be quite amazing. I think all my ideas are either just crazy or impossible to do :c

mormonman

2011-07-25 22:26:23

From: ggzz
Yup.. Exactly. U send the data to the thread which paints in real time on smart.. I was only trying to see way of improving smart..

Such ways were: Forms on smart (with a handle.. was told its not possible atm) or using threading to have real time progress reports and multi-tasking.. This can actually do a lot more than just proggies :D

It seems possible to me but I don't know how simba works. I only know how smart and C++ works so if simba CAN actually send the commands to smart and smart give the work to the thread then it would actually be quite amazing.


I think it should be possible, just use Java Graphics class. Send the text, other info to smart. would make the painting a little faster, but you would still have to call the function that sends the info to smart very often. With titan, paxCompiler is threadsafe which could help ;)

Coh3n

2011-07-25 23:00:38

Kind of off topic, but ggzz, you seem to know SMART's source pretty well. What I think needs to be done before something like multithreading is fixing the exception SMART throws if RS hasn't been loaded in a browser after an update. If that problem is fixed, SRL can easily be edited to run straight through updates (assuming the script is color).