Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: iNsaNe on November 10, 2007, 11:02 PM

Title: EID_ShowUser
Post by: iNsaNe on November 10, 2007, 11:02 PM
When I join a channel with my bot and receive the EID_ShowUser (0x01) sub message for SID_ChatEvent, 75% of the time I don't receive the first two users (at the top of the channel). So if there was 25 users in the channel, I would be only able to add 23 of them to my channel list. I'm not sure how to parse this message correctly, unless I make battle.net give me a user update which I dont want to do (for flooding reasons). I am using war3

This is my code:

case 0x0F: //chat event
{
int eventid = rd.ReadInt32();
switch (eventid)
{
case 0x01: //show user
{
rd.SeekTo(0);
while (rd.Position != rd.Length)
{
rd.Seek(28);     //moves past the header and other values

String ^username = rd.ReadNTString();
array<String ^> ^userinfo = rd.ReadNTString()->Split(' ');

lvChannel->Items->Add(username, geticonpos(userinfo[0], userinfo[1]));
}

break;
}
        ...
...



Wouldn't the code be correct because of the while loop? I mean, sometimes Battle.net throws in jumbled packets... so I'm not sure what is wrong and why I am not parsing it correctly.
Title: Re: EID_ShowUser
Post by: Mystical on November 10, 2007, 11:06 PM
uhm the users that it dont add would they happened to be channel operators?
Title: Re: EID_ShowUser
Post by: iNsaNe on November 10, 2007, 11:41 PM
no because channel operators have different flags, not separate packets.

--edit: When i say the at the top of the channel, i dont necessarily mean channel operators. It's who ever is at the top.
Title: Re: EID_ShowUser
Post by: l2k-Shadow on November 10, 2007, 11:54 PM
are you correctly parsing clumped TCP packets? ex: 2 0x0F messages sent inside one TCP message from the bnet server.
Title: Re: EID_ShowUser
Post by: iNsaNe on November 11, 2007, 12:08 AM
Yeah, that's what the while loop is there for. It reads all of the data sent.
Title: Re: EID_ShowUser
Post by: l2k-Shadow on November 11, 2007, 12:31 AM
imo you'd be better off splitting the packets right after your recv() call, then pass it to your 0x0F handler and get rid of the loop.

however if that is not causing the problem, perhaps it's a threading issue where the threads are running over each other.
-- it's quite hard to tell.. if the code parses the other 23 persons correctly, i'd try to look into more abstract issues outside of that code section..
Title: Re: EID_ShowUser
Post by: UserLoser on November 12, 2007, 07:17 PM
Quote from: iNsaNe on November 10, 2007, 11:41 PM
no because channel operators have different flags, not separate packets.

--edit: When i say the at the top of the channel, i dont necessarily mean channel operators. It's who ever is at the top.

Not always true, sometimes you'll get the so-called 'EID_USERFLAGS' msg
Title: Re: EID_ShowUser
Post by: Mystical on November 12, 2007, 07:18 PM
Quote from: UserLoser on November 12, 2007, 07:17 PM
Quote from: iNsaNe on November 10, 2007, 11:41 PM
no because channel operators have different flags, not separate packets.

--edit: When i say the at the top of the channel, i dont necessarily mean channel operators. It's who ever is at the top.

Not always true, sometimes you'll get the so-called 'EID_USERFLAGS' msg

I just asked because i've had somewhat the same problem in the past, and it was because of flags update.
Title: Re: EID_ShowUser
Post by: Chriso on November 13, 2007, 06:27 PM
EID_SHOWUSER is received when you join a channel where there are operators already designated. EID_USERFLAGS is received when a user gains or loses operator status.
Title: Re: EID_ShowUser
Post by: brew on November 13, 2007, 08:14 PM
Quote from: Chriso.de on November 13, 2007, 06:27 PM
EID_USERFLAGS is received when a user gains or loses operator status.
Or when there's some flag update ;) (doesn't necessarily mean just gaining/losing operator status, squelch/unsquelch, users gaining speaker flags, etc)
Title: Re: EID_ShowUser
Post by: Chriso on November 13, 2007, 10:28 PM
Quote from: brew on November 13, 2007, 08:14 PM
Or when there's some flag update ;) (doesn't necessarily mean just gaining/losing operator status, squelch/unsquelch, users gaining speaker flags, etc)
Yeah it was just an example.

Another little thing you might want to support is void viewing, which is done by sending /unignore [yourname].  It will send an EID_USERFLAGS event for each user in The Void and you will need to add each user to the listview.
Title: Re: EID_ShowUser
Post by: iNsaNe on November 14, 2007, 12:10 AM
I'm trying to avoid getting userflags to refresh the channel list.

I created a new thread (i'm quite new to threads) it seems to be working great except that now like 25% of the time im missing 1 user.