Valhalla Legends Forums Archive | Visual Basic Programming | Splitting queue by BNET send limit

AuthorMessageTime
CrAz3D
I am attempting to split w/e message is in my queue to be =< than the BNET character send limit.

EDIT: I am using Grok's RequiredTime Function
[code]Private Sub tmrQueue_Timer()
If PeekQueue(0) <> "" Then
Dim Delay As Long, TempBuf As String
Delay = 0
If Queue2 = "1" Then Delay = Funcs.RequiredDelay(Len(PeekQueue(0)))
If Delay > 10 Then Delay = 10
If Delay = 0 Then
TempBuf = GetQueue
Send TempBuf
If GetLeft(TempBuf, "/") = False Then
AddChat vbCyan, "«", vbCrLf & vbRed, CurrentUser, vbCrLf & vbCyan, "»", vbCrLf & vbWhite, TempBuf
End If
End If
DoEvents
End If
End Sub[/code]
My String is 220 characters long but if the Queue is enabled it keeps looping through & adding time to the RequiredDelay. Each time the delay to send the message grows increasingly larger, not allowing me to send the message. Any suggestions?
March 14, 2004, 5:36 AM
o.OV
For my bot..

always Len < 62
then delay 4000ms+

I don't think battle.net relies
on the algorithm anymore.
I did try testing this myself.
I don't remember the scenario clearly..
But I think this is what I did.

scenario1:
send 31 spaces
delay 3900ms
send 31 spaces
delay 3900ms
etc..
ipban before 200 sends

scenario2:
send 31 spaces
delay 4100ms
send 31 spaces
delay 4100ms
etc..
went past 1000 sends

scenario3:
send 63 spaces
delay 4100ms
send 63 spaces
delay 4100ms
etc..
ipban before 200 sends

scenario2:
send 61 spaces
delay 4100ms
send 61 spaces
delay 4100ms
etc..
went past 1000 sends

Add-On:
Are you even sure
the algorithm for RequiredDelay
is working correctly?
Is your setup even trustworthy?
Paste more code.
March 14, 2004, 7:56 AM
UserLoser.
<ot>o.OV, you obviously didn't see my post in the trash can, so I'll ask you here -- Why are all of your posts in poetic form?
Or
like
this?
It does,
tend to get,
annoying to read it like,
this.</ot>
March 14, 2004, 8:14 AM
o.OV
[quote author=UserLoser. link=board=31;threadid=5769;start=0#msg49327 date=1079252072]
<ot>o.OV, you obviously didn't see my post in the trash can, so I'll ask you here -- Why are all of your posts in poetic form?
Or
like
this?
It does,
tend to get,
annoying to read it like,
this.</ot>
[/quote]

WordWrap.
It annoys me when lines shift.
March 14, 2004, 8:58 AM
CrAz3D
More Code:
[code]Public Function RequiredDelay(ByVal Bytes As Long) As Long
Static LastTick As Long
Static SentBytes As Long
'These constants can be edited to determine the speed of the queue.
Const PerPacket = 100
Const PerByte = 15
Const MaxBytes = 400

Dim Tick As Long
Tick = GetTickCount()

If Abs(LastTick - Tick) > (SentBytes * PerByte) Then
SentBytes = 0
Else
SentBytes = SentBytes - (Abs(LastTick - Tick) / PerByte)
End If

LastTick = Tick
If (SentBytes + PerPacket + Bytes) > MaxBytes Then
If (Bytes > 200) Or ((Bytes > 25) And ((SentBytes - PerPacket) > 400)) Then
RequiredDelay = (((SentBytes + PerPacket + Bytes) - MaxBytes) * PerByte) + _
(1500 * (((SentBytes + Bytes) - ((SentBytes + Bytes) Mod 200)) / 200))
If Bytes > 200 Then
RequiredDelay = RequiredDelay + Bytes + (((Bytes - 200) - ((Bytes - 200) Mod 10)) * 50)
End If
SentBytes = SentBytes + Bytes
Else
RequiredDelay = ((SentBytes + PerPacket + Bytes) - MaxBytes) * PerByte
End If
Else
SentBytes = SentBytes + PerPacket + Bytes
RequiredDelay = 0
End If
End Function[/code]
Queue:
[code]Option Explicit
Private Queue() As String

Public Function PeekQueue(ByVal Index As Integer)
If Index - 1 > UBound(Queue) Then Exit Function
PeekQueue = Queue(Index)
End Function

Public Sub ResetQueue()
ReDim Queue(0)
UpdateQueue
End Sub
Public Sub jimboB()
Dim i As Integer
For i = 0 To UBound(Queue)
MsgBox Queue(i)
Next i
End Sub

Public Sub AddQueue(ByVal Message As String)
Dim CountBig As Long, ChrLim As Long, TotLines As Long, y As Long, _
Finishing As String, Bob() As String, i As Integer
Message = Trim(Message)
Do Until Len(Message) < 223
For y = 223 To 1 Step -1
If Asc(Mid(Message, y, 1)) = 32 Then
Finishing = Finishing & Trim(Mid(Message, 1, y)) & vbCrLf
Exit For
End If
Next
Message = Trim(Mid(Message, y))
Loop
Finishing = Finishing & Message
Bob() = Split(Finishing, vbCrLf)
For i = 0 To UBound(Bob)
Queue(UBound(Queue)) = Bob(i)
ReDim Preserve Queue(UBound(Queue) + 1)
Next i
'Queue(UBound(Queue)) = Message
'ReDim Preserve Queue(UBound(Queue) + 1)
End Sub

Public Sub InsertQueue(ByVal Index As Integer, ByVal Message As String)
If Index - 1 > UBound(Queue) Then Exit Sub
Dim i As Integer, TempBuf As String
For i = UBound(Queue) - 1 To Index Step -1
Queue(i + 1) = Queue(i)
Next i
Queue(Index) = Message
ReDim Preserve Queue(UBound(Queue) + 1)
End Sub

Public Sub DeleteQueue(ByVal Index As Integer)
If Index - 1 > UBound(Queue) Then Exit Sub
Dim i As Integer
For i = Index To UBound(Queue) - 1
Queue(i) = Queue(i + 1)
Next i
ReDim Preserve Queue(UBound(Queue) - 1)
End Sub

Private Sub StepQueue()
If UBound(Queue) = 0 Then Exit Sub
Dim i As Integer
For i = 0 To UBound(Queue) - 1
Queue(i) = Queue(i + 1)
Next i
ReDim Preserve Queue(UBound(Queue) - 1)
End Sub

Public Function GetQueue() As String
GetQueue = Queue(0)
StepQueue
UpdateQueue
End Function
Public Sub UpdateQueue()
Dim i As Integer
Form1.SB.Panels(2).text = "Queue: " & UBound(Queue)
End Sub
Public Function GetLeft(ByVal SearchStr As String, ByVal LeftStr As String) As Boolean
If Len(SearchStr) < Len(LeftStr) Then
GetLeft = False
Exit Function
ElseIf Len(SearchStr) = Len(LeftStr) And LCase(SearchStr) = LCase(LeftStr) Then
GetLeft = True
Exit Function
ElseIf Len(SearchStr) = Len(LeftStr) And LCase(SearchStr) <> LCase(LeftStr) Then
GetLeft = False
Exit Function
ElseIf Len(SearchStr) > Len(LeftStr) And LCase(Mid(SearchStr, 1, Len(LeftStr))) = LCase(LeftStr) Then
GetLeft = True
Exit Function
ElseIf Len(SearchStr) > Len(LeftStr) And LCase(Mid(SearchStr, 1, Len(LeftStr))) <> LCase(LeftStr) Then
GetLeft = False
End If
End Function
[/code]

March 14, 2004, 4:07 PM
CrAz3D
I seemed to have fixed it by modifying the RequiredDelay a bit. Changed the 'PerByt = 15' to 25 instead
March 14, 2004, 4:43 PM
Grok
[quote author=UserLoser. link=board=31;threadid=5769;start=0#msg49327 date=1079252072]
<ot>o.OV, you obviously didn't see my post in the trash can, so I'll ask you here -- Why are all of your posts in poetic form?
Or
like
this?
It does,
tend to get,
annoying to read it like,
this.</ot>
[/quote]

His Haiku sucks. :p
March 14, 2004, 4:51 PM
CrAz3D
These poems are quite nice
They are delightful in their subject
The composition is often precise
Too bad they're written by a reject

The poems have no purpose
The poems have no substance
They have no relevance on the surface
What is quite amazing is the redundance

The ending is near
Leave, cause I can't hear
March 14, 2004, 5:13 PM

Search