• Welcome to Valhalla Legends Archive.
 

Grabbing Game List

Started by botmaster, December 20, 2003, 01:21 PM

Previous topic - Next topic

botmaster

I want to beable to grab the current open games in d2 I noticed you need to send 0A but the recv is all weird will i need to decompress the packet or anything?

Killa

i made this for realm games awhile ago,im sure it could be coded alot better but it gives you an example of how to do it.

Public Count As Integer
Public Function Parsegames(Data As String)
Dim a As Integer
Dim gamename As String
Dim other As Integer
Dim game As String
Dim games As Integer
Dim z As Integer
a = Len(Data)
a = a - 2
other = 15
game = Mid(Data, other)
gamename = Split(game, HexToStr("00"))(0)
games = games + Len(gamename)
If gamename = "" Then
Else
Call Form3.List1.AddItem(gamename, Count)
Count = Count + 1
End If
If Not Len(Mid(Data, 14 + games)) = 3 Then
Do
DoEvents
game = ""
gamename = ""
game = Mid(Data, 16 + games)
gamename = Split(game, HexToStr("00"))(0)
games = games + Len(gamename) + 16
If gamename = "" Then
Else
Call Form3.List1.AddItem(gamename, Count)
Count = Count + 1
End If
Loop Until games = a
End If
End Function
Public Function HexToStr(ByVal Hex1 As String) As String
   Dim strTemp As String, strReturn As String, i As Long
   Hex1 = Replace(Hex1, " ", "")
   If Len(Hex1) Mod 2 <> 0 Then Exit Function

   For i = 1 To Len(Hex1) Step 2
   strReturn = strReturn & Chr(Val("&H" & Mid(Hex1, i, 2)))
   Next i
   HexToStr = strReturn
End Function

botmaster

what packet am i looking for on the recv to call this?

botmaster

btw thanks for the help man

UserLoser.

Quote from: botmaster on December 20, 2003, 01:21 PM
I want to beable to grab the current open games in d2 I noticed you need to send 0A but the recv is all weird will i need to decompress the packet or anything?

It isn't packet 0x0A. 0x0A is the length of the packet

Format of realm packets:
WORD Length including this WORD (+2)
BYTE ID
VOID Data

On Diablo II: Lord of Destruction (non-hardcore, non-ladder), to request a list of games you'd use packet 0x05:

DWORD 4
WORD 0
BYTE 0

From what I've seen, those are always the same.

To get info on a specific game (expansion, non-hardcore, non-ladder) you'd use packet 0x06:

WORD 6
STRING GameName

As far as parsing both 0x5 & 0x6 from server, i havn't looked into it at all.  If & when i do, I'll post my results

Killa


botmaster

cant seem to get it to send the list at all i dont think im sending the right packet

botmaster

the 0x05, 0x06

would that be sent as a dword or what?

botmaster

got it to grab the list now just cant get it to get the game names in the text that one Public Function Parsegames(Data As String) is not working right :-/

botmaster

k got all of it working but the join game part


Public Function JoinGame(gamename As String)
 Dim p As New PacketBuffer
       p.InsertNonNTString "PX2D"
       p.InsertNTString &H9
       p.InsertNonNTString &H0
       p.InsertNTString gamename
       p.InsertNTString ""
       p.SendPacket frmMain.WSbnet, &H22
       

End Function

should that be the mcp server?

Soul Taker

Going off of memory, I don't believe you tell the MCP server you are joining a game.  IIRC, you tell the chat server, which then tells you the game server to connect to.

UserLoser.

Quote from: Soul Taker on December 25, 2003, 08:15 PM
Going off of memory, I don't believe you tell the MCP server you are joining a game.  IIRC, you tell the chat server, which then tells you the game server to connect to.

Yes, you tell chat server you're joining, and you tell the realm server that you're creating

botmaster

what if i only want to join not make a game does it still need to goto 0x03 and 0x22?

botmaster

i have it sending and recving and even bnet says the bot is in a game but not in my game that i told it to join


0x03 : 0d 00 03 02 00 00 00 00 00 1f 00 00 00
0x04 : 0f 00 04 02 00 77 65 77 65 31 32 33 34 00 00


those are the packets it put out...are those the right?


UserLoser.

You'll know if it's right if you're not getting IPbanned/disconnected after sending it