Why is it, from most of the released bases I've looked at, you use C++... but you don't use C++s features?
Most of the bases looked like hacked up C that got ran over by a mack truck =/
For instance, this base... this guy didn't even use booleans:
Code:
if( f1 == 1 ){
pRunConsoleCommand("SkelModelStencil 1" );
}
if( f1 == 0 ){
pRunConsoleCommand("SkelModelStencil 0" );
}
if( f2 == 1 ){
pRunConsoleCommand("ScreenGlowEnable 1" );
}
if( f2 == 0 ){
pRunConsoleCommand("ScreenGlowEnable 0" );
}
Which, yea, I know in C++ a bool is pretty much the same thing as a short type, but still.. Them using DWORDs for booleans caused nasty checks like this:
Code:
switch(MenuSelection){
case 0:
f1--;
if(f1 < 0){
f1 = 0;
}
break;
case 1:
f2--;
if(f2 < 0){
f2 = 0;
}
break;
When obviously, it would've been much easier (Hell, even much cleaner) to do it like this:
Code:
bool menu_array[MAX_NUM_MENUS]; // Too tired to come up with a nice name for it
if(Menu && ((GetAsyncKeyState(VK_LEFT)&1))){
menu_array[MenuSelection] = !menu_array[MenuSelection];
}
Not only that, but also if you look in the above you'll notice how they're using the short-circuit operator (&& it's called this because if the first condition isn't true, it will just leave the if statement completely)
Anyway, this user does MULTIPLE checks for Menu for no reason at all...
Stripped down dirty example of the source:
Code:
if(menu && ...) {}
if(menu && ...) {}
if(menu && ...) {}
if(menu && ...) {}
Actually, some of it even has a check DIRECTLY AFTER that if statement, checking if the menu is opened AGAIN.
To make that look a lot nicer, you could just do:
Code:
if(menu)
{
if(...) {}
if(...) {}
}
Also note, I saw this a lot as well:
Code:
if(f1 == 1) { }
if(f1 == 0) { }
Since it's not possible for f1 to be 1 AND 0, that's using useless instructions for no reason whatsoever... Just do this:
(Since actually, even in C, doing == 1 is redundant; in C and C++ 0 is false and anything that's not 0 is true.)
Another thing in this source is this:
Code:
//Hack Variables
int f1 = 0;
int f2 = 0;
int f3 = 0;
int f4 = 0;
int f5 = 0;
int f6 = 0;
int f7 = 0;
int f8 = 0;
int f9 = 0;
int f10 = 0;
int f11 = 0;
int f12 = 0;
int f13 = 0;
int f14 = 0;
That's global variables... and it looks REALLY messy if I may say so myself. Do you not agree this is much nicer?
Code:
bool menu_array[14];
Maybe I'm just super picky...
Sorry about this, I guess you say rant? But it just kinda irritates me when I look around the forums and I see people asking questions such as "How can I find the LTClient" or something of the sort and I see a reply of "GO LEARN C++!" (Which may I add won't even help them in that journey any at all aside from when they make their first base; a better suggestion would be to tell them how to learn ASM and to use Olly/IDA which is a completely different different subject) when it seems like you don't know C++ yourself =/
NOTE: I'm not saying no one here knows C++, I'm sure many of you do and I'm sure many of you know it far better than me. I'm just giving a lesson-in-disguise I guess, showing people the light.
NOTE 2: Some of you may know which source this is mainly pointing out (This is _ONLY_ because I have it opened at this moment looking through it, not because it's any worse than the others), anyway, if you do know who's it is please don't mention their names.