Protocol 1.0

This page documents protocol 1.0, the protocol of ngspades-server. It starts from OpenSpades' abandoned ngspades branch ("WorldOfSpades 0.1"), with that reference's defects fixed and the packets a whole game needs added: chat, building, damage and game modes.

Current revision: 1.3 (three weapon slots, the compact player trajectory, the jetpack bits). The revision is informational; nothing is negotiated on it. There is no backward compatibility inside 1.0 yet: a wire change updates both ends together.

Connection

1.0 uses ENet 1.3 over UDP (IPv4 and IPv6), and WebRTC DataChannels in a browser. The 32-bit connect data picks the protocol:

NumberProtocol
135272729 (0x08101919)1.0
ENetHost *host = enet_host_create(NULL, 1, 2, 0, 0);
enet_host_compress_with_range_coder(host);
ENetPeer *peer = enet_host_connect(host, &address, 2, 0x08101919);
SettingValue
Port32887 by convention, the same as 0.75
Channels2: channel 0 reliable for everything, channel 1 unreliable sequenced for movement
CompressionENet's range coder, mandatory
Framingone game packet per ENet packet: one Uint8 id, then the payload

A client sends its own body (Client Side Entity Update, and an Entity Update carrying only a trajectory) on channel 1 unreliable. Everything else is reliable on channel 0. An update that must be seen before an action — right before a Hit Entity or a block build/dig — goes reliable on channel 0, or the server does not yet know you are firing or holding the right tool and refuses the action.

A server answers a vanilla server's connect data with reason 3 ("wrong protocol") and no Kick; treat that as "not a 1.0 server" and reconnect with connect data 3.

WebRTC (browsers)

A browser cannot send UDP. It reaches our servers over WebRTC DataChannels; the packets are identical, only the carrier changes. Signalling goes through our master (Master Server).

  • Two DataChannels, created before the offer: reliable (defaults) is channel 0, unreliable ({ordered: false, maxRetransmits: 0}) is channel 1. Any other label is closed by the server.
  • A text message is control. After both channels are open, send connect 135272729 on reliable (the connect data in decimal). Anything else is refused with ENet's refusal (3 = wrong protocol).
  • A binary message is exactly one 1.0 packet, at most 16 KB.
  • The server ends a connection with the text disconnect <reason>, then closes the peer. A binary message before connect is dropped.

Disconnect Reasons

NumberReasonNotes
0Unknown
1Internal server error
2Server full
3Kickeda Kick packet with the text came first
4Server stopped
5Timeouta handshake step took too long
6Malformed packet
7Protocol mismatchthe protocol name was not ours

Vanilla uses the same field with another table (1 banned, 2 connection limit, 3 wrong protocol). The meaning depends on the protocol the connection was opened with. The ambiguous case: connecting with the 1.0 magic to a vanilla server gives 3 with no Kick.

Timeouts

The server drops a connection that does not advance: 5 s for Initiate Connection (P10_TIMEOUT_INITIATE), 10 s for the certificate (P10_TIMEOUT_CERT), 300 s for the map transfer (P10_TIMEOUT_MAP), and 3 s for the client's answer to map-cached (P10_TIMEOUT_MAP_ANSWER). The reference server waited 10 s and 60 s; ours is stricter because an unfinished handshake holds a player slot. A client answers both steps in milliseconds, so it should not rely on more than the shorter figures. There is no timeout in the game; ENet's peer timeout applies.

Handshake

A world change (a new round, a reset) restarts the transfer at Game State Header for every connection. The player is removed and the client has to join again. Packets still in flight are dropped, not a protocol error.

Packets

All packets start with an unsigned byte naming their type. Unknown ids are ignored, not a reason to disconnect.

Data Types

All multi-byte fixed-width values are little-endian.

ShorthandDetails
Uint8, Uint16, Uint32fixed width
Float32-bit IEEE-754
Vec3three Floats
Varintunsigned LEB128, at most 10 bytes
Svarintzigzag, then Varint
BytesVarint length, then raw bytes (at most 1 MiB)
StringBytes of UTF-8, no NUL inside
Maprepeated String key, String value, ended by an empty key
Colorthree bytes in the order B, G, R
Block CoordSvarint x, Svarint y, Svarint z

Varint examples: 0 -> 00, 127 -> 7F, 128 -> 80 01, 300 -> AC 02. Zigzag examples: 0 -> 00, -1 -> 01, 1 -> 02, -2 -> 03.

A decoder must reject a truncated packet, a varint over 10 bytes, a string over 1 MiB or with a NUL in it, a mask bit it does not know, and an out-of-range enum. Mask bits are not self-describing: an unknown bit's payload cannot be measured, so new mask bits and new trailing fields change both ends together.

Table of Contents

Greeting

Server -> Client

InfoValue
Packet ID1
Total size1 + 1 + 5 + 1 + 2 + 128
Field NameField TypeNotes
MagicStringalways "Hello"
NonceBytes128 random bytes

Hex: 01 05 48 65 6C 6C 6F 80 01 <128 bytes>.

The nonce is used by the connect token. A client that receives any other packet id before the Greeting must treat the server as not 1.0 (about 1 in 50 public 0.75 servers accept the magic and then speak 0.75).

Initiate Connection

Client -> Server

InfoValue
Packet ID2
Total sizevariable
Field NameField TypeNotes
Protocol NameStringexactly "WorldOfSpades 1.0"
Major VersionUint161
Minor VersionUint163 (the protocol revision)
RevisionUint16your build, informational
PackageStringyour build, at most 256 bytes
EnvironmentStringOS/CPU, at most 1024 bytes
LocaleStringe.g. pt_BR, at most 256 bytes
Player NameStringUTF-8, at most 63 bytes
NonceBytes256 random bytes
Map QualityUint80 = send VXL; 1..100 = ngmap at that quality

Any other protocol name gets Protocol mismatch (7). Map Quality 0 means "I cannot decode ngmap, send map-format=vxl"; 1..100 means "ngmap is fine", clamped by the server to 20..100. The server may still answer VXL (encoding failed, map too large): trust map-format in the header, not what you asked for.

Server Certificate / Client Certificate

InfoValue
Packet IDs3 (Server -> Client), 4 (Client -> Server)
Total size1 byte, or variable
Field NameField TypeNotes
Is ValidUint80 = no certificate, nothing follows
CertificateBytesonly if Is Valid != 0
SignatureBytesonly if Is Valid != 0

Both sides send isValid = 0 normally; nothing is validated. The packets exist so accounts can be added later. Our server uses the client certificate to carry a connect token (Master Server).

Kick

Server -> Client

InfoValue
Packet ID5
Total size1 + text
Field NameField TypeNotes
ReasonStringshown to the player

Sent before a disconnect with reason 3. Show the text.

Game State Header

Server -> Client

InfoValue
Packet ID6
Total sizevariable
Field NameField TypeNotes
PropertiesMapsee below
KeyExampleMeaning
map-namePinpoint
map-formatngmap or vxlhow to decode the stream
map-size512,512,64 or 1024,1024,64x,y,z in the server's order: x and y are the two horizontal axes, z the 64 deep height. Ours sends 512 x 512 or 1024 x 1024 maps and the client accepts only those two square sizes, depth 64, refusing anything else before decoding
map-bytes1834211total stream size, for a progress bar
map-crc323f2a91c7CRC32 (zlib's) of the exact stream, 8 hex digits
Map cache. A client that already holds the stream answers with Generic Command "map-cached 1"; the server then sends no Map Data at all and goes straight to Map Data Final. Answer map-cached 0 when you do not. The server waits 3 seconds for the answer. The key is the stream, not the map: the CRC32 and byte count of the bytes the server would send, so two qualities of one map, or one map after an edit, are different cache entries.

Map Data / Map Data Final

Server -> Client

InfoValue
Packet IDs7 (Map Data), 11 (Map Data Final, empty)
Total size1 + n / 1
Field NameField TypeNotes
FragmentBytesone piece of the stream, in order

Append every fragment; the concatenation is one stream. Map Data Final ends it. Decode the map, apply the Terrain Updates that arrived during the transfer in order, then acknowledge. The server keeps broadcasting terrain edits to loading connections, so keep them until the map is ready.

Map Formats

vxl is the zlib-compressed VXL, exactly the bytes 0.75 sends in Map Chunk. One loader serves both protocols.

ngmap is a zlib stream (2-byte header, Adler-32 trailer). Decompressed:

Field NameField TypeNotes
SignatureUint320x1145148A
WidthUint16
HeightUint16
DepthUint16at most 64
QualityUint81..100
Geometrycolumn entriesone per column, boustrophedon: y 0..h-1, x 0..w-1 on even y, w-1..0 on odd y
JPEG LengthUint32
JPEGUint8 arraythe lossy colour tiles
Colour Blocksto the end

A column entry is a format byte then either a run-length list of Uint8 toggle positions (the first byte carries 0x80 when the column starts solid at z 0, the last byte is always depth) or a bitmap of 16-voxel slices. Colours are cut into 8x8x8 cells with one of six formats (constant, linear, planar, volumetric; raw or interpolated, some in JPEG tiles).

Do not re-implement ngmap from this summary. Port GameMap_ngmap.cpp from the ngspades reference (about 1,900 lines) or ship the C++ codec behind a C interface. It needs zlib and a JPEG decoder. Use Map Quality = 0 and skip it entirely if your client only needs to work.

Map Data Acknowledge

Client -> Server

InfoValue
Packet ID10
Total size1 byte

No payload. Send it after decoding the map; the server waits for it before Game State Final.

Game State Final

Server -> Client

InfoValue
Packet ID8
Total sizevariable
Field NameField TypeNotes
World ParametersMapsee below
Entity CountVarint
EntitiesEntity Update Item x counteach with Create
Player CountVarint
PlayersPlayer Update Item x counteach with Create

After this packet the connection is in the game. Take the world parameters, then build the world: every body and every player already in the match.

World Parameters

All values are strings, parsed as numbers. Unknown keys are ignored.

KeyDefaultMeaning
player-jump-vel0.36upward velocity added on jump
fall-damage-vel0.58landing speed where fall damage starts
fall-damage-fatal-vel1landing speed that kills
fog-distance96where bodies and effects stop (32..256)
fog-color0.6,0.7,0.9r,g,b 0..1
gamemodethe mode's wire name (ctf, ngctf, tc, arena, zombie, koth, ...)
team1-name, team2-nameteam names
team1-color, team2-colorr,g,b 0..255
capture-limitcaptures or rounds to win
aim-assist01 = the server allows aim assist
jetpack-fuel, jetpack-regen, jetpack-thrust, jetpack-max-rise, jetpack-air-control, jetpack-glide-control, jetpack-ignition, jetpack-refill-delay, jetpack-ceilingjetpack figures, only when the server has the jetpack
sentry-lifetimeseconds a sentry lives

Generic Command

Client <-> Server

InfoValue
Packet ID9
Total sizevariable
Field NameField TypeNotes
PartsString x nparts[0] is the command

Unknown commands are logged and ignored on both sides. Rare, human-readable actions live here; frequent or structured data gets its own packet id.

A client sends:

CommandMeaning
join <team> <weapon> [<class>]create your player: team 0/1 (255 spectator), weapon 0 rifle, 1 SMG, 2 shotgun; class 0..3 in a classes mode
leaveremove your player, back to watching
map-cached <0|1>the answer to the map header
team <n>change team in game
weapon <n>change weapon in game
class <n>pick a class (classes modes)
ping <info|danger> x y z [n]a mark for your team; n is a phrase number
ping spot <target> x y zspot an enemy
squad <n>join squad n of your team (0 = alone)
squad-rallythe squad leader drops the rally point
light <0|1>your flashlight
device <platform> <input>desktop android iphone console browser / kbm pad touch
host <cmd> <args>bot management (permission checked)

The server sends local-player <id> (you control that player and entity; no argument = nothing), and the markers and notices: hit, kill, perk-*, sentry-spot, spot, spot-refused, revive-marker, revive-channel, revived, squads, squad, squad-refused, squad-rally, restock, wallet, fog, light, sky, outfit, team-outfits, device, kill-assist, match-player, match-end, classes, class, class-info, host-status, host-bots, rocket-refused, rocket-push, drill-charges, drill-refused, crate. Ignore the ones you do not use.

Entity Update

Server -> Client

InfoValue
Packet ID30
Total sizevariable
Field NameField TypeNotes
ForcedUint81 = apply even to entities this client owns
ItemsEntity Update Item x nto the end of the packet

An update is a delta: keep the last value of each part and change only what the mask announces. An item with mask == 0 is never sent. An item for an unknown id without Create is ignored.

A client ignores parts for entities it owns, unless Forced is set or the item has Create: that is how the server corrects a client it disagrees with.

Entity Event

Server -> Client

InfoValue
Packet ID31
Total sizevariable
Field NameField TypeNotes
Entity IDVarint
Event TypeUint80 Jump, 1 Reload Weapon, 2 Suicide, 3 Explode, 4 Fire, 5 Use Perk
ParamVarintevent-specific, 0 if unused

Reload Weapon on a player tells every client but the reloader to play the reload sound and refill their view of that player's clip (without it you stop drawing their shots once your count hits 0). Explode means a grenade, rocket or explosive went off. Jump lets a body jump at once.

Entity Die

Server -> Client

InfoValue
Packet ID32
Total sizevariable
Field NameField TypeNotes
Entity IDVarintthe victim
Death TypeUint80 unspecified, 1 player, 2 explode
ParamVarintfor a player: reason | respawn << 8
Damage Infooptionalpresent only when bytes remain

Damage info:

Field NameField TypeNotes
Damage TypeUint8low 7 bits, bit 7 = a killer follows
Fire PositionVec3
Hit PositionVec3
From EntityVarintthe killer, only with bit 7
Check for the end of the packet before reading the damage type: a death without damage info has no such byte. reason is the 0.75 kill type: 0 weapon, 1 headshot, 2 melee, 3 grenade, 4 fall, 5 team change, 6 weapon change, 7 sentry, 8 explosive. This one packet drives the kill feed.

Entity Remove

Server -> Client

InfoValue
Packet ID33
Total sizevariable
Field NameField TypeNotes
Entity IDVarint

The entity is gone: a grenade exploded or was cleaned up, a rocket hit, a sentry was destroyed, a crate was taken or expired, a body left. Remove it at once.

Client Side Entity Update

Client -> Server

InfoValue
Packet ID35
Total sizevariable
Field NameField TypeNotes
ItemsEntity Update Item x nto the end; never with Create

You report your own body: trajectory, input when it changed, tool, block colour. Movement is client-authoritative, but the server checks it:

  • items for entities you do not own are dropped;
  • a change of trajectory type is refused and corrected;
  • the new position must be within 0.1 block of the server's extrapolation along the old velocity, and the velocity within 0.1, or the server sends a forced correction.

Send at a steady rate (30 Hz), unreliable on channel 1, with the input whenever it changed; one reliably on channel 0 right before a hit or a block edit.

Terrain Update

Server -> Client

InfoValue
Packet ID40
Total sizevariable

A list of edits to the end of the packet, as deltas from a cursor that starts at (0,0,0):

Field NameField TypeNotes
DXInt8if -128 (0x80): the cursor moves — read CX, CY, CZ, then DX again
DYInt8
DZInt8
HealthUint80 = destroyed, otherwise created
Red, Green, BlueUint8 x 3only when created; R, G, B here
Create TypeUint8only when created: 0 unspecified, 1 player
Destroy TypeUint8only when destroyed: 0 unspecified, 1 damage, 2 collapse

The absolute cursor fields are unsigned Varints. The cursor does not follow the edits: deltas are always relative to the last explicit cursor.

Example: create an orange block (255,128,0) at (10,20,30), health 100, by a player:

28  0A 14 1E  64  FF 80 00  01

Destroy the block at (300,5,63); x does not fit, so the cursor moves first:

28  80 AC 02 05 3F  00 00 00  00  01

A create with health below 100 is a cracked block. Cells marked Collapse are falling structures: remove them and build the falling piece from their colours and connections. Apply a whole packet, then run block physics once.

Player Update

Server -> Client

InfoValue
Packet ID50
Total sizevariable
Field NameField TypeNotes
ItemsPlayer Update Item x nto the end

Player Remove

Server -> Client

InfoValue
Packet ID51
Total sizevariable
Field NameField TypeNotes
Player IDsVarint x nto the end

Player Action

Client -> Server

InfoValue
Packet ID60
Total sizevariable
Field NameField TypeNotes
Event TypeUint80 Jump, 1 Reload Weapon, 2 Suicide, 5 Use Perk
ParamVarintevent-specific

Your request to act on your own body: jump (the zombie leap carries its charge in param), reload, the pause menu's respawn, or place a perk. The server answers with an Entity Event when it accepts.

Chat Message

Client -> Server

InfoValue
Packet ID70
Total size2 + text
Field NameField TypeNotes
ChannelUint80 all, 1 team
TextStringUTF-8, at most 255 bytes

A client cannot send channel 2 (that would forge server notices). Hex, gg to the team: 46 01 02 67 67.

Chat Broadcast

Server -> Client

InfoValue
Packet ID71
Total sizevariable
Field NameField TypeNotes
FromVarintplayer id, 0xFFFFFFFF = the server
ChannelUint80 all, 1 team, 2 system
TextStringUTF-8, at most 255 bytes

Player 3 says hi to all: 47 03 00 02 68 69. The server says Round over: 47 FF FF FF FF 0F 02 0A 52 6F 75 6E 64 20 6F 76 65 72.

Game Mode State

Server -> Client

InfoValue
Packet ID80
Total sizevariable
Field NameField TypeNotes
StateMapkey/value strings

A packet whose first entry is mode is a snapshot: forget all game mode state, then apply. Any other packet is a delta: each key replaces its value, an empty value removes it. A snapshot comes right after Game State Final and at every round start; a delta whenever something changes.

Numbers are decimal, lists comma-separated with no spaces, positions are block cells.

KeyValueMeaning
modectf, ngctf, tc, arena, zombie, koth, ...the mode; starts a snapshot
team1-name, team2-nametext
team1-color, team2-colorr,g,b0..255
team1-score, team2-scoredecimalcaptures, rounds or territories
capture-limitdecimalwhat wins
team1-intel, team2-intelbase, dropped, carriedthe intel belonging to that team
territory-countdecimal NTC
territory<i>holder,capturing,permille,rateholder 0 team 1, 1 team 2, 2 nobody; share 0..1000; change a second
arena-statewaiting, countdown, fight, endArena
arena-round, arena-time, arena-winnerArena
zombie-team, zombie-humansZombie
koth-radius, koth-state, koth-round, koth-holder, koth-on, koth-points, koth-winnerKing of the hill

Extrapolate a territory as permille + rate * elapsed, clamped to 0..1000.

The objectives are entities: each intel a Flag, each tent a Command Post, KotH's hill and TC's territories Checkpoints. Their ids are fixed: 0x7FFF0000 + 0 team 1's intel, 1 team 2's, 2 team 1's tent, 3 team 2's, 4 the hill, 5 + i territory i. A carried intel has its trajectory's parent set to the carrier. The server sends the objective's Entity Update before the Game Mode State that goes with it.

Babel is sent as ctf. A client that does not know a mode shows the scores.

Hit Entity

Client -> Server

InfoValue
Packet ID90
Total sizevariable
Field NameField TypeNotes
Entity IDVarintwho was hit
Hit TypeUint80 unspecified, 1 torso, 2 head, 3 limb
Damage TypeUint8Weapon1 (7) or Weapon2 (8): the slot fired from
Fire PositionVec3your eye
Hit PositionVec3the point the pellet met

You report hits; the server decides damage. Our server refuses a gun hit whose fire position is more than 4 blocks from the shooter's eye, whose hit position is more than 3 blocks (plus lag tolerance) from the target, or whose line crosses a solid block. A melee hit is damage type Melee (4).

Hit Terrain

Client -> Server

InfoValue
Packet ID91
Total sizevariable
Field NameField TypeNotes
BlockBlock Coordthe cell hit
Damage TypeUint85 Dig, 4 Melee, 7..9 a gun
Fire PositionVec3
Hit PositionVec3

The spade's primary is Melee (destroy one block), its secondary Dig (the block and the ones above and below). A gun's hit is Weapon1..Weapon3; the slot is not checked for a block.

Our server keeps block health: a gun sends a Hit Terrain for every pellet that meets a block, and the server subtracts the weapon's damage (rifle 50, SMG 34, shotgun 20 a pellet, revolver 34) from the cell's 100. At 100 the block breaks; below it the cell goes out in the tick's Terrain Update as a solid cell with health 100 - damage — draw the crack. A crack heals 10 s after its last hit. The spade still counts on the client and sends only the hit that breaks the block.

Damage

Server -> Client

InfoValue
Packet ID92
Total sizevariable
Field NameField TypeNotes
Entity IDVarintwho took it
Damage TypeUint8low 7 bits; bit 7 = a source follows
From EntityVarintonly with bit 7
To EntityVarint
Fire PositionVec3
Hit PositionVec3
AmountUint8hp removed

Use it for the hit indicator (direction from the fire position), screen effects and the local health. The authoritative health is the body's Health field.

Build Block

Client -> Server

InfoValue
Packet ID93
Total sizevariable
Field NameField TypeNotes
BlockBlock Coord
ColorColorB, G, R

Example, block (256,255,62) with r=0x11, g=0x22, b=0x33:

5D  80 04 FE 03 7C  33 22 11

The server answers with a Terrain Update using create type Player and the colour it accepted. Its rules apply: the block tool must be in hand, no sprinting, a solid neighbour, the block count, an editable cell. A refused build is answered with a Terrain Update restoring the cell.

Colour order trap: Build Block/Build Line send B, G, R; Terrain Update sends R, G, B.

Build Line

Client -> Server

InfoValue
Packet ID94
Total sizevariable
Field NameField TypeNotes
FromBlock Coord
ToBlock Coord
ColorColorB, G, R

Example, a line from (10,20,30) to (10,20,25), red:

5E  14 28 3C  14 28 32  00 00 FF

Throw Grenade

Client -> Server

InfoValue
Packet ID95
Total size29 bytes
Field NameField TypeNotes
OriginVec3where it leaves the hand
VelocityVec3blocks per second
FuseFloatseconds until it explodes, 0..3

A thrown grenade becomes an entity with a Gravity trajectory, and an Entity Event Explode when the fuse runs out. None of these go to the thrower: your client shows your own grenade from the moment you throw it and keeps it until Explode (the fuse is not on the wire).

Entity Update Item

Used by Entity Update, Client Side Entity Update and Game State Final.

Field NameField TypeNotes
Entity IDVarint
MaskUint8which parts follow, in the order below
BitPartPayload
0CreateUint8 entity type; plus, for a player, the skins and weapons; plus, for an owned type, owner and team
1FlagsUint8
2Trajectorysee below
3Player InputUint8 flags, Int8 xmove, Int8 ymove
4ToolUint8
5Block ColorColor
6HealthUint8

The fields follow the order above, not the bit order.

Create for a player:

Field NameField TypeNotes
Body SkinBytesclass/<name> or default
Weapon Skin 1..3Bytes x 3rifle, smg, shotgun, rocket, revolver, grenade, drill, empty
Weapon Params 1..3Weapon Params x 3see below

Create for an owned type (Command Post, Flag, Checkpoint, and every type from Sentry up) adds:

Field NameField TypeNotes
OwnerVarintplayer id, or 0xFFFFFFFF for none
TeamUint80, 1 or 255

A skin is lowercase ASCII, digits and _ / -, at most 32 bytes.

Entity flags: bit 0 playerClip, bit 1 weaponClip, bit 2 fly, bit 3 jetpack. Bits 4..7 are invalid.

Player input: bit 0 primary, bit 1 secondary, bit 2 chat (typing), bit 3 sprint, bit 4 jetpack thrust, bits 6..7 stance (0 stand, 1 crouch, 2 prone). Bit 5 is unused. xmove is strafe, ymove forward, both -127..127; the physics divides by 127 and clamps the length to 1.

Weapon Params

Field NameField TypeNotes
FlagsUint8bit 0 full automatic, bit 1 slow reload, bit 2 penetrative, bits 3-4 type
Fire IntervalUint16ms between shots
Reload TimeUint16ms
Raise TimeUint16ms before it can fire after being taken out
Max DamageUint8percent of 100 hp
MagazineUint8rounds

The field order on the wire is not a C struct's order: reload and raise come before damage. The 0.75 rifle is {0, 500, 2500, 500, 49, 10}.

Trajectory

Field NameField TypeNotes
TypeUint8low 7 bits; bit 7 = a parent follows
OriginVec3
VelocityVec3
RotationVec3compact quaternion x,y,z, w >= 0; not for Player
Angular VelocityVec3not for Player
EulerVec3Player only: pitch, roll, yaw (roll always 0)
ParentVarintonly with bit 7
ValueTypeMotion
0Constantstays at the origin
1Linearorigin + velocity * t
2Gravityorigin + velocity * t + 0.5 * g * t^2, g = (0,0,32)
3Playerthe player physics, driven by the last input
4Rigid Bodyfree body (vehicles; unused by our game)
5Player Compactthe player trajectory in 17 bytes

Player Compact: type, origin x/y as Uint16 (* 64), origin z as Int16 (* 64, rounded up, toward the sky), velocity x/y/z as Int16 (* 1024), pitch and yaw as Int16 (* 32767 / (pi/2) and * 32767 / pi), then the parent. The decoder hands it on as an ordinary Player trajectory. A client sends its own trajectory in floats; the server validates it.

Player Update Item

Field NameField TypeNotes
Player IDVarint
MaskUint8which parts follow
BitPartPayload
0CreateString name
1ScoreVarint
2FlagsUint8 (bit 0 is admin)
3TeamUint8: 0, 1, 255 spectator
4StatsVarint kills, Varint deaths
5PingVarint ms
6PerksUint8 points, Uint8 inventory, Uint8 next threshold (owner only)

The fields are written in that order, which is not the bit order.

Enumerations

Entity TypeValue
Player0
Grenade1
Rocket2
Command Post3
Flag4
Checkpoint5
Vehicle6
Sentry7
Landmine8
Dynamite9
Drill10
Ammo Crate11
Health Crate12
Tool SlotValue
Melee0
Block1
Weapon 1 (primary gun)2
Weapon 2 (second gun)3
Weapon 3 (grenades or drill)4
Damage TypeValue
Unknown0
Suicide1
Fall2
Poison3
Melee4
Dig5
Block6
Weapon 17
Weapon 28
Weapon 39
Grenade10
Vehicle Explosion11
Vehicle12
Sentry13

A player's body has the same id as the player. Players use ids 0..255; everything else uses 256 and up. Bots are player records with no connection.

Minimum Client

  1. ENet with 2 channels and the 1.0 connect data (or WebRTC), ignoring unknown ids.
  2. The primitive codec with the strict decoder rules.
  3. Initiate Connection with "WorldOfSpades 1.0" and Map Quality = 0, so you only need the VXL loader; certificates with isValid = 0.
  4. The map: header, fragments, final, decode, apply the kept terrain edits, acknowledge.
  5. Game State Final, Entity Update, Player Update, Player Remove, Entity Remove with the delta rule, the trajectory and its compact form.
  6. join <team> <weapon>, read local-player, then send Client Side Entity Update at 30 Hz.
  7. Hit Entity, Hit Terrain, Damage, Entity Die.
  8. Build Block, Build Line, Throw Grenade, Chat Message, Chat Broadcast, Terrain Update.
  9. Game Mode State for CTF, plus the Flag and Command Post entities.

Then ngmap, classes, perks, the match summary.

Implementation Notes

  1. Masks are not self-describing. One unknown bit means the packet cannot be decoded; reject it.
  2. Field order is not bit order in entity and player items.
  3. Terrain Update is R,G,B; every other colour is B,G,R.
  4. Compact trajectory z rounds up (toward the sky). Rounding to nearest puts a standing body inside the floor and the client's step-up makes every body bob.
  5. Ignore Entity Update parts for your own entity unless forced or Create, or you fight your own prediction.
  6. Send the update before the action. A hit or a build without a preceding input report is refused.
  7. Check the end before reading Entity Die's damage info.
  8. Unknown packet ids and map keys are ignored; unknown mask bits are errors.
  9. The server may restart the transfer at any time; drop the world, take the new map, join again.
  10. A Map Data Acknowledge is mandatory after decoding.
  11. map-format decides the decoder, not the quality you asked for.
  12. A WebRTC message over 16 KB is refused.
  13. Text is UTF-8; there is no CP437 in 1.0.

Other Resources

  • Protocol 0.75 — the coordinate system and the classic protocol both share.
  • Master Server — the list, WebRTC signalling, tokens.
  • Extensions — the 0.75 extension registry.
  • examples/c/ — the dependency-free C codec this document describes.
  • examples/godot/ — the same in GDScript, with a WebRTC client.