mirror of
https://gitlab.com/hashborgir/d2tools.git
synced 2025-10-13 16:34:23 -05:00
Working copy
This commit is contained in:
@@ -54,6 +54,7 @@ class D2BitReader {
|
||||
* @return array|string|string[]
|
||||
*/
|
||||
public function writeBits(string $bits, string $bitsToWrite, int $offset) {
|
||||
//$this->bits = substr_replace($bits, $bitsToWrite, $offset, strlen($bitsToWrite));
|
||||
return substr_replace($bits, $bitsToWrite, $offset, strlen($bitsToWrite));
|
||||
}
|
||||
|
||||
@@ -63,7 +64,7 @@ class D2BitReader {
|
||||
* @return string
|
||||
*/
|
||||
public function readb(int $numBits = 0, bool $str = true): string {
|
||||
$bits = null;
|
||||
$bits = '';
|
||||
for ($i = $this->offset; $i < $this->offset + $numBits; $i++) {
|
||||
$str ? $bits .= $this->bits[$i] : $bits[] = $this->bits[$i];
|
||||
}
|
||||
|
@@ -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));
|
||||
}
|
||||
|
@@ -219,7 +219,7 @@ WHERE sk.charclass = '$class'";
|
||||
unset($this->items);
|
||||
//unset($this->bData);
|
||||
unset($this->sData);
|
||||
unset($this->fp);
|
||||
//unset($this->fp);
|
||||
|
||||
return $this->cData;
|
||||
}
|
||||
@@ -292,7 +292,7 @@ WHERE sk.charclass = '$class'";
|
||||
$bytes = $this->ByteReader->toBytes($bits);
|
||||
|
||||
$stats->rewind();
|
||||
for ($i = 0; $i <= strlen($bits); $i++) {
|
||||
for ($i = 0; $i <= count($this->ISC); $i++) {
|
||||
$id = hexdec($this->ByteReader->toBytesR($stats->readb(9)));
|
||||
if ($this->ISC[$id]['CSvBits'] !== NULL && $this->ISC[$id]['CSvBits'] !== '') {
|
||||
$stats->skip($this->ISC[$id]['CSvBits']);
|
||||
@@ -314,8 +314,8 @@ WHERE sk.charclass = '$class'";
|
||||
$values['maxmana'] = (int) round($values['maxmana'] >> 11);
|
||||
$values['stamina'] = (int) round($values['stamina'] >> 11);
|
||||
$values['maxstamina'] = (int) round($values['maxstamina'] >> 11);
|
||||
$values['soulcounter'] = (int) round($values['soulcounter'] / 2);
|
||||
$values['killcounter'] = (int) round($values['killcounter'] / 2);
|
||||
// $values['soulcounter'] = (int) round($values['soulcounter'] / 2);
|
||||
// $values['killcounter'] = (int) round($values['killcounter'] / 2);
|
||||
|
||||
$this->cData['stats'] = $values;
|
||||
}
|
||||
@@ -463,7 +463,7 @@ WHERE sk.charclass = '$class'";
|
||||
}
|
||||
$stats .= "000011111111100";
|
||||
|
||||
dump($stats);
|
||||
//dump($stats);
|
||||
|
||||
$gf = strposX($this->data, 'gf', 1) + 2; // find gf and skip it
|
||||
$if = strposX($this->data, 'if', 1);
|
||||
|
@@ -140,6 +140,24 @@ class D2Database {
|
||||
$res = PDO_Execute($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return void
|
||||
*/
|
||||
public function writeTbls($table,$data) {
|
||||
$sql = "CREATE TABLE IF NOT EXISTS `$table` (`Key` VARCHAR(255), `String` VARCHAR(255));";
|
||||
$res = PDO_Execute($sql);
|
||||
|
||||
$sql = "INSERT INTO `$table` (`Key`,`String`) VALUES ";
|
||||
foreach ($data as $k => $v) {
|
||||
$sql .= "(\"$k\",\"$v\"),";
|
||||
}
|
||||
$sql = rtrim($sql, ", ");
|
||||
$sql .= ";";
|
||||
|
||||
$res = PDO_Execute($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $key
|
||||
* @return mixed
|
||||
|
Reference in New Issue
Block a user