Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
inodentry committed May 6, 2024
1 parent 8a5413a commit 9627875
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 138 deletions.
140 changes: 72 additions & 68 deletions minewars/book/print.html
Original file line number Diff line number Diff line change
Expand Up @@ -1349,8 +1349,8 @@ <h2 id="prerequisites-for-implementation"><a class="header" href="#prerequisites
<p>All <strong>time durations</strong> are encoded as:</p>
<div class="table-wrapper"><table><thead><tr><th>Bits</th><th>Meaning</th></tr></thead><tbody>
<tr><td><code>0xxxxxxx</code></td><td><code>x</code> milliseconds</td></tr>
<tr><td><code>10xxxxxx</code></td><td>(<code>x</code> + 12) centiseconds</td></tr>
<tr><td><code>11xxxxxx</code></td><td>(<code>x</code> + 7) deciseconds</td></tr>
<tr><td><code>10xxxxxx</code></td><td>(<code>x</code> + 13) centiseconds</td></tr>
<tr><td><code>11xxxxxx</code></td><td>(<code>x</code> + 8) deciseconds</td></tr>
</tbody></table>
</div>
<p><strong>PlayerId</strong>: a value between 1-15 inclusive.</p>
Expand Down Expand Up @@ -1472,15 +1472,14 @@ <h3 id="opcode-summary"><a class="header" href="#opcode-summary">Opcode Summary<
<tr><td><code>00000010</code></td><td>Smoke Start</td><td>PvP</td></tr>
<tr><td><code>00000011</code></td><td>Smoke End</td><td>PvP</td></tr>
<tr><td><code>00000100</code></td><td>City MoneyInfo</td><td>Unreliable</td></tr>
<tr><td><code>00000101</code></td><td>City Spending</td><td>Personal</td></tr>
<tr><td><code>00000101</code></td><td>City Transaction</td><td>Personal</td></tr>
<tr><td><code>00000110</code></td><td>City ResInfo</td><td>Personal</td></tr>
<tr><td><code>00000111</code></td><td>City TradeInfo</td><td>Personal</td></tr>
<tr><td><code>000010--</code></td><td>--</td><td></td></tr>
<tr><td><code>0000110-</code></td><td>--</td><td></td></tr>
<tr><td><code>00001110</code></td><td>--</td><td></td></tr>
<tr><td><code>00001111</code></td><td>Flag State</td><td>PvP</td></tr>
<tr><td><code>00010---</code></td><td>--</td><td></td></tr>
<tr><td><code>00011---</code></td><td>--</td><td></td></tr>
<tr><td><code>0001----</code></td><td>Reveal Item</td><td>PvP (foreign), Personal (own)</td></tr>
<tr><td><code>00100000</code></td><td>Structure Gone</td><td>PvP, Personal (cancel pending)</td></tr>
<tr><td><code>0010----</code></td><td>Structure HP</td><td>PvP</td></tr>
<tr><td><code>0011----</code></td><td>Explosions</td><td>PvP</td></tr>
Expand All @@ -1489,8 +1488,7 @@ <h3 id="opcode-summary"><a class="header" href="#opcode-summary">Opcode Summary<
<tr><td><code>0101----</code></td><td>Reveal Structure</td><td>PvP</td></tr>
<tr><td><code>01011111</code></td><td>--</td><td></td></tr>
<tr><td><code>0110----</code></td><td>Digits (single)</td><td>PvP</td></tr>
<tr><td><code>01110---</code></td><td>Reveal Item</td><td>PvP (foreign), Personal (own)</td></tr>
<tr><td><code>01111---</code></td><td>Tile Kind Update</td><td>PvP</td></tr>
<tr><td><code>0111----</code></td><td>Tile Kind Update</td><td>PvP</td></tr>
<tr><td><code>1000----</code></td><td>Digits (multi)</td><td>PvP</td></tr>
<tr><td><code>1-------</code></td><td>Ownership Updates</td><td>PvP</td></tr>
</tbody></table>
Expand All @@ -1502,7 +1500,9 @@ <h3 id="messages-documentation"><a class="header" href="#messages-documentation"
<h4 id="player-update"><a class="header" href="#player-update">Player Update</a></h4>
<p>Something notable happened with a specific player.</p>
<p>Assembly:</p>
<pre><code>PLAYER p status
<pre><code>PLAYER plid status ...
</code></pre>
<pre><code>PLAYER plid/sub status ...
</code></pre>
<p>Encoding:</p>
<div class="table-wrapper"><table><thead><tr><th>Bits</th><th>Meaning</th></tr></thead><tbody>
Expand All @@ -1518,28 +1518,31 @@ <h4 id="player-update"><a class="header" href="#player-update">Player Update</a>
<p>PlayerId is the gameplay plid (view) that is affected.</p>
<p>PlayerSubId is the individual user/client, in game modes where multiple people
can control a single in-game plid.</p>
<p>Some message kinds ignore PlayerSubId. See the "Granularity" column in the table below.</p>
<p>For messages that apply to all PlayerSubIds of a given PlayerId,
the PlayerSubId field must be all-ones.</p>
<p>The next byte specifies the message kind (what happened):</p>
<div class="table-wrapper"><table><thead><tr><th>Bits</th><th>Meaning</th><th>Granularity</th></tr></thead><tbody>
<tr><td><code>00000000</code></td><td>Joined</td><td>PlayerSubId</td></tr>
<tr><td><code>00000001</code></td><td>Ping/RTT Info</td><td>PlayerSubId</td></tr>
<tr><td><code>00000010</code></td><td>Stunned/Killed</td><td>PlayerId</td></tr>
<tr><td><code>00000011</code></td><td>Un-Stunned</td><td>PlayerId</td></tr>
<tr><td><code>00000100</code></td><td>(reserved)</td><td></td></tr>
<tr><td><code>00000101</code></td><td>(reserved)</td><td></td></tr>
<tr><td><code>00000110</code></td><td>Protected</td><td>PlayerId</td></tr>
<tr><td><code>00000111</code></td><td>Un-Protected</td><td>PlayerId</td></tr>
<tr><td><code>00001000</code></td><td>Eliminated</td><td>PlayerId</td></tr>
<tr><td><code>00001001</code></td><td>Surrendered</td><td>PlayerId</td></tr>
<tr><td><code>00001010</code></td><td>Disconnected</td><td>PlayerSubId</td></tr>
<tr><td><code>00001011</code></td><td>Kicked</td><td>PlayerSubId</td></tr>
<tr><td><code>00001100</code></td><td>Initiate Vote</td><td>PlayerSubId</td></tr>
<tr><td><code>00001101</code></td><td>Vote</td><td>PlayerSubId</td></tr>
<tr><td><code>00001110</code></td><td>Vote Failed</td><td>PlayerSubId</td></tr>
<tr><td><code>00001111</code></td><td>Vote Success</td><td>PlayerSubId</td></tr>
<tr><td><code>00010000</code></td><td>Chat (All)</td><td>PlayerSubId</td></tr>
<tr><td><code>00010001</code></td><td>Chat (Friendly)</td><td>PlayerSubId</td></tr>
<tr><td>...</td><td>(reserved)</td><td></td></tr>
<div class="table-wrapper"><table><thead><tr><th>Bits</th><th>Meaning</th><th>Granularity</th><th>Assembly</th></tr></thead><tbody>
<tr><td><code>00000000</code></td><td>Joined</td><td>PlayerSubId</td><td><code>JOIN</code></td></tr>
<tr><td><code>00000001</code></td><td>Ping/RTT Info</td><td>PlayerSubId</td><td><code>RTT millis</code></td></tr>
<tr><td><code>00000010</code></td><td>Timeout</td><td>Either</td><td><code>TIMEOUT millis</code></td></tr>
<tr><td><code>00000011</code></td><td>TimeoutDone</td><td>Either</td><td><code>RESUME</code></td></tr>
<tr><td><code>00000100</code></td><td>Exploded</td><td>Either</td><td><code>EXPLODE y,x killer</code></td></tr>
<tr><td><code>00000101</code></td><td>LivesRemain</td><td>Either</td><td><code>LIVES n</code></td></tr>
<tr><td><code>00000110</code></td><td>Protected</td><td>PlayerId</td><td><code>PROTECT</code></td></tr>
<tr><td><code>00000111</code></td><td>Un-Protected</td><td>PlayerId</td><td><code>UNPROTECT</code></td></tr>
<tr><td><code>00001000</code></td><td>Eliminated</td><td>PlayerId</td><td><code>ELIMINATE</code></td></tr>
<tr><td><code>00001001</code></td><td>Surrendered</td><td>PlayerId</td><td><code>SURRENDER</code></td></tr>
<tr><td><code>00001010</code></td><td>Disconnected</td><td>PlayerSubId</td><td><code>LEAVE</code></td></tr>
<tr><td><code>00001011</code></td><td>Kicked</td><td>PlayerSubId</td><td><code>KICK</code></td></tr>
<tr><td><code>00001100</code></td><td>Vote No</td><td>PlayerSubId</td><td><code>VOTE N</code></td></tr>
<tr><td><code>00001101</code></td><td>Vote Yes</td><td>PlayerSubId</td><td><code>VOTE Y</code></td></tr>
<tr><td><code>00001110</code></td><td>Vote Failed</td><td>PlayerSubId</td><td><code>VOTEFAIL</code></td></tr>
<tr><td><code>00001111</code></td><td>Vote Success</td><td>PlayerSubId</td><td><code>VOTEPASS</code></td></tr>
<tr><td><code>00010000</code></td><td>Chat (All)</td><td>PlayerSubId</td><td><code>CHATALL</code></td></tr>
<tr><td><code>00010001</code></td><td>Chat (Friendly)</td><td>PlayerSubId</td><td><code>CHAT string</code></td></tr>
<tr><td><code>00010010</code></td><td>MatchTimeRemain</td><td>Either</td><td><code>TIMELIMIT secs</code></td></tr>
<tr><td><code>00010011</code></td><td>Initiate Vote</td><td>PlayerSubId</td><td><code>VOTENEW string</code></td></tr>
<tr><td>...</td><td>(reserved)</td><td></td><td></td></tr>
</tbody></table>
</div>
<p>Then follows the data payload for the given message kind.</p>
Expand Down Expand Up @@ -1630,8 +1633,7 @@ <h4 id="digits--implied-capture"><a class="header" href="#digits--implied-captur
</tbody></table>
</div>
<p>Followed by the coordinates of the tiles.</p>
<p>Followed by the digit for each tile, two digits packed into one byte (note
big endian):</p>
<p>Followed by the digit for each tile, two digits packed into one byte:</p>
<div class="table-wrapper"><table><thead><tr><th>Bits</th><th>Meaning</th></tr></thead><tbody>
<tr><td><code>x-------</code></td><td>asterisk N</td></tr>
<tr><td><code>-xxx----</code></td><td>digit N</td></tr>
Expand All @@ -1646,12 +1648,8 @@ <h4 id="structure-gone"><a class="header" href="#structure-gone">Structure Gone<
<p>Used when a built structure is destroyed or bulldozed.
Used when a pending (unbuilt) structure is canceled.</p>
<p>Assembly:</p>
<pre><code>DECONSTRUCT y,x
</code></pre>
<p>(destroy existing)</p>
<pre><code>NOCONSTRUCT y,x
<pre><code>NOSTRUCT y,x
</code></pre>
<p>(cancel pending)</p>
<p>Encoding:</p>
<div class="table-wrapper"><table><thead><tr><th>Bits</th><th>Meaning</th></tr></thead><tbody>
<tr><td><code>00100000</code></td><td>(opcode)</td></tr>
Expand All @@ -1672,7 +1670,7 @@ <h4 id="structure-hp"><a class="header" href="#structure-hp">Structure HP</a></h
<p>HP must be &gt; 0.</p>
<p>Followed by the tile coordinates.</p>
<h4 id="explosions-1"><a class="header" href="#explosions-1">Explosions</a></h4>
<p>Explosions have occurred. Tile converts to destroyed land. Any item gone.</p>
<p>Explosions have occurred.</p>
<p>If the client should know what item was destroyed, send a "Reveal Item" first.</p>
<p>Assembly:</p>
<pre><code>EXPLODE y,x ...
Expand All @@ -1695,7 +1693,7 @@ <h4 id="construction-queued"><a class="header" href="#construction-queued">Const
<tr><td><code>----xxxx</code></td><td>Structure Kind</td></tr>
</tbody></table>
</div>
<p>The Item Kind is:</p>
<p>The Structure Kind is:</p>
<ul>
<li><code>0000</code>: Road</li>
<li><code>0001</code>: Bridge</li>
Expand All @@ -1718,7 +1716,7 @@ <h4 id="reveal-structure"><a class="header" href="#reveal-structure">Reveal Stru
<tr><td><code>----xxxx</code></td><td>Structure Kind</td></tr>
</tbody></table>
</div>
<p>The Item Kind is:</p>
<p>The Structure Kind is:</p>
<ul>
<li><code>0000</code>: Road</li>
<li><code>0001</code>: Bridge</li>
Expand Down Expand Up @@ -1749,10 +1747,10 @@ <h4 id="city-moneyinfo"><a class="header" href="#city-moneyinfo">City MoneyInfo<
income is reported too. The income field is only
present if this bit is <code>1</code>.</p>
<p>The remaining 31 bits are used for the money value.</p>
<h4 id="city-spending"><a class="header" href="#city-spending">City Spending</a></h4>
<p>Reports that a city has spent a given sum of money.</p>
<h4 id="city-transaction"><a class="header" href="#city-transaction">City Transaction</a></h4>
<p>Reports that a city has gained or spent a given sum of money.</p>
<p>Assembly:</p>
<pre><code>CITSPEND i spent
<pre><code>CITTRANS i spent
</code></pre>
<div class="table-wrapper"><table><thead><tr><th>Bits</th><th>Meaning</th></tr></thead><tbody>
<tr><td><code>00000101</code></td><td>(opcode)</td></tr>
Expand All @@ -1761,7 +1759,7 @@ <h4 id="city-spending"><a class="header" href="#city-spending">City Spending</a>
<p>Followed by:</p>
<ul>
<li><code>u8</code>: City ID</li>
<li><code>u16</code>: the amount of money spent</li>
<li><code>i16</code>: the amount of money</li>
</ul>
<h4 id="city-resinfo"><a class="header" href="#city-resinfo">City ResInfo</a></h4>
<p>Update on the resources of a city.</p>
Expand Down Expand Up @@ -1795,24 +1793,25 @@ <h4 id="city-tradeinfo"><a class="header" href="#city-tradeinfo">City TradeInfo<
<h4 id="tile-kind-update"><a class="header" href="#tile-kind-update">Tile Kind Update</a></h4>
<p>Changes the base tile type.</p>
<p>Assembly:</p>
<pre><code>TILE y,x {water|regular|fertile|destroyed|mountain|forest}
<pre><code>TILE y,x {water|regular|fertile|destroyed|foundation|mountain|forest}
</code></pre>
<p>Encoding:</p>
<div class="table-wrapper"><table><thead><tr><th>Bits</th><th>Meaning</th></tr></thead><tbody>
<tr><td><code>01111---</code></td><td>(opcode)</td></tr>
<tr><td><code>-----xxx</code></td><td>Tile Kind</td></tr>
<tr><td><code>0111----</code></td><td>(opcode)</td></tr>
<tr><td><code>----xxxx</code></td><td>Tile Kind</td></tr>
</tbody></table>
</div>
<p>The Tile Kind is:</p>
<ul>
<li><code>000</code>: Water</li>
<li><code>001</code>: (reserved)</li>
<li><code>010</code>: Mountain</li>
<li><code>011</code>: Forest</li>
<li><code>100</code>: Destroyed Land</li>
<li><code>101</code>: Foundation</li>
<li><code>110</code>: Regular Land</li>
<li><code>111</code>: Fertile Land</li>
<li><code>0000</code>: Water</li>
<li><code>0001</code>: (reserved)</li>
<li><code>0010</code>: Mountain</li>
<li><code>0011</code>: Forest</li>
<li><code>0100</code>: Destroyed Land</li>
<li><code>0101</code>: Foundation</li>
<li><code>0110</code>: Regular Land</li>
<li><code>0111</code>: Fertile Land</li>
<li>... : (reserved)</li>
</ul>
<p>Followed by tile coordinate.</p>
<h4 id="reveal-item"><a class="header" href="#reveal-item">Reveal Item</a></h4>
Expand All @@ -1823,17 +1822,17 @@ <h4 id="reveal-item"><a class="header" href="#reveal-item">Reveal Item</a></h4>
</code></pre>
<p>Encoding:</p>
<div class="table-wrapper"><table><thead><tr><th>Bits</th><th>Meaning</th></tr></thead><tbody>
<tr><td><code>01110---</code></td><td>(opcode)</td></tr>
<tr><td><code>-----xxx</code></td><td>Item Kind</td></tr>
<tr><td><code>0001----</code></td><td>(opcode)</td></tr>
<tr><td><code>----xxxx</code></td><td>Item Kind</td></tr>
</tbody></table>
</div>
<p>The Item Kind is:</p>
<ul>
<li><code>000</code>: None</li>
<li><code>001</code>: Decoy</li>
<li><code>010</code>: Mine</li>
<li><code>011</code>: Trap</li>
<li><code>1--</code>: (reserved)</li>
<li><code>0000</code>: None</li>
<li><code>0001</code>: Decoy</li>
<li><code>0010</code>: Mine</li>
<li><code>0011</code>: Trap</li>
<li>... : (reserved)</li>
</ul>
<p>Followed by tile coordinate.</p>
<h4 id="ownership-update"><a class="header" href="#ownership-update">Ownership Update</a></h4>
Expand Down Expand Up @@ -1916,7 +1915,7 @@ <h3 id="homogenous-frames"><a class="header" href="#homogenous-frames">Homogenou
<p>Homogenous frames have the following structure:</p>
<ul>
<li><code>u16</code>: Header</li>
<li><code>u8</code>/<code>u16</code>: participation mask</li>
<li><code>[u8]</code>: participation mask</li>
<li><code>u8</code>: length of data payload in bytes - 1</li>
<li>[ ... data payload ... ]</li>
</ul>
Expand All @@ -1925,8 +1924,9 @@ <h3 id="homogenous-frames"><a class="header" href="#homogenous-frames">Homogenou
milliseconds, and must not be all-ones (the max value is reserved for Keepalive Frames).</p>
<p>The participation mask is a bitmask indicating which PlayerIds the frame applies to.
Bit 0 represents the global spectator view.</p>
<p>The size of the participation mask is determined by the "max player id" bit in the
Initialization Sequence.</p>
<p>The size of the participation mask depends on the <code>n_players</code> field in the
Initialization Sequence. Use the minimum number of bytes to represent the
players. It is Big Endian!</p>
<p>The data payload is the <a href="tech/./dataformat-player.html#gameplay-messages">player protocol update messages</a>.
All of the players listed in the participation mask must receive the entire identical data payload.</p>
<h3 id="heterogenous-frames"><a class="header" href="#heterogenous-frames">Heterogenous Frames</a></h3>
Expand All @@ -1935,17 +1935,21 @@ <h3 id="heterogenous-frames"><a class="header" href="#heterogenous-frames">Heter
<p>Heterogenous frames have the following structure:</p>
<ul>
<li><code>u16</code>: Header</li>
<li><code>u8</code>/<code>u16</code>: participation mask</li>
<li><code>[u8]</code>: lengths of each player view's portion of the data payload (as many as specified in the participation mask)</li>
<li><code>[u8]</code>: participation mask</li>
<li><code>[u8]</code>: lengths of each player view's portion of the data payload - 1</li>
<li>[ ... data payload ... ]</li>
</ul>
<p>The top bit (bit 15) in the Header must be <code>0</code>, indicating that this is a Heterogenous
Frame. The remaining 15 bits represent the time delta since the previous frame, in
milliseconds, and must not be all-ones (the max value is reserved for Keepalive Frames).</p>
<p>The participation mask is a bitmask indicating which PlayerIds the frame applies to.
Bit 0 represents the global spectator view.</p>
<p>The size of the participation mask is determined by the "max player id" bit in the
Initialization Sequence.</p>
<p>The size of the participation mask depends on the <code>n_players</code> field in the
Initialization Sequence. Use the minimum number of bytes to represent the
players. It is Big Endian!</p>
<p>The size of the lengths array is equal to the number of <code>1</code> bits in the
participation mask. Each value represents the length of the data for that
player's view, - 1.</p>
<p>The data payload is the global spectator view + each player's view (in the order
of the bits in the participation mask), concatenated together.</p>
<p>Each view's data is the <a href="tech/./dataformat-player.html#gameplay-messages">player protocol update
Expand Down
2 changes: 1 addition & 1 deletion minewars/book/searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion minewars/book/searchindex.json

Large diffs are not rendered by default.

Loading

0 comments on commit 9627875

Please sign in to comment.