From 5e9ecdd9c98b22d6256a8f89402001b6cd4838da Mon Sep 17 00:00:00 2001 From: Nate Book Date: Thu, 6 Apr 2017 01:53:18 -0400 Subject: [PATCH] Friends updates are now re-requested when they are received. * Works around the bug where all parts of the SID_FRIENDSUPDATE automatic server event are your own instead of your friend's when they are online. * The initial event is completely ignored and not displayed, and the bot relies on the "server request" system to ensure only one re-request is sent. --- trunk/clsFriendlistHandler.cls | 25 ++++++++++++++++++++++++- trunk/frmChat.frm | 23 ++++++++++++----------- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/trunk/clsFriendlistHandler.cls b/trunk/clsFriendlistHandler.cls index fe016921..7881eace 100644 --- a/trunk/clsFriendlistHandler.cls +++ b/trunk/clsFriendlistHandler.cls @@ -48,7 +48,7 @@ Public Sub ParsePacket(ByVal PacketID As Long, ByVal inBuf As clsDataBuffer) RaiseEvent FriendsListReply(Friends) - Case SID_FRIENDSUPDATE ' information event + Case SID_FRIENDSUPDATE ' information event/no-cookie server request EntryNum = inBuf.GetByte ' (BYTE) Entry number Set FriendObj = New clsFriendObj With FriendObj @@ -101,6 +101,29 @@ Public Sub RequestFriendsList() Set pBuf = Nothing End Sub +Public Sub RequestFriendItem(ByVal EntryNumber As Integer, Optional ByVal eType As enuServerRequestHandlerType = reqScriptingCall, Optional ByVal Command As clsCommandObj) + Dim pBuf As clsDataBuffer + Dim oRequest As udtServerRequest + + With oRequest + .ResponseReceived = False + .HandlerType = eType + Set .Command = Command + .PacketID = SID_FRIENDSUPDATE + .PacketCommand = EntryNumber + .Tag = Empty + End With + + Call SaveServerRequest(oRequest) + + Set pBuf = New clsDataBuffer + With pBuf + .InsertByte EntryNumber + .SendPacket SID_FRIENDSUPDATE + End With + Set pBuf = Nothing +End Sub + Public Function UsernameToFLIndex(ByVal sUsername As String) As Integer Dim i As Integer diff --git a/trunk/frmChat.frm b/trunk/frmChat.frm index 6c916062..027bf448 100644 --- a/trunk/frmChat.frm +++ b/trunk/frmChat.frm @@ -3440,20 +3440,21 @@ End Sub Private Sub FriendListHandler_FriendsUpdate(ByVal EntryNumber As Byte, ByVal FriendObj As clsFriendObj) Dim ListItem As ListItem + Dim oRequest As udtServerRequest + + If FriendObj.LocationID <> FRL_OFFLINE Then + If Not FindServerRequest(oRequest, -1, SID_FRIENDSUPDATE, EntryNumber) Then + ' NOTE: There is a server bug here where, when this packet is sent automaticlaly + ' (not requested), the fields contains your own information instead when logged on. + ' Because of this, we resend the request (if there isn't one already). + ' (see: https://bnetdocs.org/packet/384/sid-friendsupdate) + Call FriendListHandler.RequestFriendItem(EntryNumber, reqInternal) + Exit Sub + End If + End If If g_Friends.Count > EntryNumber Then - ' NOTE: There is a server bug here where, when this packet is sent automaticlaly - ' (not requested), the fields contains your own information instead when logged on. - ' Because of this, we ignore that field completely and wait for the periodic updates - ' to update the value. - ' (see: https://bnetdocs.org/packet/384/sid-friendsupdate) With g_Friends.Item(EntryNumber + 1) - If .IsOnline Then - FriendObj.Status = .Status - FriendObj.LocationID = .LocationID - FriendObj.Game = .Game - FriendObj.Location = .Location - End If .Status = FriendObj.Status .LocationID = FriendObj.LocationID .Game = FriendObj.Game