Attribute VB_Name = "modPackets"
Option Explicit

Dim b As New clsPacketBuffer, r As New clsPacketDebuffer

Public Sub SendAuthInfo(Index As Integer)
On Error GoTo hErr
    With frmBot
    If Options.Verbose Then .AddChat colour.msg.mNeutral, "Authenticating client..."
    If Options.Verbose Then .AddChat colour.msg.mNeutral, "Verbyte: " & ByteToHex(CByte(verByte))
    If Options.Verbose Then .AddChat colour.msg.mNeutral, "Product ID: " & Config.ProductID
    If Not ToggleNagel(frmBot.Bot(Index).ExposeSocket.SocketHandle, True) Then
        .AddChat colour.msg.mNegative, "Error setting TCP_NODELAY, disconnecting..."
        frmBot.Bot(Index).Disconnect
        Exit Sub
    End If
    
    With frmBot.Bot(Index)
        .ExposeSocket.SendData Chr$(&H1)                              'Specify Game Protocol
        b.Clear
        b.InsertInt32 &H0                                       'Protocol ID
        b.InsertInt32 ARCH_IX86                                 'Platform ID
        b.InsertFixedString StrReverse$(.Config.ProductID)      'Product ID
        b.InsertInt32 .verByte                                  'Version Byte
        b.InsertInt32 GetRegion                                 'Region
        b.InsertInt32 inet_addr(.ExposeSocket.LocalIP)          'Local IP for NAT compatibility
        b.InsertInt32 TimeZoneBias                              'Time zone Bias
        b.InsertInt32 GetUserDefaultLCID                        'Locale ID
        b.InsertInt32 GetUserDefaultLangID                      'Language ID
        b.InsertCString GetLocaleInfo(LOCALE_SABBREVCTRYNAME)   'Country abbreviation
        b.InsertCString GetLocaleInfo(LOCALE_SENGCOUNTRY)       'Country
        .SendBnetPacket sckBnet, SID_AUTH_INFO
        If Config.Ping = DisablePing Or Config.Ping = ZeroPing Then SendPing &H0
    End If
    Exit Sub
hErr:
b.Clear
ErrorHandler Err, Erl, "Bot", "SendAuthInfo"
End Sub
