• Welcome to Valhalla Legends Archive.
 

SID_GETCHANNELLIST Question

Started by BaDDBLooD, August 24, 2004, 08:53 PM

Previous topic - Next topic

BaDDBLooD

Is there a Constant Number of Channels for ALL Clients?
There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.

K

#1
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);          
    }
}

Spht

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.

BaDDBLooD

#3
I was wondering how i am going to add these into a Menu.

EDIT: I already have the code to parse 0x0B, thanks though.
There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.

MyndFyre

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
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

BaDDBLooD

#5
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
There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.

Spht

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"?

BaDDBLooD

My original topic was is the number of channels static, it got off topic.
There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.