Skip to content
YVT edited this page Jan 6, 2018 · 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 StringEx.

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 StringEx.

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.

(Since 0.1.2) If Message Type is 2 and Text starts with C% , then it will be handled specially by the OpenSpades client. This behavior can be disabled by the user by setting cg_serverAlert to 0.

  • C% : Displays a center-aligned large message.

Piqueserver 0.1.0+ natively supports sending these messages.

# assuming self is a connection
self.send_chat_notice("Hi!")
self.send_chat_warning("don't do that")
self.send_chat_error("I'm sorry")
self.send_chat_status("You are the last player")

self.protocol.broadcast_chat_notice("Hi everyone")
self.protocol.broadcast_chat_warning("airstrike incoming", team=target_team)
self.protocol.broadcast_chat_error("I have no idea why you'd want this")
self.protocol.broadcast_chat_status("3 Players remaining")

In older servers, scripts need to construct these messages and possible fallbacks manually. This 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]

(Until 0.1.1) There must be an active loaded map for this packet to be accepted by the client. Otherwise, the client would ignore his packet. (See #644)

(Since 0.1.2) The restriction mentioned above is relaxed.

This is a new packet type introduced in OpenSpades.

Simple variant:

(empty)

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

Enhanced variant: (since 0.1.1)

+-----------------------+
|  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.

OpenSpades

34: Version Send [C2S]

This is a new packet type introduced in 0.75 compatible clients.

Simple variant (OpenSpades):

+--------------------+
|  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, and Unknown OS; Windows 10, FreeBSD, and OpenBSD (since OpenSpades 0.1.1).

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).

Simple variant ("a client thing"):

+--------------------+
|  Magic? 'b' (8)    |
+--------------------+
|        ???         |
+--------------------+

Yet to be documented.

Enhanced variant: (since 0.1.1)

(All known OpenSpades Versions) The OpenSpades client does not actually send this packet. This is a bug.

+--------------------+
|  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
  • 2: Client Feature Flags 1

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 ... |
+-----------------------+

Application Name is an ASCII-encoded string containing the product name of the game client. This will be OpenSpades in the case of the OpenSpades client.

Version Info Payload 1: User Locale

+-------------+
|  Locale...  |
+-------------+

Locale is an ASCII-encoded string containing a locale identifier defined by ISO 15897, but not including an encoding nor locale variant modifier, thus it follows this format: [language[_territory]]. Examples include ja_JP, en, and en_us.

Version Info Payload 2: Client Feature Flags 1

+--------------+----+
| Reserved (7) | SU |
+-------------------+
|   Reserved (8)    |
+-------------------+
|   Reserved (8)    |
+-------------------+
|   Reserved (8)    |
+-------------------+

SU (Supports Unicode) is a flag indicating whether the client supports sending/receiving UTF-8 encoded strings (see Type: StringEx). (0=not supported, 1=supported) OpenSpades returns 1 for this unless the Unicode support disabled by a user.

Type: StringEx

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.