675
edits
Dat Hack3r (talk | contribs) m (Added page to Documentation category.) |
(Add example per-cell protection values) |
||
Line 55: | Line 55: | ||
In order to decode the base64 string, the "@" character must first be stripped. Then, all characters must be iterated through. The base64 character must be converted to its index within the base64 table. Each base64 character holds information for three cells. To retrieve the information for the next three characters, the respective formulas are used: <code>idx >> 4 & 3</code>; <code>idx >> 2 & 3</code>; <code>idx & 3</code>. To allow for the proper encoding of protection information in base64, the writability values are shifted up by one and null is assigned 0. When decoding, the numbers are shifted down by one and what was originally zero is assigned null. To re-encode the string, the "@" character must first be added to indicate the base64 type. Then, the following formula is used for the next three characters: <code>c1 << 4 | c2 << 2 | c3</code>. If no characters are left, the value 0 is substituted. The final step is to convert the value into a base64 character and then append it to the string. | In order to decode the base64 string, the "@" character must first be stripped. Then, all characters must be iterated through. The base64 character must be converted to its index within the base64 table. Each base64 character holds information for three cells. To retrieve the information for the next three characters, the respective formulas are used: <code>idx >> 4 & 3</code>; <code>idx >> 2 & 3</code>; <code>idx & 3</code>. To allow for the proper encoding of protection information in base64, the writability values are shifted up by one and null is assigned 0. When decoding, the numbers are shifted down by one and what was originally zero is assigned null. To re-encode the string, the "@" character must first be added to indicate the base64 type. Then, the following formula is used for the next three characters: <code>c1 << 4 | c2 << 2 | c3</code>. If no characters are left, the value 0 is substituted. The final step is to convert the value into a base64 character and then append it to the string. | ||
Here is an example of a network tile object containing a per-cell protection string:<syntaxhighlight lang="json"> | |||
{ | |||
"content": "<omitted>", | |||
"properties": { | |||
"char": "@VVVWqlVVVqpVVVaqVVVWqlVVVqqqqqqqqqqqqqqqqqo" | |||
} | |||
} | |||
</syntaxhighlight> | |||
=== Example values === | |||
==== Base64 ==== | |||
Starting char: <code>@</code> | |||
Possible values per cell: 4 | |||
Full string: <code>@VVVWqlVVVqpVVVaqVVVWqlVVVqqqqqqqqqqqqqqqqqo</code> | |||
==== Comma-separated integers ==== | |||
Starting char: <code>#</code> | |||
Possible values per cell: Indeterminate | |||
Full string: <code>#1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2</code> | |||
===== Hexadecimal ===== | |||
Starting char: <code>x</code> | |||
Possible values per cell: 256 | |||
Full string: <code>x0101010101010101010101020202020201010101010101010101010202020202010101010101010101010102020202020101010101010101010101020202020201010101010101010101010202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202</code> | |||
== Per-Cell Links == | == Per-Cell Links == |