• Welcome to Valhalla Legends Archive.
 

[VB6] How to create game Diablo2LoD. ( Simple sequense ) Help request

Started by fataly, January 23, 2009, 10:37 AM

Previous topic - Next topic

fataly

I didnt find any topic about Gamecreation ( updated topic ) So i did my own ! Please respond if something is wrong!

Soon i have logged this sequense:
MCP C->S : 0x03
MCP S->C : 0x03
MCP C->S  : 0x04
BNET C->S : 0x1C
MCP S->C  : 0x04
BNET C->S : 0x22
BNET C->S : 0x10
D2GS S->C : 0xAF
D2GS C->S : 0x68
D2GS S->C : 0x06
D2GS C->S : 0x6D
D2GS S->C : 0x07
D2GS C->S : 0x6B




First Send  Mcp : 0x03

21 00 03 02 00 00 00 00 00 01 FF 08 54 65 73 74    !...........Test
67 61 6D 65 35 00 54 65 73 74 67 61 6D 65 35 00   game5.Testgame5.
00                                                                              .


Then recv Mcp : 0x03

0D 00 03 02 00 43 02 00 00 00 00 00 00                  .....C.......


Send Mcp : 0x04

19 00 04 03 00 54 65 73 74 67 61 6D 65 35 00 54   .....Testgame5.T
65 73 74 67 61 6D 65 35 00                                      estgame5.


Send bnet : 0x1C

FF 1C 2D 00 01 00 00 00 00 00 00 00 00 00 00 00   ..-.............
00 00 00 00 00 00 00 00 54 65 73 74 67 61 6D 65   ........Testgame
35 00 54 65 73 74 67 61 6D 65 35 00 00                  5.Testgame5..


Recv Mcp : 0x04

15 00 04 03 00 43 02 00 00 D5 F8 6A 23 B9 09        .....C.....j#...
05 2E 00 00 00 00                                                     .....


Send Bnet : 0x22

FF 22 20 00 50 58 32 44 0C 00 00 00 54 65 73 74   ." .PX2D....Test
67 61 6D 65 35 00 54 65 73 74 67 61 6D 65 35 00   game5.Testgame5.


Send Bnet : 0x10

FF 10 04 00                                                                ....


Recv D2GS : 0xAF

AF 01                                                                          ..


Send D2GS : 0x68

68 B9 09 05 2E 43 02 03 0C 00 00 00 50 CC 5D ED   h....C......P.].
B6 19 A5 91 00 66 61 74 61 6C 79 64 64 00 B2 6F    .....fatalydd..o
4B 00 00 00 00                                                           K....


Recv D2GS : 0x06

06 7A 09 2E EF 5C                                                      .z...\


Send D2GS : 0x6D

6D 5F FB 1C 00 00 00 00 00 00 00 00 00                   m_...........


Recv D2GS : 0x07

07 1F 7F FF FF FF C0                                                   .......


Send D2GS : 0x6B

6B                                                                               k

Barabajagal

Why the [VB6] tag? Also, aren't these documented on bnetdocs?

fataly

Almost all is in bnetdocs, and vb6 because if i add something... guys know i use vb etc.

fataly

This is right way to connect, but i get timetout every time after 0x68, i dont got even idea what i should do.. I cant see see nothing wrong on my codes :


Public Sub MCPsend0x03()
Call iClear
Call iWORD(&H2)
Call iDWORD(&H0)
Call iBYTE(&H0)
Call iBYTE(&HFF)
Call iBYTE(&H8)
Call iNTSTRING("Testplay55")
Call iNTSTRING("Testplay55")
Call iNTSTRING("")
    Call iHEADER(&H3, BNRS_HEADER)
    Call iPacket(Form1.Winsock2.SocketHandle)
    ShowChat vbYellow, "Creating game!"
End Sub


Public Sub MCPhandle0x03(Data As String)
requestedid = GetWORD(Mid(Data, 4, 2))
token = GetWORD(Mid(Data, 6, 2))
unkown = GetWORD(Mid(Data, 7, 1))
Result = GetWORD(Mid(Data, 9, 4))
If (Result = &H0) Then
'// SUXXES!
Call MCPsend0x04
'Call send0x1C
ElseIf (Result = &H1E) Then
ShowChat vbRed, "Invalid game name."
ElseIf (Result = &H1F) Then
ShowChat vbRed, "Game already exists."
ElseIf (Result = &H20) Then
ShowChat vbRed, "Game servers are down."
ElseIf (Result = &H6E) Then
ShowChat vbRed, "A dead hardcore character cannot create games."
End If
End Sub



Public Sub send0x1C()
Call iClear
Call iDWORD(&H1)
Call iDWORD(&H0)
Call iWORD(&H0)
Call iWORD(&H0)
Call iDWORD(&H1F)
Call iDWORD(&H0)
Call iNTSTRING("Testplay55")
Call iNTSTRING("Testplay55")
'Call iNTSTRING("")
    Call iHEADER(&H1C)
    Call iPacket(Form1.Winsock1.SocketHandle)
    ShowChat vbYellow, "0x1c sent"
End Sub



Public Sub MCPsend0x04()
Call iClear
Call iWORD(&H3)
Call iNTSTRING("Testplay55")
Call iNTSTRING("Testplay55")
Call iHEADER(&H4, BNRS_HEADER)
    Call iPacket(Form1.Winsock2.SocketHandle)
    ShowChat vbYellow, "Joining created game.."
    Call send0x1C
End Sub



Public Sub send0x22()
Call iClear
Call iDWORD(CLIENT_PX2D)
Call iDWORD(&HB)
Call iNTSTRING("Testplay55")
Call iNTSTRING("Testplay55")
Call iHEADER(&H22)
    Call iPacket(Form1.Winsock1.SocketHandle)
    ShowChat vbYellow, "0x22 sent - Version: " & lngVer
End Sub



Public Sub send0x10()
Call iClear
Call iHEADER(&H10)
    Call iPacket(Form1.Winsock1.SocketHandle)
    ShowChat vbYellow, "Leave chat - 0x10"
End Sub



Public Sub MCPhandle0x04(Data As String)
id = GetWORD(Mid(Data, 4, 2))
hD2GSToken = GetWORD(Mid(Data, 6, 2))
unk = GetWORD(Mid(Data, 8, 2))
IP = Asc(Mid(Data, 10, 1)) & "." & Asc(Mid(Data, 11, 1)) & "." & Asc(Mid(Data, 12, 1)) & "." & Asc(Mid(Data, 13, 1))
hD2GShash = GetDWORD(Mid(Data, 14, 4))
Result = GetDWORD(Mid(18, 4))
If (Result = &H0) Then
'//SUXXES
Call send0x22
    Call send0x10
ShowChat vbGreen, "Connecting now D2GS (" & IP & ":4000)"
Form1.Winsock2.Close
Form1.Winsock3.Close
Form1.Winsock3.Connect IP, 4000
ElseIf (Result = &H29) Then
ShowChat vbRed, "Password incorrect."
ElseIf (Result = &H2A) Then
ShowChat vbRed, "Game does not exist."
ElseIf (Result = &H2B) Then
ShowChat vbRed, "Game is full."
ElseIf (Result = &H2C) Then
ShowChat vbRed, "You do not meet the level requirements for this game."
ElseIf (Result = &H6E) Then
ShowChat vbRed, "A dead hardcore character cannot join a game."
ElseIf (Result = &H71) Then
ShowChat vbRed, "A non-hardcore character cannot join a game created by a Hardcore character."
ElseIf (Result = &H73) Then
ShowChat vbRed, "Unable to join a Nightmare game."
ElseIf (Result = &H74) Then
ShowChat vbRed, "Unable to join a Hell game."
ElseIf (Result = &H78) Then
ShowChat vbRed, "A non-expansion character cannot join a game created by an Expansion character."
ElseIf (Result = &H79) Then
ShowChat vbRed, "A Expansion character cannot join a game created by a non-expansion character."
ElseIf (Result = &H7D) Then
ShowChat vbRed, "A non-ladder character cannot join a game created by a Ladder character."
End If
End Sub




Public Sub D2GSsend0x68(ByVal hD2GShash As Long, ByVal hD2GSToken As Integer)
Dim tmpStr As String, pdBuf As String
    pdBuf = HexToStr("00 00 00 00 8F D4 77 3A 18 AE 6F 4B 00 00 00 00")
    Call CopyMemory(ByVal pdBuf, ByVal CStr(hplayer & vbNullChar), Len(hplayer) + 1)
    Call iClear
    Call iDWORD(hD2GShash)
    Call iWORD(hD2GSToken)
    Call iBYTE(&H3)
    Call iDWORD(&HB)
    Call iDWORD(&HED5DCC50)
    Call iDWORD(&H91A519B6)
    Call iBYTE(&H0)
    Call iSTRING(pdBuf)
    Call iHEADER(&H68, D2GS_HEADER)
    Call iPacket(Form1.Winsock3.SocketHandle)
    ShowChat vbGreen, "0x68 sent"
End Sub



Public Sub D2GSsend0x6D()
Call iClear
Call iDWORD(GetTickCount())
Call iDWORD(&H0)
Call iDWORD(&H0)
Call iHEADER(&H6D, D2GS_HEADER)
Call iPacket(Form1.Winsock3.SocketHandle)
ShowChat vbGreen, "0x6D sent"
End Sub



Public Sub D2GSsend0x6B()
Call iClear
Call iHEADER(&H6B, D2GS_HEADER)
Call iPacket(Form1.Winsock3.SocketHandle)
ShowChat vbGreen, "0xd6B sent - ENTER GAME! GJ ITS WORKING AWESOME!"
D2GS_PINGTIMER = True
End Sub


Ringo

Apart from sending the wrong version byte in BNCS 0x22, it looks fine, based on you're packet log's.

What server are you timeing out on, bnet, realm, game server?
When do you time out? instantly? around 45 seconds after sending 0x6B?

I can't see how you're timing out after 0x68 tho, since in you're logs, you're clearly getting as far as sending 0x6B.
Unless, you're character is tagged, aka "Fail join".
That is, if you're timing out from the game server.

fataly

That packet log is from real diablo 2 :) .     
D2gs winsock get timedout after i send 0x68.
This happends : europe uswest useast asia. so it is my code what is wrong.

And the version byte, it dosent are &hB ??? If not, where i can found it.

Yeah, and its timing out me instantly after 0x68

And here from my form:
[23:34:57] Creating game!
[23:34:58] Joining created game..
[23:34:58] 0x1c sent
[23:34:58] 0x22 sent - Version: 0
[23:34:58] Leave chat - 0x10
[23:34:58] Connecting now D2GS (63.241.83.44:4000)
[23:34:58] Connected!
[23:34:58] ¯   <-------- AF 01 :)
[23:34:58] 0x68 sent
[23:34:58] Ws 3 Connection Error: Connection is aborted due to timeout or other failure

Thanks for replay , Fataly

fataly

Here is the packet log from my bot :


0x03
21 00 03 02 00 01 00 00 00 01 FF 08 54 65 73 74 !...........Test
67 61 6D 65 35 00 54 65 73 74 67 61 6D 65 35 00 game5.Testgame5.
00                                              .

0x03
0D 00 03 02 00 66 00 00 00 00 00 00 00          .....f.......

0x04
19 00 04 02 00 54 65 73 74 67 61 6D 65 35 00 54  .....Testgame5.T
65 73 74 67 61 6D 65 35 00                        estgame5.


0x1c
FF 1C 2D 00 01 00 00 00 00 00 00 00 00 00 00 00  ..-.............
00 00 00 00 00 00 00 00 54 65 73 74 67 61 6D 65  ........Testgame
35 00 54 65 73 74 67 61 6D 65 35 00 00           5.Testgame5..

0x04
15 00 04 02 00 66 00 00 00 3F F1 53 9A 00 BD 55 .....f...?.S...U
09 00 00 00 00                                  .....

0x22
FF 22 20 00 50 58 32 44 0C 00 00 00 54 65 73 74  ." .PX2D....Test
67 61 6D 65 35 00 54 65 73 74 67 61 6D 65 35 00  game5.Testgame5.

0x10
FF 10 04 00                                      ....


AF 01                                            ..

0x68
68 00 BD 55 09 66 00 03 0B 00 00 00 50 CC 5D ED  h..U.f......P.].
B6 19 A5 91 00 46 61 74 61 6C 79 64 00 18 AE 6F  .....Fatalyd...o
4B 00 00 00 00                                   K....

fataly

Heh, Thanks ringo for help :) So, now i want leave game correct. I regonize i need send 0x69 to leave, but then - do i just connect Realm and choose character again and go to chat or what???