Thread: [508] account creation [508]

Page 1 of 6 123 ... LastLast
Results 1 to 10 of 55
  1. #1 [508] account creation [508] 
    Registered Member

    Join Date
    Sep 2008
    Posts
    1,801
    Thanks given
    4
    Thanks received
    50
    Rep Power
    636
    Tutorial: [508] account creation [508]
    Files modified/added: login.java
    Difficulty: 5/10? just a guess lol


    Ok so i had finished 508 account creation and not many people know how to fix pali's login block so it works

    lets start off with the first stage of login

    this is pali's current -
    Code:
                try {
                    if (!fillStream(p, 2))
                        return;
                } catch (Exception e) {
                    return;
                }
                int connectionType = p.stream.readUnsignedByte();
                if (connectionType == 15) {
                    updateServer(p);
                    p.loginStage = -5;
                    return;
                }
                if (connectionType != 14) {
                    p.loginStage = -1;
                    return;
                }
                int longPlayerName = p.stream.readUnsignedByte();
                p.stream.writeSignedByte(0);
                p.stream.writeQWord(serverSessionKey);
                directFlushStream(p);
                p.loginStage++;
    now whats wrong with this is the

    Code:
    if (!fillStream(p, 2))
    in order for account creation to work we have to read all available incomming bytes

    so lets change it to

    Code:
    if (!fillStream(p, p.socket.avail()))
    that way it'll read all incomming bytes

    now we need to fix the connection types

    lets change:

    Code:
                if (connectionType == 15) {
                    updateServer(p);
                    p.loginStage = -5;
                    return;
                }
                if (connectionType != 14) {
                    p.loginStage = -1;
                    return;
                }
                int longPlayerName = p.stream.readUnsignedByte();
                p.stream.writeSignedByte(0);
                p.stream.writeQWord(serverSessionKey);
                directFlushStream(p);
                p.loginStage++;
    to

    Code:
                switch(connectionType) {
                    case 15:
                        updateServer(p);
                        p.loginStage = -5;
                        return;
                    case 14:
                        int longPlayerName = p.stream.readUnsignedByte();
                        p.stream.writeSignedByte(0);
                        p.stream.writeQWord(serverSessionKey);
                        directFlushStream(p);
                        p.loginStage++;
                        break;
                    default:
                        p.loginStage = -1;
                        return;
                }
    now we have to add the first step to account creation which is checking and validating the birthdate, so lets add this to the switch statement

    Code:
                    case 85:
    			int code = 2;
    			int day = p.stream.readSignedByte();
    			int month = p.stream.readSignedByte();
    			int year = p.stream.readDWord();
    			int country = p.stream.readDWord());
    		    	p.stream.writeSignedByte(code);
    		    	// some return codes, 11 (invalid birthday), 12 (birthday is in future), 13 (was this year)
    		    	// 14 (was last year), 15 (invalid country), 21 (never ending loading)
    		    	directFlushStream(p);
                                          p.loginStage = -1;
    			break;
    You can modify it to save the data if you want

    Now lets add the second part, chosing the username the person wants (add this to the switch statement also)

    Code:
                    case 118:
    		    	int Scode = 2;
    		    	String Susername = longToString(p.stream.readQWord()).toLowerCase().replaceAll("_", " ").trim();
    		    	if(Susername == null || Susername.equals("invalid name")) {
    		            Scode = 22;
    		    	}
    		    	File Sfile = new File("../Data/characters/mainsave/" + Susername + ".dat");
    		    	if(Sfile.exists()) {
    			    Scode = 20;
    		    	}
    		    	stream.writeSignedByte(Scode); //20 = username not available, //22 = not valid username
    		    	directFlushStream(p);
                                          p.loginStage = -1;
    			break;
    Now we have to move on to the final step, chosing your password (add this to switch statement)

    Code:
                    case 48:
    		    	int code = 2;
    		    	p.stream.readUnsignedByte();//junk
    		    	p.stream.readUnsignedByte();//junk
    		    	p.stream.readUnsignedByte();//junk
    		    	p.stream.readWord();//junk
    			int revision = p.stream.readWord();
    			if(revision != 508) {
    			    code = 37;
    			}
    			String username = longToString(p.stream.readQWord()).toLowerCase().replaceAll("_", " ").trim();
    		    	p.stream.readDWord();//junk
    		    	String passwords = p.stream.readString().toLowerCase();
    		    	p.stream.readDWord();//junk
    			p.stream.readWord();//junk
    			int Fday = p.stream.readUnsignedByte(); //might be signed
    			int Fmonth = p.stream.readUnsignedByte(); //might be signed
    			p.stream.readDWord();//junk
    			int year = p.stream.readWord();
    			int location = p.stream.readWord();
    			p.stream.readDWord();
    			if(!validString(passwords)) { // you'll have to make your own validString method
    			    code = 31;
    			}
    		    	if(username == null) {
    			    code = 20;
    		    	}
    		    	if(passwords.length() < 4) {
    			    code = 32;
    		    	}
    		        if(passwords.equals(username)) {
    				code = 34;
    		    	}
    		    	if(passwords == null || passwords.equals("") || passwords.equals(" ")) {
    			    code = 30;
    		    	}
    		    	try {
    		    	    File file = new File("../Data/characters/mainsave/" + Susername + ".dat");
    		    	    if(file.exists()) {
    			    	code = 20;
    		    	    }
    		    	} catch(Exception e) {
    			    System.out.println(e);
    		    	}
    		    	stream.writeSignedByte(code);//20 = username not available anymore //29 = invalid password length
    		    	//30 = invalid characters in password, 31 = password is too easy to guess, 32 = passwords don't match
    		    	//34 = password too simliar to username, 37 = runescape ahs been updated
    		    	
    		    	try {
    			    if(code != 2) {
    			        return;
    			    }
    		    	    //create account method goes here
    		    	} catch(Exception e) {
    			    System.out.println(e);
    		    	}
    		    	directFlushStream(p);
                                           p.loginStage = -1;
                                           break;
    now we can change the login stage three so it can see if a account exists instead of auto-account creation

    change

    Code:
                if (password != null && p.password != null && p.password != "" && !p.password.equals(password)) {
                    returnCode = 3;
    to

    Code:
    		    	    File file = new File("../Data/Character/" + username + ".txt");
                if (password == null || p.password == null || p.password == "" || !p.password.equals(password) || !file.exists()) {
                    returnCode = 3;
    post any errors so OTHER people can help you

    Note:
    -you have to create YOUR OWN account creation method that creates the actual account
    -You'll have to import java.io.File;
    -Some of the reading methods might be wrong because i had to convert from my source
    Reply With Quote  
     

  2. #2  
    Super Donator

    Janizary's Avatar
    Join Date
    Jul 2009
    Age
    19
    Posts
    2,132
    Thanks given
    109
    Thanks received
    137
    Rep Power
    1031
    Nice release.

    [Only registered and activated users can see links. ]
    Quote Originally Posted by Pirlo View Post
    I don't think the cold war existed during/before WWI
    Reply With Quote  
     

  3. #3  
    Registered Member

    Join Date
    Sep 2008
    Posts
    1,801
    Thanks given
    4
    Thanks received
    50
    Rep Power
    636
    Quote Originally Posted by Ninja Assassin View Post
    Nice release.
    wow that was a fast reply
    Reply With Quote  
     

  4. #4  
    Registered Member
    timetodothis's Avatar
    Join Date
    Jul 2009
    Posts
    532
    Thanks given
    24
    Thanks received
    55
    Rep Power
    123
    Holy shit Zach,

    Ill check it out.


    Goodjob,
    Reply With Quote  
     

  5. #5  
    Номер 1


    Leanbow's Avatar
    Join Date
    Feb 2008
    Posts
    5,910
    Thanks given
    1,558
    Thanks received
    2,617
    Rep Power
    5000
    wow.. adding to my pali's atm
    Reply With Quote  
     

  6. #6  
    Ed
    Ed is offline
    AKA Edvinas
    Ed's Avatar
    Join Date
    Jun 2009
    Age
    28
    Posts
    4,504
    Thanks given
    523
    Thanks received
    512
    Rep Power
    2659
    Nice zach.
    Reply With Quote  
     

  7. #7  
    Registered Member Blayzeee's Avatar
    Join Date
    May 2009
    Posts
    216
    Thanks given
    1
    Thanks received
    8
    Rep Power
    23
    Nice release dude
    Reply With Quote  
     

  8. #8  
    Registered Member
    Join Date
    Oct 2008
    Age
    26
    Posts
    949
    Thanks given
    16
    Thanks received
    14
    Rep Power
    72
    wow very nice
    Reply With Quote  
     

  9. #9  
    Registered Member

    Join Date
    Sep 2008
    Posts
    1,801
    Thanks given
    4
    Thanks received
    50
    Rep Power
    636
    thanks guys =D
    Reply With Quote  
     

  10. #10  
    Extreme Donator


    Join Date
    Jul 2009
    Age
    24
    Posts
    4,350
    Thanks given
    824
    Thanks received
    1,237
    Rep Power
    1789
    Good Job

    You can find my [Only registered and activated users can see links. ], for what I'm currently working on.
    Reply With Quote  
     

Page 1 of 6 123 ... LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •