Skip to content

Commit

Permalink
Finally documment snapshot crc
Browse files Browse the repository at this point in the history
  • Loading branch information
ChillerDragon committed Jun 29, 2024
1 parent c596807 commit 6bb2422
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 19 deletions.
70 changes: 62 additions & 8 deletions 06/system_messages.html
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,17 @@ <h2 id="NETMSG_SNAP"><a href="#NETMSG_SNAP">NETMSG_SNAP</a></h2>
<td id="NETMSG_SNAP_crc"><a href="#NETMSG_SNAP_crc">Crc</a></td>
<td><a href="fundamentals.html#int_packing">Int</a></td>
<td>
TODO
The crc (cyclic redundancy check) is used as a checksum verifying the integrity of the snapshot.
It is all snapshot item payloads summed together into one 32 bit integer.
The reference implementation might overflow the crc and so should you to match the exact value.
More details on how to calculate the crc can be seen in the
<a href="https://protocol-docs.teeframe.com/packets/snaps-concept#calculating-crc">teeframe documentation</a>.
<br>
<br>
Important to understand is that the crc is not applied to only the snap items sent in this net message but the full snapshot.
Every snap msg is just a delta that might add or remove items from a previous snapshot.
So if the client already knows about a snapshot with 3 items and then another NETMSG_SNAP comes in with 3 additional items as payload
the crc has to be calculated on all 6 items that are now in the fully unpacked snapshot.
</td>
</tr>
<tr>
Expand Down Expand Up @@ -388,16 +398,19 @@ <h2 id="NETMSG_SNAPEMPTY"><a href="#NETMSG_SNAPEMPTY">NETMSG_SNAPEMPTY</a></h2>
<h2 id="NETMSG_SNAPSINGLE"><a href="#NETMSG_SNAPSINGLE">NETMSG_SNAPSINGLE</a></h2>
<p>
<table>
<tr><th>Sender:</th><td>TODO</td></tr>
<tr><th>Recipient:</th><td>TODO</td></tr>
<tr><th>Sender:</th><td>Server</td></tr>
<tr><th>Recipient:</th><td>Client</td></tr>
<tr><th>Message ID:</th><td>7</td></tr>
<tr>
<th>Response to:</th>
<td>TODO</td>
<td>Updates in the world</td>
</tr>
<tr>
<th>Expected response:</th>
<td>TODO</td>
<td>
The client acknowledges the <a href="system_messages.html#NETMSG_SNAPSINGLE_game_tick">Game tick</a>
in the message <a href="system_messages.html#NETMSG_INPUT_ack_game_tick">NETMSG_INPUT</a>
</td>
</tr>
</table>
<table>
Expand All @@ -407,12 +420,53 @@ <h2 id="NETMSG_SNAPSINGLE"><a href="#NETMSG_SNAPSINGLE">NETMSG_SNAPSINGLE</a></h
<th>Note</th>
</tr>
<tr>
<td id="NETMSG_SNAPSINGLE_todo"><a href="#NETMSG_SNAPSINGLE_todo">TODO</a></td>
<td><a href="fundamentals.html#string_packing">String</a></td>
<td id="NETMSG_SNAPSINGLE_game_tick"><a href="#NETMSG_SNAPSINGLE_game_tick">Game tick</a></td>
<td><a href="fundamentals.html#int_packing">Int</a></td>
<td>TODO</td>
<td>
TODO
</td>
</tr>
<tr>
<td id="NETMSG_SNAPSINGLE_delta_tick"><a href="#NETMSG_SNAPSINGLE_delta_tick">Delta tick</a></td>
<td><a href="fundamentals.html#int_packing">Int</a></td>
<td>
TODO
</td>
</tr>
<tr>
<td id="NETMSG_SNAPSINGLE_crc"><a href="#NETMSG_SNAPSINGLE_crc">Crc</a></td>
<td><a href="fundamentals.html#int_packing">Int</a></td>
<td>
The crc is a checksum. More details <a href="#NETMSG_SNAP_crc">here</a>.
</td>
</tr>
<tr>
<td id="NETMSG_SNAPSINGLE_part_size"><a href="#NETMSG_SNAPSINGLE_part_size">Part size</a></td>
<td><a href="fundamentals.html#int_packing">Int</a></td>
<td>
The size of this part. Meaning the size in bytes of the next raw data field.
</td>
</tr>
<tr>
<td id="NETMSG_SNAPSINGLE_data"><a href="#NETMSG_SNAPSINGLE_data">Data</a></td>
<td><a href="fundamentals.html#raw_packing">Raw</a></td>
<td>
The snapshot data. Which is a bunch of packed ints.
The first is the amount of removed items.
The second is the amount of item deltas.
The third a unused zero byte.
And the following ints are all snap items.
You can read more about snap items and the structure
of this data field in the
<a href="snap_items.html">snap items</a>
section.
</td>
</tr>
</table>
One full snapshot. If it does not fit into one message it will be split into
multiple parts and send as <a href="#NETMSG_SNAP">NETMSG_SNAP</a> instead.


</p>
<hr>
<h2 id="NETMSG_SNAPSMALL"><a href="#NETMSG_SNAPSMALL">NETMSG_SNAPSMALL</a></h2>
Expand Down
42 changes: 31 additions & 11 deletions 07/system_messages.html
Original file line number Diff line number Diff line change
Expand Up @@ -727,10 +727,15 @@ <h2 id="NETMSG_SNAP"><a href="#NETMSG_SNAP">NETMSG_SNAP</a></h2>
<th><strong>Message ID:</strong></th><td>6</td>
</tr>
<tr>
<th><strong>Response to:</strong></th><td>None</td>
<th><strong>Response to:</strong></th>
<td>Updates in the world</td>
</tr>
<tr>
<th><strong>Expected response:</strong></th><td>None</td>
<th><strong>Expected response:</strong></th>
<td>
The client acknowledges the <a href="system_messages.html#NETMSG_SNAP_game_tick">Game tick</a>
in the message <a href="system_messages.html#NETMSG_INPUT_ack_game_tick">NETMSG_INPUT</a>
</td>
</tr>
</table>
<table>
Expand Down Expand Up @@ -771,7 +776,17 @@ <h2 id="NETMSG_SNAP"><a href="#NETMSG_SNAP">NETMSG_SNAP</a></h2>
<td id="NETMSG_SNAP_crc"><a href="#NETMSG_SNAP_crc">Crc</a></td>
<td><a href="fundamentals.html#int_packing">Int</a></td>
<td>
TODO
The crc (cyclic redundancy check) is used as a checksum verifying the integrity of the snapshot.
It is all snapshot item payloads summed together into one 32 bit integer.
The reference implementation might overflow the crc and so should you to match the exact value.
More details on how to calculate the crc can be seen in the
<a href="https://protocol-docs.teeframe.com/packets/snaps-concept#calculating-crc">teeframe documentation</a>.
<br>
<br>
Important to understand is that the crc is not applied to only the snap items sent in this net message but the full snapshot.
Every snap msg is just a delta that might add or remove items from a previous snapshot.
So if the client already knows about a snapshot with 3 items and then another NETMSG_SNAP comes in with 3 additional items as payload
the crc has to be calculated on all 6 items that are now in the fully unpacked snapshot.
</td>
</tr>
<tr>
Expand Down Expand Up @@ -867,10 +882,15 @@ <h2 id="NETMSG_SNAPSINGLE"><a href="#NETMSG_SNAPSINGLE">NETMSG_SNAPSINGLE</a></h
<th><strong>Message ID:</strong></th><td>8</td>
</tr>
<tr>
<th><strong>Response to:</strong></th><td>None</td>
<th><strong>Response to:</strong></th>
<td>Updates in the world</td>
</tr>
<tr>
<th><strong>Expected response:</strong></th><td>None</td>
<th><strong>Expected response:</strong></th>
<td>
The client acknowledges the <a href="system_messages.html#NETMSG_SNAPSINGLE_game_tick">Game tick</a>
in the message <a href="system_messages.html#NETMSG_INPUT_ack_game_tick">NETMSG_INPUT</a>
</td>
</tr>
</table>
<table>
Expand All @@ -880,35 +900,35 @@ <h2 id="NETMSG_SNAPSINGLE"><a href="#NETMSG_SNAPSINGLE">NETMSG_SNAPSINGLE</a></h
<th>Note</th>
</tr>
<tr>
<td id="NETMSG_SNAP_game_tick"><a href="#NETMSG_SNAP_game_tick">Game tick</a></td>
<td id="NETMSG_SNAPSINGLE_game_tick"><a href="#NETMSG_SNAPSINGLE_game_tick">Game tick</a></td>
<td><a href="fundamentals.html#int_packing">Int</a></td>
<td>
TODO
</td>
</tr>
<tr>
<td id="NETMSG_SNAP_delta_tick"><a href="#NETMSG_SNAP_delta_tick">Delta tick</a></td>
<td id="NETMSG_SNAPSINGLE_delta_tick"><a href="#NETMSG_SNAPSINGLE_delta_tick">Delta tick</a></td>
<td><a href="fundamentals.html#int_packing">Int</a></td>
<td>
TODO
</td>
</tr>
<tr>
<td id="NETMSG_SNAP_crc"><a href="#NETMSG_SNAP_crc">Crc</a></td>
<td id="NETMSG_SNAPSINGLE_crc"><a href="#NETMSG_SNAPSINGLE_crc">Crc</a></td>
<td><a href="fundamentals.html#int_packing">Int</a></td>
<td>
TODO
The crc is a checksum. More details <a href="#NETMSG_SNAP_crc">here</a>.
</td>
</tr>
<tr>
<td id="NETMSG_SNAP_part_size"><a href="#NETMSG_SNAP_part_size">Part size</a></td>
<td id="NETMSG_SNAPSINGLE_part_size"><a href="#NETMSG_SNAPSINGLE_part_size">Part size</a></td>
<td><a href="fundamentals.html#int_packing">Int</a></td>
<td>
The size of this part. Meaning the size in bytes of the next raw data field.
</td>
</tr>
<tr>
<td id="NETMSG_SNAP_data"><a href="#NETMSG_SNAP_data">Data</a></td>
<td id="NETMSG_SNAPSINGLE_data"><a href="#NETMSG_SNAPSINGLE_data">Data</a></td>
<td><a href="fundamentals.html#raw_packing">Raw</a></td>
<td>
The snapshot data. Which is a bunch of packed ints.
Expand Down

0 comments on commit 6bb2422

Please sign in to comment.