wt200999 wrote:
IMy ultimate goal is to be able to check a bf2 username and password to verify it.
I had the same problem (unique nick incorrect), and it has to do with the final string you send to the server. In the gamename field, use something that isn't a real game, instead of battlefield2. I use "battlefield6". While it isn't a real game, it for some reason doesn't give the "uniquenick incorrect" error on certain names. I think it has to do with whether or not the nickname you are checking is the primary one on the gamespy account. Gamespy accounts are actually email addresses with multiple nicknames that can be in them. I'm not exactly sure how it all works, but it definitely has to do with that gamename and where it stands in the account. Changing the gamename allowed for all names to be checked properly, and not give the unique nick incorrect error. Anyways... in order to have all names work properly, you can set your code up like the following example:
Username: testuser
Password: hello123
1) Open the socket to connect to: gpcm.gamespy.com:29900
2) Server replies with something like: \lc\1\challenge\ABCDEFGHIJ\id\1\final\
3) Parse that string, and get only the challenge part (ABCDEFGHIJ) into a variable or something.
3) Now, the response you want to send to the server (given the challenge, username, and password above) would be:
\login\\challenge\1234567890abcdef1234567890abcdef\uniquenick\testuser\response\25e2cd7cdb06f2a6115d50e661815b04\port\8765\productid\10492\gamename\battlefield6\namespaceid\12\sdkrevision\3\id\1\final\
- 1234567890abcdef1234567890abcdef can be anything. Just make it a random string of 32 characters in length, and hexidecimal
- 25e2cd7cdb06f2a6115d50e661815b04 is just the md5 hash of the following data:
md5hashofpassword+48spaces+nickname+random32characterstring+10digitchallengestring+md5hashofpassword
---- 48spaces is just 48 empty spaces, not the actual string "48spaces"
---- random32characterstring is the random 32 character hex string we generated above: 1234567890abcdef1234567890abcdef
---- 10digitchallengestring is the string the server first sent us when we connected
---- the rest should be obvious. just make it 1 long string, all 1 word, without the +'s... and then md5 the entire thing. If you use the data from my example, 25e2cd7cdb06f2a6115d50e661815b04 should be the correct result.
The rest of the string (\port\8765\productid\10492\gamename\battlefield6\namespaceid\12\sdkrevision\3\id\1\final\ ) I keep the exact same every check, especially the battlefield6 so i get accurate replies :P.
That was probably more than you wanted to know, and I'm sure you knew most of that already, but I like to explain stuff in detail to make sure it's understood. I have worked in-depth on the bf2 username/password checking... so let me know if there's anything I can clarify.
Edit: I also forgot to mention that I change the productid to 10492 as shown above. By default, I think it's 10493. So you might want to keep that changed too :P.