diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000..ded57de
Binary files /dev/null and b/.DS_Store differ
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 94a25f7..b681626 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -2,5 +2,6 @@
$str\n\n\nCharacter is now alive. Go take some mushrooms!\n";
+ echo "Previous Level: $_level\n";
+ echo "Revive Penalty: " . $_level - $level . "\n";
+ echo "New Level: $level\n";
+} else {
+ echo "$str\n\n\nCharacter is not dead. Have you been taking mushrooms lately?";
+}
\ No newline at end of file
diff --git a/bin/D2SC.exe b/bin/D2SC.exe
new file mode 100644
index 0000000..8b2dfed
Binary files /dev/null and b/bin/D2SC.exe differ
diff --git a/processFiles.php b/processFiles.php
index 25605e4..a9bfcd8 100755
--- a/processFiles.php
+++ b/processFiles.php
@@ -107,14 +107,13 @@ if (file_exists(APP_DB)) {
processFilesManuallyInSqlite();
processFilesManuallyInSqliteLinux();
-
function toPngAll() {
$q = realpath("bin\qdc6.exe");
- $iPath = $_SESSION['modpath']."\data\global\items";
- $oPath = realpath("docs\\{$_SESSION['modname']}\img\\items");
- exec("$q --first-frame-only \"$iPath\" -o \"$oPath\"");
- }
-
+ $iPath = $_SESSION['modpath'] . "\data\global\items";
+ $oPath = realpath("docs\\{$_SESSION['modname']}\img\\items");
+ exec("$q --first-frame-only \"$iPath\" -o \"$oPath\"");
+ }
+
if (!is_dir("docs\\{$_SESSION['modname']}")) {
mkdir("docs\\{$_SESSION['modname']}");
mkdir("docs\\{$_SESSION['modname']}\\fonts", 0777, TRUE);
@@ -124,36 +123,38 @@ if (file_exists(APP_DB)) {
rcopy(realpath('docs/template/fonts'), realpath("docs\\{$_SESSION['modname']}\\fonts"));
rcopy(realpath('docs/template/img'), realpath("docs\\{$_SESSION['modname']}\\img"));
rcopy(realpath('docs/template/res'), realpath("docs\\{$_SESSION['modname']}\\res"));
-
+
toPngAll();
-
-
-
+
/*
Process tbl files
- *
- *
- */
+ */
$tbl = $_SESSION['tbl'];
-
// ddump($tbl);
-
/*
$string = D2Tbl::getStrings($tbl."string.tbl");
$stringExpansion = D2Tbl::getStrings($tbl."expansionstring.tbl");
$stringPatch = D2Tbl::getStrings($tbl."patchstring.tbl");
-
$strings = array_merge($stringPatch, $stringExpansion, $string);
*/
-
$strs = ["dummy" => "dummy"];
foreach (glob($tbl . "*.tbl") as $filename) {
$strings = D2Tbl::getStrings($filename);
if (!empty($strings))
$strs = array_merge($strs, $strings);
}
-
$db->writeTbl($strs);
+
+ // write each table to invidual db table
+ $tbl = $_SESSION['tbl'];
+ foreach (glob($tbl . "*.tbl") as $filename) {
+ $tblName = pathinfo($filename)['filename'];
+ $strings = D2Tbl::getStrings($filename);
+ if (!empty($strings)) {
+ $db->writeTbls($tblName, $strings);
+ }
+
+ }
} else {
// if config db does not exist, go to configure page
header("Location: /src/D2Config.php");
@@ -167,7 +168,7 @@ if (file_exists(APP_DB)) {
-
+
diff --git a/src/D2BitReader.php b/src/D2BitReader.php
index 70c61a4..861c340 100644
--- a/src/D2BitReader.php
+++ b/src/D2BitReader.php
@@ -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];
}
diff --git a/src/D2ByteReader.php b/src/D2ByteReader.php
index 4c087bd..35e62ff 100644
--- a/src/D2ByteReader.php
+++ b/src/D2ByteReader.php
@@ -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));
}
diff --git a/src/D2Char.php b/src/D2Char.php
index a4fdc75..5f8c6f7 100644
--- a/src/D2Char.php
+++ b/src/D2Char.php
@@ -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);
diff --git a/src/D2Database.php b/src/D2Database.php
index 80ac05f..1bd728b 100755
--- a/src/D2Database.php
+++ b/src/D2Database.php
@@ -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
diff --git a/test.php b/test.php
deleted file mode 100644
index 3c1c5e6..0000000
--- a/test.php
+++ /dev/null
@@ -1,42 +0,0 @@
- $byte) {
- if ($k == 12 || $k == 13 || $k == 14 || $k == 15) {
- $byte = 0;
- }
- $nSignature = ((($nSignature << 1) | ($nSignature >> 31)) + $byte & 0xFFFFFFFF);
- }
- return swapEndianness(str_pad(dechex($nSignature), 8, 0, STR_PAD_LEFT));
-}
-
-$filename = "D:\Diablo II\MODS\ironman-dev\save\Necro.d2s";
-$fp = fopen($filename, "r+b");
-
-fseek($fp, 12); // go to byte 12
-fwrite($fp, pack('I', 0)); // clear the checksum field uInt32
-
-$fileData = unpack('C*', file_get_contents($filename)); // open file and unpack
-
-
-var_dump(checksum($fileData));
-
-fseek($fp, 12); // go to byte 12
-fwrite($fp, pack('H8', checksum($fileData))); // write new checksum
-fclose($fp);
\ No newline at end of file