Skip to content
Permalink
Browse files

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.
  • Loading branch information...
nmbook committed Apr 6, 2017
1 parent 1abfaf5 commit 5e9ecdd9c98b22d6256a8f89402001b6cd4838da
Showing with 36 additions and 12 deletions.
  1. +24 −1 trunk/clsFriendlistHandler.cls
  2. +12 −11 trunk/frmChat.frm
@@ -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

@@ -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

0 comments on commit 5e9ecdd

Please sign in to comment.
You can’t perform that action at this time.