Protocol 0.75 and 0.76

This page documents the Ace of Spades 0.75 protocol and its 0.76 variation, the classic wire public servers speak. It is written from the point of view of both ends: every packet says which direction it goes, what the server sends or expects, and what a client has to send.

0.76 differs in exactly three places, marked [0.76] throughout: the ENet connect data, the Map Start packet and the World Update entry. One implementation can speak both.

Where this comes from: the packets and rules below were written from ngspades-client and ngspades-server, then checked against the AoS 0.75.015 Canon Client Doc (version 0.0.3, and the earlier 0.0.2 draft) by not a burner (CC0, a client's view of the protocol), the API documentation of his server LSd (apidoc/), the original SpadesX (the server ours started from) and BetterSpades. Where they disagree the page says so. If you see an error, please open an issue.

Connection

Ace of Spades uses ENet 1.3 over UDP. When you connect, the 32-bit connect data picks the protocol:

NumberProtocol
30.75
40.76
ENetHost *host = enet_host_create(NULL, 1, 1, 0, 0);
enet_host_compress_with_range_coder(host);
ENetPeer *peer = enet_host_connect(host, &address, 1, 3);
SettingValue
Port32887 by convention
Channels1 (channel 0)
CompressionENet's range coder, mandatory in both directions
Reliabilityeverything reliable except World Update (2), sent unreliable
Framingone game packet per ENet packet: one Uint8 id, then the payload

A server must check the length of every packet before reading it, and check the player_id field of a client packet against the sender's id.

A server may send the map again in the middle of a match (a new round); a client must handle Map Start at any time.

Disconnect Reasons

The server puts a Uint32 reason in the ENet disconnect event. ENet also uses 0 for a timeout, so 0 is ambiguous.

NumberReasonNotes
0Timeoutor an unspecified server reason
1Banned
2Kickedpiqueserver and BetterSpades read it as "too many connections" instead (the quirk SCREWED_DISCONNECT_DATA)
3Wrong protocol versionconnect data was not 3 or 4
4Server full
5Server shutting down
8, 9, 10, 11Banned, full, kicked, wrong versionthe same reasons once the player is in the game. Historically 0..4 were sent during the map transfer and 8..11 after it, because the Voxlap client uses the code during the transfer as an index into its language strings. OpenSpades only knows 10 (kicked) there
20Invalid name
61Server shutting downan alternative value some servers use

A system Chat Message from player 255 sent just before the disconnect is the kick text (the Kick Reason extension, see Extensions). Show any unknown number as "unknown"; never index a table with it. A code outside the list is handled as unknown, and a client must not crash on it.

About Addresses

aos://<address>[:<port>][<version suffix>]
  • <address> is the IPv4 address as one decimal number in little-endian byte order: aos://16777343 is 127.0.0.1 (0x0100007F). Byte 0 of the address is the low byte of the number.
  • <address> ranges from 1 to 4294967295 and <port> from 1 to 65535. A value outside the range is not an address.
  • <port> defaults to 32887.
  • A suffix after the port (:0.75, /0.76) names a version. An unknown suffix means 0.75.

Accept a dotted address (aos://1.2.3.4:32887) and a bare host:port too.

About Coordinates

The map is 512 x 512 x 64 voxels. x goes east, y goes south, and z grows downwards: 0 is the top of the world, 63 is the bottom (water) layer.

  • A float position (0,0,0) is the corner of voxel (0,0,0); (0.5,0.5,0.5) is its centre. Floor each axis to get the voxel.
  • A player's position is its eye, not its feet.
  • Servers do not let a player dig or build at z = 62 and z = 63. A client still applies what it receives: only the spade-3 and grenade block actions (2 and 3) leave z >= 62 alone.
  • Terrain outside 0..511 on x/y is drawn as a copy of the map (toroidal wrap). Players, block edits and block physics do not wrap; grenades do.
  • A look direction is the unit vector (ox, oy, oz); oz is negative when looking up (because z grows downwards).

If your engine has y up, convert at the protocol boundary: engine = (x, 63 - z, y), and back with (x, z, 63 - y).

About Text

  • CP437 is the original encoding. Bytes 0x80..0xFF are code page 437.
  • UTF-8 is sent by newer servers: a string beginning with byte 0xFF and valid UTF-8 after it is UTF-8 (drop the 0xFF). Anything else is CP437. To send, use CP437 when every character fits, otherwise 0xFF + UTF-8 — and only to a server known to read it (its extended version answer's feature bit 0, or a 0xFF line it wrote).

Chat text may contain colour control bytes: 0x01-0x02 team colours, 0x03 spectators, 0x04 red, 0x05 green, 0x06 white, 0x07 grey, 0x08 yellow. \n and \r break the line.

On the wire, 0x01-0x07 are the colour bytes real servers send, in both encodings; 0x08 (yellow) belongs to the UTF-8 variant of the text (the one that begins with 0xFF), so a CP437 string from a server that does not speak UTF-8 does not carry it. A reader should treat every other byte below 0x20 as having no colour meaning. This describes what travels, not what any particular client draws.

In the UTF-8 variant the bytes 0x09-0x1F are replaced by the replacement character U+FFFD, and \n and \r both break the line. In the CP437 variant 0x01-0x1F are the symbols of the code page (☺ ☻ ♥ ♦ ♣ ♠ and so on). A NUL ends the string in both. Two other variants exist in the wild and are named by quirks: OpenSpades' own CP437 table, and an ASCII-only one that drops every other byte (see Quirks).

Packets

All packets start with an unsigned byte naming their type; the sizes below include that byte. Structures are packed, little-endian, no padding.

Data Types

ShorthandDetails
Uint88-bit unsigned
Int88-bit signed
Uint1616-bit unsigned
Int3232-bit signed
Uint3232-bit unsigned
Float32-bit IEEE-754
Vec3three Floats: x, y, z
Vec3ithree Int32: x, y, z
Colorthree bytes in the order B, G, R
CP437 StringNUL-terminated string of that encoding
UTF-8 String0xFF followed by UTF-8 (see About Text)

Table of Contents

Position Data

Server -> Client

Teleports or corrects the receiver. It carries no player id: it is always about you.

InfoValue
Packet ID0
Total size13 bytes
Field NameField TypeNotes
X, Y, ZVec3the eye position

The client sets its position at once and keeps its look. Never interpolate: it is a correction, not a movement.

Client -> Server uses the same packet to report its eye position, reliably, about once a second while alive (do not depend on exactly 1 Hz as a server) and right after a teleport. The server compares it with its simulation and answers with Position Data when it disagrees.

Orientation Data

Server -> Client

Turns the receiver to a direction. Rare; normally the look rides World Update.

InfoValue
Packet ID1
Total size13 bytes
Field NameField TypeNotes
X, Y, ZVec3unit look vector

Client -> Server: the client's look, sent whenever it changed, at most about 120 times a second, and right before each shot so the server can validate the hit. Compare for exact equality with the last value sent: a threshold ("only when it moved enough") leaves the server with a stale look.

World Update

Server -> Client

The only unreliable packet. A newer update replaces the old one.

InfoValue
Packet ID2
Total size1 + 24 * n (0.76: 1 + 25 * n)

0.75: one entry per player slot, indexed by id, up to 256 slots.

Field NameField TypeNotes
PositionVec3eye position, (0,0,0) = not visible
OrientationVec3look vector

[0.76] one entry per present player:

Field NameField TypeNotes
Player IDUint8
PositionVec3
OrientationVec3

Skip your own entry. A zero position means "not visible": keep the last known position. Servers fill dead players, players out of the fog and free slots with zeros. Interpolate between updates (about 60 a second).

Input Data

Server -> Client

Another player's movement keys.

InfoValue
Packet ID3
Total size3 bytes
Field NameField TypeNotes
Player IDUint8
KeysUint8bit packed, see below
BitKey
1forward
2back
4left
8right
16jump
32crouch
64sneak
128sprint

For yourself only the jump bit matters (the server echoes the physics it applied). Client -> Server sends the same packet whenever the keys change.

Weapon Input

Server -> Client

Another player's fire buttons.

InfoValue
Packet ID4
Total size3 bytes
Field NameField TypeNotes
Player IDUint8
ButtonsUint8bit 0 primary (left), bit 1 secondary (right)

It is not the raw mouse: a server sends 0 while a player sprints, switches tool or reloads. Use it to draw tracers, swings and muzzle flashes for that player; ignore it for yourself.

Client -> Server sends it whenever a button changes, except while sprinting.

Set HP / Hit

Server -> Client — Set HP

InfoValue
Packet ID5
Total size15 bytes
Field NameField TypeNotes
HPUint8the receiver's new health, 0..100
TypeUint80 fall damage, 1 anything else. Clients ignore it
SourceVec3where the damage came from. A non-zero source shows a directional hit marker, zero (a fall) shows none

A drop below the current health flashes the screen red and plays the hit sound. The value is informational: at 0 a Kill Action follows, and a client can be alive with 0 health until it arrives.

Client -> Server — Hit. Packet id 5 again; the direction decides.

InfoValue
Packet ID5
Total size3 bytes
Field NameField TypeNotes
VictimUint8player id
Hit TypeUint80 torso, 1 head, 2 arms, 3 legs, 4 melee

The client reports every hit its shot or swing made; the server decides whether it counts and how much it hurts. Send only hits you really saw.

Grenade

Server -> Client

InfoValue
Packet ID6
Total size30 bytes
Field NameField TypeNotes
Player IDUint8thrower
FuseFloatseconds until it explodes
PositionVec3
VelocityVec3blocks per 1/32 s

Gravity is 32 blocks/s². The server does not echo a grenade to its thrower.

Client -> Server: the throw, with the fuse left (up to 3 s), where it leaves the hand, and velocity in blocks per 1/32 s (blocks_per_second / 32).

Set Tool

Server -> Client

InfoValue
Packet ID7
Total size3 bytes
Field NameField TypeNotes
Player IDUint8
ToolUint80 spade, 1 block, 2 gun, 3 grenade

A value above 3 is read as the spade (the clidoc's rule for every unknown tool). Client -> Server sends it whenever the tool changes.

Set Color

Server -> Client

InfoValue
Packet ID8
Total size5 bytes
Field NameField TypeNotes
Player IDUint8
ColorColorB, G, R

Keep it even for a player who is not alive or not joined yet: later block packets use it. Client -> Server sends it when the player picks a colour.

Existing Player

Client <-> Server

A player already in the match (server to client), or the client's join (client to server).

InfoValue
Packet ID9
Total size12 + name (the NUL is part of the name), so at least 13
Field NameField TypeNotes
Player IDUint8client to server: ignored, the sender is the connection
TeamInt80 team 1, 1 team 2, -1 (255 on the wire) spectator
WeaponUint80 rifle, 1 SMG, 2 shotgun
ToolUint8as in Set Tool
KillsInt32the score. Overflow wraps
ColorColorB, G, R
NameCP437 Stringat least 15 characters must be readable, cut on a character boundary

A server sends it for every other player after the map and before State Data. It carries no position: keep the player hidden until a World Update or Create Player places them.

A client sends it after State Data to join, with the chosen team, weapon, tool (gun), zero kills, its block colour and its name. The Player ID it writes is not trusted (SpadesX skips it: a client "always sends a dumb id", and the server's receive_existing_player only accepts it from a spectator). The server answers with Create Player.

A joined player's position is not in the packet: the usual place for the hidden player is far out of the map, for example (256, 256, 1024) in the packet's coordinates, and its orientation is the spawn orientation of its team. Its inputs start at zero.

The extended version answer reuses this id: the first byte after the id is 'x' (0x78), which no player id can be (see Extensions).

Short Player Data

Client -> Server — joining from the spectators

Not an older form of Existing Player. A player who is already named, and is a spectator, picks a team and a weapon with it. There is no name in the packet (the clidoc calls it "join from spectator" in 0.0.2 and "spectator switch" in 0.0.3, which adds that a player who is not spectating uses Change Team and Change Weapon).

InfoValue
Packet ID10
Total size4 bytes
Field NameField TypeNotes
Player IDUint8ignored, the sender is the connection
TeamInt80 or 1, 255 spectator. Anything else becomes spectator
WeaponUint80 rifle, 1 SMG, 2 shotgun

A server reads it only from a connection that is currently a spectator (SpadesX and ours drop it otherwise: a player already in a team uses Change Team and Change Weapon). It keeps the name the player gave in its Existing Player. The server then spawns the player and answers with Create Player.

The first thing a client sends to join is Existing Player, which carries the name. A server that treats Short Player Data as a first join has no name to use. The author of LSd reports that the original Voxlap server does accept it that way, and then shows uninitialised memory as the player's name. A client should join with Existing Player, and a server should not accept this packet from a connection that has not sent one.

A client with the quirk NOSHORTPLAYER never sends it and uses Change Team and Change Weapon instead (see Quirks). The packet is never sent by a server, and a client that receives one logs it and carries on.

Move Object

Server -> Client

InfoValue
Packet ID11
Total size15 bytes
Field NameField TypeNotes
ObjectUint8CTF: 0/1 intels, 2/3 tents. TC: territory index
TeamInt8the owner, for TC
PositionVec3the new cell

CTF: moving an intel also drops it from its carrier, silently. TC: team is 0 or 1, or neutral. Servers send neutral as 2 (pyspades and piqueserver do; our server's 0.75 profile has no TC, so it never sends one). A client should read any value other than 0 or 1 as neutral in territory and object packets, and as spectator (-1) in every packet that names a player's team. Some drafts treat 2 as a "neutral spectator" and 3 as neutral; the rule above covers both.

Create Player

Server -> Client

A player spawned (or joined for the first time).

InfoValue
Packet ID12
Total size15 + name (16 with an empty name)
Field NameField TypeNotes
Player IDUint8
WeaponUint8
TeamInt8spectator = not alive
PositionVec3the eye
NameCP437 Stringabsent in a 16-byte packet

The player is alive unless the team is spectator. It faces east for team 1 and west for team 2. Reset its block colour to (111,111,111) and restock it (full health, 50 blocks, 3 grenades, full magazine and reserve).

A 16-byte packet has no name: keep the one you had (a player not yet joined gets an empty one), and a longer packet sets the name.

The offset applied to z is where the sources differ. The original Voxlap client and LSd's default are z - 2; the clidoc's 0.0.2 draft said z - 2, its 0.0.3 says z - 2.4, which LSd names the quirk INSKY; and INFLOOR uses z as it is. ngspades-server sends the eye position and ngspades-client uses it as given (INFLOOR). A server that does not know which a client implements sees a player a little too high or too low for a moment. See Quirks.

Block Action

Client <-> Server

InfoValue
Packet ID13
Total size15 bytes
Field NameField TypeNotes
Player IDUint8
ActionUint8see below
X, Y, ZVec3ithe block cell
ActionEffect
0build one block with the player's colour (a repaint when already solid)
1destroy one block
2spade: destroy the block and the ones above and below (1 x 1 x 3)
3grenade: destroy 3 x 3 x 3, silently
4destroy one block (a gun)
5destroy one block (a spade)

Actions 2 and 3 leave z >= 62 alone; cells outside the map are ignored.

A value of Action not in the table is ignored. For the client's own block count (the HUD, the server counts for the rules): a build (0) costs one when you have more than one block, a destroy (1) gives one back only while holding the spade and below 50, and 5 gives one back below 50. Actions 4 and 5 are later additions of the same two destroys.

A server applies its rules (tool in hand, no sprinting, reach about 4 blocks, a solid neighbour for a build, the block count, editable cells) and relays it to everyone. A client batches edits that arrive together: keys by position (last wins), apply creates then destroys, then run block physics once. Applying them one by one makes a repaint collapse a structure.

Block Line

Client <-> Server

InfoValue
Packet ID14
Total size26 bytes
Field NameField TypeNotes
Player IDUint8
StartVec3i
EndVec3i

Builds a line of blocks between the two cells with pyspades' modified DDA (not a ray cast: cube_line, not cast_ray), skipping cells that are already solid and drawing every cell in full whatever the length. The line always has |dx| + |dy| + |dz| + 1 cells, the already-solid ones included. It costs that many blocks. A client with fewer blocks than that does not send it. The edits are batched like a Block Action (see below).

State Data

Server -> Client

Ends the map download.

InfoValue
Packet ID15
Total size84 bytes (CTF), 33 + 13 * n (TC)
Field NameField TypeNotes
Player IDUint8you
FogColor
Team 1 ColorColor
Team 2 ColorColor
Team 1 Name10 bytesNUL padded, may lack the NUL: read it as if its last byte were a NUL
Team 2 Name10 bytes
ModeUint80 CTF, 1 TC

CTF (52 bytes)

Field NameField TypeNotes
Team 1 ScoreUint8captures
Team 2 ScoreUint8
Capture LimitUint8
Intel StateUint8bit 0 team 1's intel held, bit 1 team 2's
Team 1 Intel12 bytesheld: {Uint8 carrier; 11 bytes padding}; else Vec3 position
Team 2 Intel12 bytesthe same
Team 1 BaseVec3the tent
Team 2 BaseVec3

TC (1 + 13 * n)

Field NameField TypeNotes
CountUint8number of territories
TerritoriesCount x Territory
Territory FieldField TypeNotes
PositionVec3
TeamUint80 or 1; any other value is neutral (servers send 2)

Treat an unknown mode as TC. Read the names as 10 bytes, and never strcpy them. Load the map only now, then open the team menu. The packet also leaves the map transfer mode and tells you your own player id.

The original SpadesX wrote the two intel bits the other way round (set when the intel was not carried) and wrote the carrier where the position belongs, so a joining client read both intels as carried. The bits above are what pyspades and the clients read, and what ngspades-server writes. SpadesX also sends the packet padded to 104 bytes.

Kill Action

Server -> Client

InfoValue
Packet ID16
Total size5 bytes
Field NameField TypeNotes
VictimUint8
KillerUint8equal to the victim for a suicide
KindUint8see below
RespawnUint8seconds until the respawn
KindMeaning
0weapon
1headshot
2melee
3grenade
4fall
5team change
6weapon/class change

For kinds 0 to 3 the victim was killed by Killer and the killer's score goes up by one if it is not on the victim's team; for kinds 4 to 6 Killer is ignored and nobody scores. Do not handle 5 and 6 specially. Draw the kill feed and start the respawn countdown. Respawn is whole seconds, to display.

Chat Message

Client <-> Server

InfoValue
Packet ID17
Total size3 + text (the NUL is included)
Field NameField TypeNotes
Player IDUint8255 = the server
TypeUint80 all, 1 team, 2 system; 3-6 optional (see Message Types)
TextCP437 Stringor UTF-8 with the 0xFF prefix

A packet with a type not in this list is ignored. Server notices use type 2 from player 255 (the clidoc: the id is ignored for type 2). Types 3-6 (big, info, warning, error) are the Message Types extension. A client sends types 0 and 1 only.

A system line from player 255 sent just before a disconnect is the kick text.

Map Start

Server -> Client

InfoValue
Packet ID18
Total size5 bytes (0.76: 73)
Field NameField TypeNotes
Map SizeUint32length of the compressed map stream

[0.76]

Field NameField TypeNotes
Map SizeUint32
CRC32Uint32of the compressed stream
Map Name64 bytesNUL padded

The stream is a zlib-compressed VXL map. Append every Map Chunk until you have Map Size bytes, then inflate and load. A 0.76 server asks first: answer Map Cached with 1 when you already have that CRC32, and it sends no chunks.

Map Chunk

Server -> Client

InfoValue
Packet ID19
Total size1 + n
Field NameField TypeNotes
DataUint8 arraya piece of the stream, in order

Chunks may be any size. Do not start decoding before the total matches.

Player Left

Server -> Client

InfoValue
Packet ID20
Total size2 bytes
Field NameField TypeNotes
Player IDUint8

Clear the slot.

Territory Capture

Server -> Client

InfoValue
Packet ID21
Total size4 bytes
Field NameField TypeNotes
TerritoryUint8index
WinningUint81 ends the round
TeamUint80 or 1; any other value is neutral (servers send 2)

Some clients read an uninitialized pointer when team is not 0/1/2; a server should only send those three.

Progress Bar

Server -> Client

InfoValue
Packet ID22
Total size8 bytes
Field NameField TypeNotes
TerritoryUint8index
TeamInt8the capturing team
RateInt8progress per 50 s
ProgressFloat0..1

A client advances 0.05 * rate a second, like the 0.75 reference.

Intel Capture

Server -> Client

InfoValue
Packet ID23
Total size3 bytes
Field NameField TypeNotes
Player IDUint8
WinningUint81 ends the round

The capturing player's team scores one and the player ten (clidoc 0.0.3; LSd's API document says one for the player, so servers differ). If Winning is not 0 both scores reset to 0 and the round is over. A packet in a mode that is not CTF is ignored.

Intel Pickup

Server -> Client

InfoValue
Packet ID24
Total size2 bytes
Field NameField TypeNotes
Player IDUint8the carrier

Intel Drop

Server -> Client

InfoValue
Packet ID25
Total size14 bytes
Field NameField TypeNotes
Player IDUint8who dropped it
PositionVec3where it lies now

Restock

Server -> Client

InfoValue
Packet ID26
Total size2 bytes
Field NameField TypeNotes
Player IDUint8

That player gets full health, 50 blocks, 3 grenades and a full reserve. For yourself update the HUD; for someone else only play the sound. Ignore it while you are dead.

Fog Color

Server -> Client

InfoValue
Packet ID27
Total size5 bytes
Field NameField TypeNotes
Player IDUint8ignored (the clidoc). Some servers write 0, some an alpha value
ColorColorB, G, R

0.75 has no fog distance: it is always 128 blocks.

Weapon Reload

Client <-> Server

InfoValue
Packet ID28
Total size4 bytes
Field NameField TypeNotes
Player IDUint8
MagazineUint8rounds now in the gun
ReserveUint8rounds left

A client sends it when it starts a reload. The server answers when the reload finishes; for yourself that answer settles the ammo, for another player it only plays the sound (and refills your view of their clip, or you stop drawing their shots).

Change Team

Client -> Server

InfoValue
Packet ID29
Total size3 bytes
Field NameField TypeNotes
Player IDUint8
TeamUint80, 1 or 255

A team change during a match is a death (kill kind 5) followed by a respawn. A spectator who changes to a team is spawned and, in LSd, killed at once again so that the next spawn uses the new team: other servers differ. An unknown value is read as spectator.

Change Weapon

Client -> Server

InfoValue
Packet ID30
Total size3 bytes
Field NameField TypeNotes
Player IDUint8
WeaponUint80 rifle, 1 SMG, 2 shotgun

A death with kill kind 6, then a respawn. An unknown weapon is read as the rifle.

Handshake Init

Server -> Client

Optional client fingerprinting.

InfoValue
Packet ID31
Total size5 bytes
Field NameField TypeNotes
ChallengeUint32echo it back

The Voxlap client does not answer; a server must never require it.

Handshake Return

Client -> Server

InfoValue
Packet ID32
Total size5 bytes
Field NameField TypeNotes
ChallengeUint32the same four bytes

Version Get

Server -> Client

InfoValue
Packet ID33
Total size1 byte, or 1 + n for the extended form

Version Get with property ids after the id asks for the extended answer (see Extensions).

Version Send

Client -> Server

InfoValue
Packet ID34
Total size69 bytes
Field NameField TypeNotes
ClientUint8'B' BetterSpades and ours, 'o' OpenSpades
Major, Minor, RevisionUint8 x 3
OS64 bytesNUL padded

Map Cached

Client -> Server [0.76]

InfoValue
Packet ID31
Total size2 bytes
Field NameField TypeNotes
CachedUint81 = I have the map, send no chunks

Ext Info

Client <-> Server

The extension negotiation. Its layout and the registry are in Extensions.

Player Properties

Server -> Client

Optional extension 0x00.

InfoValue
Packet ID64
Total size12 bytes
Field NameField TypeNotes
SubUint80
Player IDUint8
HealthUint80 for an enemy
BlocksUint80 for an enemy
GrenadesUint80 for an enemy
MagazineUint8
ReserveUint8
ScoreUint32kills plus score

Sent when a value changes, at most every 100 ms per player.

Light

Client <-> Server

Optional extension 0x32 (Flashlight).

InfoValue
Packet ID114
Total size4 bytes
Field NameField TypeNotes
SubUint80 (this packet: Light). Sub 1 is Light State and sub 2 Light Config, see Extensions
Player IDUint8
OnUint80 or 1

Send a request only after you accepted the extension, and draw the beam only when the server relays it. A light goes off silently on Create Player, Kill Action, Player Left and a new map.

Quirks

Quirks are switches in how a client and a server read the protocol: places where implementations disagree. The clidoc numbers the first seven and LSd's API names nine. A client that tells the server which ones it has implemented (and none that it has not fully implemented) lets the server make better choices. LSd also guesses them for clients that do not say (is_quirk_heuristic). The wire format of the announcement is not documented anywhere; ngspades does not send one.

NumberNameEffect
0INFLOORthe pos of Create Player is used as it is, with no offset to z
1NOSHORTPLAYERShort Player Data is not used; Change Team and Change Weapon are sent separately
2SCREWED_DISCONNECT_DATAdisconnect code 2 means "too many connections" instead of "kicked"
3OS_CP437OpenSpades' variant of CP437 instead of Voxlap's
4UTF8strings may start with 0xFF and carry UTF-8
5ASCIIonly printable ASCII (the space included) is used, the other bytes are dropped
6OS_BACTION_CULLthe voxels already empty inside a destroy shape are not touched by block gravity (OpenSpades' rule, which is also the clidoc's)
-UTF8_COLOR_IMGthe grey colour byte moves from 0x07 to 0x08, and 0x07 followed by a lower case letter shows an inline image (LSd)
-INSKYCreate Player uses an offset of -2.4 to z instead of -2 (LSd)

Game Rules

The wire carries state; the game still needs these rules.

Players

Ids 0..255. Keep state for all 256: joined, alive, team, weapon, tool, score, name, block colour, position, orientation, input. Only for yourself: health, blocks, grenades, magazine, reserve. Out-of-range values fall back to something safe (spectator, rifle, spade); never index a table with a value from the wire.

Fog

Sight is a cylinder of radius 128 around the camera. Nothing beyond is drawn, shots stop there, the sky is the fog colour. State Data and Fog Color set the colour. A server may send positions beyond the fog anyway; do not draw them (that is a wallhack).

Block Physics

When a voxel stops being solid, check its six neighbours. Each solid one starts a flood fill through solid voxels. If the fill reaches z >= 62, nothing happens; otherwise everything it reached is detached, falls and is removed. Voxels that were already empty inside a spade or grenade area must not start a check.

Damage, Death and Respawn

The client reports hits; the server sends Set HP, then Kill Action at 0. On death the intel is dropped (Intel Drop), the corpse is drawn (or a grave), the kill feed updates and the respawn counter runs from the kill packet. The server spawns the player with Create Player.

Blocks

A player carries at most 50 blocks. A build costs one, a spade destroy gives one back. Restock refills at the tent. The client counts locally for the HUD; the server counts for the rules.

Weapons

What pyspades and SpadesX do (ngspades-server's 0.75 profile too). The wire does not carry any of it: the server applies it and tells the client the result with Set HP, Kill Action, Weapon Reload and Restock.

WeaponMagazine / reserve (0.75)(0.76)Delay between shotsHead / torsoArms and legs
Rifle (0)10 / 508 / 48500 mskills / 4933
SMG (1)30 / 12030 / 150100 ms75 / 2918
Shotgun (2)6 / 488 / 481000 ms, 8 pellets37 / 2716

A spade hit does 80. A player starts with 100 health, 50 blocks and 3 grenades, and Restock restores them. The server counts: a client only reports hits (the hit type is in Hit: 0 torso, 1 head, 2 arms, 3 legs, 4 melee).

A grenade does damage to every player within 16 blocks on each axis who is in line of sight of it, 4096 / d^2 with d the distance, at most 100, and only above z = 62. It destroys a 3 x 3 x 3 block volume with the silent block action. LSd documents a different formula, so two servers can disagree.

A landing at a downward speed above 0.24 (the physics' own unit) halves the horizontal speed and plays the fall sound. Above 0.58 it also hurts, by (speed - 0.58)^2 * 4096 health, sent as a Set HP of type 0 with no source. SpadesX also lets a player restock at its tent at most every 15 seconds and counts a capture only if 5 seconds have passed since the player was last in its tent. These are server rules, not protocol.

CTF

Two scores, a capture limit, two intels (held by a player or lying at a cell), two tents. Touching the enemy intel picks it up, carrying it into your tent captures it, dying drops it. A capture puts the intel back at its base (Move Object). A round ends at the capture limit.

TC

A list of territories (position and owner). Standing in one moves its capture towards your team; the server sends Progress Bar and then Territory Capture. Owning them all wins.

Server List

The classic public list is a JSON array at /serverlist.json, for example https://services.buildandshoot.com/serverlist.json. Each entry has at least:

KeyExampleNotes
name"Deuces Wild"
identifier"aos://16777343:32887"the address to join
map"Hallway"
game_mode"ctf"
country"US"ISO 3166-1 alpha-2
latency120ms, measured by the list
players_current, players_max16, 32
last_updated1301931731Unix seconds
game_version"0.75"

Ignore keys you do not know and expect duplicates. Our master serves the same shape plus id, identifier6 and info; see Master Server.

Writing a Server

Must

  1. An ENet host with the range coder, accepting connect data 3 (and 4).
  2. Version, ban and capacity checks with the right disconnect reasons.
  3. The map: VXL, zlib, Map Start, Map Chunk.
  4. Existing Player for every player, then State Data, after the map.
  5. The join: Existing Player from a connection that has not joined (its name is in the packet), then Create Player to everyone. A spectator joins a team with Short Player Data or Change Team, and only a spectator may.
  6. World Update at a steady rate, unreliable, zeros for unseen slots.
  7. Relay and validate Input Data, Weapon Input, Set Tool, Set Color, Orientation Data, Position Data.
  8. Hit -> Set HP -> Kill Action -> respawn.
  9. Block Action and Block Line with validation, block physics, Restock.
  10. Chat and Player Left.
  11. At least CTF.

Should

  • Server-side movement physics with corrections.
  • Create Player for players that do not move (bots) when someone joins, or they stand at the map corner until the next World Update.
  • Grenades simulated on the server.
  • Version Get / Handshake Init, as optional checks.
  • 0xFF + UTF-8 for text CP437 cannot express.
  • Ext Info and the extensions.

Spawn a player with 100 health, 50 blocks, 3 grenades, a full magazine and reserve, the gun in hand and no input held. Send every packet reliable except World Update, and one game packet per ENet packet.

Other Resources