Valhalla Legends Forums Archive | .NET Platform | Re: MBNCSUtil.CheckRevision.ExtractMPQNumber

AuthorMessageTime
DDA-TriCk-E
I keep receiving a run-time error "Input string was not in a correct format." for this line of code:
[code]
            int MpqNum = CheckRevision.ExtractMPQNumber(MpqName);
[/code]
Any ideas why I am getting this error?
September 19, 2007, 1:34 PM
rabbit
Maybe if you posted some input strings...
September 19, 2007, 5:15 PM
DDA-TriCk-E
MpqName "lockdown-IX86-18.mpq" string
MpqNum 0 int

Those are the inputs...
September 19, 2007, 5:21 PM
Myndfyr
As MBNCSUtil doesn't yet support lockdown, it also doesn't support extracting lockdown MPQ numbers.
September 20, 2007, 9:36 AM
Camel
If you need it, your best bet would be to completely circumvent that library and use BNLS_VERSIONCHECKEX2.
September 20, 2007, 8:20 PM
Barabajagal
Or one of the few Lockdown DLLs.
September 20, 2007, 8:46 PM
Camel
Or, this Java library:

[tt] 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;
                }[/tt]

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/
September 21, 2007, 4:34 AM
devcode
A nice huge project there Camel ;) SVN unfortunately sucks, Perforce > *

[quote author=Camel link=topic=17031.msg173003#msg173003 date=1190349285]
Or, this Java library:

[tt] 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;
                }[/tt]

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/
[/quote]
September 22, 2007, 5:15 AM
Camel
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.
September 22, 2007, 7:06 AM
Smarter
How bout you just do:
[code]
Convert.ToInt32(mpqFilename.Substring(14, 2));[/code]  - I also added the Convert, so it's ready for your packet:

Example:
[code]
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);
        }[/code]
September 26, 2007, 1:14 PM
Camel
How bout you just do: BNLS_VERSIONCHECKEX2
September 27, 2007, 3:45 AM
DDA-TriCk-E
[quote author=Smarter link=topic=17031.msg173250#msg173250 date=1190812499]
How bout you just do:
[code]
Convert.ToInt32(mpqFilename.Substring(14, 2));[/code][/quote]

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.
September 27, 2007, 7:33 AM
Camel
[quote author=Camel link=topic=17031.msg173308#msg173308 date=1190864719]
How bout you just do: BNLS_VERSIONCHECKEX2
[/quote]
September 28, 2007, 1:07 AM

Search