SRL Archive - C/C++ Help and Tutorials

Scar++


boberman

2008-05-10 17:18:06

Dev-C++ DevPak: Rev. 36

SVN: http://svn2.assembla.com/svn/ScarPP
Project Home: http://www.assembla.com/wiki/show/ScarPP


How to get it from the svn:
1. download SVN
2. make a directory that you want Scar++ to be in and go there from the terminal (click run, then type in "cmd" without the quotes. us cd to get to the directory you created)
3. type in "svn co http://svn2.assembla.com/svn/ScarPP"
4. profit? Your done, you should now have scar++

Demo Scar++ Program:
#include <Scar++.h>
#include <iostream>

using namespace std;

int main()
{
Scar setup;
cout << "I've got me a scar!\n";
while(true)
MoveMouseSmooth(rand(), rand());
return 0;
}

The easiest way to install Scar++ is to download the devpak and run it through dev-C++. Make sure that you go into Project->Project Options->Parameters and under linker you put -lScar++. It won't compile without that.

For all that wonder, Scar++ is an open source c++ library to try to aid users who are coming from scar to start to use c++. It is not an IDE or an interpreted language, it is c++ in all its glory.

For now, all functions are part of one giant Scar object. This was done as an attempt to let the auto complete functions of many c++ IDE's help in writing some excellent cheating programs. (as well as making the ++ justified, if it wasn't there then this would really be c :))

The first stage will be to mimic all the essential functions for cheating in runescape. This includes color finding, bitmap matching, and even the ability to map out letter and such. Mainly in this stage I am trying to get the project to the point where moving the SRL library into a c++ version will be a fairly trivial thing. I will not be adding functions that do tasks that are already vastly available to c++ (For example, string manipulation, Standard I/O, ect.) There are already vast libraries available to c++ so there is no reason to add these sorts of functions.

The second stage will be a refining stage. Somethings might not be done the fastest, so I will be reviewing what has been written and pulling out every trick I know of to increase the speed of the code and remove bugs (sometimes it takes many readings to remove bugs) No new functions will be added, the code will basically be in a frozen state.

The final stage will be to add some functions that I think should be in scar anyways, for example, PathFinding (one of the big reasons I took on this project). I will be open to extra suggestions at this point so suggestions will be welcome.

The final stage will span out indefinitely.

Right now the project is midway through stage 1. Many of the useful functions have been ported over (and there are quite a few that I expect will be done here quickly) As always, comments on the code or improvements you see fit are fully welcome. I hesitated to release the initial code, so don't make me regret it (so Please Participate if you can.)

Here is the link to the project Scar++ Revisions will be going up pretty dang fast (We are at 20 now) so if you are participating make sure you keep yourself up to date.

[ORIGINAL POST]
Would anyone be interested in a C++ version of scar? I have already started work on it (got the color converting functions and most of the mouse functions done) and was wondering if it would be interesting to anyone else.

It would not be a full IDE, just the library (well, most of the library) so it wouldn't have as much protection as scar has.

On the plus side, it should be pretty fast and extremely flexible (the whole reason I've started this project). Allowing users the full power of C++ and its associated compilers.

If you are interested, let me know. If you have suggestions I would love to hear them as well. If you would like to help, I would be happy to share what I have now and work with you to get there.

For any interested, I'm including a list a finished functions, if you want to help, go ahead an look up the scar manual and pick a function to port.
      void GetMousePos(int& x, int& y);
void MoveMouse(int x, int y);
void MoveMouseSmooth(int x, int y);
void MoveMouseSmoothEx(int x, int y, int minsleeptime = 1,
int maxsleeptime = 3, int maxdistance = 45,
int gravity = 20, int forces = 10);
void MoveMouseSmoothFrom(int x0, int y0, int x1, int y1);
void MoveMouseSmoothFromEx(int x0, int y0, int x1, int y1, int minsleeptime = 1,
int maxsleeptime = 3, int maxdistance = 45,
int gravity = 20, int forces = 10);
void MoveMouseSpline(int x, int y, int rx, int ry); // This function uses "MoveMouseSplineEx" so isn't really done, but once MoveMouseSplineEx is done it will be
void MoveMouseSplineFrom(int x0, int y0, int x1, int y1, int rx, int ry);
void MoveMouseSplineFromEx(int x0, int y0, int x1, int y1, int rx, int ry,
int mouseSpeed = 50, int ctrlSpacing = 30,
int ctrlVariance = 65);
void MouseBox(int x0, int y0, int x1, int y1);
void MoveMouseCC(int x, int y, int range, int segments, int pcount,
int delay);
void ClickMouse(int x, int y, bool Left);
void ClickMouseMid(int x, int y);
void ClickMouseSpline(int x, int y, int rx, int ry, bool Left);
void ClickMouseBox(int x0, int y0, int x1, int y1, bool Left);
void HoldMouse(int x, int y, bool Left);
void ReleaseMouse(int x, int y, bool Left);
void HoldMouseMid(int x, int y);
void ReleaseMouseMid(int x, int y);
bool IsMouseButtonDown(bool LeftButton);

void ColortoRGB(unsigned int color, int& R, int& G, int& B);
unsigned int RGBtoColor(int R, int G, int B);
void ColortoHSL(unsigned int color, double& H, double& S, double& L);
unsigned int HSLtoColor(double H, double S, double L);
void RGBtoHSL(int R, int G, int B, double& H, double& S, double& L);
void HSLtoRGB(double H, double S, double L, int& R, int& G, int& B);
void RGBtoXYZ(int R, int G, int B, double& X, double& Y, double& Z);
void XYZtoRGB(double X, double Y, double Z, int& R, int& G, int& B);
void ColortoXYZ(unsigned int color, double& X, double& Y, double& Z);
unsigned int XYZtoColor(double X, double Y, double Z);
void HSLtoXYZ(double H, double S, double L, double& X, double& Y, double& Z);
void XYZtoHSL(double X, double Y, double Z, double& H, double& S, double& L);
[/ORIGINAL POST]

R0b0t1

2008-05-10 19:43:10

Correction! I do not think you do


void GetMousePos(int &x, int &y);

but this


void GetMousePos(int *x, int *y);

and call it like


int x, y;

GetMousePos( &x, &y);

or just have it return a POINT.



And how you'd include them is by splitting them up into header files with the function prototypes, and then have .cpp files that include the function proto's and define the functions, so you'd just include the .cpp files. (Or just have the proto's + code in one header, but both mentioned ways are bad style)

boberman

2008-05-10 21:35:04

From: R0b0t1
Correction! I do not think you do


void GetMousePos(int &x, int &y);

but this


void GetMousePos(int *x, int *y);

and call it like


int x, y;

GetMousePos( &x, &y);

or just have it return a POINT.



And how you'd include them is by splitting them up into header files with the function prototypes, and then have .cpp files that include the function proto's and define the functions, so you'd just include the .cpp files. (Or just have the proto's + code in one header, but both mentioned ways are bad style)


:) thanks, but you're in my world now (Mu ha ha ha….). in C++ it is perfectly legal to do void thing(int& i) as a function call. basically that means that you are passing the variable by reference and not value. It is a good way to avoid pointer usage and avoids complicating things for the user. Essentially, it is like saying GetMousePos(var x, y : Integer);.

I've already made several separate files, I just included a copy of all the functions in those files. Currently I am using classes to make objects (not sure how much I like doing this as they are more like a bunch of functions and less like objects).

I want to make this as easy as possible transition from Scar to Scar++ so I have tried to keep the same function syntax for the most part.

Here might be an example of how my code would work

int main()
{
int x;
int y;

scar test;
test.mouse.GetMousePos(x, y);
test.mouse.MoveMouseSmooth(x + 10, y + 10);
}

I should note that I have already tested this and it works fine. :)

mastaraymond

2008-05-11 08:57:56

Scar is an interpeter I looked around and I didn't find any good C++ interpeters.. Did you have more luck?

boberman

2008-05-11 10:37:55

From: mastaraymond
Scar is an interpeter I looked around and I didn't find any good C++ interpeters.. Did you have more luck?


What do you mean by interpreter? The fact that it just translates the code to pascal?

once this is done, this will be an addition to a full blown computer language. It wont be interpreted (so you can still do whatever you want in c++). There are plenty of good C++ compilers and IDEs out there so I won't be dabbling with that, just the straight up code.

Here's a taste of what I have done so far maybe to give a feel for how this works. (You need to include the library file libScar++.a if you want to make a project based off of it) You should also note that this is still a work in progress. As a result, all functions with the word "Spline" in them, don't work. Everything else listed is done.

*THIS IS AN OLD VERSION OF SCAR, USE THE SVN! (I will not be constantly updating this)*

mixster

2008-05-11 11:07:14

Mastaraymond, I believe it is an include for a c++ application that has a Scar class that then has the Scar functions he has converted. It does sound cool, but I think it will probably be a long time until it will catch up with Scar as the more advanced functions will probably take a while to replicate, but if you do continue it that far, then it should provide a lot of benefits over Scar (mainly as it would be compiled and not interpreted, thus run much much quicker).

mastaraymond

2008-05-11 14:49:42

Whats the point then? Just make a dll like Cruel Lib..

I wanted to make this in Delphi once, but then the point came that you will have to distribute stuff in .exe since not everyone has a compiler.. Which can cause lots of problems, as you know .exe's can contain bad stuff.
On the otherside there are lots of c++ compilers which means this project probably has more luck in finishing, although this community is mostly pascal\delphi..

boberman

2008-05-11 18:09:39

From: mastaraymond
Whats the point then? Just make a dll like Cruel Lib..

I wanted to make this in Delphi once, but then the point came that you will have to distribute stuff in .exe since not everyone has a compiler.. Which can cause lots of problems, as you know .exe's can contain bad stuff.
On the otherside there are lots of c++ compilers which means this project probably has more luck in finishing, although this community is mostly pascal\delphi..


Its just as easy to put malicious code in a scar script as it is in C++. I would say that, pending the full version, all programs should have the source code with them, to at least give the person the ability to check it out and compile it for themselves. (and a bannable offense if it isn't included). That won't eliminate the threat of virii, but it will go a long ways to prevent them.

Scar still has its place, but I think the serious programmers will really appreciate the ability to use C++ in a similar way.

bullzeye95

2008-05-11 18:43:12

From: boberman
Its just as easy to put malicious code in a scar script as it is in C++.


Not really. SCAR is pretty limited to what it can do to a computer.

boberman

2008-05-11 19:39:46

From: bullzeye95
Not really. SCAR is pretty limited to what it can do to a computer.


Really? Can it access files and change data in them? That is all that is required for a language to be malicious, just because a language is simple doesn't mean it can't be dangerous, it just means someone wanting to be malicious has to go through one more hoop.

Heck, the fact that scar can open sockets, is enough for data to be stolen. If a user doesn't read the code it would be quite easy to hide a password stealer in scar. Heck, if you wanted to be ambitious you could store a malicious program in a string, write the string to a file, then edit the registry to run the file on start up, and boom, you have yourself a keylogger.

Don't get me wrong, that hasn't happened a whole lot with scar (that I know of) but that doesn't mean it isn't possible. The only reason C++ is potentially scarier is because it can compile the code to make it harder to read (hence the reason I suggest that not including the source code should be a bannable offense)

Don't believe me?

\/ DO NOT RUN THIS SCRIPT \/
   procedure ScrewUpComputer;
var a, b : Integer;
begin
b := RewriteFile('C:\Windows\system.ini', false);
a := 0;
Repeat
WriteFileString(b, 'Lol, I just screwed up youre computer! ');
a := a + 1;
Until (a > 100);
end;
/\ DO NOT RUN THIS SCRIPT! /\

Just a proof of concept, I guess scar warns you before you run it, but how many people just click through those popups anyways without reading them?

mastaraymond

2008-05-12 08:07:15

From: boberman
Really? Can it access files and change data in them? That is all that is required for a language to be malicious, just because a language is simple doesn't mean it can't be dangerous, it just means someone wanting to be malicious has to go through one more hoop.

Heck, the fact that scar can open sockets, is enough for data to be stolen. If a user doesn't read the code it would be quite easy to hide a password stealer in scar. Heck, if you wanted to be ambitious you could store a malicious program in a string, write the string to a file, then edit the registry to run the file on start up, and boom, you have yourself a keylogger.

Don't get me wrong, that hasn't happened a whole lot with scar (that I know of) but that doesn't mean it isn't possible. The only reason C++ is potentially scarier is because it can compile the code to make it harder to read (hence the reason I suggest that not including the source code should be a bannable offense)

Don't believe me?

\/ DO NOT RUN THIS SCRIPT \/
   procedure ScrewUpComputer;
var a, b : Integer;
begin
b := RewriteFile('C:\Windows\system.ini', false);
a := 0;
Repeat
WriteFileString(b, 'Lol, I just screwed up youre computer! ');
a := a + 1;
Until (a > 100);
end;
/\ DO NOT RUN THIS SCRIPT! /\

Just a proof of concept, I guess scar warns you before you run it, but how many people just click through those popups anyways without reading them?

Atleast it does warn.
Some people might click through, but most will stop..

.exe on the other hand can still do stuff like sending your rs + ip etc..

While scar does warn..

In scar you can't edit the registery..

Scar has lots of protections against this kind of stuff.. While .exe's don't have this.

Ever seen a .exe come up with a pop-up window asking to allow you to connect to a website? The only thing you can do is, turn your c++ thing into a .dll and let the user make his own scripts by publishing the source code and let the user compile it himself. Even this can be a bad sign since you can hide stuff in the source to..

Bobarkinator

2008-05-12 12:06:00

Not everyone has to have a compiler. If they don't trust the person then they don't have to use it. I personally think that this is a good idea. And I will definitely use it.

Yakman

2008-05-12 13:53:08

From: mastaraymond
I wanted to make this in Delphi once, but then the point came that you will have to distribute stuff in .exe since not everyone has a compiler.. Which can cause lots of problems, as you know .exe's can contain bad stuff.


so you destribute the source AND exectuable

so if you're suspicious, you can compile it yourself
if not, you just run the provided exe (people on this forum take this option, they cant see scar's source)


you might want to look at Not Quite C which is easier to make an interpreter for, and easier to use, so people new to programming might find it easier to start.

although i support this project 100%, i dont think it will do that well, since freddy1990 is quite opposed to any scar clones,

boberman

2008-05-12 15:22:04

Dang, I was hoping that he wouldn't be so opposed to something like this as some of the more complex functions will be beasts to tackle, (DTM and bitmap stuff that loads it from a string).

Ohh well, once I get all the easy functions out of the way Ill focus my efforts on the more difficult ones and then if I get really stuck I will see if I can't get some help from him (though, as you said, it isn't likely).

Right now, Im trying to decide how I want to implement MoveMouseSpline. There are several types of spline functions in math and it would just be a matter of choosing the right one. (Bezier Curves look like what I am shooting for), once that is done all the IO functions will be done.

I should say, that Really, I'm not far from completion. There are several functions that I probably wont implement just because they are heavily related to already existent, and very common, C++ functions. For example, FileIO and Console output. C++ has excellent resources for both of those and adding another layer would be pointless in my opinion (though if there is high demand I might). String manipulation is another area the C++ has LOADS of functions for, so I probably won't do anything there either.

Bobarkinator

2008-05-12 16:21:23

From: boberman


Right now, Im trying to decide how I want to implement MoveMouseSpline. There are several types of spline functions in math and it would just be a matter of choosing the right one. (Bezier Curves look like what I am shooting for), once that is done all the IO functions will be done.




Ben's mouse is the Bezier curve unless it changed. You should set up an SVN so that people like Yakman and others could try to help, unless you don't want to help.

boberman

2008-05-12 16:35:30

From: Bobarkinator
Ben's mouse is the Bezier curve unless it changed. You should set up an SVN so that people like Yakman and others could try to help, unless you don't want to help.


I have been debating over this issue (with myself of course). On the one hand, it would be nice to have others who can critque, add comments, and in general help polish out the code. On the other, Scar is really the creation of Freddy1990, and if I released to source I would feel like I was minimalizing his work. I dont know, maybe that isn't a good enough reason for not posting the code, Ill have to give it some more thought.

Having read that, Im open to your opinions. if you guys really think my logic on this one is scewed, let me know. (Of course, if Freddy tells me not to release the source, thats it, I won't do it. Ill still develop, but Ill respect his wishes on this issue).

As a side note, do you think sourceforge would host a project like this? Or are there some other free svn hosts available (I really don't want the hassle of maintaining a server, and I am cheap)

(Another reason I am reluctant to release the source is because that would mean that I need to start adding more comments… :) My code follows a school standard I learned pretty good, but I just never liked commenting code. It makes sense to me :))

Smartzkid

2008-05-12 19:09:43

1) Don't worry about Freddy, there's plenty of people here who aren't smart enough, don't have enough time, or will plain refuse to learn C++.

2) Setting up a SVN would definitely be wise; this would advance far faster.

3) RS cheating at a something of a rock bottom concerning new innovations; a new compiled alternative could give some new life to the scene.

4) If you release the code, I'll be able to figure out those little detailey things that you're 'supposed' to do, but nobody really tells you how to do. :)

EDIT:

From: mastaraymond
Ever seen a .exe come up with a pop-up window asking to allow you to connect to a website?


Yeah. It's called a firewall.

boberman

2008-05-12 21:07:27

I've created an SVN, but it will not be public. If you want to help out, send me a PM or respond here and Ill be glad to let you join. Ill ask you one simple question and if you pass it, you can join (it will be a basic C++ question, just somewhat of a filter, it will take about 10 secs for you to answer if you know c++)

*W00t added comments (oh the pain!) so at least someone might be able to figure this out*

Yakman

2008-05-13 07:04:36

From: boberman
Having read that, Im open to your opinions. if you guys really think my logic on this one is scewed, let me know. (Of course, if Freddy tells me not to release the source, thats it, I won't do it. Ill still develop, but Ill respect his wishes on this issue).


dont let freddy control you like that, he has control of scar, that doesnt give him the right to control every other colour-clicker ever made,
there were colour-clickers before scar, there were ones made after scar.


no reason why sourceforge wouldnt host it, there is also www.assembla.com which hosts svns, but i think sourceforge would be better


i really think open source would be the upmost importance for a project like this,
one good reason is you (boberman) simply dont have enough time/energy to do everything, its a purely volentering project, and open source allows other people to help you,

you might say there arnt many people who know c++, but another thing open source does it help people learn, so eventually they could help you,
and it doesnt take that much knowledge to fix some bugs


also i think any svn you make, it should be public enough that anyone can just checkout, without going through the hassle of asking you to add them to the list,
think of a shop, its always much easier to buy something, then it is to return it,
like with wikipedia, to contribute, its fairly easy to just press the [edit] button and fix

Bobarkinator

2008-05-13 08:07:19

If you don't plan on releasing the source then I would say don't even do it.

boberman

2008-05-13 10:39:49

From: Yakman
dont let freddy control you like that, he has control of scar, that doesnt give him the right to control every other colour-clicker ever made,
there were colour-clickers before scar, there were ones made after scar.


no reason why sourceforge wouldnt host it, there is also www.assembla.com which hosts svns, but i think sourceforge would be better


i really think open source would be the upmost importance for a project like this,
one good reason is you (boberman) simply dont have enough time/energy to do everything, its a purely volentering project, and open source allows other people to help you,

you might say there arnt many people who know c++, but another thing open source does it help people learn, so eventually they could help you,
and it doesnt take that much knowledge to fix some bugs


also i think any svn you make, it should be public enough that anyone can just checkout, without going through the hassle of asking you to add them to the list,
think of a shop, its always much easier to buy something, then it is to return it,
like with wikipedia, to contribute, its fairly easy to just press the [edit] button and fix


Lets not get ahead of ourselves here, this project really isn't THAT hard. Ill admit that certain aspects of it are more difficult (DTM's and Bitmaps from strings) but most of the functions are just straight calls to the windows API.

That said, my mouse is delicately hoovering over the public button (I am using assembla). The part of me that wants to keep it private is slowly being wained.

Meh, alright, you guys talked me into it. The source is available at http://svn2.assembla.com/svn/ScarPP

mastaraymond

2008-05-13 11:30:17

From: Smartzkid


EDIT:



Yeah. It's called a firewall.

Oh c'mon you know where I'm talking about :(.

I really think that the core functions should be a .dll meaning that people who don't want to learn C++ can still use the functions in other languages :p.

Of course people will learn from this project, but making SRL for a c++ version will be a pain in the ass I guess..

boberman

2008-05-13 11:44:21

From: mastaraymond

Of course people will learn from this project, but making SRL for a c++ version will be a pain in the ass I guess..


Not really, we have all the SRL source code available, it takes like 2 seconds to rewrite them into c++ and 3 if you want to make them run a bit faster :)

mastaraymond

2008-05-13 11:54:54

From: boberman
Not really, we have all the SRL source code available, it takes like 2 seconds to rewrite them into c++ and 3 if you want to make them run a bit faster :)

If you say so :rolleyes:.. I'm trying to say that the rewriting is a big job.. But the updating is even worse.. x)

boberman

2008-05-13 12:47:23

Big job, yes, hard job, no. Updating shouldn't be too bad as SVN supports the ability to see a change log. Once we get the SRL portion written I hope that the SRL team would consider adopting the C++ code and maintain it side by side. If not, updates usually aren't to huge.

Jason2gs

2008-05-14 23:28:04

I would definitely get behind this project.

Mind you, I might as well be just starting off with C++ (I don't know hardly anything, but I have experience programming, and I understand the syntax to a degree. That counts for something.), but school is just about finishing up for me, so I'll have plenty of time to learn more.

Oh, question: Will this be available to Linux users? As my main operating system, compatibility is rather important :)

Now for working out this SVN…

boberman

2008-05-15 09:37:35

From: Jason2gs
I would definitely get behind this project.

Mind you, I might as well be just starting off with C++ (I don't know hardly anything, but I have experience programming, and I understand the syntax to a degree. That counts for something.), but school is just about finishing up for me, so I'll have plenty of time to learn more.

Oh, question: Will this be available to Linux users? As my main operating system, compatibility is rather important :)

Now for working out this SVN…


Initially, no, but I hope that after it is finished we can begin work porting code over. Some things Im not sure if you can do (Take control of the mouse, and send keys through the keyboard) But we'll see. It just depends on how X works. (Yay getting to read thousands of pages of Documentation :))

Starblaster100

2008-05-15 11:38:24

From: mastaraymond
Atleast it does warn.
Some people might click through, but most will stop..

.exe on the other hand can still do stuff like sending your rs + ip etc..

While scar does warn..

In scar you can't edit the registery..


You can connect to a website and edit the registry using SCAR without getting confirmation from the user. Using plugins will allow you to do that, and more and more people are using them now a days

mastaraymond

2008-05-15 12:20:24

From: Starblaster100
You can connect to a website and edit the registry using SCAR without getting confirmation from the user. Using plugins will allow you to do that, and more and more people are using them now a days

I know..

And you cannot edit the registery with scar. And yes I know plugins are like .exe's.
But then again, if you all so like the exe idea, why no one ever want to make something that compiles your script into a .exe?

Smartzkid

2008-05-15 17:02:03

Ehhh, that'd be this…

Speed + Standalone = Perfection ;)

R0b0t1

2008-05-15 17:33:48

I wouldn't use objects for the functions… Seems pretty… useless to me.


PointDef

But all Freddy does (or what I would do) is make a DTM record, TDTM, and all his code does is something like


var What : File of TDTM;

WriteFile(What, {..});

It's something like that, search delphi basics…


But it stores a record in a file as Hex or bytes. So he just prints that string out. HE changed it to use base 64 or something though.

boberman

2008-05-15 21:20:59

From: R0b0t1
I wouldn't use objects for the functions… Seems pretty… useless to me.


PointDef

But all Freddy does (or what I would do) is make a DTM record, TDTM, and all his code does is something like


var What : File of TDTM;

WriteFile(What, {..});

It's something like that, search delphi basics…


But it stores a record in a file as Hex or bytes. So he just prints that string out. HE changed it to use base 64 or something though.


He is using compression which is why it no longer is readable.

As for the object things, I have debated over this. For some areas they are pretty worthless (ColorConversions) but I am already seeing a good benifit for them in other areas (ColorFinding). Right now everything is in objects just to make things a bit smoother, syntax wise. Most IDEs will give a list of member functions when you type object.(whatever) which makes it easy to browse the available functions. So for scar++ it would be something like Scar.Color.FindColorSpiral(blah);

There are a few more benefits besides that. for example, I plan on using some private functions to change between fast color finding and slow color finding.

Im still not completely satisfied with the way things are setup, but once we near completion I hope to have that hammered out pretty good. (right now it is just writing a bunch of functions)

R0b0t1

2008-05-15 21:54:20

I know he uses compression, but I was talking about how he gets the data to compress in the first place.

boberman

2008-05-15 22:05:29

From: R0b0t1
I know he uses compression, but I was talking about how he gets the data to compress in the first place.


Gocha, Yeah, I think it is just a list of bytes. Shouldn't be too hard to break down once it is decompressed (I believe I know the method used for the compression. so it should be too bad)

Wizzup?

2008-05-16 05:09:33

From: boberman
Gocha, Yeah, I think it is just a list of bytes. Shouldn't be too hard to break down once it is decompressed (I believe I know the method used for the compression. so it should be too bad)


I think BenLand100 has done the Bitmap Decryption…

Markus

2008-05-16 05:14:16

I did DTMs for Nielsie once, I'll send you the bytes as soon as I get home and found it :)

Hugolord

2008-05-16 05:50:00

I support this project 100%

plus, learning C++ will make me much more motivated to script (yes I finally found my army .txt details so I might start scripting again sometime).

WhoCares357

2008-05-16 07:10:39

I remember a long time ago (on Sythe) someone introduced a replicated VB version of Scar (it was in development I think). The guy got banned for the post. Good luck with the project. It won't be very easy.

R0b0t1

2008-05-16 18:30:20

Cruels? google Cruellib.

WhoCares357

2008-05-16 22:27:23

From: R0b0t1
Cruels? google Cruellib.


I really don't remember. It was so long ago.. It very-well may have been. But either way, the guy's project wasn't very successful.

PS I "can" script c++. I know the basic principles, the syntax, etc, but I don't have enough experience with it. I've never even created forms before. If I helped out on this project perhaps I could learn some (by at least looking at the source, etc.).

Bobarkinator

2008-05-16 23:09:05

From: WhoCares357
I really don't remember. It was so long ago.. It very-well may have been. But either way, the guy's project wasn't very successful.

PS I "can" script c++. I know the basic principles, the syntax, etc, but I don't have enough experience with it. I've never even created forms before. If I helped out on this project perhaps I could learn some (by at least looking at the source, etc.).


That is what I'm doing, I don't have a ton of experience, hoping to pick up some.

R0b0t1

2008-05-17 07:14:07

Third Commandment: Thou shalt not refer to thy holy Programming as 'scripting'.

Bobarkinator

2008-05-17 10:40:50

Wow…I didn't even notice that he did it. IT IS PROGRAMMING!

boberman

2008-05-17 17:37:44

From: R0b0t1
Third Commandment: Thou shalt not refer to thy holy Programming as 'scripting'.


Amen brother, Amen… :). Today and yesterday I haven't had a lot of time to work on this thing. Hopefully in the near future my schedule will free up a bit. (Sister had a baby, 12 lbs..)

WhoCares357

2008-05-17 22:25:37

From: R0b0t1
Third Commandment: Thou shalt not refer to thy holy Programming as 'scripting'.


Haha. My friend always says that. Shame on me for my poor memory.

BenLand100

2008-05-18 23:43:46

From: Wizzup?
I think BenLand100 has done the Bitmap Decryption…

He has, along with figuring out how most of the algorithms used in scar work, which has gotten freddy quite pissed at him ;) That being said, I like this project a lot. You know, SMART is run from a C++ dll, it might make a good "client" for this project, It shouldn't be hard at all for someone to figure out how to use the dll without SCAR, as boberman seems to know his way around c++ quite well. In addition, that would simplify the way the library would interface with RS a lot… Regardless, pm or msn me with any questions.

Edit: @boberman, don't worry about the "Spline" mouse functions, unless you want them for compatibility's sake. If that's the case, I'll find the source for them and send you a copy (I wrote them to begin with, they aren't as good as WindMouse in SRL however). I also know the algorithm used for MoveMouseSmoothEx, however it shouldn't be too hard to get your hands on elsewhere if you know where to look.

Bobarkinator

2008-05-19 08:16:23

BenLand is always so secretive :p.

boberman

2008-05-28 12:10:02

For all that care (and even those that don't) Scar++ is making some great strides. As it stands, it can actually do something somewhat useful now (Find colors and send keys, Yeay!) Most of the colorfinding functions have been written, so if you want to give them a test run and report any bugs you find, that would be great.

And since the source is available. Feel free to pick it apart and yell at me if you find something that is completely inefficient or broken. As always, if you want to contribute a function, I'm completely open to that.

Hugolord

2008-05-28 12:13:08

From: boberman
For all that care (and even those that don't) Scar++ is making some great strides. As it stands, it can actually do something somewhat useful now (Find colors and send keys, Yeay!) Most of the colorfinding functions have been written, so if you want to give them a test run and report any bugs you find, that would be great.

And since the source is available. Feel free to pick it apart and yell at me if you find something that is completely inefficient or broken. As always, if you want to contribute a function, I'm completely open to that.


good to hear :) and if BenLand is on your side this project really is going to be finished ^^ GL :)

Bobarkinator

2008-05-28 13:30:53

From: boberman
For all that care (and even those that don't) Scar++ is making some great strides. As it stands, it can actually do something somewhat useful now (Find colors and send keys, Yeay!) Most of the colorfinding functions have been written, so if you want to give them a test run and report any bugs you find, that would be great.

And since the source is available. Feel free to pick it apart and yell at me if you find something that is completely inefficient or broken. As always, if you want to contribute a function, I'm completely open to that.


I would be working more but I've been caught up in FindColorsSpiralTolerance, I can't figure it out :p

boberman

2008-05-28 13:35:28

From: Bobarkinator
I would be working more but I've been caught up in FindColorsSpiralTolerance, I can't figure it out :p


:), I committed it already (it is part of the new revision, 15). Basically I just used FindColorsTolerance then sorted out the colors after that (using the Pythagoreans theory). Might not be as fast as a real spiral, but shouldn't be too bad. (FindColorsTolerance will probably be faster then most Color Spirals, but the sort is what will make things take a bit longer then a real spiral)

mixster

2008-05-28 14:07:29

Finding the colours first then sorting should actually be faster as spiral searching first would require maybe thousands more calculations to be run as it makes the points to check :)
Anyway, look forward to testing it out and I'll be sure to report any bugs etc. ;)
Edit: Maybe add the link on the first post? Took me a while to find it hiding on the second page :(
Edit2: What compiler are you using? Just asking :)

Bobarkinator

2008-05-28 14:47:08

MinGW

boberman

2008-05-28 16:25:23

From: mixster
Finding the colours first then sorting should actually be faster as spiral searching first would require maybe thousands more calculations to be run as it makes the points to check :)
Anyway, look forward to testing it out and I'll be sure to report any bugs etc. ;)
Edit: Maybe add the link on the first post? Took me a while to find it hiding on the second page :(
Edit2: What compiler are you using? Just asking :)


Well, it really depends on the method used. Spiral finding follows a somewhat linear path where as sorting is more logarithmic. So when dealing with lots of points (Found points mind you) spiral searching will be faster. But when you deal with only a few, I believe doing a sort will be somewhat quicker.

One thing you have to remember with sorting is that to do it properly you have to take a square root of a square, that can be somewhat cumbersome at times. I have tried to minimize the number of times this is done (only one pass per all the points) but the damage is still done.

Also, the results are somewhat different, mine returns the results of a circular spiral rather then a square one, I don't know that that makes much of a difference though. (The reason for using this function would be to have the first point close to the middle)

I don't know that this function will be used too much as FindColorsTolerance would require less work and give you the same data in just a different order.

Oh, and I updated the front page, it was a good suggestion :).

Smartzkid

2008-05-29 00:37:36

extraFuncs.cpp

- tBoxCompair: Spelled wrong. tBoxCompare is correct.

- Greater: it returns the Greatest number, it should be named thus; 'greater' could be misleading as to the return type (seems more logical that it'd return a boolean, basically the same thing as >)

- Lesser: See Greater.

Little stuff. Hoping to experiment some tomorrow.

EDIT:
return (Mouse::IsLeftDown && LeftButton) || (Mouse::IsRightDown && !LeftButton);

Not confused at all ;)

nielsie95

2008-05-29 02:08:13

I don't know if I understood it properly, but do you use GetPixel in FindColor? Isn 't there something faster (ScanLines)?

Bobarkinator

2008-05-29 02:17:59

From: nielsie95
I don't know if I understood it properly, but do you use GetPixel in FindColor? Isn 't there something faster (ScanLines)?


Honestly, we are trying to get everything to work right now. Tweaks will be made later. For example, FindColorsSpiralTolerance takes around 2 seconds or longer for 40,000 points in SCAR++, regular SCAR takes 15 ms. We will tweak it later.

boberman

2008-05-29 11:00:27

From: Smartzkid
extraFuncs.cpp

- tBoxCompair: Spelled wrong. tBoxCompare is correct.

- Greater: it returns the Greatest number, it should be named thus; 'greater' could be misleading as to the return type (seems more logical that it'd return a boolean, basically the same thing as >)

- Lesser: See Greater.

Little stuff. Hoping to experiment some tomorrow.

EDIT:
return (Mouse::IsLeftDown && LeftButton) || (Mouse::IsRightDown && !LeftButton);

Not confused at all ;)


Dang it, I knew there would be some spelling errors in there, :). As for the greater lesser thing, I would disagree with your grammatical logic.

If I ask you which is greater 1 or 2, of course you would respond 2. If I ask you which is greatest 1 or 2, of course you would respond 2. Both are perfectly correct grammatically. To return a bool would be confusing, IMO (Why would you make such a short function for that anyways?). Greatest implies the biggest of a set while greater implies the bigger of a pair, but not necessarily the biggest in a set. if I did a greatest function I would probably pass it an array and then return the biggest number in the array.

mastaraymond

2008-05-29 11:04:51

From: Bobarkinator
Honestly, we are trying to get everything to work right now. Tweaks will be made later. For example, FindColorsSpiralTolerance takes around 2 seconds or longer for 40,000 points in SCAR++, regular SCAR takes 15 ms. We will tweak it later.

As you might have noticed, freddy tried to tweak his functions quite often.. But not always with the wanted result :rolleyes:.

boberman

2008-05-29 11:26:30

From: mastaraymond
As you might have noticed, freddy tried to tweak his functions quite often.. But not always with the wanted result :rolleyes:.


:) in this case we are pretty sure whats going on in the background and how to change it so its a bit faster. But for now, if you look for a color and find over 40,000 points that are valid, then something is probably wrong with your script (IMO) the lower you go the faster the function will be.

sherlockmeister

2008-05-29 12:27:57

well, this is kind of stupid but you could write ismousebutton down from smatrzkid's post as
'return LeftButton?Mouse::IsLeftDown:Mouse::IsRightDown;' save like 10 bytes of source size lol

edit:

From: boberman
Well, it really depends on the method used. Spiral finding follows a somewhat linear path where as sorting is more logarithmic. So when dealing with lots of points (Found points mind you) spiral searching will be faster. But when you deal with only a few, I believe doing a sort will be somewhat quicker.

One thing you have to remember with sorting is that to do it properly you have to take a square root of a square, that can be somewhat cumbersome at times. I have tried to minimize the number of times this is done (only one pass per all the points) but the damage is still done.

Also, the results are somewhat different, mine returns the results of a circular spiral rather then a square one, I don't know that that makes much of a difference though. (The reason for using this function would be to have the first point close to the middle)

I don't know that this function will be used too much as FindColorsTolerance would require less work and give you the same data in just a different order.

Oh, and I updated the front page, it was a good suggestion :).


is this the code you are talking about??

void ColorFind::FindColorsSpiralTolerance(int x, int y, std::vector<POINT>& Points, int color,
574 int xs, int ys, int xe, int ye, int Tolerance)
575 {
576 int i = 0;
577 int pointsSize;
578 double* distances;
579
580 ColorFind::FindColorsTolerance(Points, color, xs, ys, xe, ye, Tolerance);
581 pointsSize = Points.size();
582
583 distances = new double[pointsSize];
584
585 for(int i = 0; i < pointsSize; ++i)
586 distances[i] = sqrt(((Points[i].x - x) * (Points[i].x - x)) +
587 ((Points[i].y - y) * (Points[i].y - y)));
588
589 i = 0;
590
591 // Heap Sort, Yeay!
592 while(i < pointsSize)
593 {
594 int j = i;
595 double minDistance = 2000;
596 int closestPoint;
597 for (j = i; j < pointsSize; ++j)
598 {
599 if(distances[j] < minDistance)
600 {
601 closestPoint = j;
602 minDistance = distances[j];
603 }
604 }
605 std::swap(distances[i], distances[closestPoint]);
606 std::swap(Points[i], Points[closestPoint]);
607 ++i;
608 }
609 delete[] distances;
610 }

well, first off dont allocate a bunch of doubles, ints, or unsigned is good enough because you don't really need to calculate the sqrt of all those pts.
it is enough to know that if ((x1 - x2)^2 + (y2 - y2)^2) is greater than that of another pt then the sqrt will obviously be greater (plus more accuracy that way).

edit 2:

	bool Keyboard::IsFunctionKeyDown(int Key)
111 {
112 int newKey;
113
114 switch (Key) // I wish there was a better way to do this, but alas none of
115 { // the key codes are in order :(
116 case 0:
117 newKey = VK_SHIFT;
118 break;
119 case 1:
120 newKey = VK_CONTROL;
121 break;
122 case 2:
123 newKey = VK_MENU;
124 break;
125 case 3:
126 newKey = VK_LSHIFT;
127 break;
128 case 4:
129 newKey = VK_LCONTROL;
130 break;
131 case 5:
132 newKey = VK_LMENU;
133 break;
134 case 6:
135 newKey = VK_RSHIFT;
136 break;
137 case 7:
138 newKey = VK_RCONTROL;
139 break;
140 case 8:
141 newKey = VK_RMENU;
142 break;
143 default:
144 newKey = 0;
145 }
146 }

well, isn't a better way to do a simple bin search? like this
	return
(x<5)?
((x<3)?
((x<2)?
((x<1)?
(VK_SHIFT):
(VK_CONTROL)):
(VK_MENU)):
((x<4)?
(VK_LSHIFT):
(VK_LCONTROL))):
((x<8)?
((x<7)?
((x<6)?
(VK_LMENU):
(VK_RSHIFT)):
(VK_RCONTROL)):
((x<9)?
(VK_RMENU):
(0)));
erm? hope that works..(your probably saving at least 2 nanoseconds with that lol)

boberman

2008-05-29 14:34:31

From: sherlockmeister
well, this is kind of stupid but you could write ismousebutton down from smatrzkid's post as
'return LeftButton?Mouse::IsLeftDown:Mouse::IsRightDown;' save like 10 bytes of source size lol

edit:



is this the code you are talking about??

void ColorFind::FindColorsSpiralTolerance(int x, int y, std::vector<POINT>& Points, int color,
574 int xs, int ys, int xe, int ye, int Tolerance)
575 {
576 int i = 0;
577 int pointsSize;
578 double* distances;
579
580 ColorFind::FindColorsTolerance(Points, color, xs, ys, xe, ye, Tolerance);
581 pointsSize = Points.size();
582
583 distances = new double[pointsSize];
584
585 for(int i = 0; i < pointsSize; ++i)
586 distances[i] = sqrt(((Points[i].x - x) * (Points[i].x - x)) +
587 ((Points[i].y - y) * (Points[i].y - y)));
588
589 i = 0;
590
591 // Heap Sort, Yeay!
592 while(i < pointsSize)
593 {
594 int j = i;
595 double minDistance = 2000;
596 int closestPoint;
597 for (j = i; j < pointsSize; ++j)
598 {
599 if(distances[j] < minDistance)
600 {
601 closestPoint = j;
602 minDistance = distances[j];
603 }
604 }
605 std::swap(distances[i], distances[closestPoint]);
606 std::swap(Points[i], Points[closestPoint]);
607 ++i;
608 }
609 delete[] distances;
610 }

well, first off dont allocate a bunch of doubles, ints, or unsigned is good enough because you don't really need to calculate the sqrt of all those pts.
it is enough to know that if ((x1 - x2)^2 + (y2 - y2)^2) is greater than that of another pt then the sqrt will obviously be greater (plus more accuracy that way).

edit 2:

	bool Keyboard::IsFunctionKeyDown(int Key)
111 {
112 int newKey;
113
114 switch (Key) // I wish there was a better way to do this, but alas none of
115 { // the key codes are in order :(
116 case 0:
117 newKey = VK_SHIFT;
118 break;
119 case 1:
120 newKey = VK_CONTROL;
121 break;
122 case 2:
123 newKey = VK_MENU;
124 break;
125 case 3:
126 newKey = VK_LSHIFT;
127 break;
128 case 4:
129 newKey = VK_LCONTROL;
130 break;
131 case 5:
132 newKey = VK_LMENU;
133 break;
134 case 6:
135 newKey = VK_RSHIFT;
136 break;
137 case 7:
138 newKey = VK_RCONTROL;
139 break;
140 case 8:
141 newKey = VK_RMENU;
142 break;
143 default:
144 newKey = 0;
145 }
146 }

well, isn't a better way to do a simple bin search? like this
	return
(x<5)?
((x<3)?
((x<2)?
((x<1)?
(VK_SHIFT):
(VK_CONTROL)):
(VK_MENU)):
((x<4)?
(VK_LSHIFT):
(VK_LCONTROL))):
((x<8)?
((x<7)?
((x<6)?
(VK_LMENU):
(VK_RSHIFT)):
(VK_RCONTROL)):
((x<9)?
(VK_RMENU):
(0)));
erm? hope that works..(your probably saving at least 2 nanoseconds with that lol)


Ill be honest, I don't like using turinary operators what you gain in potential speed (I don't even know that there is a gain) you loose in readability and maintainability. Speed isn't always key (Especially with simple functions that won't be called very often).

Though, you make a good point with the sqrt thing, since the exact distance isn't important there is really no reason to sqrt it.

The List stays, though. It shouldn't take up that much memory and should provide a substantial speed increase. BTW, why would that be more accurate? should be the same, I would imagine

Thanks for the suggestions, keep them comming :)

sherlockmeister

2008-05-29 15:02:55

the accuracy thing was just this
cout<<sqrt((double)1000000)<<endl;
cout<<sqrt((double)1000001)<<endl;
they would be the same, what i said about the list was to make it of ints (or unsigned ints), really unneccessary to use doubles right?

boberman

2008-05-29 15:36:51

From: sherlockmeister
the accuracy thing was just this
cout<<sqrt((double)1000000)<<endl;
cout<<sqrt((double)1000001)<<endl;
they would be the same, what i said about the list was to make it of ints (or unsigned ints), really unneccessary to use doubles right?


ahh, I see. Ok, yep, I agree completely the doubles were not needed in that situation.

MylesMadness

2008-05-29 16:42:50

Will we have to learn c++ to script this or will you stick with scar.

boberman

2008-05-29 17:02:58

From: Mylesmadness
Will we have to learn c++ to script this or will you stick with scar.


You will need to learn C++. You won't be able to use the scar interface either (So it might not be as intuitive as some may like). You could potentially use pascal with the compiled dll if you really wanted to.

Smartzkid

2008-05-29 18:09:31

From: boberman
Dang it, I knew there would be some spelling errors in there, :). As for the greater lesser thing, I would disagree with your grammatical logic.

If I ask you which is greater 1 or 2, of course you would respond 2. If I ask you which is greatest 1 or 2, of course you would respond 2. Both are perfectly correct grammatically. To return a bool would be confusing, IMO (Why would you make such a short function for that anyways?). Greatest implies the biggest of a set while greater implies the bigger of a pair, but not necessarily the biggest in a set. if I did a greatest function I would probably pass it an array and then return the biggest number in the array.


Hmm, yes, I see your point.

Got it to compile, pretty happy :p

mixster

2008-05-29 18:31:38

I fail at getting it to compile - no zlib (just commented out the include as I'm too lazy to download it) then a GetColor and DeleteObject error XD

kingarabian

2008-05-29 18:44:18

From: boberman
You will need to learn C++. You won't be able to use the scar interface either (So it might not be as intuitive as some may like). You could potentially use pascal with the compiled dll if you really wanted to.


Its pretty good for the community to. What more do you want from a community with more than half of its people knowing c++ and scar :). Good luck on the project. As for me, I dont know any C++, but will try to learn it after school dies.

boberman

2008-05-29 18:57:32

From: mixster
I fail at getting it to compile - no zlib (just commented out the include as I'm too lazy to download it) then a GetColor and DeleteObject error XD


What are you using to compile it? and what is the error exactly? While I am using Dev-C++ I would like this to be a seamless experience for compiling if you use another building environment.

mixster

2008-05-29 19:39:26

Using the latest version of CodeBlocks with MinGW pre-installed on it (the binary bundle) with rev 17. I'll quickly get the latest and try to compile again and get the exact error.
Edit: Installed zLib just to make sure it wasn't that but still get the 2 errors:
.objs\ColorFind.o:ColorFind.cpp: (.text+0xcb)||undefined reference to `_DeleteObject@4'|
.objs\ColorFind.o:ColorFind.cpp: (.text+0x11e)||undefined reference to `_GetPixel@12'|

boberman

2008-05-29 20:24:23

You need to point your linker to the libgdi32.a file (or something similar) to compile.

Bobarkinator

2008-05-29 20:41:55

Hmm if using MinGW, it should compile. Default compiler for Dev-C++ is MinGW

mixster

2008-05-29 21:00:00

Adding the linker fixed it ;)
Now I just need to continue learning C++ and try to contribute before I have no idea what's going on :)

R0b0t1

2008-05-29 21:22:02

You can't do scanlines in C++, use GetDIBits.


Well, anyway, if the only reason for FindColorSpiral would be to get a point closest to the given, just find an array of colors and search through them and compare distances. It would be efficient until you find a way to search in a spiral – I saw it somewhere, I can't remember… Maybe in the depths of Cruel's VB section.

boberman

2008-05-29 21:55:25

From: R0b0t1
You can't do scanlines in C++, use GetDIBits.


Well, anyway, if the only reason for FindColorSpiral would be to get a point closest to the given, just find an array of colors and search through them and compare distances. It would be efficient until you find a way to search in a spiral – I saw it somewhere, I can't remember… Maybe in the depths of Cruel's VB section.


I already have a function that works pretty well for FindColorSpiral. FindColorsSpiral is a different story (I actually do what you suggest). Sorting, though, takes time, and that is where we run into problems. For very few points it isn't too bad, but once you get into the larger numbers you start running into problems.

Smartzkid

2008-05-29 22:30:00

You should link to zlib from the front page, save people some time - http://www.zlib.net/zlib123-dll.zip

Note to others - I was getting a bunch of linker problems; turns out, I had mingw already installed; got rid of it, and it fixed everything.

Bobarkinator

2008-05-30 00:11:44

Why is everybody compiling it? The .dll is already in the folder, the only reason to compile is if you change something.

boberman

2008-05-30 00:20:46

From: Bobarkinator
Why is everybody compiling it? The .dll is already in the folder, the only reason to compile is if you change something.


I haven't been updating the dll as I go along (maybe I should?). To some extent, it is safer that way.

Bobarkinator

2008-05-30 01:23:26

When I commit it's the updated dll

Wizzup?

2008-05-30 18:03:21

Moved to C++ Programming. :)

Smartzkid

2008-05-30 20:56:09

From: Wizzup?
Moved to C++ Programming. :)


Thanks soo much, Wizz; every time I would go looking for this, I had to search to find it :p


How hard would it be to build a sound detection system? (not really how hard, it shouldn't be too hard; but does anyone have the knowledge to?)

mastaraymond

2008-05-31 08:27:02

From: Smartzkid
Thanks soo much, Wizz; every time I would go looking for this, I had to search to find it :p


How hard would it be to build a sound detection system? (not really how hard, it shouldn't be too hard; but does anyone have the knowledge to?)

I'm not truly sure if it is possible, in any language.. It is possible to get the system wide sound, but with smart etc most people auto and listen to music at the same time.. So we would need SMART for a sound detection..

solarwind

2008-05-31 14:08:03

I haven't posted on SRL for a while, so here I go…

1. Wow this is an amazing project.
2. C++ is an awesome language to program in.
3. You should use SCONS to build.
4. Where is the source to libScar++.a?

R0b0t1

2008-05-31 15:17:53

Actually, I was wondering about solarwind's #4 also. When I downloaded the .7z, it only had the headers in it.

And what is zlib used for?

solarwind

2008-05-31 15:29:47

From: R0b0t1
Actually, I was wondering about solarwind's #4 also. When I downloaded the .7z, it only had the headers in it.

And what is zlib used for?


zlib is a compression library…

R0b0t1

2008-05-31 15:47:04

Well, duh. I meant how is it used in the project? I'm guessing bitmap to string… or something

solarwind

2008-05-31 15:49:32

From: R0b0t1
Well, duh. I meant how is it used in the project? I'm guessing bitmap to string… or something


I think the bitmaps represented as strings are compressed…

boberman

2008-05-31 15:58:54

From: solarwind
I haven't posted on SRL for a while, so here I go…

1. Wow this is an amazing project.
2. C++ is an awesome language to program in.
3. You should use SCONS to build.
4. Where is the source to libScar++.a?


1. Thanks.

2. I agree. :D

3. Interesting, I have never heard of it. For now, we want to get the project done, but maybe in the future we can have it.

4. libScar++.a is automatically generated by the compiler when you build the project. If you use MSVC the file will most likely end with a .lib.

Actually, I was wondering about solarwind's #4 also. When I downloaded the .7z, it only had the headers in it.

And what is zlib used for?


oh, wow, I forgot that I put that up there. It is a fairly old version of Scar++, it doesn't even have all the mouse moving stuff in it and quite a few bugs that have been resolved. The best place to get it is from the SVN, though Ill update that link anyways (just for kicks and giggles).

Right now, zLib is not being used, but it will be used in compressing and decompressing DTM and Bitmap strings. We have a pretty good idea how that works now, so it wont be too bad at all.

R0b0t1

2008-05-31 18:23:36

Oh, ok.

I was working on some mouse functions on my own, because, actually, I was going to make my own 'real-language' auto's in a while. They're pretty stupid though.

Gl with the rest of it.

boberman

2008-09-03 15:09:03

Well there has actually been some work done on Scar++ (Yay!). For starters, DTMs have been added, along with Dynamic DTMs. (and the FindDTM function). They aren't perfect, but they have all the data needed to be made.

Whats good about them is that the FreeDTM function no longer needs to be called! The shouldn't leak any memory at all (That should make some happy). Whats bad is that the calling convention is slightly different to the way Scar makes a DDTM. Here is how you would do it.

DTM createDDTM()
{
vector<DTMNode*> nodes;
nodes.push_back(new DTMNode(NULL, somex, somey, somecolor, shape, area, tolerance, foundifmatch));
nodes.push_back(new DTMNode(nodes[0], somex, somey, somecolor, shape, area, tolerance, foundifmatch));
return DTM(nodes);
}

Saves a bit of space ehh! DTMs from a string are as follows


DTM bob("SomeUberLongStringWithLotsOfCandyInside");

Again, Nice, isn't it :D. And like I said there is no FreeDTM. They don't cause memory leaks. (nodes are freed inside the DTM so you don't have to worry about those either)

The other changes primarily reside in the way things are setup. I desided the super objects was a bad idea. So now to make a scar++ program it is just

#include "Scar++.h"

int main()
{
SomeScarFunction();
return 0;
}

It will make conversions Simpler. (I've already started to port SRL in my free time. That will give me an Idea of what functions I'll still need)

Macrosoft

2008-09-03 16:51:21

Is there anyway to make a plugin using scar and put it into a C++ compiler? I know you can do the opposite… That would make Scar++ a lot easier to make (you could transfer all the scar functions).

boberman

2008-09-03 17:14:56

From: Macrosoft
Is there anyway to make a plugin using scar and put it into a C++ compiler? I know you can do the opposite… That would make Scar++ a lot easier to make.


You can use plugins that where made for scar in scar++, but you can't make plugins in scar.. (well you can but it isn't really easy, you basically have to saddle the scar executable with the plugin).

So the short answer is not really.

Besides, its funner to get working functions that everyone can see. Once that is done, I might try my hand at a linux version.

Widget

2008-09-03 22:28:37

You should check out CBAS, since I don't think it was written when this thread was started.

http://www.mediafire.com/?4jsmxzzptom
Extract it somewhere and figure out how it works since I can't read C++ :p. It's a Java IDE on top of a pile of leet C++ that runs more C++ (Don't ask me about it, it's Ben's)

Bobarkinator

2008-09-04 08:22:02

From: Widget
You should check out CBAS, since I don't think it was written when this thread was started.

http://www.mediafire.com/?4jsmxzzptom
Extract it somewhere and figure out how it works since I can't read C++ :p. It's a Java IDE on top of a pile of leet C++ that runs more C++ (Don't ask me about it, it's Ben's)


Ben made CBAS after we started this project. He says he had the idea long before this but I'm not sure :p.

R0b0t1

2008-09-06 12:51:54

If you want to complete a Linux version you should start with "Xlib.h". You will need to drastically change almost everything (as in the basic mouse functions and findcolor).

boberman

2008-09-06 13:10:41

From: R0b0t1
If you want to complete a Linux version you should start with "Xlib.h". You will need to drastically change almost everything (as in the basic mouse functions and findcolor).


yeah, I've noticed that. Linux does a lot of things very differently from the windows way. There are still some similarities, but there are pretty huge differences as well (like having to declare which session you want to open…) Hopefully it will just be mostly the base functions that I have to change like GetColor and MoveMouse.

As a side note. I almost got bitmapsfromstrings to work correctly. I have the raw data from them, all that is left is converting that data into a bitmap handle.

R0b0t1

2008-09-06 19:28:10

Er, and where is the SVN link?

boberman

2008-09-06 21:22:28

From: R0b0t1
Er, and where is the SVN link?


Updated the first page, Now you should be able to find it a bit better.

Seroko

2008-09-15 12:40:53

So does this like make a scar++ lib for C++ so you can user scar-like procs in c++? Sorry trying to understand what this is. yay for being on my phone and can't open cpp/h files

boberman

2008-09-15 16:59:15

From: Seroko
So does this like make a scar++ lib for C++ so you can user scar-like procs in c++? Sorry trying to understand what this is. yay for being on my phone and can't open cpp/h files


Pretty much. This makes it so you should be able to take just about any Scar function or procedure and call it in C++ in almost the same fashion.

BazzBarrett

2008-09-16 18:54:44

wtf i dnt understand any how to use it i have very limited c++ knowlage but i wanna learn it unfortunatly your instructions are not written in english i understand how to get it ive got it but how do i include it? i have Dev-Cpp (FTW) had it a while but could you please for the people who dnt know loads about c++ exsplain how to include it

boberman

2008-09-16 19:13:56

From: bazzbarrett
wtf i dnt understand any how to use it i have very limited c++ knowlage but i wanna learn it unfortunatly your instructions are not written in english i understand how to get it ive got it but how do i include it? i have Dev-Cpp (FTW) had it a while but could you please for the people who dnt know loads about c++ exsplain how to include it


on the top of your program you should have
#include <scar++.h>

You can either have this, or you can copy every .h file into ../Dev-CPP/include folder and then put the libScar++.a file into the ../Dev-CPP/lib folder.

In a new project you should go Project->Project Options->Parameters->Add Library or Object. Then find your libScar++.a file and select it.

After that, it should make it so you can build a scar++ program. Maybe someday Ill add a devpak to the front page.

Once you do that, make sure that Scar++.dll is in the same folder as the program you build.

Seroko

2008-09-17 17:04:53

May I suggest changing your linker options from something like

..\..\..\..\libz.a


to something a little more friendly such as….

-lgdi32
-lz

boberman

2008-09-17 17:13:09

From: Seroko
May I suggest changing your linker options from something like
to something a little more friendly such as….


good point, I'm not using dev-c++ at the moment, but once I boot up a windows computer Ill be sure to make that change.

R0b0t1

2008-09-21 19:08:20

I'm pretty sure he's talking about whatever command like compiler you are using. Instead of specifying the path somewhere else, try (This would link to the X library):


gcc xtest.c -o xtest -lX11

On Linux systems its usually traditional to only have one library of each, unlike Windows, where each program usually makes you get another copy.

EDIT:

Although, since he does specifically mention the the Windows gdi file – I imagine that his linking command would search the project directory…

Seroko

2008-10-08 03:55:29

From: R0b0t1
I'm pretty sure he's talking about whatever command like compiler you are using. Instead of specifying the path somewhere else, try (This would link to the X library):


gcc xtest.c -o xtest -lX11

On Linux systems its usually traditional to only have one library of each, unlike Windows, where each program usually makes you get another copy.

EDIT:

Although, since he does specifically mention the the Windows gdi file – I imagine that his linking command would search the project directory…


I am unsure about linux systems since I have always used windows, I was being fairly specific for dev-c++ because if I remember correctly thats the compiler they have the project set up with in the svn, which you could just add that to the linker for more friendly distribution.

Wizzup?

2008-10-31 12:42:56

Stickied… :)

boberman

2008-11-26 14:37:13

NEWS! (nope, its not dead)

I added FindDTMRotated and gave DTMs some better support. Soon I will be adding OCR capabilities via DTMS. Stay tuned!

Bobarkinator

2008-11-27 00:05:42

Been getting the emails on the changesets, good luck on speeding up color finding.

boberman

2008-11-27 10:21:56

From: Bobarkinator
Been getting the emails on the changesets, good luck on speeding up color finding.


:D, Well, I already know how to do it, its just a matter of not being lazy and implementing it. I would like it to be pretty clean, but that looks almost impossible to do :(.

The main slowdown is using the GetPixel call from windows. It is very slow. A faster method would be using BitBlt to copy the data over and then reading the direct pixel data. BitBlt is extremely fast in copying over pixels (depending on the speed of your video card, if you have a modern one that can play runescape, or use scar, you'll be fine)

Using the current method, it too me 2 seconds to scan a 640x480 area. Thats way too slow, and most of that time was spent in the "FindColorsTolerance" function.

But, on the bright side, once this is implemented that lag should pretty much disappear.

Wizzup?

2008-11-27 10:41:34

From: boberman
:D, Well, I already know how to do it, its just a matter of not being lazy and implementing it. I would like it to be pretty clean, but that looks almost impossible to do :(.

The main slowdown is using the GetPixel call from windows. It is very slow. A faster method would be using BitBlt to copy the data over and then reading the direct pixel data. BitBlt is extremely fast in copying over pixels (depending on the speed of your video card, if you have a modern one that can play runescape, or use scar, you'll be fine)

Using the current method, it too me 2 seconds to scan a 640x480 area. Thats way too slow, and most of that time was spent in the "FindColorsTolerance" function.

But, on the bright side, once this is implemented that lag should pretty much disappear.


GetPixel is indeed, way too slow. Are you planning to keep scar++ cross platform? Cause you'd need to use WINE if you want to use BitBlt…

boberman

2008-11-27 15:46:45

From: Wizzup?
GetPixel is indeed, way too slow. Are you planning to keep scar++ cross platform? Cause you'd need to use WINE if you want to use BitBlt…


My intentions where eventually to make it cross platform. Since its inception it hasn't been cross platform. It runs under wine as is, (im developing under linux). It is more important to me to have it working well on windows and then worry about linux. There just isn't enough linux demand to program it so that it is cross platform from the beginning.

*edit* as a small note, I sped up Color finding by a LARGE amount. As a result, DTMs operate at a usable speed now :D

*Edit 2* DTM color finding is now as fast as SCAR (it is slightly slower when a color match is on the screen, however, it is MUCH faster if no match is found on screen). Color finding in general is faster then scar.

*Edit 3* Big News! Scar++ can now be compiled natively on linux! I'm sure you're pleased. First, get Scar++, then cp Makefile.linux to Makefile. Then type in "make clean && make && sudo make install" And viola! You have scar++ on your nice linux machine! :D

Scaper

2009-01-14 16:00:57

i need a lil help ok i downloaded allt he files through tortoise SVN then i goto the folder and i have a bunch of files what do i do ith em??

also if i open the Scar++ pack thing i get this error


then i press ok and this opens


any help muchl appreciated please

boberman

2009-01-14 17:19:56

From: Scaper
i need a lil help ok i downloaded allt he files through tortoise SVN then i goto the folder and i have a bunch of files what do i do ith em??

also if i open the Scar++ pack thing i get this error


then i press ok and this opens


any help muchl appreciated please


Ok, I don't have much along an installer going yet, and the pac doesn't work all that great. To manually install scar++, put all the .h files into a folder named scar++ in your include folder. Then put libScar++.a into your lib folder. After that, place the scar++ dll in the folder that contains the project you will be working on.

The scar++ dll that is in the file has zlib built into it, so there is no worries about having to find that. If you want to compile scar++ on your own, you will have to get zlib installed on your machine (sometimes a pain).

When you are compiling projects based on scar++, make sure you have the scar++ in your linker.

Ron

2009-01-15 00:54:40

This seems awesome boberman. If I ever get my Dec-C++ Compiler to stop giving me errors on Hello World apps, I will definitely give this a try!

HyperSecret

2009-01-15 11:53:34

I am taking a Intro to C++ programming class right now this semester. The teacher is great so I am sure I will learn a lot. Already got cout and cin working for me, haha.

I am hoping by the end of the semester I will be able to help you out with it. If I don't learn enough to help this project I am hoping that I will have enough understanding to help me learn more on via internet more easily.

Take a look at the course schedule and lecture let me know if you think it covers a decent amount or gives a good basis.

http://staffwww.fullcoll.edu/brippe/csci123/lectures.aspx

boberman

2009-01-15 15:04:42

From: HyperSecret
I am taking a Intro to C++ programming class right now this semester. The teacher is great so I am sure I will learn a lot. Already got cout and cin working for me, haha.

I am hoping by the end of the semester I will be able to help you out with it. If I don't learn enough to help this project I am hoping that I will have enough understanding to help me learn more on via internet more easily.

Take a look at the course schedule and lecture let me know if you think it covers a decent amount or gives a good basis.

http://staffwww.fullcoll.edu/brippe/csci123/lectures.aspx


While it covers the needed subjects, it kind of crams a lot of stuff in, but looks complete at least for the basics (how well it is taught is another matter).

If you would like to help, I would suggest searching through the windows API in MSDN and also the XLib manual. Once you feel you can understand the functions there, you would be a great asset.

Go ahead and take a look at Scar++ and maybe even scar, if you see a function in scar that you want to implement, and think you can implement, by all means do it and post the results here. I will be more then happy to add any additions.

zenma

2009-01-17 22:40:03

Does scar++ support reflectioN? If it doesnt will it eveR? Maybe i could help if it doesn'T.

Yakman

2009-01-18 11:13:52

it would be easily possible to make scar++ load smart.dll and run it.

boberman

2009-01-23 02:50:12

From: Yakman
it would be easily possible to make scar++ load smart.dll and run it.


Yep, the plugin capabilities are there, One would just have to load the file (the easy part) and define the plugins correctly (the hard part). But, it should be able to load all Scar plugins theoretically.

Bobarkinator

2009-01-24 11:37:34

From: Yakman
it would be easily possible to make scar++ load smart.dll and run it.


When scar++ was just starting out, Ben did it and I think I still have the code somewhere.

boberman

2009-01-24 12:09:20

From: Bobarkinator
When scar++ was just starting out, Ben did it and I think I still have the code somewhere.


It's already in. Checkout the plugin.cpp file. Not exactly like ben did it, but the concept is the same.

Smartzkid

2009-01-25 19:11:07

#include "Plugins.h"
#include <iostream>

using namespace std;

typedef long (*GetFunctionInfo)(int index, void** address, char** def) __attribute__((stdcall));
typedef long (*GetFunctionCount)() __attribute__((stdcall));

void lower(char* str) {
while (*str != 0) {
*str = (char) tolower(*str);
*str++;
}
}

PluginLoader::PluginLoader(const char* pluginDir) {
cout << "Loading plugins from " << pluginDir << "\n";
int dirlen = strlen(pluginDir);
char search[MAX_PATH];
char temp[MAX_PATH];
strcpy(search, pluginDir);
strcat(search, "/*.dll");
HANDLE find;
WIN32_FIND_DATA file;
find = FindFirstFile(search, &file);
if (find != INVALID_HANDLE_VALUE) {
do {
strcpy(temp, pluginDir);
strcat(temp, "/");
strcat(temp, file.cFileName);
cout << "Loading " << file.cFileName << "\n";
HINSTANCE inst = LoadLibrary(temp);
if (inst) {
handles.push_back(inst);
GetFunctionCount count = (GetFunctionCount)GetProcAddress(inst,"GetFunctionCount");
GetFunctionInfo info = (GetFunctionInfo)GetProcAddress(inst,"GetFunctionInfo");
if (count != 0 && info != 0) {
long functions = count();
for (int i = 0; i < functions; i++) {
try {
void* address;
char* def = (char*)malloc(512);
if (info(i,&address,&def) == -1) break;
char* ref = def;
lower(def);
while (*def == ' ') def++;
while (*def != ' ') def++;
while (*def == ' ') def++;
char* start = def;
while ((*def != ' ') && (*def != '(') && (*def != ':') && (*def != ';')) def++;
*def = 0;
char* name = (char*)malloc(def - start + 1);
strcpy(name, start);
addrs[name] = address;
cout << "\t" << name << "\n";
free(ref);
} catch (...) {
cout << "Error loading function index " << i << " from " << file.cFileName << "\n";
}
}
}
}
} while (FindNextFile(find, &file));
cout << "Done loading plugins!\n";
FindClose(find);
}
}

PluginLoader::~PluginLoader() {
while (!handles.empty()) {
FreeLibrary(handles.back());
handles.pop_back();
}
map<const char*, void*>::iterator it;
for (it = addrs.begin(); it != addrs.end(); it++) {
free((void*)(it->first));
}
addrs.clear();
}

void* PluginLoader::getMethodAddress(const char* name) {
char* lowerName;
lowerName = (char*)malloc(strlen(name)+1);
strcpy(lowerName, name);
lower(lowerName);
if (addrs.end() != addrs.find(lowerName))
return addrs[lowerName];
return 0;
}

From Plugins.cc, CBAS beta B

Phoenix13nl

2009-01-30 07:52:16

Even though the instructions are find, i found a topic where some one asked how to download scar++, so i guess a few more people would have the same problem (Just read boberman's instructions! :P).

anyway, for the people that are to lazy to read, i've created a programm for helping those people :D i've also included the source code so you could see what it does. because its an in C# i've also included it in a txt for the ones that cant open it.

it still requiers svn. (i wonder if people will actualy use my programm :P)

HyperSecret

2009-04-03 15:23:12

Still working on this Boberman?

We are just getting into structures. I don't really know if anything c++ specific I that I have learned that will benefit this yet but I still have yet to look at the code.

Loops and statements are pretty universal so nothing new was learned there. The only libraries that we have really interacted with so far are:

iostream
fstream
string
cctype
math (very little)
vector

I believe that is it. Hopefully I will be able to help soon enough though.

boberman

2009-04-05 11:10:53

Yes, work is still happening on scar++, right now at a slow pace. I have University studies that take precedence over scar++ development (unfortunately). However, What I am learning in school now will ultimately lead to some pretty good stuff for scar++ If I do say so myself :)

rogue poser

2009-05-30 01:06:48

From: boberman
Yes, work is still happening on scar++, right now at a slow pace. I have University studies that take precedence over scar++ development (unfortunately). However, What I am learning in school now will ultimately lead to some pretty good stuff for scar++ If I do say so myself :)


Very good work with your project!!! i just wanted to bring some things to your attention.

1) i rewrote all the WINDOWS handles to WIN32 because it wouldnt compile in vista or xp with those handles.

2) the find color tolerace functions return the value relative to the window specified and not relative to the active window, this can be solved by adding xs to x and ys to y, to get the actual position not the relative.

didnt really try to call much else

very good work!!!

Tv-XxX

2009-10-14 15:23:05

this looks awsome, but how do i use it :P

im using visual studio, cant get it to work at all :(

i've put all the hearder files in
C:\Program Files\Microsoft C#\VC\include

and the libScar++.a in
C:\Program Files\Microsoft C#\VC\lib

and the Scar++.dll in the project file…

i still get 122 errors…


1>—— Build started: Project: Scar++ Testing, Configuration: Debug Win32 ——
1>Compiling…
1>main.cpp
1>c:\program files\microsoft c#\vc\include\mouse.h(9) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(9) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft c#\vc\include\mouse.h(9) : error C2491: '__attribute__' : definition of dllimport data not allowed
1>c:\program files\microsoft c#\vc\include\mouse.h(9) : error C2199: syntax error : found 'void (' at global scope (was a declaration intended?)
1>c:\program files\microsoft c#\vc\include\mouse.h(10) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(10) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft c#\vc\include\mouse.h(10) : error C2374: '__attribute__' : redefinition; multiple initialization
1> c:\program files\microsoft c#\vc\include\mouse.h(9) : see declaration of '__attribute__'
1>c:\program files\microsoft c#\vc\include\mouse.h(10) : error C2491: '__attribute__' : definition of dllimport data not allowed
1>c:\program files\microsoft c#\vc\include\mouse.h(10) : error C2199: syntax error : found 'void (' at global scope (was a declaration intended?)
1>c:\program files\microsoft c#\vc\include\mouse.h(11) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(11) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft c#\vc\include\mouse.h(11) : error C2374: '__attribute__' : redefinition; multiple initialization
1> c:\program files\microsoft c#\vc\include\mouse.h(9) : see declaration of '__attribute__'
1>c:\program files\microsoft c#\vc\include\mouse.h(11) : error C2491: '__attribute__' : definition of dllimport data not allowed
1>c:\program files\microsoft c#\vc\include\mouse.h(11) : error C2199: syntax error : found 'void (' at global scope (was a declaration intended?)
1>c:\program files\microsoft c#\vc\include\mouse.h(12) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(12) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft c#\vc\include\mouse.h(12) : error C2374: '__attribute__' : redefinition; multiple initialization
1> c:\program files\microsoft c#\vc\include\mouse.h(9) : see declaration of '__attribute__'
1>c:\program files\microsoft c#\vc\include\mouse.h(12) : error C2491: '__attribute__' : definition of dllimport data not allowed
1>c:\program files\microsoft c#\vc\include\mouse.h(12) : error C2199: syntax error : found 'void (' at global scope (was a declaration intended?)
1>c:\program files\microsoft c#\vc\include\mouse.h(13) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(13) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft c#\vc\include\mouse.h(13) : error C2374: '__attribute__' : redefinition; multiple initialization
1> c:\program files\microsoft c#\vc\include\mouse.h(9) : see declaration of '__attribute__'
1>c:\program files\microsoft c#\vc\include\mouse.h(13) : error C2491: '__attribute__' : definition of dllimport data not allowed
1>c:\program files\microsoft c#\vc\include\mouse.h(13) : error C2199: syntax error : found 'void (' at global scope (was a declaration intended?)
1>c:\program files\microsoft c#\vc\include\mouse.h(14) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(14) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft c#\vc\include\mouse.h(14) : error C2374: '__attribute__' : redefinition; multiple initialization
1> c:\program files\microsoft c#\vc\include\mouse.h(9) : see declaration of '__attribute__'
1>c:\program files\microsoft c#\vc\include\mouse.h(14) : error C2491: '__attribute__' : definition of dllimport data not allowed
1>c:\program files\microsoft c#\vc\include\mouse.h(14) : error C2199: syntax error : found 'void (' at global scope (was a declaration intended?)
1>c:\program files\microsoft c#\vc\include\mouse.h(15) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(15) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft c#\vc\include\mouse.h(15) : error C2374: '__attribute__' : redefinition; multiple initialization
1> c:\program files\microsoft c#\vc\include\mouse.h(9) : see declaration of '__attribute__'
1>c:\program files\microsoft c#\vc\include\mouse.h(15) : error C2491: '__attribute__' : definition of dllimport data not allowed
1>c:\program files\microsoft c#\vc\include\mouse.h(15) : error C2199: syntax error : found 'void (' at global scope (was a declaration intended?)
1>c:\program files\microsoft c#\vc\include\mouse.h(16) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(16) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft c#\vc\include\mouse.h(16) : error C2374: '__attribute__' : redefinition; multiple initialization
1> c:\program files\microsoft c#\vc\include\mouse.h(9) : see declaration of '__attribute__'
1>c:\program files\microsoft c#\vc\include\mouse.h(16) : error C2491: '__attribute__' : definition of dllimport data not allowed
1>c:\program files\microsoft c#\vc\include\mouse.h(16) : error C2199: syntax error : found 'void (' at global scope (was a declaration intended?)
1>c:\program files\microsoft c#\vc\include\mouse.h(17) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(17) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft c#\vc\include\mouse.h(17) : error C2374: '__attribute__' : redefinition; multiple initialization
1> c:\program files\microsoft c#\vc\include\mouse.h(9) : see declaration of '__attribute__'
1>c:\program files\microsoft c#\vc\include\mouse.h(17) : error C2491: '__attribute__' : definition of dllimport data not allowed
1>c:\program files\microsoft c#\vc\include\mouse.h(17) : error C2199: syntax error : found 'void (' at global scope (was a declaration intended?)
1>c:\program files\microsoft c#\vc\include\mouse.h(18) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(18) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft c#\vc\include\mouse.h(18) : error C2374: '__attribute__' : redefinition; multiple initialization
1> c:\program files\microsoft c#\vc\include\mouse.h(9) : see declaration of '__attribute__'
1>c:\program files\microsoft c#\vc\include\mouse.h(18) : error C2491: '__attribute__' : definition of dllimport data not allowed
1>c:\program files\microsoft c#\vc\include\mouse.h(18) : error C2199: syntax error : found 'void (' at global scope (was a declaration intended?)
1>c:\program files\microsoft c#\vc\include\mouse.h(19) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(19) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft c#\vc\include\mouse.h(19) : error C2374: '__attribute__' : redefinition; multiple initialization
1> c:\program files\microsoft c#\vc\include\mouse.h(9) : see declaration of '__attribute__'
1>c:\program files\microsoft c#\vc\include\mouse.h(19) : error C2491: '__attribute__' : definition of dllimport data not allowed
1>c:\program files\microsoft c#\vc\include\mouse.h(19) : error C2199: syntax error : found 'void (' at global scope (was a declaration intended?)
1>c:\program files\microsoft c#\vc\include\mouse.h(20) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(20) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft c#\vc\include\mouse.h(20) : error C2374: '__attribute__' : redefinition; multiple initialization
1> c:\program files\microsoft c#\vc\include\mouse.h(9) : see declaration of '__attribute__'
1>c:\program files\microsoft c#\vc\include\mouse.h(20) : error C2491: '__attribute__' : definition of dllimport data not allowed
1>c:\program files\microsoft c#\vc\include\mouse.h(20) : error C2199: syntax error : found 'void (' at global scope (was a declaration intended?)
1>c:\program files\microsoft c#\vc\include\mouse.h(21) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(21) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft c#\vc\include\mouse.h(21) : error C2374: '__attribute__' : redefinition; multiple initialization
1> c:\program files\microsoft c#\vc\include\mouse.h(9) : see declaration of '__attribute__'
1>c:\program files\microsoft c#\vc\include\mouse.h(21) : error C2491: '__attribute__' : definition of dllimport data not allowed
1>c:\program files\microsoft c#\vc\include\mouse.h(21) : error C2199: syntax error : found 'void (' at global scope (was a declaration intended?)
1>c:\program files\microsoft c#\vc\include\mouse.h(22) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(22) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft c#\vc\include\mouse.h(22) : error C2374: '__attribute__' : redefinition; multiple initialization
1> c:\program files\microsoft c#\vc\include\mouse.h(9) : see declaration of '__attribute__'
1>c:\program files\microsoft c#\vc\include\mouse.h(22) : error C2491: '__attribute__' : definition of dllimport data not allowed
1>c:\program files\microsoft c#\vc\include\mouse.h(22) : error C2199: syntax error : found 'void (' at global scope (was a declaration intended?)
1>c:\program files\microsoft c#\vc\include\mouse.h(23) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(23) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft c#\vc\include\mouse.h(23) : error C2374: '__attribute__' : redefinition; multiple initialization
1> c:\program files\microsoft c#\vc\include\mouse.h(9) : see declaration of '__attribute__'
1>c:\program files\microsoft c#\vc\include\mouse.h(23) : error C2491: '__attribute__' : definition of dllimport data not allowed
1>c:\program files\microsoft c#\vc\include\mouse.h(23) : error C2199: syntax error : found 'void (' at global scope (was a declaration intended?)
1>c:\program files\microsoft c#\vc\include\mouse.h(24) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(24) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft c#\vc\include\mouse.h(24) : error C2374: '__attribute__' : redefinition; multiple initialization
1> c:\program files\microsoft c#\vc\include\mouse.h(9) : see declaration of '__attribute__'
1>c:\program files\microsoft c#\vc\include\mouse.h(24) : error C2491: '__attribute__' : definition of dllimport data not allowed
1>c:\program files\microsoft c#\vc\include\mouse.h(24) : error C2199: syntax error : found 'void (' at global scope (was a declaration intended?)
1>c:\program files\microsoft c#\vc\include\mouse.h(25) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(25) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft c#\vc\include\mouse.h(25) : error C2374: '__attribute__' : redefinition; multiple initialization
1> c:\program files\microsoft c#\vc\include\mouse.h(9) : see declaration of '__attribute__'
1>c:\program files\microsoft c#\vc\include\mouse.h(25) : error C2491: '__attribute__' : definition of dllimport data not allowed
1>c:\program files\microsoft c#\vc\include\mouse.h(25) : error C2199: syntax error : found 'void (' at global scope (was a declaration intended?)
1>c:\program files\microsoft c#\vc\include\mouse.h(26) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(26) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft c#\vc\include\mouse.h(26) : error C2374: '__attribute__' : redefinition; multiple initialization
1> c:\program files\microsoft c#\vc\include\mouse.h(9) : see declaration of '__attribute__'
1>c:\program files\microsoft c#\vc\include\mouse.h(26) : error C2491: '__attribute__' : definition of dllimport data not allowed
1>c:\program files\microsoft c#\vc\include\mouse.h(26) : error C2199: syntax error : found 'void (' at global scope (was a declaration intended?)
1>c:\program files\microsoft c#\vc\include\mouse.h(27) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(27) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft c#\vc\include\mouse.h(27) : error C2374: '__attribute__' : redefinition; multiple initialization
1> c:\program files\microsoft c#\vc\include\mouse.h(9) : see declaration of '__attribute__'
1>c:\program files\microsoft c#\vc\include\mouse.h(27) : error C2491: '__attribute__' : definition of dllimport data not allowed
1>c:\program files\microsoft c#\vc\include\mouse.h(27) : error C2199: syntax error : found 'void (' at global scope (was a declaration intended?)
1>c:\program files\microsoft c#\vc\include\mouse.h(28) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(28) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft c#\vc\include\mouse.h(28) : error C2374: '__attribute__' : redefinition; multiple initialization
1> c:\program files\microsoft c#\vc\include\mouse.h(9) : see declaration of '__attribute__'
1>c:\program files\microsoft c#\vc\include\mouse.h(28) : error C2491: '__attribute__' : definition of dllimport data not allowed
1>c:\program files\microsoft c#\vc\include\mouse.h(28) : error C2199: syntax error : found 'bool (' at global scope (was a declaration intended?)
1>c:\program files\microsoft c#\vc\include\mouse.h(30) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(30) : error C2448: '__attribute__' : function-style initializer appears to be a function definition
1>c:\program files\microsoft c#\vc\include\mouse.h(31) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(31) : error C2448: '__attribute__' : function-style initializer appears to be a function definition
1>c:\program files\microsoft c#\vc\include\mouse.h(33) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(33) : error C2448: '__attribute__' : function-style initializer appears to be a function definition
1>c:\program files\microsoft c#\vc\include\mouse.h(34) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(34) : error C2448: '__attribute__' : function-style initializer appears to be a function definition
1>c:\program files\microsoft c#\vc\include\mouse.h(37) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(37) : error C2448: '__attribute__' : function-style initializer appears to be a function definition
1>c:\program files\microsoft c#\vc\include\mouse.h(38) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(38) : error C2448: '__attribute__' : function-style initializer appears to be a function definition
1>c:\program files\microsoft c#\vc\include\mouse.h(41) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(41) : error C2448: '__attribute__' : function-style initializer appears to be a function definition
1>c:\program files\microsoft c#\vc\include\mouse.h(42) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(42) : error C2448: '__attribute__' : function-style initializer appears to be a function definition
1>c:\program files\microsoft c#\vc\include\mouse.h(44) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(44) : error C2448: '__attribute__' : function-style initializer appears to be a function definition
1>c:\program files\microsoft c#\vc\include\mouse.h(45) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(45) : error C2448: '__attribute__' : function-style initializer appears to be a function definition
1>c:\program files\microsoft c#\vc\include\mouse.h(48) : error C2065: 'stdcall' : undeclared identifier
1>c:\program files\microsoft c#\vc\include\mouse.h(48) : error C2448: '__attribute__' : function-style initializer appears to be a function definition
1>c:\program files\microsoft c#\vc\include\mouse.h(48) : fatal error C1003: error count exceeds 100; stopping compilation
1>Build log was saved at "file://c:\Users\Sam\C++ Coding\Scar++ Testing\Scar++ Testing\Debug\BuildLog.htm"
1>Scar++ Testing - 122 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========




yours
tv

YoHoJo

2009-10-14 17:23:47

Hey TV, that was kind of a large bump, thread is like 5 months old, but maybe its still being worked on well see…

Tv-XxX

2009-10-14 17:50:35

sorry didnt realise :P if its not been worked on then fair enough, im sure from looking at the cpp files i can make use of the commands i need anyways :)

Yours
Tv

Bobarkinator

2009-10-15 02:30:43

This hasn't been worked on in a while. Maybe you can respark boberman's interests ;)

marpis

2009-10-15 04:48:09

I think this is a great idea and should be kept alive.
PLUS! Make an option to make code closedsource ;)

Wizzup?

2009-10-15 05:04:30

From: marpis
PLUS! Make an option to make code closedsource ;)


Huh?

EvilChicken!

2009-10-15 06:18:59

From: Wizzup?
Huh?


I think he means an option to obfuscate the code.

fronty

2009-10-15 08:58:16

I think closed source software clearly means closed source software, not program which source code is formatted to look like a helicopter and which can be used to wash clothes.

noidea

2009-10-15 09:25:48

No I think he means, Make it able to run obfuscated scripts.

boberman

2009-10-15 11:39:31

From: Tv-XxX
sorry didnt realise :P if its not been worked on then fair enough, im sure from looking at the cpp files i can make use of the commands i need anyways :)

Yours
Tv


Tv, I still have interest in the project, I just have a lot of stuff going on. Last time development happened was when I was off on a school break. Well, unfortunately for Scar++ I went to school year round this year, so that is somewhat the reason for the lag in development.

Scar++ doesn't have C# compatible headers right now. I'm more focused on getting it useful for C++ at the moment. If I get time in the future I will write them, just understand that it isn't really a priority.

As for the closed source thing. Scar++ doesn't have any sort of licensing. I I where to put one on it I would probably go for the creative commons or put it into public domain. I don't like the idea of making a tools license forcing a user to change the licensing of their program just to match it. (ALA GPL).

If you mean code obfuscation, well, there is nothing stopping it from being able to be built with obfuscated code. There just isn't much reason to do so. (Most people don't have the skill to break down an assembly level file and recreate it)

If I have time, I'll work on it, I just don't have time :(

Tv-XxX

2009-10-15 12:20:03

but still :P I cant get it to work with devc++ or microsoft c++ any idea why?

yours
tv

fronty

2009-10-15 13:34:46

Yeah, this fails miserably when compiling with Visual Studio 2008. Big part of errors got fixed when replaced checks for macro MSVC to _MSC_VER. Another one I quickly spotted was usage of identifier stdcall, when right one is __stdcall. I also had to change several compiler options.

I'll keep bashing these errors and post a diff here when I manage to compile it.

EDIT: Damn, I have to get some zlib development stuff. :/

EDIT2: Got it compiling but with frigging many warnings, I'll fix some of those before posting diff.

In function FindDTM there is one switch statement which doesn't have anything but default case. Of course I replaced the whole statement with contents of default case. There is one thing about it, though. THe default case ended with break, which would break out of switch. Is this meant behaviour and it should be removed, or is it meant to break out of loop where the switch was? I took it out to let you think about correct behaviour, but I still wanted to check it from you.

And btw Tv, it's only good thing that you can't get it working with Dev-C++. ;)

boberman

2009-10-15 14:56:36

From: fronty
Yeah, this fails miserably when compiling with Visual Studio 2008. Big part of errors got fixed when replaced checks for macro MSVC to _MSC_VER. Another one I quickly spotted was usage of identifier stdcall, when right one is __stdcall. I also had to change several compiler options.

I'll keep bashing these errors and post a diff here when I manage to compile it.

EDIT: Damn, I have to get some zlib development stuff. :/

EDIT2: Got it compiling but with frigging many warnings, I'll fix some of those before posting diff.

In function FindDTM there is one switch statement which doesn't have anything but default case. Of course I replaced the whole statement with contents of default case. There is one thing about it, though. THe default case ended with break, which would break out of switch. Is this meant behaviour and it should be removed, or is it meant to break out of loop where the switch was? I took it out to let you think about correct behaviour, but I still wanted to check it from you.

And btw Tv, it's only good thing that you can't get it working with Dev-C++. ;)


Didn't I upload the VC++ project file? It compiles fine on mine (other then the tons of warnings. GCC doesn't mind them as much). Ill update the svn to my local copy just to be sure.

The DTM Thing is there for the potential future of putting shapes into the dtm. Right now, dtms will only find square objects. In the future I was hoping to put in a more scar-like dtm finding function.

The break was ment to terminate the loop. Looks like it doesn't do that, nice catch. (it would still find dtm's, but that will slow it down. Putting in a proper break should provide a little speed boost for larger dtms.)

fronty

2009-10-15 16:17:49

Yes, I used your project file and I used it to build it. Didn't work with Visual Studio 9.0 Professional SP1.

Created this patch with TortoiseSVN with default settings, didn't check if it works.

I added usage for unreferenced parameters like (x);. That shouldn't change speed or size or anything, because things like that will be optimized away, because they don't really do anything.

Index: bitmap.cpp
===================================================================
--- bitmap.cpp (revision 47)
+++ bitmap.cpp (working copy)
@@ -16,28 +16,34 @@

EXPORT IMAGE BitmapFromString(int Width, int Height, std::string data)
{
- if(data[0] == 'b')
- {
- int outputSize;
- unsigned char* output;
- unsigned char* dOutput;
+ (Height);
+ (Width);

- data.erase(0, 1);
- output = base64Dec(data, outputSize);
- dOutput = decompress(output, outputSize, outputSize);
+ if(data[0] == 'b')
+ {
+ int outputSize;
+ unsigned char* output;
+ unsigned char* dOutput;

- delete[] output; // Avoid memory leaks
- output = NULL;
+ data.erase(0, 1);
+ output = base64Dec(data, outputSize);
+ dOutput = decompress(output, outputSize, outputSize);

- /* TODO (#1#): Write BitmapFromString Function */
- }
- return NULL;
+ delete[] output; // Avoid memory leaks
+ output = NULL;
+
+ /* TODO (#1#): Write BitmapFromString Function */
+ }
+ return NULL;
}

EXPORT IMAGE BitmapFromString2(bool Validate, std::string str)
{
- /* TODO (#1#): Write BitmapFromString2 function */
- return NULL;
+ (Validate);
+ (str);
+
+ /* TODO (#1#): Write BitmapFromString2 function */
+ return NULL;
}

EXPORT IMAGE BitmapFromMem(HDC hDC)
@@ -70,24 +76,38 @@

EXPORT IMAGE CreateBitmapMaskFromText(std::string Text, int Chars)
{
- /* TODO (#1#): Write CreateBitmapMaskFromText Function */
- return NULL;
+ (Text);
+ (Chars);
+
+ /* TODO (#1#): Write CreateBitmapMaskFromText Function */
+ return NULL;
}

EXPORT IMAGE CreateBitmapFromText(std::string Text, int Chars, int TextColor)
{
- /* TODO (#1#): Write CreateBitmapFromText Function */
- return NULL;
+ (Text);
+ (Chars);
+ (TextColor);
+
+ /* TODO (#1#): Write CreateBitmapFromText Function */
+ return NULL;
}

EXPORT IMAGE CreateMirroredBitmap(IMAGE bitmap)
{
- /* TODO (#1#): Write CreateMirroredBitmap */
+ (bitmap);
+
+ /* TODO (#1#): Write CreateMirroredBitmap */
return NULL;
}

EXPORT std::vector< std::vector<int> > GetBitmapAreaColors(int xs, int ys, int xe, int ye)
{
+ (xs);
+ (ys);
+ (xe);
+ (ye);
+
std::vector< std::vector<int> > empty;
return empty;
}
Index: cimath.h
===================================================================
--- cimath.h (revision 47)
+++ cimath.h (working copy)
@@ -4,7 +4,7 @@
// Compiler independant math

#include <math.h>
-#ifdef MSVC
+#ifdef _MSC_VER
int lround(double in);
#endif
#endif
\ No newline at end of file
Index: ColorFind.cpp
===================================================================
--- ColorFind.cpp (revision 47)
+++ ColorFind.cpp (working copy)
@@ -359,14 +359,19 @@
// The way my sprial tolerance looks makes these functions pretty much the same.
EXPORT bool FindColorCircle(int& x, int& y, int color, int mx, int my, int r)
{
- return FindColorSpiralTolerance(x, y, color, x - r, y - r, x + r, y + r, 0);
+ (mx);
+ (my);
+ return FindColorSpiralTolerance(x, y, color, x - r, y - r, x + r, y + r, 0);
}

EXPORT bool FindColorCircleTolerance(int& x, int& y, int color, int mx, int my,
int r, int Tolerance)
{
- return FindColorSpiralTolerance(x, y, color, x - r, y - r, x + r,
- y + r, Tolerance);
+ (mx);
+ (my);
+
+ return FindColorSpiralTolerance(x, y, color, x - r, y - r, x + r, y + r,
+ Tolerance);
}

/* EXPORT bool FindColorTriangle(int& x, int& y, int color, int x1, int y1, int x2,
Index: dtm.cpp
===================================================================
--- dtm.cpp (revision 47)
+++ dtm.cpp (working copy)
@@ -76,7 +76,7 @@

void DTM::setColor(int color, int nodeNum)
{
- if (nodeNum < nodes.size())
+ if ((unsigned)nodeNum < nodes.size())
{
nodes[nodeNum]->setColor(color);
}
@@ -84,7 +84,7 @@

void DTM::setTol(int tol, int nodeNum)
{
- if (nodeNum < nodes.size())
+ if ((unsigned)nodeNum < nodes.size())
{
nodes[nodeNum]->setTol(tol);
}
@@ -116,7 +116,7 @@
int shape = 0;
int tol = 0;
int parent = 0;
- int found = 0;
+ int found = false;

// This chunk will convert the from a DTM to a string.
for(int j = 4; j >= 1; --j)
@@ -131,7 +131,7 @@
parent = (parent << 8) + decompressed[(i * 36) + j + 31];
}

- if ((parent == -1) || (parent == nodes.size()))
+ if ((parent == -1) || ((unsigned int)parent == nodes.size()))
out = new DTMNode(NULL, x, y, color, shape, area, tol, found);
else
out = new DTMNode(nodes[parent], x, y, color, shape, area, tol, found);
@@ -154,7 +154,7 @@
std::string out = inStr.substr(0, inStr.size() / 2);
for (size_t i = 0; i < strSize; ++i)
{
- char currChar = tolower(inStr[i]);
+ char currChar = (char)tolower(inStr[i]);
size_t outIndex = (i / 2);
out[outIndex] = ((out[outIndex] & 0xF) << 4);
if ((currChar >= 'a') && (currChar <= 'f'))
@@ -184,7 +184,7 @@

DTMNode* DTM::nodeAt(int i) const
{
- if (i < nodes.size())
+ if ((unsigned)i < nodes.size())
return nodes[i];
else
return NULL;
@@ -242,20 +242,16 @@
}
else
{
- switch (node->getShape())
- {
- default:
- int gv;
- int dist = node->getArea() << 1;
- if((FindColorTolerance(gv, gv, node->getColor(),
- newCoord.x - dist, newCoord.y - dist, newCoord.x + dist,
- newCoord.y + dist, node->getTol())) != node->getFound())
- {
- valid = false;
- break;
- }
- }
- }
+ int gv;
+ int dist = node->getArea() << 1;
+ if((FindColorTolerance(gv, gv, node->getColor(),
+ newCoord.x - dist, newCoord.y - dist, newCoord.x + dist,
+ newCoord.y + dist, node->getTol())) != node->getFound())
+ {
+ valid = false;
+ break;
+ }
+ }
++i;
}

@@ -350,16 +346,12 @@
}
else
{
- switch(next->getShape())
- {
- default:
- int gv;
- int boxSize = next->getArea() << 1;
- if((FindColorTolerance(gv, gv, next->getColor(),
- lround(newX - boxSize), lround(newY - boxSize), lround(newX + boxSize),
- lround(newY + boxSize), next->getTol()) != next->getFound()))
- valid = false;
- }
+ int gv;
+ int boxSize = next->getArea() << 1;
+ if((FindColorTolerance(gv, gv, next->getColor(),
+ lround(newX - boxSize), lround(newY - boxSize), lround(newX + boxSize),
+ lround(newY + boxSize), next->getTol()) != next->getFound()))
+ valid = false;
}
}
++j;
Index: dtm.h
===================================================================
--- dtm.h (revision 47)
+++ dtm.h (working copy)
@@ -1,6 +1,6 @@
-#ifndef _DTM_H_
-#define _DTM_H_
-
+#ifndef _DTM_H_
+#define _DTM_H_
+
#include "preprocessor.h"
#include <vector>
#include <string>
@@ -12,13 +12,13 @@
public:
DTMNode(DTMNode* myParent, int myX, int myY, int myColor, int myShape,
int myArea, int myTol, bool myFound);
- POINT getCoords() const;
- void setColor(int inColor) { color = inColor; }
+ POINT getCoords() const;
+ void setColor(int inColor) { color = inColor; }
void setTol(int inTol) { tol = inTol; }
int getColor() const;
int getShape() const;
int getArea() const;
- int getTol() const;
+ int getTol() const;
bool getFound() const;
DTMNode* getParent() const;
private:
@@ -37,10 +37,10 @@
protected:
std::vector<DTMNode*> nodes;
std::string makeDecompressable(std::string inStr);
- public:
- void setAllColor(int color);
- void setAllTol(int tol);
- void setColor(int color, int nodenum);
+ public:
+ void setAllColor(int color);
+ void setAllTol(int tol);
+ void setColor(int color, int nodenum);
void setTol(int tol, int nodeNum);
DTM(std::vector<DTMNode*> newNodes);
DTM(std::string dtmFromString);
@@ -50,8 +50,8 @@
DTMNode* nodeAt(int i) const;
};

-EXPORT bool FindDTM(const DTM& theDTM, int& x, int& y, int x1, int y1, int x2, int y2);
-EXPORT bool FindDTMRotated(const DTM& theDTM, int& x, int& y, int x1,
- int y1, int x2, int y2, double minAngle,
- double maxAngle, double step, double& angle);
+EXPORT bool FindDTM(const DTM& theDTM, int& x, int& y, int x1, int y1, int x2, int y2);
+EXPORT bool FindDTMRotated(const DTM& theDTM, int& x, int& y, int x1,
+ int y1, int x2, int y2, double minAngle,
+ double maxAngle, double step, double& angle);
#endif
Index: extraFuncs.cpp
===================================================================
--- extraFuncs.cpp (revision 47)
+++ extraFuncs.cpp (working copy)
@@ -4,7 +4,7 @@
#include <assert.h>
#include <zlib.h>

-#ifdef MSVC
+#ifdef _MSC_VER
int lround(double in)
{
return (int)(in + .5);
@@ -143,7 +143,7 @@

short currByteSize = 0;
unsigned char carryOver;
- unsigned char outByte;
+ unsigned char outByte = 0;

while(i < inSize)
{
Index: extraFuncs.h
===================================================================
--- extraFuncs.h (revision 47)
+++ extraFuncs.h (working copy)
@@ -1,8 +1,8 @@
#ifndef _EXTRA_FUNCS_H_
#define _EXTRA_FUNCS_H_
#include "scarStructs.h"
-#include <string>
-#include "os.h"
+#include <string>
+#include "os.h"

/* This file is for any function that has its uses elsewhere but doesnt really
Fit in the other catgories */
@@ -15,16 +15,16 @@
return a;
else
return b;
-}
+}

bool tBoxCompair(TBox a, TBox b);
void tBoxCorrect(TBox& in);

-std::string literalStringValue(std::string inString);
-unsigned char* decompress(unsigned char* in, int inLen, int& outLen);
-unsigned char* base64Dec(std::string in, int& outLen);
-
-IMAGE GetRawScreenData(int& xs, int& ys, int& xe, int& ye, HDC screen);
-
+std::string literalStringValue(std::string inString);
+unsigned char* decompress(unsigned char* in, int inLen, int& outLen);
+unsigned char* base64Dec(std::string in, int& outLen);
+
+IMAGE GetRawScreenData(int& xs, int& ys, int& xe, int& ye, HDC screen);
+
unsigned int GetRawColor(int x, int y, IMAGE data);
#endif
Index: Keyboard.cpp
===================================================================
--- Keyboard.cpp (revision 47)
+++ Keyboard.cpp (working copy)
@@ -1,22 +1,22 @@
#include "Keyboard.h"
-#include "scarmain.h"
+#include "scarmain.h"

-#ifdef WINDOWS
+#ifdef WINDOWS
EXPORT void SendKeys(std::string S)
{
SendKeysWait(S, 0, 1); // Same function, nobody will notice 1ms
}

EXPORT void SendKeysWait(std::string text, int tWait, int tRandom)
-{
+{
Scar* window = returnScarObject();
- HWND client = window->returnClient();
+ HWND client = window->returnClient();

for(unsigned int i = 0; i < text.size(); ++i)
- {
+ {
#ifdef WINDOWS
if(GetFocus() != client)
- SetFocus(client);
+ SetFocus(client);
#endif
Sleep(tWait + rand() % tRandom);
KeyDown(GetKeyCode(text[i]));
@@ -37,12 +37,12 @@

EXPORT void SendArrowWait(int Key, int WaitTime)
{
- short newKey;
+ short newKey;
Scar* window = returnScarObject();
HWND client = window->returnClient();

switch (Key) // Microsoft Virtual key codes
- {
+ {
#ifdef WINDOWS
case 0:
newKey = VK_UP;
@@ -55,25 +55,25 @@
break;
case 3:
newKey = VK_LEFT;
- break;
-#else
- case 0:
- newKey = XK_Up;
- break;
- case 1:
- newKey = XK_Right;
- break;
- case 2:
- newKey = XK_Down;
- break;
- case 3:
- newKey = XK_Left;
- break;
+ break;
+#else
+ case 0:
+ newKey = XK_Up;
+ break;
+ case 1:
+ newKey = XK_Right;
+ break;
+ case 2:
+ newKey = XK_Down;
+ break;
+ case 3:
+ newKey = XK_Left;
+ break;
#endif
default:
newKey = 0;
}
-
+
#ifdef WINDOWS
if(GetFocus() != client) // Make sure the keys are going to the right place
SetFocus(client);
@@ -98,23 +98,23 @@
SendInput was for Win2k and Higher, so at least this should work with the few
Win98 people out there */
EXPORT void KeyDown(int Key)
-{
+{
#ifdef WINDOWS
keybd_event(Key, 0, 0, 0);
-#else
- Display* display = returnScarObject()->returnDisplay();
- XTestFakeKeyEvent(display, XKeysymToKeycode(display, Key), true, 0);
-#endif
+#else
+ Display* display = returnScarObject()->returnDisplay();
+ XTestFakeKeyEvent(display, XKeysymToKeycode(display, Key), true, 0);
+#endif
}

EXPORT void KeyUp(int Key)
-{
+{
#ifdef WINDOWS
keybd_event(Key, 0, KEYEVENTF_KEYUP, 0);
-#else
- Display* display = returnScarObject()->returnDisplay();
- XTestFakeKeyEvent(display, XKeysymToKeycode(display, Key), false, 0);
-#endif
+#else
+ Display* display = returnScarObject()->returnDisplay();
+ XTestFakeKeyEvent(display, XKeysymToKeycode(display, Key), false, 0);
+#endif
}

EXPORT void KeyDownSilent(int Key)
@@ -128,12 +128,12 @@
}

EXPORT int GetKeyCode(char Key)
-{
+{
#ifdef WINDOWS
- return VkKeyScan(Key);
-#else
- char buf[] = {Key, '\0'};
- return XStringToKeysym(buf);
+ return VkKeyScan(Key);
+#else
+ char buf[] = {Key, '\0'};
+ return XStringToKeysym(buf);
#endif
}

@@ -142,7 +142,7 @@
int newKey;

switch (Key) // I wish there was a better way to do this, but alas none of
- { // the key codes are in order :(
+ { // the key codes are in order :(
#ifdef WINDOWS
case 0:
newKey = VK_SHIFT;
@@ -170,8 +170,8 @@
break;
case 8:
newKey = VK_RMENU;
- break;
-#else
+ break;
+#else
case 0:
newKey = XK_Shift_Lock;
break;
@@ -198,17 +198,17 @@
break;
case 8:
newKey = VK_Hyper_R;
- break;
+ break;
#endif
default:
newKey = 0;
- }
+ }
#ifdef WINDOWS
- return (GetKeyState(newKey) < 0);
-#else
- Display* display = returnScarObject()->returnDisplay();
- char keys[32];
- XQueryKeymap(display, keys);
+ return (GetKeyState(newKey) < 0);
+#else
+ Display* display = returnScarObject()->returnDisplay();
+ char keys[32];
+ XQueryKeymap(display, keys);
#endif
}

@@ -251,4 +251,4 @@
{
return (GetKeyState(VK_NUMPAD0 + Key) < 0);
}
-#endif
+#endif
Index: Mouse.cpp
===================================================================
--- Mouse.cpp (revision 47)
+++ Mouse.cpp (working copy)
@@ -162,6 +162,13 @@
int ctrlSpacing, int ctrlVariance)
{
/* TODO (#1#): Write MoveMouseSplineEx */
+ (x);
+ (y);
+ (rx);
+ (ry);
+ (mouseSpeed);
+ (ctrlSpacing);
+ (ctrlVariance);
}

EXPORT void _MoveMouseSplineFrom(int x0, int y0, int x1, int y1, int rx, int ry)
Index: Plugin.cpp
===================================================================
--- Plugin.cpp (revision 47)
+++ Plugin.cpp (working copy)
@@ -1,9 +1,9 @@
#include "os.h"
#include "Plugin.h"

-#ifndef MSVC
-typedef long (*GFInfo)(int index, void** address, char** def) __attribute__((stdcall));
-typedef long (*GFCount)() __attribute__((stdcall));
+#ifndef _MSC_VER
+typedef long (*GFInfo)(int index, void** address, char** def) __attribute__((__stdcall));
+typedef long (*GFCount)() __attribute__((__stdcall));
#else
typedef long (__stdcall *GFInfo)(int index, void** address, char** def);
typedef long (__stdcall *GFCount)();
@@ -32,7 +32,6 @@
if ((space != string::npos) && (par != string::npos))
{
newName = newName.substr(space + 1, par - space - 1);
- size_t pos = newName.find_first_of("(;:) ");
functions[newName] = addr;
}
}
Index: preprocessor.h
===================================================================
--- preprocessor.h (revision 47)
+++ preprocessor.h (working copy)
@@ -1,28 +1,28 @@
#ifndef _PREPROCESSOR_H_
#define _PREPROCESSOR_H_
-
+
// Linux doesn't use the same dllexport stuff.
#ifndef LINUX
# if BUILDING_DLL
-# ifdef MSVC
+# ifdef _MSC_VER
# define EXPORT __declspec(dllexport)
# define CLASS class __declspec (dllexport)
# else
-# define EXPORT __declspec (dllexport) __attribute__((stdcall))
+# define EXPORT __declspec (dllexport) __attribute__((__stdcall))
# define CLASS class __declspec (dllexport)
# endif
# else /* Not BUILDING_DLL */
-# ifdef MSVC
+# ifdef _MSC_VER
# define EXPORT __declspec (dllimport)
# define CLASS class __declspec (dllimport)
# else
-# define EXPORT __declspec (dllimport) __attribute__((stdcall))
+# define EXPORT __declspec (dllimport) __attribute__((__stdcall))
# define CLASS class __declspec (dllimport)
# endif
# endif /* Not BUILDING_DLL */
#else /* Linux environment */
-# define EXPORT
+# define EXPORT
# define CLASS class
#endif
-
-#endif /* header endif */
+
+#endif /* header endif */
Index: Scar++.vcproj
===================================================================
--- Scar++.vcproj (revision 47)
+++ Scar++.vcproj (working copy)
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="9.00"
+ Version="9,00"
Name="Scar++"
ProjectGUID="{B45C07E5-3055-4DC3-8124-78D20C1948BE}"
+ RootNamespace="Scar++"
Keyword="Win32Proj"
TargetFrameworkVersion="0"
>
@@ -41,13 +42,13 @@
Optimization="3"
OmitFramePointers="true"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SCAR_EXPORTS;WINDOWS;BUILDING_DLL"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
+ MinimalRebuild="false"
+ BasicRuntimeChecks="0"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="4"
+ WarningLevel="4"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -60,6 +61,7 @@
/>
<Tool
Name="VCLinkerTool"
+ AdditionalDependencies="zdll.lib"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="2"
Index: scarmain.cpp
===================================================================
--- scarmain.cpp (revision 47)
+++ scarmain.cpp (working copy)
@@ -1,4 +1,4 @@
-#ifdef MSVC
+#ifdef _MSC_VER
// MSVC is dumb, it won't let us use pre-processors unless one is
// declared on the first line.
#endif
@@ -52,6 +52,9 @@
DWORD reason /* Reason this function is being called. */ ,
LPVOID reserved /* Not used. */ )
{
+ (hInst);
+ (reserved);
+
switch (reason)
{
case DLL_PROCESS_ATTACH:

boberman

2009-10-15 16:56:47

fonty, I've applied your patch. however, do note that the way I was using standard call was indeed correct. In GCC, __attribute__((stdcall)) is the notation to do standard calls. in MSVC it is __stdcall. It is a difference in compilers and definitely not a c standard.

I went ahead and applied your patch to my local branch for now, but undid your __stdcall changes. I'll apply it as soon as assembla lets me :) (Dang thing is down for now)

Wizzup?

2009-10-15 17:13:29

I think that creating statements that will be optimized away to prevent compiler warnings is totally useless, and not pretty. Better let the compiler warn about it; it does so for a reason.

Or just disable the warning?

boberman

2009-10-15 19:27:27

Well, what's Ironic is that vc++ warns if the statements aren't there, gcc warns that the statements ARE there :)

Whatever though, I'll clean it up later if I ever get the time to fix things up.

Wizzup?

2009-10-15 19:52:16

From: boberman
Well, what's Ironic is that vc++ warns if the statements aren't there, gcc warns that the statements ARE there :)

Whatever though, I'll clean it up later if I ever get the time to fix things up.


Why not use gcc on windows too though?

EDIT: Yeah, that's quite ironic, but expected. :p

boberman

2009-10-16 02:26:18

From: Wizzup?
Why not use gcc on windows too though?

EDIT: Yeah, that's quite ironic, but expected. :p


:) I use gcc (mingw) as my primary compiler. I just tried to get things setup so that MSVC can work as well.

fronty

2009-10-16 06:45:34

Oh yeah, I didn't spot that those stdcalls were in blocks meant for non-MSVC. I just spotted how it complained about syntax error at stdcall and changed it into __stdcall, and then spotted usage of macro MSVC and changed it.

I prefer that kind of preventing of those warnings, and I think every part of code that causes compiler warning should be corrected. Most of those warnings were in functions (or methods, don't remember) that aren't fully implemented, so those statements will be removed in future. Some of those warnings came from functions which are implemented and those parameters really were of no use. I think disabling warnings is definitely not The Right Thing To Do in any case.

I prefer native utilities on every platform. GCC doesn't even support Windows, so I think using VC or ICC for C++, or some other programs that support Windows for Windows development, and GNU's compilers on BSD/Linux/others or some other compilers for different languages, like pcc for C and fpc for Pascal.

WTF? Doesn't GCC warn about unused parameters? Do you compile with -W -Wall -Wextra?

Wizzup?

2009-10-16 06:52:34

From: fronty
Oh yeah, I didn't spot that those stdcalls were in blocks meant for non-MSVC. I just spotted how it complained about syntax error at stdcall and changed it into __stdcall, and then spotted usage of macro MSVC and changed it.

I prefer that kind of preventing of those warnings, and I think every part of code that causes compiler warning should be corrected. Most of those warnings were in functions (or methods, don't remember) that aren't fully implemented, so those statements will be removed in future. Some of those warnings came from functions which are implemented and those parameters really were of no use. I think disabling warnings is definitely not The Right Thing To Do in any case.

I prefer native utilities on every platform. GCC doesn't even support Windows, so I think using VC or ICC for C++, or some other programs that support Windows for Windows development, and GNU's compilers on BSD/Linux/others or some other compilers for different languages, like pcc for C and fpc for Pascal.

WTF? Doesn't GCC warn about unused parameters? Do you compile with -W -Wall -Wextra?


GCC should warn about unused parameters, but it also warns about useless statements, like the ones you added.
GNU doesn't "support" Windows on idealogical level, but their compiler works fine for Windows. FPC is also cross platform.

I dislike paying for any development tool.

fronty

2009-10-16 08:35:34

MinGW works under Windows. Can you see MinGW in GCC tree? No.

I know fpc is cross platform. Did I say it wasn't? No. I know I maybe didn't express my opinion very well, but what I meant was that fpc is an alternative for GCC for Pascal family, and one option like any other compiler for Pascal developement under Windows.

You can get both ICC and VC for free.

Some projects I've participated and which were supposed to be compilable with many compilers, including MSVC and GCC, without warnings, used macros for this purpose. IIRC in one project there was two macros, unused, and USE(). They were used and defined like this:
#ifdef __GNUC__
# define unused __attribute__((unused))
# define USE(x)
#elif defined(_MSC_VER)
# define unused
# define USE(x) (x)
#endif /* __GNUC__ */

void func(int x unused)
{
USE(x);
...
}

I know this isn't very elegant solution, but I think it's better than long list of warnings.

boberman

2009-10-16 10:55:15

From: fronty
MinGW works under Windows. Can you see MinGW in GCC tree? No.

I know fpc is cross platform. Did I say it wasn't? No. I know I maybe didn't express my opinion very well, but what I meant was that fpc is an alternative for GCC for Pascal family, and one option like any other compiler for Pascal developement under Windows.

You can get both ICC and VC for free.

Some projects I've participated and which were supposed to be compilable with many compilers, including MSVC and GCC, without warnings, used macros for this purpose. IIRC in one project there was two macros, unused, and USE(). They were used and defined like this:
#ifdef __GNUC__
# define unused __attribute__((unused))
# define USE(x)
#elif defined(_MSC_VER)
# define unused
# define USE(x) (x)
#endif /* __GNUC__ */

void func(int x unused)
{
USE(x);
...
}

I know this isn't very elegant solution, but I think it's better than long list of warnings.


MingW is just gcc with a little extra code to handle POSTIX problems that happen on windows. Just because it isn't an official part of the gcc, doesn't mean it shouldn't be considered a gcc compiler.

Using macros to eliminate warnings is retarded. Getting ride of them is ok. but trying to completely stamp them out by using bad coding practice is bad. I hate macros, and I wish that I could do this project without them. However, I can't do it without making two separate branches, so I've been burdened with the macros.

But like I said, I prefer the GCC. Partially because I'm familiar with the kind of code it generates, partially because it is easier to get code to work for all platforms if it works with the gcc on one platform. I'm not saying that the MSVC is bad, I'm just less familiar with it.

fronty

2009-10-16 12:27:03

Yes, MinGW is GCC port, but it's not pure GCC. If GCC would out of box without any special arrangements run on Windows, I would say GCC would support Windows. But now, I would just say you can run it on Windows and use it to produce PEs runnable on Windows.

Wtf, does someone nowadays really meddle with assembly generated by compilers or use machine level debugger that much, that he can say he is familiar with code generated by some compiler? ;o

It is useful to have one compiler which can be used on several platforms and works same way on every platform (if we don't care about ABI, etc.). But still the biggest concern is libraries, which don't depend on compilers. And compiler extension are just plain bad.

Wizzup?

2009-10-16 13:21:21

From: fronty
Yes, MinGW is GCC port, but it's not pure GCC. If GCC would out of box without any special arrangements run on Windows, I would say GCC would support Windows. But now, I would just say you can run it on Windows and use it to produce PEs runnable on Windows.

Wtf, does someone nowadays really meddle with assembly generated by compilers or use machine level debugger that much, that he can say he is familiar with code generated by some compiler? ;o

It is useful to have one compiler which can be used on several platforms and works same way on every platform (if we don't care about ABI, etc.). But still the biggest concern is libraries, which don't depend on compilers. And compiler extension are just plain bad.


I'm pretty sure lots of people are familiar with code generated by GCC… Probably more than with ICC or Microsoft C Compiler. ( I'm sure you can guess why… :) )

footballjds

2009-10-16 13:52:41

From: boberman
Amen brother, Amen… :). Today and yesterday I haven't had a lot of time to work on this thing. Hopefully in the near future my schedule will free up a bit. (Sister had a baby, 12 lbs..)


12 lbs? damn! is she alright?

fronty

2009-10-16 14:27:04

From: Wizzup?
I'm pretty sure lots of people are familiar with code generated by GCC… Probably more than with ICC or Microsoft C Compiler. ( I'm sure you can guess why… :) )


I was wondering earlier this week, what kind of code does GCC generate for this C++ program?

#include <iostream>
#include <sstream>
#include <string>

template< T >
class a
{
private:
T value;

public:
a(void) { }
a(T val) :value(val) { }

std::string serialize(void) {
std::stringstream ss;
ss << "<a><val>" << value << "</val></a>";
return ss.str();
}
};

int
main(void)
{
a<int> foo('a');
std::cout << foo.serialize() << std::endl;
return 0;
}

It's such a good thing that here is people who are familiar with GCC's output code. :)

Wizzup?

2009-10-16 16:00:13

From: fronty
I was wondering earlier this week, what kind of code does GCC generate for this C++ program?

#include <iostream>
#include <sstream>
#include <string>

template< T >
class a
{
private:
T value;

public:
a(void) { }
a(T val) :value(val) { }

std::string serialize(void) {
std::stringstream ss;
ss << "<a><val>" << value << "</val></a>";
return ss.str();
}
};

int
main(void)
{
a<int> foo('a');
std::cout << foo.serialize() << std::endl;
return 0;
}

It's such a good thing that here is people who are familiar with GCC's output code. :)


Bad thing you (presumably) don't know enough about C++ templates.

However, Good thing gcc has the option to directly dump assembly it generates. (change gcc to g++)


gcc -O0 -S <yourfile>

Yakman

2009-10-16 16:00:54

I hope you trolling fronty, that code suggests you know almost nothing about templates.

R0b0t1

2009-10-16 16:06:49

I hope you trolling fronty, that code suggests there are people who actually think templates make more readable code.


EDIT: Also, most large projects compile with warnings. Just forget about them.

fronty

2009-10-16 16:38:37

Damn, forgot 'class' from template. My fault. When correcting that, it compiles without any warning with Visual Studio 2008 and GCC 4.3.2. So syntatically and semantically it's completely correct, I think. I admit the way I build the string expects too much from type used with the class and the whole class is very horribly designed. But my point wasn't publishing some class library that can do miracles.

I am familiar with different sorts of metaprogramming, including templates. I know it's possible to generate just asm with gcc and not to feed it automatically to assember, which is useful when learning at&t syntax.

Many projects compile with warnings, but warnings point out many things that should be fixed. IMHO ignoring good advice is wrong.

In right places templates let you reuse code, which imo is better than writing huge amount of code just to let you do same things with different datatypes.

My point was that I think being familiar with code some compiler outputs is not something you can easily say in case of language like C++ if you don't work often with the compiler itself. Templates, virtual functions and different kinds of kinkinds of optimizations make it very hard, especially if you aren't familiar with the compiler's back end.

EDIT: Wizzup, when generating just asm it doesn't matter do you use gcc or g++, both generate the same code. GCC is smart enough to choose the right compiler to use in compilation depending on file extension or flags. The difference is in linker's input.

Wizzup?

2009-10-16 16:53:45

From: fronty
Damn, forgot 'class' from template. My fault. When correcting that, it compiles without any warning with Visual Studio 2008 and GCC 4.3.2. So syntatically and semantically it's completely correct, I think. I admit the way I build the string expects too much from type used with the class and the whole class is very horribly designed. But my point wasn't publishing some class library that can do miracles.

I am familiar with different sorts of metaprogramming, including templates. I know it's possible to generate just asm with gcc and not to feed it automatically to assember, which is useful when learning at&t syntax.

Many projects compile with warnings, but warnings point out many things that should be fixed. IMHO ignoring good advice is wrong.

In right places templates let you reuse code, which imo is better than writing huge amount of code just to let you do same things with different datatypes.

My point was that I think being familiar with code some compiler outputs is not something you can easily say in case of language like C++ if you don't work often with the compiler itself. Templates, virtual functions and different kinds of kinkinds of optimizations make it very hard, especially if you aren't familiar with the compiler's back end.

EDIT: Wizzup, when generating just asm it doesn't matter do you use gcc or g++, both generate the same code. GCC is smart enough to choose the right compiler to use in compilation depending on file extension or flags. The difference is in linker's input.


Hmm.. I get your point; but I don't think that is what boberman referred to when he said he was familiar with the code it generates. At least not in that level of complexity. /me waits on a reaction by boberman.

@ gcc/g++: OK. I didn't know that. I recall that when I first started with c++, I got errors because I was using gcc, and not g++ explicitly. :)

boberman

2009-10-16 17:01:41

From: fronty
Yes, MinGW is GCC port, but it's not pure GCC. If GCC would out of box without any special arrangements run on Windows, I would say GCC would support Windows. But now, I would just say you can run it on Windows and use it to produce PEs runnable on Windows.

Wtf, does someone nowadays really meddle with assembly generated by compilers or use machine level debugger that much, that he can say he is familiar with code generated by some compiler? ;o

It is useful to have one compiler which can be used on several platforms and works same way on every platform (if we don't care about ABI, etc.). But still the biggest concern is libraries, which don't depend on compilers. And compiler extension are just plain bad.


When you are taking high performance code. Yes, someone does indeed need to know what the low level stuff is doing :). I couldn't really tell you what is going on with object oriented code or templates. That is a little complex. However, knowing how memory is packed, knowing what code is generated, and knowing how to tweak that code generation is pretty necessary when you talk about low level high speed code.

I know it isn't implemented yet, however, I could easily see a day when scar++ has bits of assembly included in it.

fronty

2009-10-16 17:22:21

Good to hear what was the thinking behind you post so you don't talk about fence and I about nails in the fence.

It is good to know some methods used by your compiler in code generation, especially when integrating asm with higher level code. However, in my opinion knowing how to optimize your algorithms and loops will lead to faster programs than doing some trickery with memory packing of your compiler, and it will work better programs with other compilers, too. Even writing some parts of program in assembly can be bad choice, because compiler bay be able to optimize some things and choose better instructions than you. But that is highly dependant on compiler, optimizing level, processor architecture and processor, and assembly programming skills.

If you plan to write some parts in assembly, so long toolchain independence. :)