Skip to content
Permalink
Browse files

Improve void-view performance

- Changed refresh time to 60 seconds (either after joining if no users
received or after the last user is processed).
- Re-arranged flag update event handler so that the channel list isn't
iterated over needlessly.
- The VoidView setting now only controls whether automatic /unignore
commands are sent and if users discovered by flag updates are added to
the visible channel list. Event_FlagUpdate is raised even if this is
disabled and the internal user list (Channel.Users()) is updated
normally. This doesn't appear to have any noticeable performance impact
given the new packet processing method.
  • Loading branch information...
Davnit committed Apr 27, 2018
1 parent 7d1e87d commit 83d33be95146128494c6eaa6b2a51c191c832832
Showing with 103 additions and 115 deletions.
  1. +24 −34 trunk/frmChat.frm
  2. +79 −81 trunk/modEvents.bas
@@ -852,7 +852,7 @@ Begin VB.Form frmChat
Begin VB.Timer tmrSilentChannel
Enabled = 0 'False
Index = 1
Interval = 30000
Interval = 60000
Left = 5760
Top = 4560
End
@@ -6358,48 +6358,38 @@ Private Sub tmrSilentChannel_Timer(Index As Integer)
#If (COMPILE_DEBUG <> 1) Then
On Error GoTo ERROR_HANDLER
#End If

Dim User As clsUserObj
Dim Item As ListItem

Dim i As Integer
Dim j As Integer
Dim found As Boolean
Dim WasZero As Boolean
Dim pBuff As clsDataBuffer

Static bCleared As Boolean
Static bSkipRefresh As Boolean

If (g_Channel.IsSilent = False) Then
tmrSilentChannel(0).Enabled = False
Exit Sub
End If

If (Index = 0) Then
If (Config.VoidView) Then
'For i = 1 To g_Channel.Users.Count
' ' with our doevents, we can miss our cue indicating that we
' ' need to stop silent channel processing and cause an rte.
' If (i > g_Channel.Users.Count) Then
' Exit For
' End If
'
' Set user = g_Channel.Users(i)
'
' If (lvChannel.FindItem(user.DisplayName) Is Nothing) Then
' Dim Stats As String
' Dim Clan As String
'
' ParseStatstring user.Statstring, Stats, Clan
'
' AddName User
' End If
'Next i

Call EnableWindowRedraw(lvChannel.hWnd)
Call UpdateListviewTabs
' If we've received users
If g_Channel.Users.Count > 0 Then
' If we haven't marked the buffer as cleared, and it is cleared.
If ((bCleared = False) And (ReceiveBuffer(stBNCS).IsFullPacket(2) = False)) Then
bCleared = True
bSkipRefresh = True

Call UpdateListviewTabs
End If
End If

tmrSilentChannel(0).Enabled = False
ElseIf (Index = 1) Then
If (Config.VoidView) Then
Call AddQ("/unignore " & GetCurrentUsername, enuPriority.SPECIAL_MESSAGE)
' If we haven't received users, or the receive buffer is cleared.
If g_Channel.Users.Count = 0 Or bCleared = True Then
If bSkipRefresh = True Then
bSkipRefresh = False
Else
bCleared = False
' Go ahead and refresh.
If Config.VoidView Then Call AddQ("/unignore " & GetCurrentUsername, enuPriority.SPECIAL_MESSAGE)
End If
End If
End If

@@ -42,41 +42,42 @@ Public Sub Event_FlagsUpdate(ByVal Username As String, ByVal Flags As Long, ByVa
Exit Sub
End If

UserIndex = g_Channel.GetUserIndexEx(CleanUsername(Username))
If (g_Channel.IsSilent) Then
Set UserObj = New clsUserObj

With UserObj
.Name = Username
.Statstring = Message
End With

g_Channel.Users.Add UserObj
If Config.VoidView Then
frmChat.AddName UserObj
End If
Else
UserIndex = g_Channel.GetUserIndexEx(CleanUsername(Username))

If (UserIndex > 0) Then
Set UserObj = g_Channel.Users(UserIndex)
If (UserIndex > 0) Then
Set UserObj = g_Channel.Users(UserIndex)

If (QueuedEventID = 0) Then
If (UserObj.Queue.Count > 0) Then
Set UserEvent = New clsUserEventObj
If (QueuedEventID = 0) Then
If (UserObj.Queue.Count > 0) Then
Set UserEvent = New clsUserEventObj

With UserEvent
.EventID = ID_USERFLAGS
.Flags = Flags
.Ping = Ping
.GameID = UserObj.Game
End With
With UserEvent
.EventID = ID_USERFLAGS
.Flags = Flags
.Ping = Ping
.GameID = UserObj.Game
End With

UserObj.Queue.Add UserEvent
UserObj.Queue.Add UserEvent
Else
PreviousFlags = UserObj.Flags
End If
Else
PreviousFlags = UserObj.Flags
End If
Else
PreviousFlags = UserObj.Queue(QueuedEventID - 1).Flags
End If
Else
If (g_Channel.IsSilent) Then
If (g_Channel.Users.Count >= 200) Then
Exit Sub
PreviousFlags = UserObj.Queue(QueuedEventID - 1).Flags
End If

Set UserObj = New clsUserObj

With UserObj
.Name = Username
.Statstring = Message
End With
Else
frmChat.AddChat g_Color.ErrorMessageText, StringFormat("Warning! Phantom user {0} has received a flags update.", CleanUsername(Username))
Exit Sub
@@ -86,10 +87,6 @@ Public Sub Event_FlagsUpdate(ByVal Username As String, ByVal Flags As Long, ByVa
' convert user name
Username = UserObj.DisplayName

' get channel list position
pos = g_Channel.GetUserIndexByPriority(UserObj.Name, , True)
'Debug.Print "OLD POS: " & pos

With UserObj
.Flags = Flags
.Ping = Ping
@@ -106,57 +103,55 @@ Public Sub Event_FlagsUpdate(ByVal Username As String, ByVal Flags As Long, ByVa
SharedScriptSupport.BotFlags = MyFlags
End If

' we aren't in a silent channel, are we?
If (g_Channel.IsSilent) Then
g_Channel.Users.Add UserObj
frmChat.AddName UserObj
Else
If ((UserObj.Queue.Count = 0) Or (QueuedEventID > 0)) Then
If (Flags <> PreviousFlags) Then
If (g_Channel.Self.IsOperator) Then
If ((StrComp(Username, GetCurrentUsername, vbBinaryCompare) = 0) And (Not frmChat.IsPriorityUser(PreviousFlags))) Then
g_Channel.CheckUsers
Else
g_Channel.CheckUser Username
End If
If (g_Channel.IsSilent = False) And ((UserObj.Queue.Count = 0) Or (QueuedEventID > 0)) Then
If (Flags <> PreviousFlags) Then
If (g_Channel.Self.IsOperator) Then
If ((StrComp(Username, GetCurrentUsername, vbBinaryCompare) = 0) And (Not frmChat.IsPriorityUser(PreviousFlags))) Then
g_Channel.CheckUsers
Else
g_Channel.CheckUser Username
End If
End If

' get channel list position
pos = g_Channel.GetUserIndexByPriority(UserObj.Name, , True)
'Debug.Print "OLD POS: " & pos

If (pos) Then
Dim NewFlags As Long
Dim LostFlags As Long

If (pos) Then
Dim NewFlags As Long
Dim LostFlags As Long

frmChat.AddName UserObj, pos

' voodoo magic: only show flags that are new
NewFlags = Not (Flags Imp PreviousFlags)
LostFlags = Not (PreviousFlags Imp Flags)

' default to display this event
Displayed = False

' check whether it has been
If QueuedEventID > 0 And UserObj.Queue.Count >= QueuedEventID Then
Set UserEvent = UserObj.Queue(QueuedEventID)
Displayed = UserEvent.Displayed
End If
frmChat.AddName UserObj, pos

' voodoo magic: only show flags that are new
NewFlags = Not (Flags Imp PreviousFlags)
LostFlags = Not (PreviousFlags Imp Flags)

' default to display this event
Displayed = False

' check whether it has been
If QueuedEventID > 0 And UserObj.Queue.Count >= QueuedEventID Then
Set UserEvent = UserObj.Queue(QueuedEventID)
Displayed = UserEvent.Displayed
End If

' display if it has not
If Not Displayed Then
Dim FDescN As String
Dim FDescO As String
FDescN = frmChat.GetFlagDescription(NewFlags, False)
FDescO = frmChat.GetFlagDescription(LostFlags, False)

' display if it has not
If Not Displayed Then
Dim FDescN As String
Dim FDescO As String
FDescN = frmChat.GetFlagDescription(NewFlags, False)
FDescO = frmChat.GetFlagDescription(LostFlags, False)

If LenB(FDescN) > 0 And LenB(FDescO) > 0 Then
frmChat.AddChat g_Color.JoinUsername, "-- ", g_Color.JoinedChannelName, _
Username, g_Color.JoinText, " is now a " & FDescN & " and no longer a " & FDescO & "."
ElseIf LenB(FDescN) > 0 Then
frmChat.AddChat g_Color.JoinUsername, "-- ", g_Color.JoinedChannelName, _
Username, g_Color.JoinText, " is now a " & FDescN & "."
ElseIf LenB(FDescO) > 0 Then
frmChat.AddChat g_Color.JoinUsername, "-- ", g_Color.JoinedChannelName, _
Username, g_Color.JoinText, " is no longer a " & FDescO & "."
End If
If LenB(FDescN) > 0 And LenB(FDescO) > 0 Then
frmChat.AddChat g_Color.JoinUsername, "-- ", g_Color.JoinedChannelName, _
Username, g_Color.JoinText, " is now a " & FDescN & " and no longer a " & FDescO & "."
ElseIf LenB(FDescN) > 0 Then
frmChat.AddChat g_Color.JoinUsername, "-- ", g_Color.JoinedChannelName, _
Username, g_Color.JoinText, " is now a " & FDescN & "."
ElseIf LenB(FDescO) > 0 Then
frmChat.AddChat g_Color.JoinUsername, "-- ", g_Color.JoinedChannelName, _
Username, g_Color.JoinText, " is no longer a " & FDescO & "."
End If
End If
End If
@@ -254,11 +249,14 @@ Public Sub Event_JoinedChannel(ByVal ChannelName As String, ByVal Flags As Long)
frmChat.AddChat g_Color.InformationText, "If you experience a lot of lag while within " & _
"this channel, try selecting 'Disable Silent Channel View' from the Window menu."

' Enable timers for handling VoidView state.
frmChat.tmrSilentChannel(0).Enabled = True
frmChat.tmrSilentChannel(1).Enabled = True

frmChat.AddQ "/unignore " & GetCurrentUsername
End If
Else
frmChat.tmrSilentChannel(0).Enabled = False
frmChat.tmrSilentChannel(1).Enabled = False
End If

0 comments on commit 83d33be

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