Author | Message | Time |
---|---|---|
dRAgoN | [code]Public Function P09(Data09 As String) Dim strPacketHead As String Dim intNumberOfGames As Long Dim strDataToBeParsed As String Dim intPort As Integer Dim strIP As String Dim strGameName As String Dim strGameDiscription As String Dim strMapStatstring As String Dim strGameCreatorName As String Dim strMapName As String Dim intLoop As Integer Dim strSplitDlm As String Dim varGameData As Variant Dim strOutput As String Dim strTempData As String strPacketHead = Mid(Data09, 1, 8) intNumberOfGames = MakeLong(Mid(strPacketHead, 5, 4)) If intNumberOfGames = 0 Then Exit Function strDataToBeParsed = Mid(Data09, 9, Len(Data09)) strSplitDlm = Chr(&HD) & Chr(&H0) varGameData = Split(strDataToBeParsed, strSplitDlm) For intLoop = 0 To intNumberOfGames - 1 strTempData = Mid(varGameData(intLoop), 11, Len(varGameData(intLoop))) intPort = (Asc(Mid(strTempData, 1, 1)) * (2 ^ 8)) + Asc(Mid(strTempData, 2, 1)) strTempData = Mid(strTempData, 3, Len(strTempData)) strIP = Asc(Mid(strTempData, 1, 1)) & "." & _ Asc(Mid(strTempData, 2, 1)) & "." & _ Asc(Mid(strTempData, 3, 1)) & "." & _ Asc(Mid(strTempData, 4, 1)) strTempData = Mid(strTempData, 21, Len(strTempData)) strGameName = KillDlm(strTempData, Chr(&H0)) strTempData = Mid(strTempData, Len(strGameName) + 1, Len(strTempData)) strGameDiscription = KillDlm(strTempData, Chr(&H0)) strTempData = StrReverse(Mid(strTempData, Len(strGameDiscription) + 1, Len(strTempData))) If strGameDiscription = "" Then strGameDiscription = "None" strMapName = StrReverse(KillDlm(strTempData, Chr(&HD))) strGameCreatorName = KillDlm(StrReverse(KillDlm(Mid(strTempData, Len(strMapName) + 1, Len(strTempData)), ",")), Chr(&HD)) strMapStatstring = StrReverse(KillDlm(Mid(strTempData, Len(strMapName) + Len(strGameCreatorName) + 2, Len(strTempData)), Chr(&H0))) strOutput = strOutput & "Game (" & (intLoop + 1) & ")" & vbCrLf & _ "GameName: " & strGameName & vbCrLf & _ "MapName: " & strMapName & vbCrLf & _ "Discription: " & strGameDiscription & vbCrLf & _ "Statstring: " & ParseMapStats(strMapStatstring) & vbCrLf & _ "CreatorInfo: " & strGameCreatorName & " (" & strIP & ":" & intPort & ")" & vbCrLf strTempData = "" Next intLoop rtbAdd vbYellow, strOutput End Function Private Function KillDlm(ByVal text As String, ByVal dlm As String) As String Dim i As Integer i = InStr(1, text, dlm) If i = 0 Then KillDlm = text Exit Function End If KillDlm = Left(text, i - 1) End Function Private Function MakeLong(X As String) As Long If Len(X) < 4 Then Exit Function End If CopyMemory MakeLong, ByVal X, 4 End Function[/code] ~l)ragon | December 16, 2002, 5:58 AM |
dRAgoN | [code]Public Function ParseMapStats(ByVal strStats As String) As String Dim strMapSize As String Dim strGameType As String Dim strGameSpeed As String Dim strPenalty As String Dim strIcon As String Dim varSplit As Variant varSplit = Split(strStats, ",") strMapSize = "Mapsize: " & (Mid(varSplit(1), 1, 1) * 32) & "x" & (Mid(varSplit(1), 2, 1) * 32) & vbCrLf '2 strGameSpeed = "Speed: " & GameSpeed(varSplit(3)) & vbCrLf strIcon = "Icon: " & MapIcon(varSplit(4)) & vbCrLf strGameType = "Gametype: " & Gametype(varSplit(5)) & vbCrLf '6 strPenalty = "Rules: " & GamePenalty(varSplit(7)) & vbCrLf '8 '9 '10 ParseMapStats = vbTab & strMapSize & _ vbTab & strGameSpeed & _ vbTab & strIcon & _ vbTab & strGameType & _ vbTab & strPenalty End Function Public Function MapIcon(ByVal strCase As String) As String Select Case strCase Case "1": MapIcon = "Blizzard Approved" Case "2": MapIcon = "Ladder" Case "3": MapIcon = "GF" Case "4": MapIcon = "KBK" Case Else: MapIcon = "None" End Select End Function Public Function GamePenalty(ByVal strCase As String) As String Select Case strCase Case "2": GamePenalty = "Dissconnect is a Loss" Case "4": GamePenalty = "1 Team Victory only" Case Else: GamePenalty = "No rules" End Select End Function Public Function GameSpeed(ByVal strCase As String) As String Select Case strCase Case "0": GameSpeed = "Slowest" Case "1": GameSpeed = "Slower" Case "2": GameSpeed = "Slow" Case "3": GameSpeed = "Normal" Case "4": GameSpeed = "Fast" Case "5": GameSpeed = "Faster" Case "6": GameSpeed = "Fastest" Case Else: GameSpeed = "Default" End Select End Function Public Function Gametype(ByVal strCase As String) As String Select Case strCase 'Case "0": GameType = "?" 'Case "1": GameType = "?" Case "2": Gametype = "Melee" Case "3": Gametype = "Free For All" Case "4": Gametype = "One on One" Case "5": Gametype = "Capture the Flag" Case "6": Gametype = "Greed" Case "7": Gametype = "Slaughter" Case "8": Gametype = "Sudden Death" Case "9": Gametype = "Ladder" Case "a": Gametype = "Use Map Settings" Case "b": Gametype = "Team Melee" Case "c": Gametype = "Team Free For All" Case "d": Gametype = "Team Capture the Flag" 'Case "e": GameType = "?" Case "f": Gametype = "Top vs. Bottom" Case Else: Gametype = "Unknowen Game Type (" & strCase & ")" End Select End Function[/code] [code]Fig 0.2 Game (1) GameName: 3v3 bring it MapName: •Fa§te§t Po§§ible Map• Green Discription: None Statstring: Mapsize: 128x128 Speed: Fastest Icon: None Gametype: Top vs.Bottom Rules: 1 Team Victory only CreatorInfo: can_of_zs (24.19.151.250:6112) Game (2) GameName: 3vs3 comp kill terran MapName: THË WØR£Ð§ FŧTʧT 6 GµÑ Discription: None Statstring: Mapsize: 128x128 Speed: Fastest Icon: None Gametype: Top vs.Bottom Rules: 1 Team Victory only CreatorInfo: XRodimusX[DA] (63.184.0.92:6112) Game (3) GameName: 2v2 bgh NO LAGGERS ~ MapName: Big Game Hunters Discription: None Statstring: Mapsize: 128x128 Speed: Fastest Icon: Blizzard Approved Gametype: Top vs.Bottom Rules: 1 Team Victory only CreatorInfo: weiweiwei (154.20.204.237:6112) Game (4) GameName: comperstomper MapName: Fa§te§t Po§§ible Map Ever Discription: None Statstring: Mapsize: 128x128 Speed: Fastest Icon: None Gametype: Top vs.Bottom Rules: No rules CreatorInfo: hiilikeeggs (66.81.57.172:6112)[/code] Fig 0.2 - Output from starcraft Note: When I get some time, I will fix this up for Diablo II aswell, and maybe even Diablo 1. Note #2: If you want to understand it look over it carefully read the damn thing line for line. Note #3: This function as is assumes that you are sending it the entire packet this means the packet header + packet length + the rest. Change - 11/15/04 fixed an overflow problem. Change - 03/03/05 Finaly got around to putting up this crude map parser removed fig 0.1 (reason: obsolete) Any comments direct them to PM's as this is a dead topic and for referance only, and will be requested locked when ever I finaly finnish it ;p ~l)ragon | March 4, 2005, 3:30 AM |