Valhalla Legends Archive

Programming => Battle.net Bot Development => Topic started by: phvckmeh on November 08, 2004, 05:48 PM

Title: Infitate loop problem
Post by: phvckmeh on November 08, 2004, 05:48 PM
Alright, well sometimes on my bot, like every couple hours, my bot will loop forever on this sub, i broke it and i marked where it broke too (while it was in a loop) My CPU goes up to 99% when its like this, and it just stays like that untill it crashes.

Any ideas?

Private Sub sckBnet_DataArrival(ByVal bytesTotal As Long)
On Error Resume Next
  Dim strBuffer As String, strTemp As String, lngLen As Long
 
sckBNET.GetData strTemp, vbString

strBuffer = strBuffer & strTemp
While Len(strBuffer) > 4
'//Error
    If Left(strBuffer, 1) <> Chr(&HFF) Then
        Exit Sub
    End If

lngLen = Val("&H" & StrToHex(StrReverse(Mid(strBuffer, 3, 2))))

If Len(strBuffer) < lngLen Then Exit Sub

If ReadINI("Server", "USEBnls") = "1" Then
    ParseBNET2 (Left(strBuffer, lngLen))
Else
    ParseBNET (Left(strBuffer, lngLen))
End If

strBuffer = Mid(strBuffer, lngLen + 1)
Wend
Title: Re: Infitate loop problem
Post by: UserLoser. on November 08, 2004, 05:51 PM
Note some BNCS packets have a length of four
Title: Re: Infitate loop problem
Post by: Yegg on November 08, 2004, 05:52 PM
im not sur if this will help but heres my winsock dataarrival code (my bot uses hashes)

Private Sub wsBNET_DataArrival(ByVal bytesTotal As Long)
    On Error Resume Next
    Static strBuffer As String
    Dim strTemp As String, lngLen As Long
    wsBNET.GetData strTemp, vbString
    strBuffer = strBuffer & strTemp
    While Len(strBuffer) > 4
      lngLen = Val("&H" & StrToHex(StrReverse(Mid(strBuffer, 3, 2))))
      If Len(strBuffer) < lngLen Then Exit Sub
       parsep (Left(strBuffer, lngLen))
       
      strBuffer = Mid(strBuffer, lngLen + 1)
    Wend
   
   
End Sub
Title: Re: Infitate loop problem
Post by: MyndFyre on November 08, 2004, 05:58 PM
Quote from: phvckmeh on November 08, 2004, 05:57 PM
Quote from: UserLoser on November 08, 2004, 05:51 PM
Note some BNCS packets have a length of four

so i should make it >= 4?

Crazy enough to work.
Title: Re: Infitate loop problem
Post by: Minux on November 08, 2004, 07:14 PM
The funny thing about both of the codes provided is they both have


Val("&H" & StrToHex(StrReverse(Mid(strBuffer, 3, 2))))


Which points out they didn't write it themselves. And due to DarkMinion's packetbuffer's popularity, you would figure you would instead see


pBuffer.GetWORD(Mid$(strBuffer, 3, 2))


That is...if they really knew what they were doing :P
Title: Re: Infitate loop problem
Post by: Banana fanna fo fanna on November 09, 2004, 07:53 PM
see the answer on www.clancybr.com

note: people who read the forum will get my joke :)