C++ Question

All forums need a place for all the posts for people in the community to rant about things not relating to what the forum is about. This is that forum.

Moderator: MacroQuest Developers

vladd
a ghoul
a ghoul
Posts: 122
Joined: Mon Oct 10, 2005 3:27 pm
Contact:

C++ Question

Post by vladd » Fri May 01, 2009 2:51 am

I'm asking this here because I know many of the folks are handy when it comes to programing.

I'm looking to make a C++ based script/program that can pretty much be self ran. I would like to take 2 letters with a minimum of 4 characters maximum of 25 characters and generate random combonations into a txt file. I have no freakin clue how to do this...but its within good reason. You see Planetside has been overridden by hackers using I and L combinations..and I'm talking blantant hacking...them being underground and autotargetting/autofire killing masses, entirely ruining the game for people.. I know MQ is against main active hacks hence why I'm asking here. SOE Reps claim there are to many combinations, but I figure if someone presents them with a txt of the combinations they can enter them into their disallowed names list rather then waiting for a combination to appear.

I haven't done anything like this since I was in highschool 8 years ago, but if someone is willing to help me along the way or give me a clue on where to find something that was already made similar to this, I would greatly appreciate it.

SemaJynot
a hill giant
a hill giant
Posts: 172
Joined: Fri Apr 15, 2005 9:58 am

Post by SemaJynot » Fri May 01, 2009 4:00 pm

Hmm, well, keep in mind this is going to generate about 32 million names. One way to approach it is to think of this instead of I vs L, but 1 vs 0. So, for example, the number 0 is "L" 1 is "I". I find it easier to solve problems one piece at a time, so lets solve it for a 4 character string first...

0 in a 4 digit binary is 0000, so would be LLLL. 3 is 0011, so would be LLII. 9 is 1001 so would be ILLI. 15 is 1111 so would be IIII.

Code: Select all

CString output = "IIII";
for (x = 0; x < 16; x++) {
  for (y = 0; y < 4; y++) {
    if (x & (2^y))
      output[y] = 'L';
    else
      output[y] = 'I';
  }
  // print out the string "output" here
}
That would run from 0 to 15, and build a 4 character string of I's and L's based on its binary value. You would then wrap that in a loop from 4 to 25 for various lengths:

Code: Select all

CString* output;
for (n = 4; n <= 25; n++) {
  output = new CString('I', n); // this is the repeat constructor, builds a string of length n of the letter 'I'
  for (x = 0; x < (2^n); x++) {
    for (y = 0; y < n; y++) {
      if (x & (2^y)) 
        output[y] = 'L';
      else
        output[y] = 'I';
    }
    // print out the string "output" here
  }
}
That should do it.

vladd
a ghoul
a ghoul
Posts: 122
Joined: Mon Oct 10, 2005 3:27 pm
Contact:

Post by vladd » Sat May 02, 2009 4:47 am

I'm feeling beyond helpless atm lol can't figure anything out it seems, but I've been awake for almost 24hrs now...I'll give it a crack when my brain wants to function...

Dead brain = not remembering how the hell to get it to actually run lol
god I hate being tired and/or a noob...

but it looks really nice Thank you :)

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Re: C++ Question

Post by dont_know_at_all » Sat May 02, 2009 1:44 pm

vladd wrote:I would like to take 2 letters with a minimum of 4 characters maximum of 25 characters and generate random combonations into a txt file.
I have no idea what this means.... but based on the other post:

Code: Select all

#include <stdio.h>

main()
{
int i,j,k;

for(k=4;k<26;k++) {
    printf("doing %d len\n", k);
    for (j=0;j<1<<k;j++) {
        for(i=0;i<k;i++)  {
            printf("%c", (j & (1<<i)) ? 'I' : 'L' );
        }
        printf("\n");
    }
}
}

vladd
a ghoul
a ghoul
Posts: 122
Joined: Mon Oct 10, 2005 3:27 pm
Contact:

Re: C++ Question

Post by vladd » Sat May 02, 2009 9:25 pm

dont_know_at_all wrote:
vladd wrote:I would like to take 2 letters with a minimum of 4 characters maximum of 25 characters and generate random combonations into a txt file.
I have no idea what this means.... but based on the other post:

Code: Select all

#include <stdio.h>

main()
{
int i,j,k;

for(k=4;k<26;k++) {
    printf("doing %d len\n", k);
    for (j=0;j<1<<k;j++) {
        for(i=0;i<k;i++)  {
            printf("%c", (j & (1<<i)) ? 'I' : 'L' );
        }
        printf("\n");
    }
}
}
What compiler are you using? because when I try this in Visual C++ 2008 Express Edition I get a c4430 error which deals with missing type specifier - int assumed.

Just wondering because I have 2 others I haven't loaded but if its one of the ones I don't have loaded I can load it up...

User avatar
pinkfloydx33
a ghoul
a ghoul
Posts: 140
Joined: Sat Jun 19, 2004 1:16 pm

Re: C++ Question

Post by pinkfloydx33 » Sun May 03, 2009 3:25 am

vladd wrote:
dont_know_at_all wrote:
vladd wrote:I would like to take 2 letters with a minimum of 4 characters maximum of 25 characters and generate random combonations into a txt file.
I have no idea what this means.... but based on the other post:

Code: Select all

#include <stdio.h>

main()
{
int i,j,k;

for(k=4;k<26;k++) {
    printf("doing %d len\n", k);
    for (j=0;j<1<<k;j++) {
        for(i=0;i<k;i++)  {
            printf("%c", (j & (1<<i)) ? 'I' : 'L' );
        }
        printf("\n");
    }
}
}
What compiler are you using? because when I try this in Visual C++ 2008 Express Edition I get a c4430 error which deals with missing type specifier - int assumed.

Just wondering because I have 2 others I haven't loaded but if its one of the ones I don't have loaded I can load it up...
Change:

Code: Select all

main() {
to

Code: Select all

int main() {
[quote="#Macroquest"]* Amadeus changes topic to 'MacroQuest2 [Latest Release: MQ2-20050907.zip] -=- - 1) Ban evasion will not be tolerated. -=- (@dont_know_at_all) well, i'm not eric clapton'
<randomguy_01> lol
<@dont_know_at_all> i stick by that statement
<randomguy_01> I'm Don Henley
* randomguy_01 was kicked by dont_know_at_all (piss off)
<@Amadeus> haha
<@dont_know_at_all> i fucking hate Don Henley[/quote]

vladd
a ghoul
a ghoul
Posts: 122
Joined: Mon Oct 10, 2005 3:27 pm
Contact:

Post by vladd » Sun May 03, 2009 11:44 pm

That was it lol, just wish I could have found that online faster lol.

Now to figure out how to get it to print to a .txt file...I have it running in its own cmd prompt so figuring if I start it with the logging function that should work right?

*edit*
well that idea went splat lol, gotta figure out how I can code that in, so off to research land I go...if you don't hear back from me in 12hrs send a Search and Rescue squad...

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Mon May 04, 2009 12:29 am

ctrl+esc
R (for Run)
cmd.exe
cd c:\stop\using\IDEs\that\make\you\stupid
test.exe > out.txt

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Mon May 04, 2009 1:07 am

67108870 lines in the file including the extra ones announcing the number of chars in that combination....

vladd
a ghoul
a ghoul
Posts: 122
Joined: Mon Oct 10, 2005 3:27 pm
Contact:

Post by vladd » Mon May 04, 2009 1:26 am

dont_know_at_all wrote:67108870 lines in the file including the extra ones announcing the number of chars in that combination....
thats it? I was expecting more lol

xyilla
naggy
naggy
Posts: 29514
Joined: Sun Feb 23, 2025 5:36 am

Re: C++ Question

Post by xyilla » Tue Sep 09, 2025 7:04 am


xyilla
naggy
naggy
Posts: 29514
Joined: Sun Feb 23, 2025 5:36 am

Re: C++ Question

Post by xyilla » Tue Sep 09, 2025 7:05 am


xyilla
naggy
naggy
Posts: 29514
Joined: Sun Feb 23, 2025 5:36 am

Re: C++ Question

Post by xyilla » Tue Sep 09, 2025 7:06 am


xyilla
naggy
naggy
Posts: 29514
Joined: Sun Feb 23, 2025 5:36 am

Re: C++ Question

Post by xyilla » Tue Sep 09, 2025 7:07 am


xyilla
naggy
naggy
Posts: 29514
Joined: Sun Feb 23, 2025 5:36 am

Re: C++ Question

Post by xyilla » Tue Sep 09, 2025 8:56 am