• Welcome to Valhalla Legends Archive.
 

D2 help ~_~

Started by NetNX, July 04, 2004, 07:34 AM

Previous topic - Next topic

NetNX

Alright.... um im fiddling with huk chat's source code and i want it to join a game but when i try to get the game's ip it fucks up and gives me some random ipaddress

OutPut:
[08:18:08]  Joining game: kion4/qwe
[08:18:08]  Etheran's packet for joing a game has sucessfully been sent...
[08:18:08]  Realm Socket: Failed to parse ID = 0
[08:18:08]  Received 0x03.
[08:18:08]  Game doesn't exist, creating it.
[08:18:08]  Received 0x04.
[08:18:08]  Raw Packet Recieved!: [08:18:08]  Packet In Hexidecimal:02003F0300003FF0CA218DD6572600000000
[08:18:08]  IPDATA: !?ÖW
[08:18:08]  33.141.214.87
[08:18:08]  Server Ip Obtained!:33.141.214.87
[08:18:29]  D2GameSocket:The attempt to connect timed out
[08:18:56]  BNLS Connection has ended!

Code:

Private Sub sckRealm_DataArrival(ByVal bytesTotal As Long)
Dim id As Byte
Dim Length As Integer
Dim Header As String
Dim PacketData As String

Dim CurrentPacket As clsBnetPacket
Set CurrentPacket = New clsBnetPacket

Dim Data As String
Dim PacketID As Integer

sckRealm.GetData Data

RealmRecvBuf.AddData Data
   
While RealmRecvBuf.FullRealmPacket
   Packet = RealmRecvBuf.GetRealmPacket
Call CurrentPacket.FillRealmValues(Packet)


Select Case CurrentPacket.id
   Case &H1 'startup packet
 'check for non-zero
 If InStr(CurrentPacket.PacketData, Chr(&H1)) <> 0 Then
   AddChat vbRed, "Error in your MCP."
   sckBnet.Close
 Else
 AddChat vbGreen, "MCP Chunk was accepted by BNet."
   'woohoo, we passed
   frmCharacterOptions.Show
 End If
   
 Case &H2 'create character 0 pass, non-zero fail
   If InStr(CurrentPacket.PacketData, Chr(&H1)) <> 0 Then
     AddChat vbRed, "Error creating your character!"
   Else
     AddChat vbGreen, "Character created!"
   End If
 Case &H7 'logon - 0 pass, non-zero fail
   If InStr(CurrentPacket.PacketData, Chr(&H1)) <> 0 Then
     AddChat vbRed, "Logon unsuccessfull!"
   Else
     AddChat vbGreen, "Logon successfull!!"
     With packetbuf
       .SendRealmPacket sckRealm, &H12
                   
                   
       .InsertNonNTString StrReverse("D2XP")
       .SendPacket sckBnet, &HB
       .InsertNTString BotData.Bnet.charname
       .InsertNTString BotData.Bnet.RealmTitle & "," & BotData.Bnet.charname
       .SendPacket sckBnet, &HA
                   
                   
                   
       '.InsertDWORD &H2
       '.InsertNTString "Clan ~AoD~~"
       '.sendPacket sckBnet, &HC
   End With
   End If
 Case &H17
   Dim mcount As Long
   mcount = Asc(Mid(CurrentPacket.PacketData, 3, 1))
   pos = 9
   Dim tmpData As String
   tmpData = CurrentPacket.PacketData
   frmCharacterOptions.lsvCharacters.ListItems.Clear
   For I = 1 To mcount
       pA = Split(Mid(tmpData, pos), Chr(0), 3)
       frmCharacterOptions.lsvCharacters.ListItems.Add , , pA(0)
       frmCharacterOptions.lsvCharacters.ListItems(frmCharacterOptions.lsvCharacters.ListItems.count).Tag = pA(1)
       tmpData = pA(2)
       pos = 1
   Next I
 Case &H12

   packetbuf.InsertNonNTString StrReverse(BotData.Bnet.Product)
   packetbuf.SendPacket sckBnet, &HB
   packetbuf.InsertNTString BotData.Bnet.charname
   packetbuf.InsertNTString BotData.Bnet.RealmTitle & "," & BotData.Bnet.charname
   packetbuf.SendPacket sckBnet, &HA
   'plog PacketData

Case &H3
AddChat vbYellow, "Received 0x03."
If Right(StrToHex(CurrentPacket.PacketData), 4) = &H0 Then
AddChat vbWhite, "Game doesn't exist, creating it."
With packetbuf
.InsertBYTE &H2
.InsertBYTE &H0
.InsertNTString Form1.Text1
.InsertNTString Form1.Text2
.SendRealmPacket sckRealm, &H4
'
.InsertDWORD &H1
.InsertDWORD &H0
.InsertDWORD &H0
.InsertDWORD &H0
.InsertDWORD &H0
.InsertNTString Form1.Text1
.InsertNTString Form1.Text2
.InsertBYTE &H0
.SendPacket sckBnet, &H1C
End With
Else
AddChat vbYellow, "Game exists!"
End If

Case &H4
AddChat vbYellow, "Received 0x04."
AddChat vbRed, "Raw Packet Recieved!: " & CurrentPacket.PacketData
AddChat vbWhite, "Packet In Hexidecimal:" & StrToHex(CurrentPacket.PacketData)
Dim FinIp As String
ip = Mid(CurrentPacket.PacketData, 10, 4)
AddChat vbGreen, "IPDATA: " & ip
For I = 1 To 4
   tmpIp = Mid(ip, I, 1)
   FinIp = FinIp & Asc(tmpIp)
   If I <> 4 Then FinIp = FinIp & "."
 Next I
 Dim ipb As String
 strTemp = CurrentPacket.PacketData
 ipb = Asc(Mid(strTemp, 10, 1)) & "." & _
        Asc(Mid(strTemp, 11, 1)) & "." & Asc(Mid(strTemp, 12, 1)) & "." & _
           Asc(Mid(strTemp, 13, 1))
 AddChat vbCyan, ipb
AddChat vbGreen, "Server Ip Obtained!:" & FinIp
sckD2Game.Close
DoEvents
'sckD2Game.RemoteHost = FinIp
'sckD2Game.RemotePort = 4000
sckD2Game.Connect FinIp, 4000

With packetbuf
.InsertNonNTString "PX2D"
.InsertNTString &H9
.InsertNonNTString &H0
.InsertNTString Form1.Text1
.InsertNTString Form1.Text2
.SendPacket sckBnet, &H22
End With

 Case Else
   AddChat vbRed, "Realm Socket: Failed to parse ID = " & PacketID
End Select
Wend
End Sub

NetNX

i got it all fixed ... another question dose anyone have any ingame documention of packets ?

ChR0NiC


MyndFyre

Quote from: NetNX on July 06, 2004, 05:17 PM
i got it all fixed ... another question dose anyone have any ingame documention of packets ?

What did you do to fix it?
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.