mirror of
https://gitlab.com/hashborgir/d2tools.git
synced 2025-10-23 05:04:24 -05:00
Working copy
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
Reference in New Issue
Block a user