Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: Godzilla on April 22, 2007, 11:29 PM

Title: [C#] Another Quick Q.
Post by: Godzilla on April 22, 2007, 11:29 PM
This time it's about C# and MBNCSUtil:
I just decided to switch over to C# so I'm trying to re-write my code from VB. My question is, how come in C# it's only letting me declare a "new" BncsPacket variable once? The first BncsPacket that the code runs through will work, all the following ones won't the code stops executing when I insert a value to the BncsPacket.
For example:
            BncsPacket WorkingPacket = new BncsPacket(WhateverByte);
            WorkingPacket.Insert(WhateverValue);
            BncsPacket NotWorkingPacket = new BncsPacket(WhateverByte);
            //code fom this line and below will not execute
            NotWorkingPacket.Insert(WhateverValue);
            NotWorkingPacket.Insert(WhateverValue);

Sort of unclear example but if any answers would be greatly appreciated.. im unfamiliar with C#
Title: Re: [C#] Another Quick Q.
Post by: MyndFyre on April 23, 2007, 02:16 AM
So the code stops executing....  Is there an exception raised? 
Title: Re: [C#] Another Quick Q.
Post by: Godzilla on April 23, 2007, 09:22 AM
Nope. I get no warnings, no errors. It's the bncspacket because when I was debugging it I tested it in multiple ways, and it's always the second BncsPacket i create where it stops
Title: Re: [C#] Another Quick Q.
Post by: Kp on April 23, 2007, 09:47 AM
Does execution return from creating the second BncsPacket?  What happens when the program fails?  Does it go into a CPU spinning loop, exit the process, or something else?
Title: Re: [C#] Another Quick Q.
Post by: MyndFyre on April 23, 2007, 11:46 AM
Quote from: Godzilla on April 23, 2007, 09:22 AM
Nope. I get no warnings, no errors. It's the bncspacket because when I was debugging it I tested it in multiple ways, and it's always the second BncsPacket i create where it stops

Have you tried using the MBNCSUtil source code and stepping into it?

I mean, there's not really anything in BncsPacket(byte) (http://www.jinxbot.net/CodeBrowse/MBNCSUtil_2_0_0_10/BncsPacket.cs.aspx) doesn't do anything blocking

My guessing is that you've got a cross-thread call that affects the GUI somewhere and it just so happens that the problem is coming up right here.

Do you have a GUI?
Title: Re: [C#] Another Quick Q.
Post by: Godzilla on April 23, 2007, 03:12 PM
Quote from: Kp on April 23, 2007, 09:47 AM
Does execution return from creating the second BncsPacket?
Yes, the second packet is created (only the 4 byte header), then the moment I .Insert() a value the code stops, but I do not get failures. Just nothing happens when im debugging it as if nothing has happened.

Would you guys like me to post some of my code?
btw MyndFyre i used your PacketId enum.
Title: Re: [C#] Another Quick Q.
Post by: MyndFyre on April 23, 2007, 08:35 PM
Yeah, .zip your project and let me see it.
Title: Re: [C#] Another Quick Q.
Post by: Godzilla on April 23, 2007, 08:55 PM
wow omg.. I'm such an idiot. If i looked more closely to my debugging and variable values I could have easily found the problem:

Files[0] = "C:/Program Files/Warcraft III/war3.exe"
Files[1] = "C:/Program Files/Warcraft III/storm.dll"
Files[2] = "C:/Program Files/Warcraft III/game.gll"

funny.
This caused my code to stop executing because my Files for the CheckRevision were wrong :P
Title: Re: [C#] Another Quick Q.
Post by: MyndFyre on April 26, 2007, 11:27 AM
Ahh.  I was wondering what was up - I never got your project.