• Welcome to Valhalla Legends Archive.
 

starcraft in-game protocol

Started by aton, May 01, 2005, 05:47 AM

Previous topic - Next topic

aton

hi!
(sorry if this is the wrong place for what i am posting.. i am coding c only thats why i post here)

i am looking for information about the starcraft in-game protocol, like packets that move units, packets that make buildings, packets that change mineral count etc.

if anyone has any information, i'd greatly appreciate that.
(i have been sniffing a long time now, and its getting on my nerves)

thanks in advance,

aton

aton

what i have so far is at http://aton.skillzenmasse.de/packet.txt
it might be wrong, i will update it constantly. please tell me if you have any idea/data thats more correct than mine.

UserLoser.

Quote
                  player string        '\0'
                  |                    |
0030  00 00 00 00 55 72 7A 61 68 69 6C 00 50 58 45 53    ....Urzahil.PXES

      |- these are probably version info etc.
0040  20 30 20 30 20 31 20 30 20 30 20 30 20 30 20 30     0 0 1 0 0 0 0 0
         "SEXP" starcraft expansion
          |            '\0'
          |              |
0050  20 50 58 45 53 00                                   PXES.


That's just their battle.net account name and their statstring.  Statstring contains what product they're using, wins, rating, rank, high rank, rating, high rating, spawn, icon etc.

Edit: eww at bnetd stuff at bottom

aton

do you know what field means what exactly? i think i can find out the wins/losses but not the icon for example

UserLoser.

Quote from: aton on May 01, 2005, 04:28 PM
do you know what field means what exactly? i think i can find out the wins/losses but not the icon for example


Icon is last part, in this case, 'SEXP'.

Document on user statstrings

aton

#5
thanks, i updated the file.

you dont have any information on "click" packets (or do i better call them "movement" packets?), have you?

as i understand only the player actions are transmitted over the net, i.e. when a player moves a unit, or builds a building, correct?

edit: btw has anyone got an outline of how the udp checksum is created? i am into linux and cannot really debug in windows very well...  just a description of the algorithm would be sufficient, i'd write my own routine...

l)ragon

your first ?.?.? in the statstring = the persons ladder rank it will only show up if they are ranked on the list eg. #1 - #1000.
*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*ˆ¨¯¯¨ˆ*^~·.,l)ragon,.-·~^*ˆ¨¯¯¨ˆ*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*

Adron

Only player actions are transmitted yes. Say, when a player queues up a building or unit to be built.

The udp checksum is something like a loop summing the packet. The data in the packet is summed into one accumulator, and that accumulator is summed into another one.

aton

so each byte is summed together? i.e. longer packets -> bigger checksum? sounds too easy for my taste  ;)
do you have the assembly routine for it?

R.a.B.B.i.T

I've got the VB6 code here, which I ported from C++ with Pianka (that code I can't find, but is on the forums somewhere).  It should be easy enough to port it back if you can't find the original code.


Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
    (ByRef Destination As Any, ByRef Source As Any, ByVal numBytes As Long)

Private Function UDPChecksum(ByRef bufa As String) As Single
    Dim subsum As Double
    Dim A As Double
    Dim B As Single
    Dim buf As Long
   
    buf = MakeLong(bufa)
   
    subsum = SubChecksum(buf + 2, buf - 1)

    A = &HFF - ((subsum And &HFF) + (subsum Xor 8)) Mod &HFF
    B = CSng(((&HFF - (A + (ShiftRight(subsum, 8))) Mod &HFF) And &HFF) Or (ShiftLeft(A, 8)))
   
    UDPChecksum = B
End Function

Private Function SubChecksum(ByRef buf As Long, length As Long) As Currency
    Dim sum1 As Double
    Dim sum2 As Double
    Dim p As Long
   
    sum1 = sum2 = 0
   
    p = buf And (length - 1)
    While length - 1 > 0
        sum2 = sum2 + p
        p = p - 1
        If sum2 > &HFF Then sum2 = sum2 - &HFF
        sum1 = sum1 + sum2
        length = length - 1
    Wend
   
    SubChecksum = ((sum2 And &HFF) Xor 8) Or ((sum1 Mod &HFF) And &HFF)
End Function

Private Sub Form_Load()
    Debug.Print UDPChecksum(1234)
End Sub

Public Function ShiftRight(ByVal A As Long, ByVal L As Long) As Double
    ShiftRight = CDbl(A / (2 ^ L))
End Function

Public Function ShiftLeft(ByVal A As Long, ByVal L As Long) As Double
    ShiftLeft = CDbl(A * (2 ^ L))
End Function

Private Function MakeLong(str As String) As Long
    CopyMemory MakeLong, ByVal str, Len(str)
End Function

Adron


Eric

Quote from: Adron on May 02, 2005, 12:20 PM
Does your VB6 code work?

It looks as if it was just ported from your NBBot :p

R.a.B.B.i.T

It was ported from some C++ code that someone asked about (if there was an equivolent of in VB6).  Nobody knew about any so that's why Pianka and I ported it.  Where ever the original code came from, I don't know, is where it was ported from.  So, maybe.

aton

cool thanks, i will port that back to c, i think i gotta fresh up my vb a bit, has been quite a while...

Banana fanna fo fanna

I think I was able to get into the pregame room, but that was it.