}
}
if(dis.available() > 0) {
BNCSPacketReader pr = new BNCSPacketReader(dis, cs.packetLog);
BNetInputStream is = pr.getData();
switch(pr.packetId) {
case BNCSCommandIDs.SID_EXTRAWORK:
case BNCSCommandIDs.SID_REQUIREDWORK:
break;
case BNCSCommandIDs.SID_NULL: {
lastNullPacket = timeNow;
BNCSPacket p = new BNCSPacket(BNCSCommandIDs.SID_NULL);
p.SendPacket(dos, cs.packetLog);
break;
}
case BNCSCommandIDs.SID_PING: {
BNCSPacket p = new BNCSPacket(BNCSCommandIDs.SID_PING);
p.writeDWord(is.readDWord());
p.SendPacket(dos, cs.packetLog);
break;
}
case BNCSCommandIDs.SID_AUTH_INFO:
case BNCSCommandIDs.SID_STARTVERSIONING: {
if(pr.packetId == BNCSCommandIDs.SID_AUTH_INFO) {
nlsRevision = is.readDWord();
serverToken = is.readDWord();
is.skip(4); //int udpValue = is.readDWord();
}
long MPQFileTime = is.readQWord();
String MPQFileName = is.readNTString();
String ValueStr = is.readNTString();
recieveInfo("MPQ: " + MPQFileName);
byte extraData[] = null;
if(is.available() == 0x80) {
extraData = new byte[0x80];
is.read(extraData, 0, 0x80);
}
assert(is.available() == 0);
// Hash the CD key
byte keyHash[] = null;
byte keyHash2[] = null;
if(nlsRevision != -1) {
keyHash = HashMain.hashKey(clientToken, serverToken, cs.cdkey).getBuffer();
if(cs.product == ConnectionSettings.PRODUCT_LORDOFDESTRUCTION)
keyHash2 = HashMain.hashKey(clientToken, serverToken, cs.cdkeyLOD).getBuffer();
if(cs.product == ConnectionSettings.PRODUCT_THEFROZENTHRONE)
keyHash2 = HashMain.hashKey(clientToken, serverToken, cs.cdkeyTFT).getBuffer();
}
// Hash the game files
String files[] = HashMain.getFiles(cs.product, HashMain.PLATFORM_INTEL);
int exeHash;
int exeVersion;
String exeInfo;
try {
String tmp = MPQFileName;
tmp = tmp.substring(tmp.indexOf("IX86")+4);
while((tmp.charAt(0) < 0x30) || (tmp.charAt(0) > 0x39))
tmp = tmp.substring(1);
tmp = tmp.substring(0,tmp.indexOf("."));
int mpqNum = Integer.parseInt(tmp);
exeHash = CheckRevision.checkRevision(ValueStr, files, mpqNum);
exeVersion = HashMain.getExeVer(cs.product);
exeInfo = HashMain.getExeInfo(cs.product);
} catch(Exception e) {
recieveError("Local hashing failed. Trying BNLS server.");
BNLSProtocol.OutPacketBuffer exeHashBuf;
if((cs.bnlsServer == null)
|| (cs.bnlsServer.length() == 0)) {
exeHashBuf = CheckRevisionBNLS.checkRevision(ValueStr, cs.product, MPQFileName, MPQFileTime);
} else {
exeHashBuf = CheckRevisionBNLS.checkRevision(ValueStr, cs.product, MPQFileName, MPQFileTime, cs.bnlsServer);
}
BNetInputStream exeStream = new BNetInputStream(new java.io.ByteArrayInputStream(exeHashBuf.getBuffer()));
exeStream.skipBytes(3);
int success = exeStream.readDWord();
if(success != 1) {
Out.error(this.getClass().getName(), HexDump.hexDump(exeHashBuf.getBuffer()));
throw new Exception("BNLS failed to complete 0x1A sucessfully");
}
exeVersion = exeStream.readDWord();
exeHash = exeStream.readDWord();
exeInfo = exeStream.readNTString();
exeStream.readDWord(); // cookie
/*int exeVerbyte =*/ exeStream.readDWord();
assert(exeStream.available() == 0);
}
if((exeVersion == 0) || (exeHash == 0) || (exeInfo == null) || (exeInfo.length() == 0)) {
recieveError("Checkrevision failed!");
setConnected(false);