summaryrefslogtreecommitdiff
path: root/includes/bitset.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/bitset.php')
-rw-r--r--includes/bitset.php46
1 files changed, 34 insertions, 12 deletions
diff --git a/includes/bitset.php b/includes/bitset.php
index 272325a..6483669 100644
--- a/includes/bitset.php
+++ b/includes/bitset.php
@@ -1,18 +1,24 @@
<?php
function parseBitset ($bitset) {
- $bin = str_repeat("0", 24 - strlen(decbin($bitset))) . decbin($bitset);
+ $bin = str_repeat("0", 48 - strlen(decbin($bitset))) . decbin($bitset);
- $sharedMemory = bindec(substr($bin, 0, 2));
- $median = substr($bin, 2, 1) !== "0";
- $little = bindec(substr($bin, 3, 2));
- $protector = substr($bin, 5, 1) !== "0";
- $fictive = substr($bin, 6, 1) !== "0";
- $notTalking = substr($bin, 7, 1) !== "0";
- $host = substr($bin, 8, 1) !== "0";
- $robot = substr($bin, 21, 1) !== "0";
- $species1 = substr($bin, 9, 4);
- $species2 = substr($bin, 13, 4);
+ $sharedMemory = bindec(substr($bin, 8 + 16, 2));
+ $median = substr($bin, 10 + 16, 1) !== "0";
+ $little = bindec(substr($bin, 11 + 16, 2));
+ $food = bindec(substr($bin, 16, 2));
+ $magic = bindec(substr($bin, 2 + 16, 3));
+ $sensitivity = bindec(substr($bin, 5 + 16, 3));
+ $protector = substr($bin, 13 + 16, 1) !== "0";
+ $fictive = substr($bin, 14 + 16, 1) !== "0";
+ $notTalking = substr($bin, 15 + 16, 1) !== "0";
+ $host = substr($bin, 16 + 16, 1) !== "0";
+ $robot = substr($bin, 29 + 16, 1) !== "0";
+ $plush = substr($bin, 30 + 16, 1) !== "0";
+ $age = substr($bin, 31 + 16, 1) !== "0";
+ $species1 = substr($bin, 17 + 16, 4);
+ $species2 = substr($bin, 21 + 16, 4);
+ $species3 = substr($bin, 25 + 16, 4);
$species1 = match ($species1) {
"0001" => "earth",
@@ -34,6 +40,16 @@ function parseBitset ($bitset) {
default => null,
};
+ $species3 = match ($species3) {
+ "0001" => "earth",
+ "0010" => "unicorn",
+ "0011" => "pegasus",
+ "0100" => "alicorn",
+ "0101" => "batpony",
+ "0110" => "crystal",
+ default => null,
+ };
+
return [
'shared_memory' => $sharedMemory,
'median' => $median,
@@ -43,9 +59,15 @@ function parseBitset ($bitset) {
'not_talking' => $notTalking,
'host' => $host,
'robot' => $robot,
+ 'magic' => $magic,
+ 'sensitivity' => $sensitivity,
+ 'food' => $food,
+ 'plush' => $plush,
+ 'age_spells' => $age,
'species' => array_filter([
$species1,
- $species2
+ $species2,
+ $species3
], function ($i) {
return isset($i);
})