Skip to content

Commit

Permalink
Friends updates are now re-requested when they are received.
Browse files Browse the repository at this point in the history
* 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 5e9ecdd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 12 deletions.
25 changes: 24 additions & 1 deletion trunk/clsFriendlistHandler.cls
Expand Up @@ -48,7 +48,7 @@ Public Sub ParsePacket(ByVal PacketID As Long, ByVal inBuf As clsDataBuffer)


RaiseEvent FriendsListReply(Friends) RaiseEvent FriendsListReply(Friends)


Case SID_FRIENDSUPDATE ' information event Case SID_FRIENDSUPDATE ' information event/no-cookie server request
EntryNum = inBuf.GetByte ' (BYTE) Entry number EntryNum = inBuf.GetByte ' (BYTE) Entry number
Set FriendObj = New clsFriendObj Set FriendObj = New clsFriendObj
With FriendObj With FriendObj
Expand Down Expand Up @@ -101,6 +101,29 @@ Public Sub RequestFriendsList()
Set pBuf = Nothing Set pBuf = Nothing
End Sub 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 Public Function UsernameToFLIndex(ByVal sUsername As String) As Integer
Dim i As Integer Dim i As Integer


Expand Down
23 changes: 12 additions & 11 deletions trunk/frmChat.frm
Expand Up @@ -3440,20 +3440,21 @@ End Sub


Private Sub FriendListHandler_FriendsUpdate(ByVal EntryNumber As Byte, ByVal FriendObj As clsFriendObj) Private Sub FriendListHandler_FriendsUpdate(ByVal EntryNumber As Byte, ByVal FriendObj As clsFriendObj)
Dim ListItem As ListItem 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 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) 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 .Status = FriendObj.Status
.LocationID = FriendObj.LocationID .LocationID = FriendObj.LocationID
.Game = FriendObj.Game .Game = FriendObj.Game
Expand Down

0 comments on commit 5e9ecdd

Please sign in to comment.