Valhalla Legends Forums Archive | Battle.net Bot Development | Channel Type's?

AuthorMessageTime
BaDDBLooD
[code]

Public Function GetChannelType(ByVal Flags As Long) As String

Select Case Flags
Case CHANNEL_PUBLIC&
GetChannelType = "Public Channel"
Case CHANNEL_MODERATED&
GetChannelType = "Moderated channel"
Case CHANNEL_RESTRICTED&
GetChannelType = "Restricted Channel"
Case CHANNEL_SILENT&
GetChannelType = "Silent Channel"
Case CHANNEL_SYSTEM&
GetChannelType = "System CHannel"
Case CHANNEL_PRODUCTSPECIFIC&
GetChannelType = "Product Specific"
Case CHANNEL_GLOBAL&
GetChannelType = "Global Channel"
End Select

End Function

[/code]

Not sure if those are correct or not...
i tested a few of them out, it shows it shows clan, and op channels as public. Although it showed channels like clan recruitment, kbk info etc.. as Nothing..

Little help? ;o
March 8, 2004, 3:32 AM
Myndfyr
For future reference, when making words plural, you don't need to add an apostrophe. "Types" is the correct transcription, not "type's."
March 8, 2004, 3:41 AM
o.OV
I never thought anyone would care about channel flags.
Use zDS bot to compare..
I think zDS shows channel flag when you join a channel.

Add-On:
Where did you get that anyways.
I hate Constants.
You should comment the constants with actual value.
And have the channel flag display on screen
when you enter a channel.
March 8, 2004, 3:45 AM
BaDDBLooD
i don't have a zds bot lol

i got them at bnetdoc's..

anyone else have Input?
March 8, 2004, 3:54 AM
LoRd
[quote author=BaDDBLooD link=board=17;threadid=5659;start=0#msg48299 date=1078718089]
i don't have a zds bot lol
[/quote]
[quote author=BaDDBLooD link=board=17;threadid=5659;start=0#msg48300 date=1078718124]
all i have to say is... bnet doc's
[/quote]
Learn how to use the edit button.
March 8, 2004, 3:57 AM
Fr0z3N
[code]
Public Function ChannelFlags(ByVal Flags As Long) As String
Dim Result As String
Dim StrFlags As String
StrFlags = DecToBin(Flags)
StrFlags = Right(StrFlags, Len(StrFlags) - 1)
Do While Len(StrFlags) < 16
StrFlags = "0" & StrFlags
Loop

If IsBit(StrFlags, 0) Then Result = "Public"
If IsBit(StrFlags, 1) Then Result = Result & "Moderated"
If IsBit(StrFlags, 2) Then Result = Result & "Restricted"
If IsBit(StrFlags, 3) Then Result = Result & "Silent"
If IsBit(StrFlags, 4) Then Result = Result & "System"
If IsBit(StrFlags, 5) Then Result = Result & "Product-Specific"
If IsBit(StrFlags, 11) Then Result = Result & "Globally-Accessible"
If Flags = &H0 Then Result = "Private"

ChannelFlags = Result
End Function
[/code]

That works for me.
March 8, 2004, 4:35 AM
Grok
[quote author=o.OV link=board=17;threadid=5659;start=0#msg48298 date=1078717545]Add-On:
Where did you get that anyways.
I hate Constants.
You should comment the constants with actual value.[/quote]

Ack. CompSci 101. Use Named Constants for repeated-use literal constants. This significantly improves readability of code and maintainability. If one of the constants changes values, you only have to change the definition.
March 8, 2004, 4:48 AM
Soul Taker
You both are missing the redirecting channel flag, 0x4000.
March 8, 2004, 11:47 AM
Fr0z3N
[quote author=Fr0z3N link=board=17;threadid=5659;start=0#msg48304 date=1078720524]
[code]
If IsBit(StrFlags, 4) Then Result = Result & "System"
[/code]

[/quote]


I don't think I am.
March 8, 2004, 12:49 PM
Arta
0x4 != 0x4000.
March 8, 2004, 2:33 PM
iago
[quote author=Grok link=board=17;threadid=5659;start=0#msg48306 date=1078721284]
[quote author=o.OV link=board=17;threadid=5659;start=0#msg48298 date=1078717545]Add-On:
Where did you get that anyways.
I hate Constants.
You should comment the constants with actual value.[/quote]

Ack. CompSci 101. Use Named Constants for repeated-use literal constants. This significantly improves readability of code and maintainability. If one of the constants changes values, you only have to change the definition.
[/quote]

Agreed, I take off more and more marks on each assignment for using Literal constants. But people still do it, so obviously they aren't reading my comments of WHY they lost marks.

Anyway, your problem is that you're using a case for flags. I would recommend looking up the right way to do flags, and why it works, but, basically, use bitwise operations.

Instead of this:
[code]select Flags
Case CHANNEL_PUBLIC&
GetChannelType = "Public Channel"
[/code]
do this:
[code]
if((Flags AND CHANNEL_PUBLIC) <> 0)
   returnString = returnString + "public"
[/code]
Or something like that. Keep in mind it can be >1 type.
March 8, 2004, 3:28 PM
tA-Kane
In case you find a channel that has flags that you aren't supporting, it would be a good idea to make a note of it. The codes I see here aren't making use of that, so I'll make an example:

[code]Function ChannelFlagsToFlagString(Value As Integer, DoUnknown As Boolean, DoPrivate As Boolean) As String
Dim FlagString As String
Dim Flags As Integer

CONST kChannelFlags_Public = 1//0x1
CONST kChannelFlags_Moderated = 2//0x2
CONST kChannelFlags_Restricted = 4//0x4
CONST kChannelFlags_Silent = 8//0x8
CONST kChannelFlags_System = 16//0x10
CONST kChannelFlags_ProductSpecific = 32//0x20
CONST kChannelFlags_Global = 4096//0x1000

Flags = Value//set temporary usage to the channel's flags value

//get all the flag strings
//rules: check for a specific flag
//if that flag doesn't exist (not 1), then move on
//else, add ", " and the name of the flag to the flag string
//then, remove the flag from the temporary buffer
//why remove? allows to check for unknown flags at the end of the function
If BitwiseAnd(Flags,kChannelFlags_Global) = kBnetGame_ChannelFlags_Global Then
FlagString = FlagString + ", Global"
Flags = BitwiseXOr(Flags,kChannelFlags_Global)
End If
If BitwiseAnd(Flags,kChannelFlags_ProductSpecific) = kBnetGame_ChannelFlags_ProductSpecific Then
FlagString = FlagString + ", Product Specific"
Flags = BitwiseXOr(Flags,kChannelFlags_ProductSpecific)
End If
If BitwiseAnd(Flags,kChannelFlags_System) = kBnetGame_ChannelFlags_System Then
FlagString = FlagString + ", System"
Flags = BitwiseXOr(Flags,kChannelFlags_System)
End If
If BitwiseAnd(Flags,kChannelFlags_Silent) = kBnetGame_ChannelFlags_Silent Then
FlagString = FlagString + ", Silent"
Flags = BitwiseXOr(Flags,kChannelFlags_Silent)
End If
If BitwiseAnd(Flags,kChannelFlags_Restricted) = kBnetGame_ChannelFlags_Restricted Then
FlagString = FlagString + ", Restricted"
Flags = BitwiseXOr(Flags,kChannelFlags_Restricted)
End If
If BitwiseAnd(Flags,kChannelFlags_Moderated) = kBnetGame_ChannelFlags_Moderated Then
FlagString = FlagString + ", Moderated"
Flags = BitwiseXOr(Flags,kChannelFlags_Moderated)
End If
If BitwiseAnd(Flags,kChannelFlags_Public) = kBnetGame_ChannelFlags_Public Then
FlagString = FlagString + ", Public"
Flags = BitwiseXOr(Flags,kChannelFlags_Public)
End If

//check for unknown flags
If Flags <> 0 Then
//check to make sure that the calling function wants to see the unknown flags
If DoUnknown = True Then
FlagString = ", Unknown ("+MyHex(Flags)+")"
End If
End If

//check for no flags at all (flags = 0 and flagstring is empty)
If Flags = 0 And FlagString = "" Then
//check to make sure calling function wants private channel string
If DoPrivate = True Then
FlagString = FlagString + ", Private"
End If
End If

//return the string, without the first ", "
Return Mid(FlagString,3)[/code]

Then, in the calling function, you would pass the channel's flags in the first parameter. If you want to display any unknown flags, pass true for the second parameter. And then if you want to display private channels (eg, no flags), pass true for the third.

Hopefully with this you'll be able to notice that BnetDocs is incomplete with regards to channel flags; there are 3 channel flags that BnetDocs does not document that are easily findable:

kChannelFlags_TechSupport
kChannelFlags_ChatAccessible
kChannelFlags_LoadBalanced (aka kChannelFlags_Redirected)

March 8, 2004, 7:54 PM
Eli_1
[quote author=tA-Kane link=board=17;threadid=5659;start=0#msg48368 date=1078775673]
In case you find a channel that has flags that you aren't supporting, it would be a good idea to make a note of it. The codes I see here aren't making use of that, so I'll make an example:

[code]Function ChannelFlagsToFlagString(Value As Integer, DoUnknown As Boolean, DoPrivate As Boolean) As String
Dim FlagString As String
Dim Flags As Integer

CONST kChannelFlags_Public = 1//0x1
CONST kChannelFlags_Moderated = 2//0x2
CONST kChannelFlags_Restricted = 4//0x4
CONST kChannelFlags_Silent = 8//0x8
CONST kChannelFlags_System = 16//0x10
CONST kChannelFlags_ProductSpecific = 32//0x20
CONST kChannelFlags_Global = 4096//0x1000
[/code]
[/quote]

btw, // won't work as comments with VB :P
March 8, 2004, 8:03 PM
hismajesty
Seeing as how Kane doesn't use VB they may be the comment character used in his language (I forget the name, but it's said to be similar to VB). I guess, the Mac version of VB. :P
March 8, 2004, 8:19 PM
BaDDBLooD
[quote author=Fr0z3N link=board=17;threadid=5659;start=0#msg48304 date=1078720524]
[code]
Public Function ChannelFlags(ByVal Flags As Long) As String
Dim Result As String
Dim StrFlags As String
StrFlags = DecToBin(Flags)
StrFlags = Right(StrFlags, Len(StrFlags) - 1)
Do While Len(StrFlags) < 16
StrFlags = "0" & StrFlags
Loop

If IsBit(StrFlags, 0) Then Result = "Public"
If IsBit(StrFlags, 1) Then Result = Result & "Moderated"
If IsBit(StrFlags, 2) Then Result = Result & "Restricted"
If IsBit(StrFlags, 3) Then Result = Result & "Silent"
If IsBit(StrFlags, 4) Then Result = Result & "System"
If IsBit(StrFlags, 5) Then Result = Result & "Product-Specific"
If IsBit(StrFlags, 11) Then Result = Result & "Globally-Accessible"
If Flags = &H0 Then Result = "Private"

ChannelFlags = Result
End Function
[/code]

That works for me.
[/quote]


Now i just need the IsBit, and DecToBin functions :P
March 8, 2004, 9:44 PM
Kp
[quote author=hismajesty link=board=17;threadid=5659;start=0#msg48378 date=1078777197]
Seeing as how Kane doesn't use VB they may be the comment character used in his language (I forget the name, but it's said to be similar to VB). I guess, the Mac version of VB. :P[/quote]

Kane uses REALBasic, iirc. (Yes, that's the capitalization it uses too.)
March 8, 2004, 9:46 PM
Eli_1
[quote author=hismajesty link=board=17;threadid=5659;start=0#msg48378 date=1078777197]
Seeing as how Kane doesn't use VB they may be the comment character used in his language (I forget the name, but it's said to be similar to VB). I guess, the Mac version of VB. :P
[/quote]

I wasn't trying to criticise Kane about it, was just trying to make aware that the value of the constants like kChannelFlags_Public wasn't 1//0x1, it was 1 with a comment of 0x1... :P

I think he uses [s]Real Basic[/s] REALBasic btw
March 8, 2004, 9:49 PM
BaDDBLooD
Frozen, where can i get those 2 Functions?
March 10, 2004, 3:50 AM
tA-Kane
[quote author=Kp link=board=17;threadid=5659;start=15#msg48397 date=1078782411]Kane uses REALBasic, iirc. (Yes, that's the capitalization it uses too.)[/quote]Actually, it's not. It's REALbasic (note the lowercase 'b').

[quote author=Eli_1 link=board=17;threadid=5659;start=15#msg48399 date=1078782566]I wasn't trying to criticise Kane about it, was just trying to make aware that the value of the constants like kChannelFlags_Public wasn't 1//0x1, it was 1 with a comment of 0x1...[/quote]Yes. What does VB use for comments? /**/? Or single-quote?

REALbasic uses double-slash (//) and single-quote (') for comments identification.

I prefer to use double-slash since it's also used in C and C++, but REALbasic's method for commenting (eg, you select some code and select the "Comment" menu item, it checks to see if the beginning of the line is a comment-identifier, and if it is, then it removes it, if not, then it adds a single-quote to the beginning of the line.

[quote author=BaDDBLooD link=board=17;threadid=5659;start=15#msg48672 date=1078890643]where can i get those 2 Functions?[/quote]

You can make GetBit by using your language's "raise to the nth power" function, or if your language doesn't have that, you can use multiplication and an if statement.

There's an even easier way if your language has a bitshift function.

I'll list examples in C here, but I don't remember the keyword in C to "raise to the nth power"... porhaps Yoni might? :P
[code]unsigned long GetBitByMultiplication(int BitNum){
int i;
unsigned long rVal;

for (i = 0, rVal = 1; i < BitNum; i++){
rVal *= 2;
}
return rVal;
}

#define GetBitByBitShift(BitNum) (1 << BitNum)
//now to clean up, we should define GetBit as either of these... since GetBitByBitShift is the cleanest (and the fastest), we'll use that...
#define GetBit GetBitByBitShift[/code]
I haven't tested this code; I wrote it from memory, but it should work. Shame on me if that's not the case.

edit: actually, you don't even need the if statement.
March 10, 2004, 6:15 PM
Adron
[quote author=tA-Kane link=board=17;threadid=5659;start=15#msg48743 date=1078942545]
I'll list examples in C here, but I don't remember the keyword in C to "raise to the nth power"... porhaps Yoni might? :P
[/quote]

You don't raise to the nth power with a C keyword... You may call pow, which uses floating point math and the fpu, but normally you'd use bitshifts where possible.
March 10, 2004, 8:16 PM
Fr0z3N
[code]

Private Function IsBit(ByVal BitString As String, ByVal BitNumber As Integer) As Boolean
If Mid(BitString, 16 - BitNumber, 1) = "1" Then
IsBit = True
Else
IsBit = False
End If
End Function

Private Function DecToBin(ByVal Dec As Long) As String
Dim Temp As String, Retrn As String ' as string so that we don't Get number limitations


Do
Temp = str(Dec Mod 2)
Retrn = Temp & Retrn
Dec = IIf(Right(str(Dec), 2) = ".5", Dec - 0.5, IIf(Dec Mod 2 > 0, Dec - 1, Dec)) / 2
Loop Until Dec = 0
DecToBin = Replace(Retrn, " ", "")
End Function

[/code]
March 10, 2004, 8:49 PM
tA-Kane
[quote author=Adron link=board=17;threadid=5659;start=15#msg48762 date=1078949813]You don't raise to the nth power with a C keyword... You may call pow, which uses floating point math and the fpu[/quote]My mistake.
March 10, 2004, 9:17 PM
BaDDBLooD
Why don't clan recruitment, and kbk info show up?
March 10, 2004, 9:34 PM
LoRd
[quote author=BaDDBLooD link=board=17;threadid=5659;start=15#msg48786 date=1078954461]
Why don't clan recruitment, and kbk info show up?
[/quote]
[13:37:45] Joining public channel: Clan Recruitment
[13:37:48] Joining public channel: KBK Info

Perhaps you forgot to add or incorrectly added the public channel flag.
March 10, 2004, 9:38 PM
Eli_1
[quote author=tA-Kane link=board=17;threadid=5659;start=15#msg48743 date=1078942545]
Yes. What does VB use for comments? /**/? Or single-quote?

[/quote]

VB uses single-quote also
March 10, 2004, 9:39 PM
tA-Kane
Someone slap me for not paying attention, I feel embarassed. :-[

Sorry for any confusion I made for GetBit instead of IsBit. It's still good code though.
March 10, 2004, 10:03 PM
BaDDBLooD
Lord, would you post your Flag function?
March 10, 2004, 11:19 PM

Search