Game Update Messages

Updates for the players are encoded as any number of messages concatenated together. Each message is a variable-length byte sequence.

Each message is at least one byte long. The type of the message is determined by magic bits in that first byte (similar to opcodes in CPU instruction set encodings). The first byte may also have bit-fields embedding data into it, for some message types.

Opcode Summary

Quick table summarizing the opcodes of all the message types. A few are left unused, reserved for future use.

BitsMessage Kind
00000000Player Update
00000001Tremor
00000010Smoke Start
00000011Smoke End
00000100City MoneyInfo
00000101City Transaction
00000110City ResInfo
00000111City TradeInfo
000010----
0000110---
00001110Debug
00001111Flag State
0001----Reveal Item
00100000Structure Gone
0010----Structure HP
0011----Explosions
0100----Construction Queued
01001111Construction Update
0101----Reveal Structure
01011111--
0110----Digits (single)
0111----Tile Kind Update
1000----Digits (multi)
1-------Ownership Updates

The patterns must be checked in the correct order, so that more specific bit sequences are matched first.

Messages Documentation

Here is the complete list of game update messages and their encodings:

Player Update

Something notable happened with a specific player.

Assembly:

PLAYER plid status ...
PLAYER plid/sub status ...

Encoding:

BitsMeaning
00000000(opcode)

The next byte:

BitsMeaning
----xxxxPlayerId
xxxx----PlayerSubId

PlayerId is the gameplay plid (view) that is affected.

PlayerSubId is the individual user/client, in game modes where multiple people can control a single in-game plid.

For messages that apply to all PlayerSubIds of a given PlayerId, the PlayerSubId field must be all-ones.

The next byte specifies the message kind (what happened):

BitsMeaningGranularityAssemblyClass
00000000JoinedPlayerSubIdJOINNotification
00000001Ping/RTT InfoPlayerSubIdRTT millisUnreliable
00000010TimeoutEitherTIMEOUT millisNotification
00000011TimeoutDoneEitherRESUMENotification
00000100ExplodedEitherEXPLODE y,x killerNotification
00000101LivesRemainEitherLIVES nNotification
00000110ProtectedPlayerIdPROTECTNotification
00000111Un-ProtectedPlayerIdUNPROTECTNotification
00001000EliminatedPlayerIdELIMINATENotification
00001001SurrenderedPlayerIdSURRENDERNotification
00001010DisconnectedPlayerSubIdLEAVENotification
00001011KickedPlayerSubIdKICKNotification
00010010MatchTimeRemainEitherTIMELIMIT secsNotification
10001000Capturing CityEitherCITCAPTING citid millisPvP
10001001Capture CityEitherCITCAPTURE citidPvP
10001010Contested CityEitherCITCONTEST citidPvP
...(reserved)

Then follows the data payload for the given message kind.

Tremor

Some explosion occurred at an unknown location. Client should shake the screen lightly.

Assembly:

SHAKE

Encoding:

BitsMeaning
00000001(opcode)

Smoke Start

A tile was smoked.

Assembly:

SMOKE y,x

Encoding:

BitsMeaning
00000010(opcode)

Followed by the coordinate of the tile.

Smoke End

A tile is no longer smoked.

Assembly:

UNSMOKE y,x

Encoding:

BitsMeaning
00000011(opcode)

Followed by the coordinate of the tile.

Debug

Special message reserved for use during development.

Assembly:

DEBUG i y,x

Encoding:

BitsMeaning
00001110(opcode)

Followed by:

  • u8 magic value
  • Tile coordinate

Flag State

Report the presence or absence of a flag on a given tile.

Assembly:

FLAG p y,x

(p == plid, 0 == no flag)

Encoding:

BitsMeaning
00001111(opcode)

Followed by:

BitsMeaning
0000----(reserved)
----ppppPlayerId

Reserved bits must be zero.

p is the PlayerId that placed the flag. Zero means no flag.

Followed by the coordinate of the tile.

Construction Update

Update on the progress of a pending structure.

Assembly:

BUILD y,x current rate
BitsMeaning
01001111(opcode)

Followed by the coordinates of the tile.

Followed by u16 indicating current accumulated units.

Followed by u16 indicating rate of construction.

Digits (+ Implied Capture)

The specified tiles are owned by the player and display the given Minesweeper digit.

Can be used to capture tiles, if the tile is not owned by the player.

Can be used to update digits on owned tiles, when they change.

Assembly:

DIGITS d/y,x ...
DIGITS d*/y,x ...

Compact (single) Encoding:

BitsMeaning
0110----(opcode)
----x---Asterisk
-----xxxDigit Value

Followed by the coordinate of the tile.

Multi-tile Encoding:

BitsMeaning
1---0000(opcode)
-xxx----Tile Count - 1

Followed by the coordinates of the tiles.

Followed by the digit for each tile, two digits packed into one byte:

BitsMeaning
x-------asterisk N
-xxx----digit N
----x---asterisk N+1
-----xxxdigit N+1

(this encoding allows them to be easily read when inspecting a hex dump)

For an odd number of tiles, the final digit is ignored (should be encoded as zero).

Structure Gone

The structure on the given tile is removed.

Used when a built structure is destroyed or bulldozed. Used when a pending (unbuilt) structure is canceled.

Assembly:

NOSTRUCT y,x

Encoding:

BitsMeaning
00100000(opcode)

Followed by the tile coordinates.

Structure HP

The HP of a structure changed.

Assembly:

STRUCTHP y,x hp

Encoding:

BitsMeaning
0010----(opcode)
----xxxxHP

HP must be > 0.

Followed by the tile coordinates.

Explosions

Explosions have occurred.

If the client should know what item was destroyed, send a "Reveal Item" first.

Assembly:

EXPLODE y,x ...

Encoding:

BitsMeaning
0011----(opcode)
----xxxxTile Count - 1

Followed by the coordinates of the tiles.

Construction Queued

A new structure is pending construction.

Assembly:

BUILDNEW y,x {road|bridge|wall|tower}

Encoding:

BitsMeaning
0100----(opcode)
----xxxxStructure Kind

The Structure Kind is:

  • 0000: Road
  • 0001: Bridge
  • 0010: Wall
  • 0011: Tower
  • other values reserved

Must not be 1111.

Followed by tile coordinate.

Followed by u16 indicating total points required to complete construction.

Reveal Structure

There is a structure on the specified tile.

Used both when revealing foreign structures and also when own structures finish construction.

Assembly:

STRUCT y,x {road|bridge|wall|tower}

Encoding:

BitsMeaning
0101----(opcode)
----xxxxStructure Kind

The Structure Kind is:

  • 0000: Road
  • 0001: Bridge
  • 0010: Wall
  • 0011: Tower
  • other values reserved

Must not be 1111.

Followed by tile coordinate.

City MoneyInfo

Reports how much money a city has.

Assembly:

CITMONEY i money
CITINCOME i money income
BitsMeaning
00000100(opcode)

Followed by:

  • u8: City ID
  • u32: current money
  • [u16: current income rate]

The top bit (bit 31) of money indicates whether the income is reported too. The income field is only present if this bit is 1.

The remaining 31 bits are used for the money value.

City Transaction

Reports that a city has gained or spent a given sum of money.

Assembly:

CITTRANS i spent
BitsMeaning
00000101(opcode)

Followed by:

  • u8: City ID
  • i16: the amount of money

City ResInfo

Update on the resources of a city.

Assembly:

CITRES i res
BitsMeaning
00000110(opcode)

Followed by:

  • u8: City ID
  • u16: the amount of resources

City TradeInfo

Update on the export/import policy of a city.

Assembly:

CITTRADE export import
BitsMeaning
00000111(opcode)

Followed by:

  • u8: City ID
  • u8: Export rate
  • u8: Import rate

Tile Kind Update

Changes the base tile type.

Assembly:

TILE y,x {water|regular|fertile|destroyed|foundation|mountain|forest}

Encoding:

BitsMeaning
0111----(opcode)
----xxxxTile Kind

The Tile Kind is:

  • 0000: Water
  • 0001: (reserved)
  • 0010: Mountain
  • 0011: Forest
  • 0100: Destroyed Land
  • 0101: Foundation
  • 0110: Regular Land
  • 0111: Fertile Land
  • ... : (reserved)

Followed by tile coordinate.

Reveal Item

There is an item on the specified tile.

Used both when revealing foreign items and also when acking own deployed items.

Assembly:

ITEM y,x {none|decoy|mine|trap}

Encoding:

BitsMeaning
0001----(opcode)
----xxxxItem Kind

The Item Kind is:

  • 0000: None
  • 0001: Decoy
  • 0010: Mine
  • 0011: Trap
  • ... : (reserved)

Followed by tile coordinate.

Ownership Update

Multiple tiles are now known to be owned by the specified player id.

Assembly:

OWNER p y,x ...

Encoding:

BitsMeaning
1-------(opcode)
----xxxxPlayerId
-xxx----Tile Count - 1

The PlayerId must not be zero.

Followed by the coordinates of the tiles.

If any of the tiles are of a clustered tile kind (mountain, forest), it is assumed that the ownership update applies to the entire cluster. There is no need to list every tile coordinate of the cluster.