Skip to content
YVT edited this page Jan 7, 2017 · 25 revisions

ENet Packets

S2C: server to client C2S: client to server

17: Chat Message [S2C/C2S]

C2S variant:

+-----------------------+
|  Sender Player ID (8) |
+-----------------------+
|  Message Type (8)     |
+-----------------------+----+
|  Text ...                  |
+----------------------------+

Text is a string of the type ChatMessageString.

There are no further differences from the original protocol.

S2C variant:

+-----------------------+
|  Sender Player ID (8) |
+-----------------------+
|  Message Type (8)     |
+-----------------------+----+
|  Text ...                  |
+----------------------------+

Text is a string of the type ChatMessageString.

If Message Type is 2 and Text starts with N% , !% , or %% , then it will be handled specially by the OpenSpades client. This behavior can be disabled by the user by setting cg_serverAlert to 0.

  • N% : Displays a "Notice" alert.
  • !% : Displays a "Error" alert accompanied with a sound.
  • %% : Displays a "Warning" alert accompanied with a sound.

The following code snippet from buildandsplat.py shows how to send a global alert message in a pyspades script.

def report_stat(self):
    self.send_chat("N% " + self.get_stat_message())

There are no further differences from the original protocol.

33: Version Get [S2C]

This is a new packet type introduced in OpenSpades.

Simple variant:

(empty)

The OpenSpades client will send back a Version Send of simple variant upon receiving this packet.

Enhanced variant: (since 0.1.TBD)

+-----------------------+
|  Property IDs (8) ... |
+-----------------------+

Property IDs contains a list of one or more property IDs represented b unsigned 8-bit integers. The OpenSpades client will send back a Version Send of enhanced variant upon receiving this packet.

34: Version Send [C2S]

This is a new packet type introduced in OpenSpades.

Simple variant:

+--------------------+
|  Magic? 'o' (8)    |
+--------------------+
|  Major version (8) |
+--------------------+
|  Minor version (8) |
+--------------------+
|  Revision (8)      |
+--------------------+-------+
|  Operating System Name ... |
+----------------------------+

Contains the version number of the currently running OpenSpades client software.

Operating System Name contains a human-readable ASCII encoded string, and does NOT end with a null character, The value of the field is not formally defined but it's usually one of Linux, Mac OS X, Windows 2000, Windows XP, Windows XPx64, Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10 (since OpenSpades 0.1.1), Unknown OS.

Example: OpenSpades 0.1.0 running on macOS would send the byte sequence 6f 00 01 00 4d 61 63 20 4f 53 20 58 (excluding the packet type byte).

Enhanced variant: (since 0.1.TBD)

+--------------------+
|  Magic? 'x' (8)    |
+--------------------+-------+
|  Chunks ...                |
+----------------------------+

Chunks is a sequence of one or more chunks. The structure of each chunk is shown below:

+--------------------+
|  Property ID (8)   |
+--------------------++
|  Payload Length (8) |
+---------------------+------+
|  Payload ...               |
+----------------------------+

The format of Payload differs from one property to another. Property ID is one of following values:

  • 0: Application Name and Version
  • 1: User Locale

Property IDs contained in a Version Send must match those in the corresponding Version Get packet. If the client does not support a specified property ID, an empty payload will be returned (and therefore Payload Length will be zero).

Version Info Payload 0: Application Name and Version

+--------------------+
|  Major version (8) |
+--------------------+
|  Minor version (8) |
+--------------------+
|  Revision (8)      |
+--------------------+--+
|  Application Name ... |
+-----------------------+

TODO

Version Info Payload 1: User Locale

TODO

Type: ChatMessageString

In the original client (AoS 0.75β) the chat text was encoded using CP437 (code page 437). OpenSpades extends this by supporting UTF-8.

UTF-8 encoded strings are distinguished by the prefix byte 0xff. For example, the text ほげ will be encoded to the byte sequence ff e3 81 bb e3 81 92. A string without the prefix shall be decoded as a CP437 string.

The OpenSpades client will send a UTF-8 string only in the circumstances where the string cannot encoded with CP437 and the user has not disabled this behavior by setting cg_unicode to 0. In other cases the string will be encoded with CP437, and all characters unrepresentable in CP437 will be replaced with U+00A0, which will be encoded to 0xff in CP437.