Working copy

This commit is contained in:
Hash Borgir
2023-05-30 12:06:58 -06:00
parent eb28039f88
commit dd662e26f6
11 changed files with 206 additions and 85 deletions

View File

@@ -54,7 +54,22 @@ class D2ByteReader {
* @param bool $str
* @return string
*/
public function readh(int $offset, int $numBytes, bool $str = true): string {
public function read(int $offset, int $numBytes) {
$this->seek($offset);
$bytes = null;
for ($i = $this->offset; $i < $this->offset + $numBytes; $i++) {
$bytes .= $this->data[$i];
}
return $bytes;
}
/**
* @param int $offset
* @param int $numBytes
* @param bool $str
* @return string
*/
public function readh(int $offset, int $numBytes, bool $str = true) {
$this->seek($offset);
$bytes = null;
for ($i = $this->offset; $i < $this->offset + $numBytes; $i++) {
@@ -62,14 +77,14 @@ class D2ByteReader {
}
return unpack('H*', $bytes)[1];
}
/**
* @param int $offset
* @param int $numBytes
* @param bool $str
* @return array
*/
public function readc(int $offset, int $numBytes, bool $str = true): array {
public function readc(int $offset, int $numBytes, bool $str = true) {
$this->seek($offset);
$bytes = null;
for ($i = $this->offset; $i < $this->offset + $numBytes; $i++) {
@@ -187,6 +202,7 @@ class D2ByteReader {
* @return string
*/
public function toBytesR(string $bits) : string {
$bytes = '';
foreach (str_split($bits, 8) as $byteString) {
$bytes .= strtoupper(str_pad(dechex(bindec(($byteString))), 2, 0, STR_PAD_LEFT));
}