|
async login(u, p, reconnecting) { |
|
if (this.worldFullTimeout > 0) { |
|
this.showLoginScreenStatus('Please wait...', 'Connecting to server'); |
|
await sleep(2000); |
|
this.showLoginScreenStatus('Sorry! The server is currently full.', 'Please try again later'); |
|
return; |
|
} |
|
|
|
try { |
|
this.username = u; |
|
u = Utility.formatAuthString(u, 20); |
|
|
|
this.password = p; |
|
p = Utility.formatAuthString(p, 20); |
|
|
|
if (u.trim().length === 0) { |
|
this.showLoginScreenStatus('You must enter both a username', 'and a password - Please try again'); |
|
return; |
|
} |
|
|
|
if (reconnecting) { |
|
this.drawTextBox('Connection lost! Please wait...', 'Attempting to re-establish'); |
|
} else { |
|
this.showLoginScreenStatus('Please wait...', 'Connecting to server'); |
|
} |
|
|
|
this.packetStream = new PacketStream(await this.createSocket(this.server, this.port), this); |
|
this.packetStream.maxReadTries = GameConnection.maxReadTries; |
|
|
|
let l = Utility.usernameToHash(u); |
|
|
|
this.packetStream.newPacket(clientOpcodes.SESSION); |
|
this.packetStream.putByte(l.shiftRight(16).and(31).toInt()); |
|
this.packetStream.flushPacket(); |
|
|
|
let sessId = await this.packetStream.getLong(); |
|
this.sessionID = sessId; |
|
|
|
if (sessId.equals(0)) { |
|
this.showLoginScreenStatus('Login server offline.', 'Please try again in a few mins'); |
|
return; |
|
} |
|
|
|
console.log('Verb: Session id: ' + sessId); |
|
|
|
let ai = new Int32Array(4); |
|
ai[0] = (Math.random() * 99999999) | 0; |
|
ai[1] = (Math.random() * 99999999) | 0; |
|
ai[2] = sessId.shiftRight(32).toInt(); |
|
ai[3] = sessId.toInt(); |
|
|
|
this.packetStream.newPacket(clientOpcodes.LOGIN); |
|
|
|
if (reconnecting) { |
|
this.packetStream.putByte(1); |
|
} else { |
|
this.packetStream.putByte(0); |
|
} |
|
|
|
this.packetStream.putShort(GameConnection.clientVersion); |
|
this.packetStream.putByte(0); // limit30 |
|
|
|
this.packetStream.putByte(10); |
|
this.packetStream.putInt(ai[0]); |
|
this.packetStream.putInt(ai[1]); |
|
this.packetStream.putInt(ai[2]); |
|
this.packetStream.putInt(ai[3]); |
|
this.packetStream.putInt(0); // uuid |
|
this.packetStream.putString(u); |
|
this.packetStream.putString(p); |
|
|
|
this.packetStream.flushPacket(); |
|
//this.packetStream.seedIsaac(ai); |
|
|
|
let resp = await this.packetStream.readStream(); |
|
console.log('login response:' + resp); |
|
|
|
if (resp === 25) { |
|
this.moderatorLevel = 1; |
|
this.autoLoginTimeout = 0; |
|
this.resetGame(); |
|
return; |
|
} |
|
|
|
if (resp === 0) { |
|
this.moderatorLevel = 0; |
|
this.autoLoginTimeout = 0; |
|
this.resetGame(); |
|
return; |
|
} |
|
|
|
if (resp === 1) { |
|
this.autoLoginTimeout = 0; |
rsc-client/src/packet-stream.js
Lines 35 to 39 in 2146ae2
Not sure what else is needed here to enable ISAAC.
Also in
rsc-client/src/game-connection.js
Lines 58 to 150 in 2146ae2