D2S Parsing almost done. Todo: full item parsing, Editor GUI, NPC Intro Data, refactor code, writeQuest/writeStat function etc.

This commit is contained in:
Hash Borgir
2022-06-29 01:53:27 -06:00
parent 29063867c5
commit e51e40175e
5 changed files with 146 additions and 59 deletions

View File

@@ -5,7 +5,7 @@ require_once './src/D2BitReader.php';
class D2ByteReader {
private string $data;
private string $data = '';
private int $offset = 0;
public function __construct(string $data) {
@@ -102,13 +102,18 @@ class D2ByteReader {
}
}
public function toBytes(string $bits) {
public function toBytesR(string $bits) : string {
foreach (str_split($bits, 8) as $byteString) {
$bytes[] = (bindec(strrev($byteString)));
$bytes .= strtoupper(str_pad(dechex(bindec(($byteString))), 2, 0, STR_PAD_LEFT));
}
foreach ($bytes as $byte) {
dump($byte);
return $bytes;
}
public function toBytes(string $bits) : string {
foreach (str_split($bits, 8) as $byteString) {
$bytes .= strtoupper(str_pad(dechex(bindec(strrev($byteString))), 2, 0, STR_PAD_LEFT));
}
return $bytes;
}
public function bitsToHexString(string $bits): string {