Named: ServerNotify
SEND-> 0000   00 01 45 AB E5 C1 01 00                            ..E.....
'Hi!  Send me a key


Named: ServerKey
RECV-> 0000   00 02 45 AB E5 C1                                  ..E...
'Use this one =)
'I need 2 ACKs, a PW packet and an 05 information packet plz


'---------Login checks---------


Named: PasswordPacket
SEND-> 0000   00 03 00 00 00 00 09 WW NN NN NN NN NN NN NN NN    ........Catid...
SEND-> 0010   NN NN NN NN NN NN NN NN NN NN NN NN NN NN NN NN    ................
SEND-> 0020   NN NN NN NN NN NN NN NN PP PP PP PP PP PP PP PP    ........disgrunt
SEND-> 0030   PP PP PP PP PP PP PP PP PP PP PP PP PP PP PP PP    led.............
SEND-> 0040   PP PP PP PP PP PP PP PP MM MM MM MM 03 II II II    ...........]....
SEND-> 0050   II 86 00 BC 01 00 00 2B 02 00 00 MM MM MM MM 00    .......+......].
SEND-> 0060   00 00 00 00 00 00 00 00 00 00 00                   ...........
'WW=New user? (1=yes,0=no)
'NN=Name
'PP=Password (*password included)
'MM=MachineID
'II=PermissionID
'Public Function MakeLogin(User As String, Password As String, MachineID As Long, PermissionID As Long, NewUser As Byte) As String
'    MakeLogin = Chr(0) + Chr(3) + NextSID + Chr(9) + Chr(NewUser) + FillZero(User, 32) + FillZero(Password, 32) + _
'		 GetString(MachineID) + Chr(3) + GetString(PermissionID) + GetString2(&H86) + GetString(&H1BC) + _
'		 GetString(&H22B) + GetString(MachineID) + String(12, Chr(0))
'End Function


Named: SyncPacket
'SEND-> 0000   00 05 6D E1 1E 00 06 00 00 00 04 00 00 00          ..m...........
'              ^^ ^^ ^^ Not required! 
'RECV-> 0000   00 06 6D E1 1E 00 71 E1 1E 00                      ..m...q...
'No need to ACK


Named: UselessACK ;)
RECV-> 0000   00 04 00 00 00 00                                  ......
'just ACKing the PW packet, ignore for now


'I explain these FULLY farther down
RECV-> 0000   00 0E 2A 

Named: LoginResponse
                       00 03 00 00 00 00 0A WW 86 00 00 00 00    ..*.............
RECV-> 0010   00 00 00 FF FF FF FF 00 00 00 00 00 00 FF FF FF    ................
RECV-> 0020   FF 74 B3 FB 41 01 00 00 00 84 F3 70 00 07 
'WW=Unknown username (1=new user)
'SEND-> 0000   00 04 00 00 00 00                                  ......

Named: ????
                                                        00 03    .t..A......p....
RECV-> 0030   01 00 00 00 31                                     ....1
'SEND-> 0000   00 04 01 00 00 00                                  ......
'Others are a mystery for now, just ACK


Named: ArenaRequest
SEND-> 0000   00 03 01 00 00 00 01 SS 01 00 00 04 00 03 FF FF    ................
SEND-> 0010   XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    ................
'XX XX XX.. = Arena (""=random public arena)
'SS = Starting shiptype.  (8-spec,0-warbird,7-shark)


'---------End of login checks---------


Named: SettingsPackets
RECV-> 0000   00 03 XX XX XX XX 00 08 0F 00 00 00 01 00 00 00    ................
RECV-> 0010   01 00 00 00 B8 0B 64 00 D6 06 D6 06 FC 08 00 00    ......d.........
RECV-> 0020   58 02 00 00 50 14 28 23 00 00 00 00 00 00 4D 01    X...P.(#......M.
RECV-> 0030   32 00 64 00 0F 01 14 00 88 13 59 1B 70 17 0E 01    2.d.......Y.p...
RECV-> 0040   28 00 C4 09 58 1B 7C 15 00 00 00 00 00 00 00 00    (...X.|.........
RECV-> 0050   28 23 10 27 C8 00 A0 0F 00 00 00 00 28 00 28 00    (#.'........(.(.
RECV-> 0060   64 00 4B 00 E8 03 C8 00 00 00 2C 01 C8 00 D0 07    d.K.......,.....
RECV-> 0070   0C 00 40 00 A0 0F 0A 64 03 02 00 01 00 00 02 03    ..@....d........
RECV-> 0080   02 00 00 02 00 01 03 00 84 A0 55 11 00 00 00 00    ..........U.....
RECV-> 0090   00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00    ................
RECV-> 00A0   01 00 00 00 B8 0B 64 00 D0 07 D0 07 C4 09 00 00    ......d.........
RECV-> 00B0   58 02 00 00 88 13 28 23 00 00 00 00 00 00 4D 01    X.....(#......M.
RECV-> 00C0   32 00 64 00 D3 00 0A 00 88 13 65 19 58 1B D2 00    2.d.......e.X...
RECV-> 00D0   14 00 AC 0D 64 19 64 19 00 00 00 7D 00 7D 00 00    ....d.d....}.}..
RECV-> 00E0   28 23 40 1F 00 00 A0 0F 00 00 00 00 28 00 28 00    (#@.........(.(.
RECV-> 00F0   64 00 4B 00 E8 03 C8 00 00 00 2C 01 C8 00 D0 07    d.K.......,.....
RECV-> 0100   0C 00 40 00 A0 0F 0A 64 03 02 00 01 00 00 00 02    ..@....d........
RECV-> 0110   02 00 00 00 00 01 02 00 84 A0 55 11 00 00 00 00    ..........U.....
RECV-> 0120   00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00    ................
RECV-> 0130   01 00 00 00 B8 0B 64 00 98 08 98 08 C4 09 00 00    ......d.........
RECV-> 0140   58 02 00 00 A0 0F B8 0B 00 00 00 00 32 00 4D 01    X...........2.M.
RECV-> 0150   32 00 64 00 E7 00 14 00 88 13 59 1B 58 1B E6 00    2.d.......Y.X...
RECV-> 0160   1E 00 C4 09 58 1B 64 19 00 00 00 00 00 00 00 00    ....X.d.........
RECV-> 0170   28 23 10 27 00 00 00 00 00 00 00 00 14 00 14 00    (#.'............
RECV-> 0180   4B 00 4B 00 E8 03 C8 00 00 00 2C 01 C8 00 D0 07    K.K.......,.....
RECV-> 0190   0C 00 40 00 A0 0F 0A 00 03 01 00 01 02 00 00 03    ..@.............
RECV-> 01A0   01 00 00 00 02 01 03 00 84 A8 55 10 00 00 00 00    ..........U.....
RECV-> 01B0   00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00    ................
RECV-> 01C0   01 00 00 00 B8 0B 64 00 CA 08 CA 08 40 1F 00 00    ......d.....@...
RECV-> 01D0   E8 03 00 00 A0 0F 28 23 00 00 00 00 00 00 4D 01    ......(#......M.
RECV-> 01E0   32 00 64 00 E7 00 14 00                            2.d.....
'Mid(Packet, 7, 1) = Chr(0)
'For now, we can ACK them and get away with it.
'SEND-> 0000   00 04 XX XX XX XX


'Keep going down, it took me a while to realize it..
RECV-> 0000   00 0E 06 
                       00 04 01 00 00 00 
'an ACK for the ArenaRequest

                                         09
                                            00 03 02 00 00 00    ................
RECV-> 0010   01 01 00 23 
'SEND-> 0000   00 04 02 00 00 00                                  ......
'Dunno what it does yet

Named: ????
                          00 03 06 00 00 00 22 FF FF FF FF FF    ...#......".....
RECV-> 0020   FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF    ................
RECV-> 0030   FF FF FF FF FF FF FF                               .......
'SEND-> 0000   00 04 06 00 00 00                                  ......


'Then, I saw it.  SS encryption is FKing slow and connection bottlenecks
' are tight..  Why not heap a bunch of packets on the same boat?
'This packet below is a cluster of smaller packets stacked end-on-end.
'Observe:
RECV-> 0000   00 0E 86 

Named: NewUserInfo
                      00 03 07 00 00 00 03 SS 01 2B 4C 61 7A    ............+Laz
RECV-> 0010   79 52 65 66 00 00 00 00 00 00 00 00 00 00 00 00    yRef............
RECV-> 0020   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
RECV-> 0030   00 00 00 00 00 00 00 00 00 00 00 00 00 00 9A 02    ................
RECV-> 0040   00 00 00 
'SS=ship-type
'SEND-> 0000   00 04 07 00 00 00                                  ......

Named: NewUserInfo
                      00 FF FF 00 00 00 03 SS 01 43 61 74 69    ............Cati
RECV-> 0050   64 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    d...............
RECV-> 0060   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
RECV-> 0070   00 00 00 00 00 00 00 00 94 11 00 00 01 00 00 00    ................
RECV-> 0080   00 00 00 
'SS=ship-type
'SEND-> 0000   00 04 08 00 00 00                                  ......

Named: ????
                      00 FF FF 00 00 00 07 00 03 08 00 00 00    ................
RECV-> 0090   21                                                 !
'This last one must contain some redundant data..  
'   00 03 08 00 00 00 belongs in the second chunk, for instance
'I knew these sub-packets were at these offsets bc they are the same type of packet


'Using the same method as above, we can pick this one apart as well..
'Observe:
RECV-> 0000   00 0E 1B 

Named: MapInfo
                       00 03 09 00 00 00 29 61 69 6D 2E 6C 76    .........)aim.lv
RECV-> 0010   6C 00 00 00 00 00 00 00 00 00 15 0C 16 79 07 
'The SS client must decide if it needs the map!  YES!  Maybe we won't need
' to generate the checksum afterall =)

Named: ????
                                                           00    l............y..
RECV-> 0020   03 0A 00 00 00 02 17 
'?

Named: ????
                                   00 03 0B 00 00 00 18 08 C4    ................
RECV-> 0030   2F 11 C0 14 9A 09 33 BA 1E 00 00 00 00 00 3D
'I think this is a player position packet.. =(

Named: ArenaMessage
                                                           00    /.....3.......=.
RECV-> 0040   03 0C 00 00 00 07 00 00 FF FF 53 70 61 63 65 20    ..........Space 
RECV-> 0050   44 75 63 6B 20 42 61 74 74 6C 65 20 28 48 6F 6D    Duck Battle (Hom
RECV-> 0060   65 20 6F 66 20 74 68 65 20 73 61 66 65 2D 68 75    e of the safe-hu
RECV-> 0070   67 67 65 72 20 65 6C 69 74 65 29 00                gger elite).
'This is not actually a part of the login ;)


'Tadda!  Now if I am right, SS should ACK -4- packets...
'SEND-> 0000   00 04 09 00 00 00                                  ......
'SEND-> 0000   00 04 0A 00 00 00                                  ......
'SEND-> 0000   00 04 0B 00 00 00                                  ......
'SEND-> 0000   00 04 0C 00 00 00                                  ......
'AAaaahh, it is good to be the king.. =)


'------From this point on, the bot is connected-------

'[End log]


Conclusions-

The best approach (in hindsight of writing this) to creating a successful
login request for a S.S. zone is to make the handlers as modular as possible.
The map checksum may not be needed afterall, so we should go ahead and code
this information I have compiled into a sample login APP we can agree upon.
It is time to write some real code now, Coco!  This is supposed to be the
fun part, so let's not ruin it by making two separate programs; instead let's
work together and get this battle won ;)


'Here is some lame code for recognizing a few types of chat messages:
    Select Case Left(Message, 2)
        Case Chr(0) + Chr(3)
            UDPSend Sender, Chr(0) + Chr(4) + Mid(Message, 3, 4)
            Select Case Asc(Mid(Message, 7, 1))
                Case 7
                    'some sort of message
                    Select Case GetInteger(Mid(Message, 8, 2))
                        Case 0
                            If GetInteger(Mid(Message, 10, 2)) = -1 Then
                                AddMessage "Arena:" + TrimZero(Mid(Message, 12))
                            Else
                                AddMessage "Arena:" + PList(GetInteger(Mid(Message, 10, 2))) + "> " + TrimZero(Mid(Message, 12))
                            End If
                        Case 2
                            If GetInteger(Mid(Message, 10, 2)) = -1 Then
                                AddMessage "Public:" + TrimZero(Mid(Message, 12))
                            Else
                                AddMessage "Public:" + PList(GetInteger(Mid(Message, 10, 2))) + "> " + TrimZero(Mid(Message, 12))
                            End If
                        Case 3
                            If GetInteger(Mid(Message, 10, 2)) = -1 Then
                                AddMessage "Team:" + TrimZero(Mid(Message, 12))
                            Else
                                AddMessage "Team:" + PList(GetInteger(Mid(Message, 10, 2))) + "> " + TrimZero(Mid(Message, 12))
                            End If
                        Case 4
                            If GetInteger(Mid(Message, 10, 2)) = -1 Then
                                AddMessage "TeamPrivate:" + TrimZero(Mid(Message, 12))
                            Else
                                AddMessage "TeamPrivate:" + PList(GetInteger(Mid(Message, 10, 2))) + "> " + TrimZero(Mid(Message, 12))
                            End If
                        Case 5
                            If GetInteger(Mid(Message, 10, 2)) = -1 Then
                                AddMessage "Private:" + TrimZero(Mid(Message, 12))
                            Else
                                AddMessage "Private:" + PList(GetInteger(Mid(Message, 10, 2))) + "> " + TrimZero(Mid(Message, 12))
                                    Select Case TrimZero(Mid(Message, 12))
                                        Case "!help"
                                            PrivateMessage GetInteger(Mid(Message, 10, 2)), "No commands yet =("
                                        Case Else
                                            PrivateMessage GetInteger(Mid(Message, 10, 2)), "Unknown command"
                                    End Select
                            End If
                        Case 7
                            If GetInteger(Mid(Message, 10, 2)) = 0 Then
                                AddMessage "RemotePrivate:" + TrimZero(Mid(Message, 12))
                            Else
                                AddMessage "RemotePrivate:" + PList(GetInteger(Mid(Message, 10, 2))) + "> " + TrimZero(Mid(Message, 12))
                            End If
                        Case Else
                            AddMessage "Unknown chat message(type " + CStr(GetInteger(Mid(Message, 8, 2))) + "):" + TrimZero(Mid(Message, 12))
                    End Select
            End Select
    End Select

'How to send a private message to someone in the current arena (including yourself)
Public Sub PrivateMessage(PIndex As Integer, Message As String)
    UDPSend UDPMySock.Remote, Chr(0) + Chr(3) + NextSID + Chr(6) + GetString2(5) + GetString2(PIndex) + Message + Chr(0)
End Sub