• Welcome to Valhalla Legends Archive.
 

Splitting queue by BNET send limit

Started by CrAz3D, March 13, 2004, 11:36 PM

Previous topic - Next topic

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

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?
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

o.OV

#1
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.
If the facts don't fit the theory, change the facts. - Albert Einstein

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>

o.OV

Quote from: UserLoser. on March 14, 2004, 02:14 AM
<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>

WordWrap.
It annoys me when lines shift.
If the facts don't fit the theory, change the facts. - Albert Einstein

CrAz3D

More 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

Queue:
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


rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

CrAz3D

I seemed to have fixed it by modifying the RequiredDelay a bit.  Changed the 'PerByt = 15' to 25 instead
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

Grok

Quote from: UserLoser. on March 14, 2004, 02:14 AM
<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>

His Haiku sucks.  :p

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
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...