Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: BaDDBLooD on August 24, 2004, 08:53 PM

Title: SID_GETCHANNELLIST Question
Post by: BaDDBLooD on August 24, 2004, 08:53 PM
Is there a Constant Number of Channels for ALL Clients?
Title: Re:SID_GETCHANNELLIST Question
Post by: K on August 24, 2004, 09:09 PM
Probably not.  If your question is because you're wondering how to parse it, you just need to keep reading strings out of your packet until you find a double null, since the channel list is terminated by a double null.


psuedocode
OnGetChannelList(BncsPacket p)
{
    list<string> channels;
    string current_channel;

    while(p.PeekWord() != 0)
    {
         current_channel = p.ReadString();
         channels.add(current_channel);          
    }
}
Title: Re:SID_GETCHANNELLIST Question
Post by: Spht on August 24, 2004, 09:16 PM
Quote from: BaDDBLooD on August 24, 2004, 08:53 PM
Is there a Constant Number of Channels for ALL Clients?

No.  I assume you're asking this because you don't know how to grab each channel name in a SID_GETCHANNELLIST response?

Each channel is null-terminated.  To handle this in VB it's easy.  Let's say s is your data (not including the header):

Dim a As Long, b
b = Split(s, vbNullChar)
For a = LBound(b) To UBound(b) - 1 ' ignore last empty null
   ' b(a) is the next channel
Next a


That is simply splitting the data by each null so you can read channel.  That is one way which is probably the easiest to explain/understand.  Others can post other methods if they so desire.
Title: Re:SID_GETCHANNELLIST Question
Post by: BaDDBLooD on August 24, 2004, 09:16 PM
I was wondering how i am going to add these into a Menu.

EDIT: I already have the code to parse 0x0B, thanks though.
Title: Re:SID_GETCHANNELLIST Question
Post by: MyndFyre on August 24, 2004, 09:20 PM
Quote from: BaDDBLooD on August 24, 2004, 09:16 PM
I was wondering how i am going to add these into a Menu.

EDIT: I already have the code to parse 0x0B, thanks though.

I know you're using .NET.  Here's some pseudo-code:

You have the menu (such as Channels) you want -- since the Channels menu is of type MenuItem, let's call it miChannels.


For Each s As String in ListOfChannels
 ' Create new MenuItem using constructor
 ' Set the MenuItem.Click event handler on that item instance.
 miChannels.MenuItems.Add(myNewMenuItem)
Next
Title: Re:SID_GETCHANNELLIST Question
Post by: BaDDBLooD on August 24, 2004, 09:22 PM
Except for.. i'm not using .NET Cause i could never get my .NET Bot to work! Yeah, that's right!

EDIT: I am using VB6, i WISH I Could use .NET
Title: Re:SID_GETCHANNELLIST Question
Post by: Spht on August 24, 2004, 09:23 PM
Quote from: BaDDBLooD on August 24, 2004, 09:16 PM
I was wondering how i am going to add these into a Menu.

EDIT: I already have the code to parse 0x0B, thanks though.

Then you asked your question VERY badly.  Maybe start a thread in the "X Programming forum" for "Adding items to a menu"?
Title: Re:SID_GETCHANNELLIST Question
Post by: BaDDBLooD on August 24, 2004, 09:24 PM
My original topic was is the number of channels static, it got off topic.