K was bored today so decided to turn blakescape into 377. My cryption and stream class file are perfectly set up for a 377 server.


My
public static final int packetSizes[] = { int is still the same as when i downloaded the source btw.


My error when i try logging in.

Code:
C:\Documents and Settings\Administrator\Desktop\BlackScape>java server
Starting BlakeScape Server on 0.0.0.0:43594
ClientHandler: Accepted from localhost:3117
Fatal: Encrypted packet data length (26) different from length byte thereof (0)
ClientHandler: Client null disconnected.
ClientHandler: Accepted from localhost:3118
Fatal: Encrypted packet data length (26) different from length byte thereof (0)
ClientHandler: Client null disconnected.
ClientHandler: Accepted from localhost:3119
Fatal: Encrypted packet data length (26) different from length byte thereof (0)
ClientHandler: Client null disconnected.
And if you want my public void run

Code:
public void run() {
		isActive = false;
		long serverSessionKey = 0;
		long clientSessionKey = 0;
		serverSessionKey = ((long)(java.lang.Math.random() * 99999999D) << 32) + (long)(java.lang.Math.random() * 99999999D);
		try {
			fillInStream(2);
			int loginID = inStream.readUnsignedByte();
			if(loginID != 14) {
				shutdownError("Expected login ID 14 from client - ID: " + loginID);
				disconnected = true;
				return;
			}
			int namePart = inStream.readUnsignedByte();
			for(int i = 0; i < 8; i++) out.write(0);
			out.write(0);
			outStream.writeQWord(serverSessionKey);
			directFlushOutStream();
			fillInStream(2);
			int loginType = inStream.readUnsignedByte();
			if(loginType != 16 && loginType != 18) {
				shutdownError("Unexpected login type " + loginType);
				return;
			}
			int loginPacketSize = inStream.readUnsignedByte();
			int loginEncryptPacketSize = loginPacketSize-(36+1+1+2);	// the size of the RSA encrypted part (containing password)
			if(loginEncryptPacketSize <= 0) {
				shutdownError("Zero RSA packet size!");
				return;
			}
			fillInStream(loginPacketSize);
			loginID = inStream.readUnsignedByte();
			
			if(loginID != 255) {		// Client version check on different place
				shutdownError("Wrong login packet magic ID (expected 255) - ID [" + loginID + "]");
				return;
			}
			lowMemoryVersion = inStream.readUnsignedByte();
			for(int i = 0; i < 9; i++) {
				String junk = Integer.toHexString(inStream.readDWord());
			}
			loginEncryptPacketSize--;
			int tmp = inStream.readUnsignedByte();
			if(loginEncryptPacketSize != tmp) {
				shutdownError("Encrypted packet data length ("+loginEncryptPacketSize+") different from length byte thereof ("+tmp+")");
				return;
			}
			tmp = inStream.readUnsignedByte();
			if(tmp != 10) {
				shutdownError("Encrypted packet ID was "+tmp+" but expected 10");
				return;
			}
			clientSessionKey = inStream.readQWord();
			serverSessionKey = inStream.readQWord();
			int junk = inStream.readDWord();		//User ID
			playerName = inStream.readString();
			
			playerName = playerName.replaceAll("'", "");
			int sessionKey[] = new int[4];
			sessionKey[0] = (int)(clientSessionKey >> 32);
			sessionKey[1] = (int)clientSessionKey;
			sessionKey[2] = (int)(serverSessionKey >> 32);
			sessionKey[3] = (int)serverSessionKey;
			inStreamDecryption = new Cryption(sessionKey);
			for(int i = 0; i < 4; i++) sessionKey[i] += 50;
			outStreamDecryption = new Cryption(sessionKey);
			outStream.packetEncryption = outStreamDecryption;
															
			out.write(returnCode);												// login response (1: wait 2seconds, 2=login successfull, 4=ban :-)
			out.write(playerRights);											// mod level
			out.write(0);														// no log
		} catch(java.lang.Exception _ex) {
			
			_ex.printStackTrace(); 
			destruct();
			return;
		}
		isActive = true;
		if(playerId == -1 || returnCode != 2) return;
/*Login procedure ends here*/
		packetSize = 0;
		packetType = -1;
		readPtr = 0;
		writePtr = 0;
		int numBytesInBuffer;
		int offset;
		while(!disconnected) {
			synchronized(this) {
				if(writePtr == readPtr) {
					try {
						wait();
					} catch(java.lang.InterruptedException _ex) { }
				}
				if(disconnected) return;
				offset = readPtr;
				if(writePtr >= readPtr) numBytesInBuffer = writePtr - readPtr;
				else numBytesInBuffer = bufferSize - readPtr;
			}
			if(numBytesInBuffer > 0) {
				try {
					//Thread.sleep(3000);		// artificial lag for testing purposes
					out.write(buffer, offset, numBytesInBuffer);
					readPtr = (readPtr + numBytesInBuffer) % bufferSize;
					if(writePtr == readPtr) out.flush();
				} catch (java.net.SocketException _ex) {
					disconnected = true;
				} catch (java.lang.Exception _ex) {
					
					_ex.printStackTrace();
					disconnected = true;
				}
			}
		}
	}