I keep receiving a run-time error "Input string was not in a correct format." for this line of code:
int MpqNum = CheckRevision.ExtractMPQNumber(MpqName);
Any ideas why I am getting this error?
Maybe if you posted some input strings...
MpqName "lockdown-IX86-18.mpq" string
MpqNum 0 int
Those are the inputs...
As MBNCSUtil doesn't yet support lockdown, it also doesn't support extracting lockdown MPQ numbers.
If you need it, your best bet would be to completely circumvent that library and use BNLS_VERSIONCHECKEX2.
Or one of the few Lockdown DLLs.
Or, this Java library:
try {
InetAddress address = MirrorSelector.getClosestMirror(cs.bnlsServer, cs.bnlsPort);
Socket conn = new Socket(address, cs.bnlsPort);
recieveInfo("Connected to " + address + ":" + cs.bnlsPort);
BNLSPacket bnlsOut = new BNLSPacket(BNLSCommandIDs.BNLS_VERSIONCHECKEX2);
bnlsOut.writeDWord(cs.product);
bnlsOut.writeDWord(0); // Flags
bnlsOut.writeDWord(0); // Cookie
bnlsOut.writeQWord(MPQFileTime);
bnlsOut.writeNTString(MPQFileName);
bnlsOut.writeNTString(ValueStr);
bnlsOut.SendPacket(conn.getOutputStream(), cs.packetLog);
InputStream bnlsInputStream = conn.getInputStream();
long startTime = System.currentTimeMillis();
while(bnlsInputStream.available() < 3) {
Thread.sleep(10);
Thread.yield();
long timeElapsed = System.currentTimeMillis() - startTime;
if(timeElapsed > 5000)
throw new Exception("BNLS_VERSIONCHECKEX2 timeout");
}
BNLSPacketReader bpr = new BNLSPacketReader(bnlsInputStream, cs.packetLog);
BNetInputStream bnlsIn = bpr.getInputStream();
int success = bnlsIn.readDWord();
if(success != 1) {
Out.error(getClass(), "BNLS_VERSIONCHECKEX2 Failed\n" + HexDump.hexDump(bpr.getData()));
throw new Exception("BNLS failed to complete BNLS_VERSIONCHECKEX2 sucessfully");
}
exeVersion = bnlsIn.readDWord();
exeHash = bnlsIn.readDWord();
exeInfo = bnlsIn.readNTString();
bnlsIn.readDWord(); // cookie
/*int exeVerbyte =*/ bnlsIn.readDWord();
assert(bnlsIn.available() == 0);
recieveInfo("Recieved CheckRevision from BNLS");
conn.close();
} catch(UnknownHostException e) {
recieveError("BNLS connection failed: " + e.getMessage());
setConnected(false);
break;
}
if((exeVersion == 0) || (exeHash == 0) || (exeInfo == null) || (exeInfo.length() == 0)) {
recieveError("Checkrevision failed!");
setConnected(false);
break;
}
See:
http://bnubot.googlecode.com/svn/trunk/BNUBot/src/net/bnubot/core/bncs/BNCSConnection.java
http://bnubot.googlecode.com/svn/trunk/BNUBot/src/net/bnubot/core/bnls/
A nice huge project there Camel ;) SVN unfortunately sucks, Perforce > *
Quote from: Camel on September 20, 2007, 11:34 PM
Or, this Java library:
try {
InetAddress address = MirrorSelector.getClosestMirror(cs.bnlsServer, cs.bnlsPort);
Socket conn = new Socket(address, cs.bnlsPort);
recieveInfo("Connected to " + address + ":" + cs.bnlsPort);
BNLSPacket bnlsOut = new BNLSPacket(BNLSCommandIDs.BNLS_VERSIONCHECKEX2);
bnlsOut.writeDWord(cs.product);
bnlsOut.writeDWord(0); // Flags
bnlsOut.writeDWord(0); // Cookie
bnlsOut.writeQWord(MPQFileTime);
bnlsOut.writeNTString(MPQFileName);
bnlsOut.writeNTString(ValueStr);
bnlsOut.SendPacket(conn.getOutputStream(), cs.packetLog);
InputStream bnlsInputStream = conn.getInputStream();
long startTime = System.currentTimeMillis();
while(bnlsInputStream.available() < 3) {
Thread.sleep(10);
Thread.yield();
long timeElapsed = System.currentTimeMillis() - startTime;
if(timeElapsed > 5000)
throw new Exception("BNLS_VERSIONCHECKEX2 timeout");
}
BNLSPacketReader bpr = new BNLSPacketReader(bnlsInputStream, cs.packetLog);
BNetInputStream bnlsIn = bpr.getInputStream();
int success = bnlsIn.readDWord();
if(success != 1) {
Out.error(getClass(), "BNLS_VERSIONCHECKEX2 Failed\n" + HexDump.hexDump(bpr.getData()));
throw new Exception("BNLS failed to complete BNLS_VERSIONCHECKEX2 sucessfully");
}
exeVersion = bnlsIn.readDWord();
exeHash = bnlsIn.readDWord();
exeInfo = bnlsIn.readNTString();
bnlsIn.readDWord(); // cookie
/*int exeVerbyte =*/ bnlsIn.readDWord();
assert(bnlsIn.available() == 0);
recieveInfo("Recieved CheckRevision from BNLS");
conn.close();
} catch(UnknownHostException e) {
recieveError("BNLS connection failed: " + e.getMessage());
setConnected(false);
break;
}
if((exeVersion == 0) || (exeHash == 0) || (exeInfo == null) || (exeInfo.length() == 0)) {
recieveError("Checkrevision failed!");
setConnected(false);
break;
}
See:
http://bnubot.googlecode.com/svn/trunk/BNUBot/src/net/bnubot/core/bncs/BNCSConnection.java
http://bnubot.googlecode.com/svn/trunk/BNUBot/src/net/bnubot/core/bnls/
From what I've read, SVN has the largest stability e-penis, and that's all I care about. Besides, I don't choose what mechanism Google Code uses.
How bout you just do:
Convert.ToInt32(mpqFilename.Substring(14, 2));
- I also added the Convert, so it's ready for your packet:
Example:
ublic void BNLS_VERSIONCHECK()
{
DataBuffer s0x09 = new DataBuffer();
s0x09.InsertInt16(0);
s0x09.InsertByte((byte)BNLSPacketId.BNLS_VERSIONCHECK);
s0x09.InsertInt32(0x04);
s0x09.InsertInt32(Convert.ToInt32(mpqFilename.Substring(14, 2)));
s0x09.InsertCString(checksumFormula);
byte[] temp = s0x09.GetData();
temp[0] = Convert.ToByte(Convert.ToInt16(s0x09.Count));
bnls.SendData(temp);
AddChat("BNLS VersionCheck Sent", Color.Black);
}
How bout you just do: BNLS_VERSIONCHECKEX2
Quote from: Smarter on September 26, 2007, 08:14 AM
How bout you just do:
Convert.ToInt32(mpqFilename.Substring(14, 2));
Because it is not always at position 14 of the string, e.g. IX86-ver-00.mpq (starts at 10), lockdown-IX86-00.mpq (starts at 15), and ver-IX86-00.mpq (starts at 10 as well).
The CheckRevision.extractMPQNumber determines which mpq file it is before extracting the number of the mpq.